LibreOffice Module reportdesign (master) 1
xmlfilter.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 <sal/config.h>
21#include <sal/log.hxx>
22
23#include <com/sun/star/packages/WrongPasswordException.hpp>
24#include <com/sun/star/packages/zip/ZipIOException.hpp>
25#include <com/sun/star/embed/ElementModes.hpp>
26#include <com/sun/star/beans/NamedValue.hpp>
27#include <com/sun/star/util/MeasureUnit.hpp>
28#include <com/sun/star/xml/sax/SAXParseException.hpp>
29#include <com/sun/star/document/XGraphicStorageHandler.hpp>
30#include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
31#include "xmlfilter.hxx"
32#include "xmlReport.hxx"
33#include <vcl/errinf.hxx>
34#include "xmlHelper.hxx"
35#include <vcl/svapp.hxx>
36#include <vcl/window.hxx>
39#include <xmloff/xmltoken.hxx>
40#include <xmloff/txtimp.hxx>
43#include <com/sun/star/xml/sax/InputSource.hpp>
44#include <com/sun/star/beans/PropertyAttribute.hpp>
45
51#include <sfx2/docfile.hxx>
52#include <com/sun/star/io/XInputStream.hpp>
54#include <xmloff/xmluconv.hxx>
55#include <xmloff/xmlmetai.hxx>
57#include <svtools/sfxecode.hxx>
58#include "xmlEnums.hxx"
59#include "xmlStyleImport.hxx"
60#include <strings.hxx>
62#include <ReportDefinition.hxx>
63
64namespace rptxml
65{
66using namespace ::com::sun::star::uno;
67using ::com::sun::star::uno::Reference;
68using namespace ::com::sun::star;
69using namespace ::com::sun::star::container;
70using namespace ::com::sun::star::lang;
71using namespace ::com::sun::star::beans;
72using namespace ::com::sun::star::document;
73using namespace ::com::sun::star::text;
74using namespace ::com::sun::star::io;
75using namespace ::com::sun::star::report;
76using namespace ::com::sun::star::xml::sax;
77using namespace xmloff;
78using namespace ::com::sun::star::util;
79
80namespace {
81
82class RptMLMasterStylesContext_Impl:
84{
85 ORptFilter& GetImport() { return static_cast<ORptFilter&>(XMLTextMasterStylesContext::GetImport()); }
86
87public:
88
89
90 RptMLMasterStylesContext_Impl( ORptFilter& rImport );
91
92 RptMLMasterStylesContext_Impl(const RptMLMasterStylesContext_Impl&) = delete;
93 RptMLMasterStylesContext_Impl& operator=(const RptMLMasterStylesContext_Impl&) = delete;
94 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
95};
96
97}
98
99RptMLMasterStylesContext_Impl::RptMLMasterStylesContext_Impl( ORptFilter& rImport ) :
101{
102}
103
104void RptMLMasterStylesContext_Impl::endFastElement(sal_Int32 )
105{
106 FinishStyles( true );
107 GetImport().FinishStyles();
108}
109
112 const uno::Reference<XInputStream>& xInputStream,
113 const uno::Reference<XComponent>& xModelComponent,
114 const uno::Reference<XComponentContext> & rContext,
115 const uno::Reference<XFastParser>& rFastParser )
116{
117 OSL_ENSURE(xInputStream.is(), "input stream missing");
118 OSL_ENSURE(xModelComponent.is(), "document missing");
119 OSL_ENSURE(rContext.is(), "factory missing");
120
121 // prepare Parser InputSource
122 InputSource aParserInput;
123 aParserInput.aInputStream = xInputStream;
124
125 // get filter
126 SAL_WARN_IF( !rFastParser.is(), "reportdesign", "Can't instantiate filter component." );
127 if( !rFastParser.is() )
128 return ErrCode(1);
129
130 // connect model and filter
131 uno::Reference < XImporter > xImporter( rFastParser, UNO_QUERY );
132 xImporter->setTargetDocument( xModelComponent );
133
134 // finally, parser the stream
135 try
136 {
137 rFastParser->parseStream( aParserInput );
138 }
139 catch (const SAXParseException&)
140 {
141 TOOLS_WARN_EXCEPTION( "reportdesign", "");
142 return ErrCode(1);
143 }
144 catch (const SAXException&)
145 {
146 return ErrCode(1);
147 }
148 catch (const packages::zip::ZipIOException&)
149 {
151 }
152 catch (const IOException&)
153 {
154 TOOLS_WARN_EXCEPTION( "reportdesign", "");
155 return ErrCode(1);
156 }
157 catch (const Exception&)
158 {
159 TOOLS_WARN_EXCEPTION( "reportdesign", "");
160 return ErrCode(1);
161 }
162
163 // success!
164 return ERRCODE_NONE;
165}
166
169 const uno::Reference< embed::XStorage >& xStorage,
170 const uno::Reference<XComponent>& xModelComponent,
171 const char* pStreamName,
172 const uno::Reference<XComponentContext> & rxContext,
173 const Reference<document::XGraphicStorageHandler> & rxGraphicStorageHandler,
174 const Reference<document::XEmbeddedObjectResolver>& _xEmbeddedObjectResolver,
175 const OUString& _sFilterName
176 ,const uno::Reference<beans::XPropertySet>& _xProp)
177{
178 OSL_ENSURE( xStorage.is(), "Need storage!");
179 OSL_ENSURE(nullptr != pStreamName, "Please, please, give me a name!");
180
181 if ( !xStorage )
182 // TODO/LATER: better error handling
183 return ErrCode(1);
184
185 uno::Reference< io::XStream > xDocStream;
186
187 try
188 {
189 // open stream (and set parser input)
190 OUString sStreamName = OUString::createFromAscii(pStreamName);
191 if ( !xStorage->hasByName( sStreamName ) || !xStorage->isStreamElement( sStreamName ) )
192 {
193 // stream name not found! return immediately with OK signal
194 return ERRCODE_NONE;
195 }
196
197 // get input stream
198 xDocStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
199 }
200 catch (const packages::WrongPasswordException&)
201 {
203 }
204 catch (const uno::Exception&)
205 {
206 return ErrCode(1); // TODO/LATER: error handling
207 }
208
209 sal_Int32 nArgs = 0;
210 if (rxGraphicStorageHandler.is())
211 nArgs++;
212 if( _xEmbeddedObjectResolver.is())
213 nArgs++;
214 if ( _xProp.is() )
215 nArgs++;
216
217 uno::Sequence< uno::Any > aFilterCompArgs( nArgs );
218 auto aFilterCompArgsRange = asNonConstRange(aFilterCompArgs);
219
220 nArgs = 0;
221 if (rxGraphicStorageHandler.is())
222 aFilterCompArgsRange[nArgs++] <<= rxGraphicStorageHandler;
223 if( _xEmbeddedObjectResolver.is())
224 aFilterCompArgsRange[ nArgs++ ] <<= _xEmbeddedObjectResolver;
225 if ( _xProp.is() )
226 aFilterCompArgsRange[ nArgs++ ] <<= _xProp;
227
228 // the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler
229 Reference< XFastParser > xFastParser(
230 rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(_sFilterName, aFilterCompArgs, rxContext),
231 uno::UNO_QUERY_THROW );
232 uno::Reference< XInputStream > xInputStream = xDocStream->getInputStream();
233 // read from the stream
234 return ReadThroughComponent( xInputStream
235 ,xModelComponent
236 ,rxContext
237 ,xFastParser );
238}
239
240
245extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
247 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
248{
249 return cppu::acquire(new ORptFilter(context,
251 SvXMLImportFlags::SETTINGS ));
252}
253
258extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
260 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
261{
262 return cppu::acquire(new ORptFilter(context,
264 SvXMLImportFlags::AUTOSTYLES | SvXMLImportFlags::CONTENT | SvXMLImportFlags::SCRIPTS | SvXMLImportFlags::FONTDECLS ));
265}
266
271extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
273 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
274{
275 return cppu::acquire(new ORptFilter(context,
277 SvXMLImportFlags::STYLES | SvXMLImportFlags::MASTERSTYLES | SvXMLImportFlags::AUTOSTYLES |
278 SvXMLImportFlags::FONTDECLS ));
279}
280
285extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
287 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
288{
289 return cppu::acquire(new ORptFilter(context,
291 SvXMLImportFlags::META ));
292}
293
294
295ORptFilter::ORptFilter( const uno::Reference< XComponentContext >& _rxContext, OUString const & rImplementationName, SvXMLImportFlags nImportFlags )
296 :SvXMLImport(_rxContext, rImplementationName, nImportFlags)
297{
298 GetMM100UnitConverter().SetCoreMeasureUnit(util::MeasureUnit::MM_100TH);
299 GetMM100UnitConverter().SetXMLMeasureUnit(util::MeasureUnit::CM);
300 GetNamespaceMap().Add( "_report",
303
304 GetNamespaceMap().Add( "__report",
307
312}
313
314
316{
317}
318
319extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
321 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
322{
323 return cppu::acquire(new ORptFilter(context,
324 "com.sun.star.comp.report.OReportFilter",
325 SvXMLImportFlags::ALL ));
326}
327
328sal_Bool SAL_CALL ORptFilter::filter( const Sequence< PropertyValue >& rDescriptor )
329{
331 bool bRet = false;
332
333 if( pFocusWindow )
334 pFocusWindow->EnterWait();
335
336 if ( GetModel().is() )
337 bRet = implImport( rDescriptor );
338
339 if ( pFocusWindow )
340 pFocusWindow->LeaveWait();
341
342 return bRet;
343}
344
345bool ORptFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
346{
347 OUString sFileName;
348 uno::Reference< embed::XStorage > xStorage;
349 uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier;
350
351 for(const PropertyValue& rProp : rDescriptor)
352 {
353 if ( rProp.Name == "FileName" )
354 rProp.Value >>= sFileName;
355 else if ( rProp.Name == "Storage" )
356 rProp.Value >>= xStorage;
357 else if ( rProp.Name == "ComponentData" )
358 {
359 Sequence< PropertyValue > aComponent;
360 rProp.Value >>= aComponent;
361 const PropertyValue* pComponentIter = aComponent.getConstArray();
362 const PropertyValue* pComponentEnd = pComponentIter + aComponent.getLength();
363 pComponentIter = std::find_if(pComponentIter, pComponentEnd,
364 [](const PropertyValue& rComponent) { return rComponent.Name == "ActiveConnection"; });
365 if (pComponentIter != pComponentEnd)
366 {
367 uno::Reference<sdbc::XConnection> xCon(pComponentIter->Value, uno::UNO_QUERY);
368 xNumberFormatsSupplier = ::dbtools::getNumberFormats(xCon);
369 }
370 }
371 }
372
373 if ( !sFileName.isEmpty() )
374 {
376 sFileName, ( StreamMode::READ | StreamMode::NOCREATE ) );
377
378 if( pMedium.is() )
379 {
380 try
381 {
382 xStorage = pMedium->GetStorage();
383 }
384 catch (const Exception&)
385 {
386 }
387 }
388 }
389 bool bRet = xStorage.is();
390 if ( bRet )
391 {
392 m_xReportDefinition.set(GetModel(),UNO_QUERY_THROW);
393
394#if OSL_DEBUG_LEVEL > 1
395 uno::Reference < container::XNameAccess > xAccess( xStorage, uno::UNO_QUERY );
396 uno::Sequence< OUString> aSeq = xAccess->getElementNames();
397 const OUString* pDebugIter = aSeq.getConstArray();
398 const OUString* pDebugEnd = pDebugIter + aSeq.getLength();
399 for(;pDebugIter != pDebugEnd;++pDebugIter)
400 {
401 (void)*pDebugIter;
402 }
403#endif
404
405 uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler;
406 uno::Reference<document::XEmbeddedObjectResolver> xEmbeddedObjectResolver;
407 uno::Reference< uno::XComponentContext > xContext = GetComponentContext();
408
409 uno::Sequence<uno::Any> aArgs{ uno::Any(xStorage) };
410 xGraphicStorageHandler.set(
411 xContext->getServiceManager()->createInstanceWithArgumentsAndContext("com.sun.star.comp.Svx.GraphicImportHelper", aArgs, xContext),
412 uno::UNO_QUERY);
413
414 uno::Reference< lang::XMultiServiceFactory > xReportServiceFactory( m_xReportDefinition, uno::UNO_QUERY);
415 aArgs.getArray()[0] <<= beans::NamedValue("Storage", uno::Any(xStorage));
416 xEmbeddedObjectResolver.set( xReportServiceFactory->createInstanceWithArguments("com.sun.star.document.ImportEmbeddedObjectResolver",aArgs) , uno::UNO_QUERY);
417
418 static constexpr OUStringLiteral s_sOld = u"OldFormat";
419 static comphelper::PropertyMapEntry const pMap[] =
420 {
421 { OUString("OldFormat") , 1, cppu::UnoType<sal_Bool>::get(), beans::PropertyAttribute::BOUND, 0 },
422 { OUString("StreamName"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
423 { OUString("PrivateData"),0, cppu::UnoType<XInterface>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
424 { OUString("BaseURI"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
425 { OUString("StreamRelPath"), 0, cppu::UnoType<OUString>::get(), beans::PropertyAttribute::MAYBEVOID, 0 },
426 };
427 utl::MediaDescriptor aDescriptor(rDescriptor);
428 uno::Reference<beans::XPropertySet> xProp = comphelper::GenericPropertySet_CreateInstance(new comphelper::PropertySetInfo(pMap));
429 const OUString sVal( aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTBASEURL, OUString()) );
430 assert(!sVal.isEmpty()); // needed for relative URLs
431 xProp->setPropertyValue("BaseURI", uno::Any(sVal));
432 const OUString sHierarchicalDocumentName( aDescriptor.getUnpackedValueOrDefault("HierarchicalDocumentName",OUString()) );
433 xProp->setPropertyValue("StreamRelPath", uno::Any(sHierarchicalDocumentName));
434
435 uno::Reference<XComponent> xModel = GetModel();
436 static constexpr OUStringLiteral s_sMeta = u"meta.xml";
437 static constexpr OUStringLiteral s_sStreamName = u"StreamName";
438 xProp->setPropertyValue(s_sStreamName, uno::Any(OUString(s_sMeta)));
439 ErrCode nRet = ReadThroughComponent( xStorage
440 ,xModel
441 ,"meta.xml"
442 ,GetComponentContext()
443 ,xGraphicStorageHandler
444 ,xEmbeddedObjectResolver
446 ,xProp
447 );
448
449
450 try
451 {
452 xProp->setPropertyValue(s_sOld,uno::Any(!(xStorage->hasByName(s_sMeta) || xStorage->isStreamElement( s_sMeta ))));
453 }
454 catch (const uno::Exception&)
455 {
456 xProp->setPropertyValue(s_sOld,uno::Any(true));
457 }
458
459 if ( nRet == ERRCODE_NONE )
460 {
461 xProp->setPropertyValue(s_sStreamName, uno::Any(OUString("settings.xml")));
462 nRet = ReadThroughComponent( xStorage
463 ,xModel
464 ,"settings.xml"
465 ,GetComponentContext()
466 ,xGraphicStorageHandler
467 ,xEmbeddedObjectResolver
469 ,xProp
470 );
471 }
472 if ( nRet == ERRCODE_NONE )
473 {
474 xProp->setPropertyValue(s_sStreamName, uno::Any(OUString("styles.xml")));
475 nRet = ReadThroughComponent(xStorage
476 ,xModel
477 ,"styles.xml"
478 ,GetComponentContext()
479 ,xGraphicStorageHandler
480 ,xEmbeddedObjectResolver
482 ,xProp);
483 }
484
485 if ( nRet == ERRCODE_NONE )
486 {
487 xProp->setPropertyValue(s_sStreamName, uno::Any(OUString("content.xml")));
488 nRet = ReadThroughComponent( xStorage
489 ,xModel
490 ,"content.xml"
491 ,GetComponentContext()
492 ,xGraphicStorageHandler
493 ,xEmbeddedObjectResolver
495 ,xProp
496 );
497 }
498
499
500 bRet = nRet == ERRCODE_NONE;
501
502 if ( bRet )
503 {
504 m_xReportDefinition->setModified(false);
505 }
506 else
507 {
508 if( nRet == ERRCODE_IO_BROKENPACKAGE && xStorage.is() )
509 ; // TODO/LATER: no way to transport the error outside from the filter!
510 else
511 {
512 // TODO/LATER: this is completely wrong! Filter code should never call ErrorHandler directly! But for now this is the only way!
514 if( nRet.IsWarning() )
515 bRet = true;
516 }
517 }
518 }
519
520 return bRet;
521}
522
523namespace {
524
525class RptXMLDocumentSettingsContext : public SvXMLImportContext
526{
527public:
528 RptXMLDocumentSettingsContext(SvXMLImport & rImport)
529 : SvXMLImportContext(rImport)
530 {
531 }
532
533 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
534 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) override
535 {
536 if (nElement == XML_ELEMENT(OFFICE, XML_SETTINGS))
537 {
538 return new XMLDocumentSettingsContext(GetImport());
539 }
540 return nullptr;
541 }
542};
543
544class RptXMLDocumentStylesContext : public SvXMLImportContext
545{
546public:
547 RptXMLDocumentStylesContext(SvXMLImport & rImport)
548 : SvXMLImportContext(rImport)
549 {
550 }
551
552 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
553 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) override
554 {
555 ORptFilter & rImport(static_cast<ORptFilter&>(GetImport()));
556 switch (nElement)
557 {
558 case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS):
559 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
560 return rImport.CreateFontDeclsContext();
561 case XML_ELEMENT(OFFICE, XML_MASTER_STYLES):
562 {
563 SvXMLStylesContext* pStyleContext = new RptMLMasterStylesContext_Impl(rImport);
564 rImport.SetMasterStyles(pStyleContext);
565 return pStyleContext;
566 }
567 case XML_ELEMENT(OFFICE, XML_STYLES):
568 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
569 return rImport.CreateStylesContext(false);
570 case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES):
571 // don't use the autostyles from the styles-document for the progress
572 return rImport.CreateStylesContext(true);
573 }
574 return nullptr;
575 }
576};
577
578}
579
580css::uno::Reference< css::xml::sax::XFastContextHandler > RptXMLDocumentBodyContext::createFastChildContext(
581 sal_Int32 nElement,
582 const uno::Reference<xml::sax::XFastAttributeList> & xAttrList)
583{
584 ORptFilter & rImport(static_cast<ORptFilter&>(GetImport()));
585 if (nElement == XML_ELEMENT(OFFICE, XML_REPORT) || nElement == XML_ELEMENT(OOO, XML_REPORT))
586 {
587 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
588 const SvXMLStylesContext* pAutoStyles = rImport.GetAutoStyles();
589 if (pAutoStyles)
590 {
591 XMLPropStyleContext* pAutoStyle = const_cast<XMLPropStyleContext*>(dynamic_cast<const XMLPropStyleContext *>(pAutoStyles->FindStyleChildContext(XmlStyleFamily::PAGE_MASTER, "pm1")));
592 if (pAutoStyle)
593 {
594 pAutoStyle->FillPropertySet(rImport.getReportDefinition());
595 }
596 }
597 return new OXMLReport(rImport, xAttrList, rImport.getReportDefinition());
598 }
599 return nullptr;
600}
601
602namespace {
603
604class RptXMLDocumentContentContext : public SvXMLImportContext
605{
606public:
607 RptXMLDocumentContentContext(SvXMLImport & rImport)
608 : SvXMLImportContext(rImport)
609 {
610 }
611
612 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
613 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& /*xAttrList*/ ) override
614 {
615 ORptFilter & rImport(static_cast<ORptFilter&>(GetImport()));
616 switch (nElement)
617 {
618 case XML_ELEMENT(OFFICE, XML_BODY):
619 return new RptXMLDocumentBodyContext(rImport);
620 case XML_ELEMENT(OFFICE, XML_FONT_FACE_DECLS):
621 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
622 return rImport.CreateFontDeclsContext();
623 case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES):
624 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
625 return rImport.CreateStylesContext(true);
626 }
627 return nullptr;
628 }
629};
630
631}
632
634 const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
635{
636 SvXMLImportContext *pContext = nullptr;
637
638 switch (nElement)
639 {
641 GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
642 pContext = CreateMetaContext( nElement );
643 break;
645 pContext = new RptXMLDocumentContentContext(*this);
646 break;
648 pContext = new RptXMLDocumentStylesContext(*this);
649 break;
651 GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
652 pContext = new RptXMLDocumentSettingsContext(*this);
653 break;
654 }
655 return pContext;
656}
657
659{
660 SvXMLImportContext* pContext = bIsAutoStyle ? GetAutoStyles() : GetStyles();
661 if ( !pContext )
662 {
663 pContext = new OReportStylesContext(*this, bIsAutoStyle);
664 if (bIsAutoStyle)
665 SetAutoStyles(static_cast<SvXMLStylesContext*>(pContext));
666 else
667 SetStyles(static_cast<SvXMLStylesContext*>(pContext));
668 }
669 return pContext;
670}
671
673{
674 XMLFontStylesContext *pFSContext =
675 new XMLFontStylesContext( *this, osl_getThreadTextEncoding() );
676 SetFontDecls( pFSContext );
677 return pFSContext;
678}
679
681{
682 return new XMLShapeImportHelper( *this,GetModel() );
683}
684
686{
687 if( GetStyles() )
688 GetStyles()->FinishStyles( true );
689}
690
691const OUString& ORptFilter::convertFormula(const OUString& _sFormula)
692{
693 return _sFormula;
694}
695
697{
698 m_xReportDefinition.set(GetModel(),UNO_QUERY_THROW);
700 OSL_ENSURE(m_pReportModel,"Report model is NULL!");
701
702 SvXMLImport::startDocument();
703}
704
706{
707 OSL_ENSURE( GetModel().is(), "model missing; maybe startDocument wasn't called?" );
708 if( !GetModel().is() )
709 return;
710
711 // this method will modify the document directly -> lock SolarMutex
712 SolarMutexGuard aGuard;
713 // Clear the shape import to sort the shapes (and not in the
714 // destructor that might be called after the import has finished
715 // for Java filters.
716 if( HasShapeImport() )
717 ClearShapeImport();
718
719 // delegate to parent: takes care of error handling
720 SvXMLImport::endDocument();
721}
722
723void ORptFilter::removeFunction(const OUString& _sFunctionName)
724{
725 m_aFunctions.erase(_sFunctionName);
726}
727
728void ORptFilter::insertFunction(const css::uno::Reference< css::report::XFunction > & _xFunction)
729{
730 m_aFunctions.emplace(_xFunction->getName(),_xFunction);
731}
732
734{
735 SvXMLImportContext* pContext = nullptr;
736
737 if ( getImportFlags() & SvXMLImportFlags::META )
738 {
739 uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), uno::UNO_QUERY_THROW);
740 pContext = new SvXMLMetaDocumentContext(*this, xDPS->getDocumentProperties());
741 }
742 return pContext;
743}
744
746{
747 bool bOldFormat = true;
748 uno::Reference<beans::XPropertySet> xProp = getImportInfo();
749 if ( xProp.is() )
750 {
751 static constexpr OUStringLiteral s_sOld = u"OldFormat";
752 if ( xProp->getPropertySetInfo()->hasPropertyByName(s_sOld))
753 {
754 xProp->getPropertyValue(s_sOld) >>= bOldFormat;
755 }
756 }
757 return bOldFormat;
758}
759
760
761}// rptxml
762
763
764/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral sHierarchicalDocumentName
static vcl::Window * GetFocusWindow()
bool IsWarning() const
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
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()
static std::shared_ptr< rptui::OReportModel > getSdrModel(const css::uno::Reference< css::report::XReportDefinition > &_xReportDefinition)
bool implImport(const Sequence< PropertyValue > &rDescriptor)
Definition: xmlfilter.cxx:345
void removeFunction(const OUString &_sFunctionName)
Definition: xmlfilter.cxx:723
virtual sal_Bool SAL_CALL filter(const Sequence< PropertyValue > &rDescriptor) override
Definition: xmlfilter.cxx:328
static const OUString & convertFormula(const OUString &_sFormula)
Definition: xmlfilter.cxx:691
rtl::Reference< XMLPropertySetMapper > m_xRowStylesPropertySetMapper
Definition: xmlfilter.hxx:64
std::shared_ptr< rptui::OReportModel > m_pReportModel
Definition: xmlfilter.hxx:67
rtl::Reference< XMLPropertySetMapper > m_xColumnStylesPropertySetMapper
Definition: xmlfilter.hxx:63
bool isOldFormat() const
Definition: xmlfilter.cxx:745
SvXMLImportContext * CreateMetaContext(const sal_Int32 nElement)
Definition: xmlfilter.cxx:733
SvXMLImportContext * CreateStylesContext(bool bIsAutoStyle)
Definition: xmlfilter.cxx:658
SvXMLImportContext * CreateFontDeclsContext()
Definition: xmlfilter.cxx:672
virtual void SAL_CALL startDocument() override
Definition: xmlfilter.cxx:696
TGroupFunctionMap m_aFunctions
Definition: xmlfilter.hxx:59
virtual SvXMLImportContext * CreateFastContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlfilter.cxx:633
void insertFunction(const css::uno::Reference< css::report::XFunction > &_xFunction)
inserts a new function
Definition: xmlfilter.cxx:728
const Reference< XReportDefinition > & getReportDefinition() const
Definition: xmlfilter.hxx:92
virtual XMLShapeImportHelper * CreateShapeImport() override
Definition: xmlfilter.cxx:680
rtl::Reference< XMLPropertyHandlerFactory > m_xPropHdlFactory
Definition: xmlfilter.hxx:61
virtual ~ORptFilter() noexcept override
Definition: xmlfilter.cxx:315
virtual void SAL_CALL endDocument() override
Definition: xmlfilter.cxx:705
rtl::Reference< XMLPropertySetMapper > m_xCellStylesPropertySetMapper
Definition: xmlfilter.hxx:62
Reference< XReportDefinition > m_xReportDefinition
Definition: xmlfilter.hxx:66
static const XMLPropertyMapEntry * GetColumnStyleProps()
Definition: xmlHelper.cxx:175
static const XMLPropertyMapEntry * GetRowStyleProps()
Definition: xmlHelper.cxx:164
static rtl::Reference< XMLPropertySetMapper > GetCellStylePropertyMap(bool _bOldFormat, bool bForExport)
Definition: xmlHelper.cxx:106
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32, const css::uno::Reference< css::xml::sax::XFastAttributeList > &) override
Definition: xmlfilter.cxx:580
bool is() const
static constexpr OUStringLiteral PROP_DOCUMENTBASEURL
void LeaveWait()
void EnterWait()
#define TOOLS_WARN_EXCEPTION(area, stream)
float u
#define ERRCODE_IO_BROKENPACKAGE
#define ERRCODE_NONE
Sequence< sal_Int8 > aSeq
#define SAL_WARN_IF(condition, area, stream)
@ Exception
COMPHELPER_DLLPUBLIC css::uno::Reference< css::beans::XPropertySet > GenericPropertySet_CreateInstance(PropertySetInfo *pInfo)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * reportdesign_ORptImportHelper_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Imports only settings.
Definition: xmlfilter.cxx:246
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * reportdesign_ORptMetaImportHelper_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Imports only meta data.
Definition: xmlfilter.cxx:286
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * reportdesign_OReportFilter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Definition: xmlfilter.cxx:320
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * reportdesign_ORptStylesImportHelper_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Imports only styles.
Definition: xmlfilter.cxx:272
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * reportdesign_XMLOasisContentImporter_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
Imports only content.
Definition: xmlfilter.cxx:259
static ErrCode ReadThroughComponent(const uno::Reference< embed::XStorage > &xStorage, const uno::Reference< XComponent > &xModelComponent, const char *pStreamName, const uno::Reference< XComponentContext > &rxContext, const Reference< document::XGraphicStorageHandler > &rxGraphicStorageHandler, const Reference< document::XEmbeddedObjectResolver > &_xEmbeddedObjectResolver, const OUString &_sFilterName, const uno::Reference< beans::XPropertySet > &_xProp)
read a component (storage version)
Definition: xmlfilter.cxx:168
static ErrCode ReadThroughComponent(const uno::Reference< XInputStream > &xInputStream, const uno::Reference< XComponent > &xModelComponent, const uno::Reference< XComponentContext > &rContext, const uno::Reference< XFastParser > &rFastParser)
read a component (file + filter version)
Definition: xmlfilter.cxx:111
XML_DOCUMENT_SETTINGS
XML_N_RPT
XML_DOCUMENT_STYLES
XML_DOCUMENT_META
XML_REPORT
XML_N_RPT_OASIS
XML_DOCUMENT_CONTENT
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
#define ERRCODE_SFX_WRONGPASSWORD
constexpr OUStringLiteral SERVICE_STYLESIMPORTER
Definition: strings.hxx:271
constexpr OUStringLiteral SERVICE_SETTINGSIMPORTER
Definition: strings.hxx:270
constexpr OUStringLiteral SERVICE_METAIMPORTER
Definition: strings.hxx:273
constexpr OUStringLiteral SERVICE_CONTENTIMPORTER
Definition: strings.hxx:272
Reference< XModel > xModel
unsigned char sal_Bool
#define PROGRESS_BAR_STEP
Definition: xmlEnums.hxx:22
#define XML_ELEMENT(prefix, name)
SvXMLImportFlags
constexpr sal_uInt16 XML_NAMESPACE_REPORT