25#include <com/sun/star/beans/XPropertyAccess.hpp>
26#include <com/sun/star/beans/XPropertySet.hpp>
27#include <com/sun/star/beans/Pair.hpp>
28#include <com/sun/star/embed/XRelationshipAccess.hpp>
29#include <com/sun/star/frame/XModel.hpp>
30#include <com/sun/star/xml/sax/XFastSAXSerializable.hpp>
31#include <com/sun/star/xml/sax/XSAXSerializable.hpp>
32#include <com/sun/star/xml/sax/Writer.hpp>
37#include <rtl/strbuf.hxx>
38#include <rtl/ustrbuf.hxx>
39#include <osl/diagnose.h>
49#include <oox/token/namespaces.hxx>
51#include <oox/token/properties.hxx>
52#include <oox/token/tokens.hxx>
53#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
54#include <com/sun/star/document/XOOXMLDocumentPropertiesImporter.hpp>
55#include <com/sun/star/xml/dom/DocumentBuilder.hpp>
65#include <com/sun/star/util/Date.hpp>
66#include <com/sun/star/util/Duration.hpp>
72using ::com::sun::star::xml::dom::DocumentBuilder;
73using ::com::sun::star::xml::dom::XDocument;
74using ::com::sun::star::xml::dom::XDocumentBuilder;
89using ::sax_fastparser::FSHelperPtr;
90using ::sax_fastparser::FastSerializerHelper;
94const Sequence< beans::Pair< OUString, sal_Int32 > >& NamespaceIds()
96 static const Sequence< beans::Pair< OUString, sal_Int32 > > SINGLETON
98 {
"http://www.w3.org/XML/1998/namespace", NMSP_xml},
99 {
"http://schemas.openxmlformats.org/package/2006/relationships",
101 {
"http://schemas.openxmlformats.org/officeDocument/2006/relationships",
103 {
"http://purl.oclc.org/ooxml/officeDocument/relationships",
105 {
"http://schemas.openxmlformats.org/drawingml/2006/main", NMSP_dml},
106 {
"http://purl.oclc.org/ooxml/drawingml/main", NMSP_dml},
107 {
"http://schemas.openxmlformats.org/drawingml/2006/diagram",
109 {
"http://purl.oclc.org/ooxml/drawingml/diagram", NMSP_dmlDiagram},
110 {
"http://schemas.openxmlformats.org/drawingml/2006/chart",
112 {
"http://schemas.openxmlformats.org/drawingml/2006/chartDrawing",
114 {
"urn:schemas-microsoft-com:vml", NMSP_vml},
115 {
"urn:schemas-microsoft-com:office:office", NMSP_vmlOffice},
116 {
"urn:schemas-microsoft-com:office:word", NMSP_vmlWord},
117 {
"urn:schemas-microsoft-com:office:excel", NMSP_vmlExcel},
118 {
"urn:schemas-microsoft-com:office:powerpoint", NMSP_vmlPowerpoint},
119 {
"http://schemas.microsoft.com/office/2006/activeX", NMSP_ax},
120 {
"http://schemas.openxmlformats.org/spreadsheetml/2006/main",
122 {
"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
124 {
"http://schemas.microsoft.com/office/excel/2006/main",
126 {
"http://schemas.openxmlformats.org/presentationml/2006/main",
128 {
"http://schemas.openxmlformats.org/markup-compatibility/2006",
130 {
"http://schemas.openxmlformats.org/spreadsheetml/2006/main/v2",
132 {
"http://schemas.openxmlformats.org/officeDocument/2006/math",
134 {
"http://schemas.microsoft.com/office/drawing/2008/diagram",
136 {
"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
138 {
"http://schemas.libreoffice.org/", NMSP_loext},
139 {
"http://schemas.microsoft.com/office/drawing/2010/main",
141 {
"http://schemas.microsoft.com/office/powerpoint/2010/main",
143 {
"http://schemas.microsoft.com/office/powerpoint/2012/main",
145 {
"http://schemas.microsoft.com/office/spreadsheetml/2011/1/ac",
147 {
"http://schemas.microsoft.com/office/drawing/2012/chart",
149 {
"http://schemas.microsoft.com/office/spreadsheetml/2015/revision2",
155void registerNamespaces( FastParser& rParser )
157 const Sequence< beans::Pair<OUString, sal_Int32> >& ids = NamespaceIds();
163 for (
const auto& rId : ids)
166 for (
auto const& elem : aSet)
167 rParser.registerNamespace(elem);
201 mbMissingExtDrawing(false)
214 mxImpl->maFastParser.clearDocumentHandler();
220 return std::shared_ptr<::oox::drawingml::Theme>();
226 if (!xDocProps->getGenerator().startsWithIgnoreAsciiCase(
"Microsoft"))
230 uno::Reference<beans::XPropertyAccess> xUserDefProps(xDocProps->getUserDefinedProperties(), uno::UNO_QUERY);
231 if (!xUserDefProps.is())
236 if (it == aUserDefinedProperties.
end())
240 if (!(it->second >>= aValue))
243 if (!aValue.startsWithIgnoreAsciiCase(
"12."))
246 SAL_INFO(
"oox",
"a MSO 2007 document");
255 uno::Reference<beans::XPropertySet> xDocProps(xDstDoc, uno::UNO_QUERY);
258 uno::Reference<beans::XPropertySetInfo> xPropsInfo = xDocProps->getPropertySetInfo();
260 static constexpr OUStringLiteral aGrabBagPropName =
u"InteropGrabBag";
261 if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(aGrabBagPropName))
267 aGrabBag.
update(rProperties);
274 catch (
const uno::Exception&)
276 SAL_WARN(
"oox",
"Failed to save documents grab bag");
283 Reference< XInputStream > xInputStream;
286 xInputStream = xDetector->extractUnencryptedPackage( aMediaDesc );
288 Reference< XStorage > xDocumentStorage (
290 Reference< XInterface > xTemp = xContext->getServiceManager()->createInstanceWithContext(
291 "com.sun.star.document.OOXMLDocumentPropertiesImporter",
293 Reference< XOOXMLDocumentPropertiesImporter > xImporter( xTemp, UNO_QUERY );
294 Reference< XDocumentPropertiesSupplier > xPropSupplier(
xModel, UNO_QUERY);
295 Reference< XDocumentProperties > xDocProps = xPropSupplier->getDocumentProperties();
296 xImporter->importProperties( xDocumentStorage, xDocProps );
305 registerNamespaces(*pParser);
311OUString getTransitionalRelationshipOfficeDocType(std::u16string_view rPart)
313 return OUString::Concat(
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/")
317OUString getStrictRelationshipOfficeDocType(std::u16string_view rPart)
319 return OUString::Concat(
"http://purl.oclc.org/ooxml/officeDocument/relationships/") + rPart;
327 const OUString aTransitionalRelationshipType = getTransitionalRelationshipOfficeDocType(rPart);
328 OUString aFragment =
importRelations( OUString() )->getFragmentPathFromFirstType( aTransitionalRelationshipType );
329 if(aFragment.isEmpty())
331 const OUString aStrictRelationshipType = getStrictRelationshipOfficeDocType(rPart);
332 aFragment =
importRelations( OUString() )->getFragmentPathFromFirstType( aStrictRelationshipType );
341 registerNamespaces(aParser);
347 OSL_ENSURE( rxHandler.is(),
"XmlFilterBase::importFragment - missing fragment handler" );
348 if( !rxHandler.is() )
352 OUString aFragmentPath = rxHandler->getFragmentPath();
353 OSL_ENSURE( !aFragmentPath.isEmpty(),
"XmlFilterBase::importFragment - missing fragment path" );
354 if( aFragmentPath.isEmpty() )
363 Reference< XInputStream > xInStrm(
openInputStream( aFragmentPath ), UNO_SET_THROW );
371 aSource.
mxInStream = std::make_shared<BinaryXInputStream>( xInStrm,
true );
383 if( !rxHandler.is() )
393 Reference< XInputStream > xInStrm = rxHandler->openFragmentStream();
398 sal_Int32 nPathLen = aFragmentPath.lastIndexOf(
'/') + 1;
399 OUString fileName = aFragmentPath.copy(nPathLen);
400 OUString sLowerCaseFileName = fileName.toAsciiLowerCase();
401 if ( fileName != sLowerCaseFileName )
403 aFragmentPath = aFragmentPath.subView(0, nPathLen) + sLowerCaseFileName;
409 if( xInStrm.is() )
try
417 OSL_FAIL( OStringBuffer(
"XmlFilterBase::importFragment - XML parser failed in fragment '" +
418 OUStringToOString( aFragmentPath, RTL_TEXTENCODING_ASCII_US ) +
"'" ).getStr() );
429 Reference<XDocument> xRet;
432 OSL_ENSURE( !aFragmentPath.isEmpty(),
"XmlFilterBase::importFragment - empty fragment path" );
433 if( aFragmentPath.isEmpty() )
449 Reference<XDocumentBuilder> xDomBuilder( DocumentBuilder::create(
getComponentContext() ) );
452 xRet = xDomBuilder->parse(xInStrm);
462 const Reference< XFastSAXSerializable >& rxSerializer )
464 if( !rxHandler.is() )
470 rxSerializer->fastSerialize( rxHandler,
471 mxImpl->maFastParser.getTokenHandler(),
472 Sequence< StringPair >(),
489 rxRelations = std::make_shared<Relations>( rFragmentPath );
499 aPropSet.
setProperty( PROP_MediaType, rMediaType );
500 return xOutputStream;
505 const bool bWriteHeader = rMediaType.indexOf(
"vml" ) < 0 || rMediaType.indexOf(
"+xml" ) >= 0;
506 return std::make_shared<FastSerializerHelper>(
openFragmentStream( rStreamName, rMediaType ), bWriteHeader );
511OUString lclAddRelation(
const Reference< XRelationshipAccess >& rRelations, sal_Int32
nId,
const OUString& rType, std::u16string_view rTarget,
bool bExternal )
513 OUString
sId =
"rId" + OUString::number(
nId );
515 Sequence< StringPair > aEntry( bExternal ? 3 : 2 );
516 auto pEntry = aEntry.getArray();
517 pEntry[0].First =
"Type";
518 pEntry[0].Second = rType;
519 pEntry[1].First =
"Target";
523 pEntry[2].First =
"TargetMode";
524 pEntry[2].Second =
"External";
526 rRelations->insertRelationshipByID( sId, aEntry,
true );
535 Reference< XRelationshipAccess > xRelations(
getStorage()->getXStorage(), UNO_QUERY );
536 if( xRelations.is() )
537 return lclAddRelation( xRelations,
mnRelId ++, rType,
rTarget,
false );
542OUString
XmlFilterBase::addRelation(
const Reference< XOutputStream >& rOutputStream,
const OUString& rType, std::u16string_view rTarget,
bool bExternal )
548 aPropSet.getProperty(
nId, PROP_RelId );
552 Reference< XRelationshipAccess > xRelations( rOutputStream, UNO_QUERY );
553 if( xRelations.is() )
554 return lclAddRelation( xRelations,
nId, rType, rTarget, bExternal );
562 pDoc->startElement(nXmlElement);
563 pDoc->writeEscaped( sValue );
564 pDoc->endElement( nXmlElement );
570 pDoc->startElement(nXmlElement);
572 pDoc->endElement( nXmlElement );
578 if( rTime.Year == 0 )
581 if ( ( nXmlElement >> 16 ) != XML_dcterms )
582 pDoc->startElement(nXmlElement);
584 pDoc->startElement(nXmlElement,
FSNS(XML_xsi,
XML_type),
"dcterms:W3CDTF");
587 snprintf( pStr,
sizeof( pStr ),
"%d-%02d-%02dT%02d:%02d:%02dZ",
588 rTime.Year, rTime.Month, rTime.Day,
589 rTime.Hours, rTime.Minutes, rTime.Seconds );
593 pDoc->endElement( nXmlElement );
599 if( !aItems.hasElements() )
604 ::comphelper::intersperse(aItems.begin(), aItems.end(),
628 sValue =
"http://schemas.openxmlformats.org/officedocument/2006/relationships/metadata/core-properties";
631 sValue =
"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
636 "application/vnd.openxmlformats-package.core-properties+xml" );
637 pCoreProps->startElementNS( XML_cp, XML_coreProperties,
644 uno::Reference<beans::XPropertyAccess> xUserDefinedProperties(xProperties->getUserDefinedProperties(), uno::UNO_QUERY);
648 it = aUserDefinedProperties.
find(
"OOXMLCorePropertyCategory");
649 if (it != aUserDefinedProperties.
end())
652 if (it->second >>= aValue)
656 it = aUserDefinedProperties.
find(
"OOXMLCorePropertyContentStatus");
657 if (it != aUserDefinedProperties.
end())
660 if (it->second >>= aValue)
664 it = aUserDefinedProperties.
find(
"OOXMLCorePropertyContentType");
665 if (it != aUserDefinedProperties.
end())
668 if (it->second >>= aValue)
671 writeElement( pCoreProps,
FSNS( XML_dcterms, XML_created ), xProperties->getCreationDate() );
672 writeElement( pCoreProps,
FSNS( XML_dc, XML_creator ), xProperties->getAuthor() );
673 writeElement( pCoreProps,
FSNS( XML_dc, XML_description ), xProperties->getDescription() );
675 it = aUserDefinedProperties.
find(
"OOXMLCorePropertyIdentifier");
676 if (it != aUserDefinedProperties.
end())
679 if (it->second >>= aValue)
682 writeElement( pCoreProps,
FSNS( XML_cp, XML_keywords ), xProperties->getKeywords() );
684 writeElement( pCoreProps,
FSNS( XML_cp, XML_lastModifiedBy ), xProperties->getModifiedBy() );
685 writeElement( pCoreProps,
FSNS( XML_cp, XML_lastPrinted ), xProperties->getPrintDate() );
686 writeElement( pCoreProps,
FSNS( XML_dcterms, XML_modified ), xProperties->getModificationDate() );
687 writeElement( pCoreProps,
FSNS( XML_cp, XML_revision ), xProperties->getEditingCycles() );
688 writeElement( pCoreProps,
FSNS( XML_dc, XML_subject ), xProperties->getSubject() );
689 writeElement( pCoreProps,
FSNS( XML_dc, XML_title ), xProperties->getTitle() );
691 it = aUserDefinedProperties.
find(
"OOXMLCorePropertyVersion");
692 if (it != aUserDefinedProperties.
end())
695 if (it->second >>= aValue)
699 pCoreProps->endElementNS( XML_cp, XML_coreProperties );
701 pCoreProps->endDocument();
708 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",
709 u"docProps/app.xml" );
712 "application/vnd.openxmlformats-officedocument.extended-properties+xml" );
713 pAppProps->startElement( XML_Properties,
717 uno::Reference<beans::XPropertyAccess> xUserDefinedProperties(xProperties->getUserDefinedProperties(), uno::UNO_QUERY);
721 writeElement( pAppProps, XML_Template, xProperties->getTemplateName() );
723 it = aUserDefinedProperties.
find(
"Manager");
724 if (it != aUserDefinedProperties.
end())
727 if (it->second >>= aValue)
732 writeElement( pAppProps, XML_PresentationFormat,
"presentation format" );
738 writeElement( pAppProps, XML_TotalTime, xProperties->getEditingDuration() / 60 );
740 writeElement( pAppProps, XML_HiddenSlides,
"hidden slides" );
743 writeElement( pAppProps, XML_HeadingPairs,
"heading pairs" );
744 writeElement( pAppProps, XML_TitlesOfParts,
"titles of parts" );
745 writeElement( pAppProps, XML_LinksUpToDate,
"links up-to-date" );
748 writeElement( pAppProps, XML_HyperlinksChanged,
"hyperlinks changed" );
749 writeElement( pAppProps, XML_DigSig,
"digital signature" );
753 it = aUserDefinedProperties.
find(
"HyperlinkBase");
754 if (it != aUserDefinedProperties.
end())
757 if (it->second >>= aValue)
769 it = aUserDefinedProperties.
find(
"DocSecurity");
770 if (it != aUserDefinedProperties.
end())
773 if (it->second >>=
nValue)
780 it = aStats.
find(
"PageCount");
781 if (it != aStats.
end())
783 if (it->second >>=
nValue)
787 it = aStats.
find(
"WordCount");
788 if (it != aStats.
end())
790 if (it->second >>=
nValue)
794 it = aStats.
find(
"NonWhitespaceCharacterCount");
795 if (it != aStats.
end())
797 if (it->second >>=
nValue)
801 it = aStats.
find(
"CharacterCount");
802 if (it != aStats.
end())
804 if (it->second >>=
nValue)
808 it = aStats.
find(
"ParagraphCount");
809 if (it != aStats.
end())
811 if (it->second >>=
nValue)
815 it = aUserDefinedProperties.
find(
"Company");
816 if (it != aUserDefinedProperties.
end())
819 if (it->second >>= aValue)
823 pAppProps->endElement( XML_Properties );
825 pAppProps->endDocument();
831 uno::Reference<beans::XPropertyAccess> xUserDefinedProperties( xProperties->getUserDefinedProperties(), uno::UNO_QUERY );
832 auto aprop = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(xUserDefinedProperties->getPropertyValues());
833 sal_Int32 nbCustomProperties = aprop.size();
837 if (!nbCustomProperties && !bSecurityOptOpenReadOnly)
840 if (bSecurityOptOpenReadOnly)
842 PropertyValue aPropertyValue;
844 aPropertyValue.Name =
"_MarkAsFinal";
845 aPropertyValue.Value <<=
true;
846 aprop.push_back(aPropertyValue);
850 "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties",
851 u"docProps/custom.xml" );
853 "docProps/custom.xml",
854 "application/vnd.openxmlformats-officedocument.custom-properties+xml" );
855 pAppProps->startElement( XML_Properties,
860 for (
const auto& rProp : aprop)
862 if ( !rProp.Name.isEmpty() )
865 if (( rProp.Name ==
"OOXMLCorePropertyCategory" ) ||
866 ( rProp.Name ==
"OOXMLCorePropertyContentStatus" ) ||
867 ( rProp.Name ==
"OOXMLCorePropertyContentType" ) ||
868 ( rProp.Name ==
"OOXMLCorePropertyIdentifier" ) ||
869 ( rProp.Name ==
"OOXMLCorePropertyVersion" ) ||
870 ( rProp.Name ==
"HyperlinkBase" ) ||
871 ( rProp.Name ==
"AppVersion" ) ||
872 ( rProp.Name ==
"DocSecurity" ) ||
873 ( rProp.Name ==
"Manager" ) ||
874 ( rProp.Name ==
"Company" ))
878 pAppProps->startElement( XML_property ,
879 XML_fmtid,
"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
880 XML_pid, OString::number(
nIndex + 2),
881 XML_name, rProp.Name);
883 switch ( rProp.Value.getValueTypeClass() )
885 case TypeClass_STRING:
888 rProp.Value >>= aValue;
892 case TypeClass_BOOLEAN:
894 bool val = *o3tl::forceAccess<bool>(rProp.Value);
898 case TypeClass_DOUBLE:
901 if ( rProp.Value >>= num )
912 util::Duration aDuration;
913 util::DateTime aDateTime;
914 if ( rProp.Value >>= num )
919 else if ( rProp.Value >>= aDate )
921 aDateTime = util::DateTime( 0, 0 , 0, 0, aDate.Day, aDate.Month, aDate.Year,
true );
924 else if ( rProp.Value >>= aDuration )
928 OUString aDurationStr = buf.makeStringAndClear();
931 else if ( rProp.Value >>= aDateTime )
935 OSL_FAIL(
"XMLFilterBase::writeCustomProperties unsupported value type!" );
939 pAppProps->endElement( XML_property );
943 pAppProps->endElement( XML_Properties );
945 pAppProps->endDocument();
950 if( xProperties.is() )
966 return xDetector->extractUnencryptedPackage( rMediaDesc );
971 const Sequence< NamedValue > aMediaEncData = rMediaDescriptor.getUnpackedValueOrDefault(
973 Sequence< NamedValue >() );
975 if (aMediaEncData.getLength() == 0)
982 return Reference< XStream > (
983 xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.comp.MemoryStream", xContext),
984 uno::UNO_QUERY_THROW );
992 const Sequence< NamedValue > aMediaEncData = rMediaDescriptor.getUnpackedValueOrDefault(
994 Sequence< NamedValue >() );
996 if (aMediaEncData.getLength())
1040 mxImpl->mpDiagramFontHeights = pDiagramFontHeights;
1047 auto itr =
mxImpl->mrNamespaceMap.maTransitionalNamespaceMap.find(nNSID);
1048 if (itr ==
mxImpl->mrNamespaceMap.maTransitionalNamespaceMap.end())
1050 SAL_WARN(
"oox",
"missing namespace in the namespace map for : " << nNSID);
1059 Reference<XRelationshipAccess> xRelations(xDocumentStorage, UNO_QUERY);
1060 if (!xRelations.is())
1063 const uno::Sequence<uno::Sequence<beans::StringPair>> aSeqs = xRelations->getAllRelationships();
1065 std::vector<StreamDataSequence> aCustomFragments;
1066 std::vector<OUString> aCustomFragmentTypes;
1067 std::vector<OUString> aCustomFragmentTargets;
1068 for (
const uno::Sequence<beans::StringPair>&
aSeq : aSeqs)
1072 for (
const beans::StringPair& aPair :
aSeq)
1074 if (aPair.First ==
"Target")
1075 sTarget = aPair.Second;
1076 else if (aPair.First ==
"Type")
1077 sType = aPair.Second;
1081 if (!
sType.match(
"http://schemas.openxmlformats.org")
1082 && !
sType.match(
"http://purl.oclc.org"))
1087 aCustomFragments.emplace_back(aDataSeq);
1088 aCustomFragmentTypes.emplace_back(
sType);
1089 aCustomFragmentTargets.emplace_back(sTarget);
1100 std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomList;
1101 std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomPropsList;
1104 for (
int i = 1; ; ++
i)
1106 Reference<XDocument> xCustDoc =
importFragment(
"customXml/item" + OUString::number(
i) +
".xml");
1107 Reference<XDocument> xCustDocProps =
importFragment(
"customXml/itemProps" + OUString::number(
i) +
".xml");
1108 if (xCustDoc && xCustDocProps)
1110 aCustomXmlDomList.emplace_back(xCustDoc);
1111 aCustomXmlDomPropsList.emplace_back(xCustDocProps);
1122 uno::Sequence<uno::Sequence<beans::StringPair>> aContentTypeInfo;
1123 uno::Reference<io::XInputStream> xInputStream =
openInputStream(
"[Content_Types].xml");
1124 if (xInputStream.is())
1127 aGrabBagProperties[
"OOXContentTypes"] <<= aContentTypeInfo;
1136 uno::Reference<beans::XPropertySet> xPropSet(
xModel, uno::UNO_QUERY_THROW);
1138 uno::Reference<beans::XPropertySetInfo> xPropSetInfo = xPropSet->getPropertySetInfo();
1142 uno::Sequence<uno::Reference<xml::dom::XDocument>> customXmlDomlist;
1143 uno::Sequence<uno::Reference<xml::dom::XDocument>> customXmlDomPropslist;
1144 uno::Sequence<StreamDataSequence> customFragments;
1145 uno::Sequence<OUString> customFragmentTypes;
1146 uno::Sequence<OUString> customFragmentTargets;
1147 uno::Sequence<uno::Sequence<beans::StringPair>> aContentTypes;
1149 uno::Sequence<beans::PropertyValue> propList;
1151 for (
const auto& rProp : std::as_const(propList))
1153 const OUString propName = rProp.Name;
1154 if (propName ==
"OOXCustomXml")
1156 rProp.Value >>= customXmlDomlist;
1158 else if (propName ==
"OOXCustomXmlProps")
1160 rProp.Value >>= customXmlDomPropslist;
1162 else if (propName ==
"OOXCustomFragments")
1164 rProp.Value >>= customFragments;
1166 else if (propName ==
"OOXCustomFragmentTypes")
1168 rProp.Value >>= customFragmentTypes;
1170 else if (propName ==
"OOXCustomFragmentTargets")
1172 rProp.Value >>= customFragmentTargets;
1174 else if (propName ==
"OOXContentTypes")
1176 rProp.Value >>= aContentTypes;
1181 for (sal_Int32 j = 0; j < customXmlDomlist.getLength(); j++)
1183 uno::Reference<xml::dom::XDocument> customXmlDom = customXmlDomlist[j];
1184 uno::Reference<xml::dom::XDocument> customXmlDomProps = customXmlDomPropslist[j];
1185 const OUString fragmentPath =
"customXml/item" + OUString::number(j+1) +
".xml";
1186 if (customXmlDom.is())
1190 uno::Reference<xml::sax::XSAXSerializable> serializer(customXmlDom, uno::UNO_QUERY);
1193 serializer->serialize(uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW),
1194 uno::Sequence<beans::StringPair>());
1197 if (customXmlDomProps.is())
1199 uno::Reference<xml::sax::XSAXSerializable> serializer(customXmlDomProps, uno::UNO_QUERY);
1201 writer->setOutputStream(
openFragmentStream(
"customXml/itemProps"+OUString::number(j+1)+
".xml",
1202 "application/vnd.openxmlformats-officedocument.customXmlProperties+xml"));
1203 serializer->serialize(uno::Reference<xml::sax::XDocumentHandler>(writer, uno::UNO_QUERY_THROW),
1204 uno::Sequence<beans::StringPair>());
1209 Concat2View(
"itemProps"+OUString::number(j+1)+
".xml"));
1214 for (sal_Int32 j = 0; j < customFragments.getLength(); j++)
1216 addRelation(customFragmentTypes[j], customFragmentTargets[j]);
1217 const OUString aFilename = customFragmentTargets[j];
1219 if (xOutStream.is())
1221 xOutStream->writeBytes(customFragments[j]);
1222 uno::Reference<XPropertySet> xProps(xOutStream, uno::UNO_QUERY);
1226 const OUString aContentType = (aType.getLength() ? aType : OUString(
"application/octet-stream"));
1227 xProps->setPropertyValue(
"MediaType",
uno::Any(aContentType));
static OUString decode(std::u16string_view rText, DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
OUString getBcp47MS() const
static css::uno::Reference< css::embed::XStorage > GetStorageOfFormatFromInputStream(const OUString &aFormat, const css::uno::Reference< css::io::XInputStream > &xStream, const css::uno::Reference< css::uno::XComponentContext > &rxContext=css::uno::Reference< css::uno::XComponentContext >(), bool bRepairStorage=false)
iterator find(const OUString &rKey)
SequenceAsHashMapBase::iterator iterator
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
void update(const SequenceAsHashMap &rSource)
void reserve(size_type amount)
std::pair< const_iterator, bool > insert(Value &&x)
A wrapper for a UNO property set.
bool setProperty(sal_Int32 nPropId, const Type &rValue)
Puts the passed value into the property set.
void commit()
Commits the changes to the storage and all substorages.
Wrapper for a fast SAX parser that works on automatically generated OOXML token and namespace identif...
void parseStream(const css::xml::sax::InputSource &rInputSource, bool bCloseStream=false)
Parses the passed SAX input source.
void setDocumentHandler(const css::uno::Reference< css::xml::sax::XFastDocumentHandler > &rxDocHandler)
Sets the passed document handler that will receive the SAX parser events.
bool importBinaryData(StreamDataSequence &orDataSeq, const OUString &rStreamName)
Imports the raw binary data from the specified stream.
utl::MediaDescriptor & getMediaDescriptor() const
Returns the media descriptor.
const css::uno::Reference< css::frame::XModel > & getModel() const
Returns the document model (always existing).
OoxmlVersion getVersion() const
void commitStorage() const
Commits changes to base storage (and substorages)
css::uno::Reference< css::io::XInputStream > openInputStream(const OUString &rStreamName) const
Opens and returns the specified input stream from the base storage.
virtual css::uno::Reference< css::io::XStream > implGetOutputStream(utl::MediaDescriptor &rMediaDesc) const
const css::uno::Reference< css::uno::XComponentContext > & getComponentContext() const
Returns the component context passed in the filter constructor (always existing).
css::uno::Reference< css::io::XStream > const & getMainDocumentStream() const
css::uno::Reference< css::io::XOutputStream > openOutputStream(const OUString &rStreamName) const
Opens and returns the specified output stream from the base storage.
StorageRef const & getStorage() const
Returns the base storage of the imported/exported file.
void setFragmentHandler(const ::rtl::Reference< FragmentHandler > &rxHandler)
void parseStream(const RecordInputSource &rInputSource)
virtual ~XmlFilterBase() override
void setDiagramFontHeights(NamedShapePairs *pDiagramFontHeights)
bool isMSODocument() const
RelationsRef importRelations(const OUString &rFragmentPath)
Imports the relations fragment associated with the specified fragment.
virtual css::uno::Reference< css::io::XStream > implGetOutputStream(utl::MediaDescriptor &rMediaDesc) const override
NamedShapePairs * getDiagramFontHeights()
void importDocumentProperties()
Read the document properties and also the customXml entries (xlsx and pptx only).
::sax_fastparser::FSHelperPtr openFragmentStreamWithSerializer(const OUString &rStreamName, const OUString &rMediaType)
Opens specified output stream from the base storage with specified media type and returns new fast se...
OUString addRelation(const OUString &rType, std::u16string_view rTarget)
Adds new relation.
static FastParser * createParser()
void setMissingExtDrawing()
Signal that an MSO 2007-created SmartArt was found, need to warn the user about it.
OUString getFragmentPathFromFirstTypeFromOfficeDoc(std::u16string_view rPart)
virtual std::shared_ptr<::oox::drawingml::Theme > getCurrentThemePtr() const
May be implemented by filters which handle Diagrams, default returns empty ptr.
bool importFragment(const rtl::Reference< FragmentHandler > &rxHandler)
Imports a fragment using the passed fragment handler, which contains the full path to the fragment st...
void checkDocumentProperties(const css::uno::Reference< css::document::XDocumentProperties > &xDocProps)
css::uno::Reference< css::io::XOutputStream > openFragmentStream(const OUString &rStreamName, const OUString &rMediaType)
Opens and returns the specified output stream from the base storage with specified media type.
XmlFilterBase(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
OUString getNamespaceURL(sal_Int32 nNSID) const
void exportCustomFragments()
Write the customXml entries we are preserving (xlsx and pptx only).
::std::unique_ptr< XmlFilterBaseImpl > mxImpl
virtual bool implFinalizeExport(utl::MediaDescriptor &rMediaDescriptor) override
void importCustomFragments(css::uno::Reference< css::embed::XStorage > const &xDocumentStorage)
virtual css::uno::Reference< css::io::XInputStream > implGetInputStream(utl::MediaDescriptor &rMediaDesc) const override
bool isMSO2007Document() const
virtual StorageRef implCreateStorage(const css::uno::Reference< css::io::XInputStream > &rxInStream) const override
static void putPropertiesToDocumentGrabBag(const css::uno::Reference< css::lang::XComponent > &xDstDoc, const comphelper::SequenceAsHashMap &rProperties)
void exportDocumentProperties(const css::uno::Reference< css::document::XDocumentProperties > &xProperties, bool bSecurityOptOpenReadOnly)
Write the document properties into into the current OPC package.
Implements stream access for binary OLE storages.
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
static OUString GetGeneratorString()
constexpr sal_Int32 FSNS(sal_Int32 namespc, sal_Int32 element)
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
uno::Sequence< uno::Sequence< beans::StringPair > > ReadContentTypeSequence(const uno::Reference< io::XInputStream > &xInStream, const uno::Reference< uno::XComponentContext > &rContext)
OUString GetContentTypeByName(const css::uno::Sequence< css::uno::Sequence< css::beans::StringPair > > &rContentTypes, const OUString &rFilename)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Reference< XComponentContext > getProcessComponentContext()
constexpr OUStringLiteral gaBinSuffix(u".bin")
static void writeAppProperties(XmlFilterBase &rSelf, const Reference< XDocumentProperties > &xProperties)
static void writeElement(const FSHelperPtr &pDoc, sal_Int32 nXmlElement, std::u16string_view sValue)
std::shared_ptr< Relations > RelationsRef
static void writeCoreProperties(XmlFilterBase &rSelf, const Reference< XDocumentProperties > &xProperties)
static void writeCustomProperties(XmlFilterBase &rSelf, const Reference< XDocumentProperties > &xProperties, bool bSecurityOptOpenReadOnly)
std::map< OUString, ShapePairs > NamedShapePairs
OUString getRelationship(Relationship eRelationship)
std::shared_ptr< StorageBase > StorageRef
css::uno::Sequence< sal_Int8 > StreamDataSequence
NamespaceMap & StaticNamespaceMap()
Thread-safe singleton of a map of all supported XML namespace URLs.
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::shared_ptr< FastSerializerHelper > FSHelperPtr
constexpr OUStringLiteral OFOPXML_STORAGE_FORMAT_STRING
A map that contains all XML namespace URLs used in the filters.
RefMap< OUString, Relations > RelationsMap
NamedShapePairs * mpDiagramFontHeights
const NamespaceMap & mrNamespaceMap
RelationsMap maRelationsMap
Reference< XModel > xModel
constexpr OUStringLiteral UNO_NAME_MISC_OBJ_INTEROPGRABBAG