avmedia/source/framework/soundhandler.cxx | 5 chart2/source/controller/main/ChartFrameloader.cxx | 9 desktop/source/app/dispatchwatcher.cxx | 5 desktop/source/lib/init.cxx | 4 embeddedobj/source/commonembedding/persistence.cxx | 3 filter/qa/unit/svg.cxx | 4 filter/qa/unit/textfilterdetect.cxx | 6 filter/source/config/cache/typedetection.cxx | 31 filter/source/config/cache/typedetection.hxx | 23 filter/source/storagefilterdetect/filterdetect.cxx | 16 filter/source/svg/svgfilter.cxx | 5 filter/source/textfilterdetect/filterdetect.cxx | 46 filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx | 4 framework/inc/classes/taskcreator.hxx | 4 framework/source/classes/taskcreator.cxx | 5 framework/source/dispatch/oxt_handler.cxx | 4 framework/source/fwe/helper/titlehelper.cxx | 2 framework/source/helper/statusindicatorfactory.cxx | 2 framework/source/inc/loadenv/loadenv.hxx | 6 framework/source/layoutmanager/helpers.cxx | 3 framework/source/loadenv/loadenv.cxx | 28 framework/source/services/autorecovery.cxx | 32 framework/source/services/desktop.cxx | 6 framework/source/services/dispatchhelper.cxx | 4 framework/source/services/frame.cxx | 6 framework/source/uielement/toolbarmanager.cxx | 3 hwpfilter/source/hwpreader.cxx | 9 include/oox/core/filterbase.hxx | 11 include/oox/core/filterdetect.hxx | 4 include/oox/core/xmlfilterbase.hxx | 6 include/unotools/mediadescriptor.hxx | 481 ++----- oox/source/core/filterbase.cxx | 24 oox/source/core/filterdetect.cxx | 25 oox/source/core/xmlfilterbase.cxx | 14 oox/source/drawingml/chart/objectformatter.cxx | 1 oox/source/drawingml/shape.cxx | 1 reportdesign/inc/ReportDefinition.hxx | 6 reportdesign/source/core/api/ReportDefinition.cxx | 15 reportdesign/source/filter/xml/xmlfilter.cxx | 3 reportdesign/source/ui/report/ReportController.cxx | 2 sc/source/filter/oox/viewsettings.cxx | 1 sc/source/filter/oox/workbooksettings.cxx | 1 sc/source/filter/orcus/filterdetect.cxx | 3 sc/source/ui/docshell/docsh.cxx | 3 sc/source/ui/unoobj/exceldetect.cxx | 18 sc/source/ui/unoobj/scdetect.cxx | 10 scripting/source/provider/BrowseNodeFactoryImpl.cxx | 3 sd/qa/unit/SdrPdfImportTest.cxx | 4 sd/source/ui/framework/factories/BasicToolBarFactory.cxx | 3 sd/source/ui/unoidl/sddetect.cxx | 10 sfx2/source/appl/fileobj.cxx | 3 sfx2/source/bastyp/fltfnc.cxx | 2 sfx2/source/control/unoctitm.cxx | 4 sfx2/source/doc/DocumentMetadataAccess.cxx | 10 sfx2/source/doc/SfxDocumentMetaData.cxx | 10 sfx2/source/doc/docfile.cxx | 12 sfx2/source/doc/objmisc.cxx | 4 sfx2/source/doc/objstor.cxx | 2 sfx2/source/doc/sfxbasemodel.cxx | 6 starmath/source/smdetect.cxx | 6 starmath/source/unofilter.cxx | 5 svx/qa/unit/unodraw.cxx | 4 sw/qa/core/undo/undo.cxx | 4 sw/qa/extras/globalfilter/globalfilter.cxx | 10 sw/qa/extras/tiledrendering/tiledrendering.cxx | 6 sw/qa/extras/unowriter/unowriter.cxx | 3 sw/source/core/docnode/retrieveinputstream.cxx | 7 sw/source/core/layout/dumpfilter.cxx | 3 sw/source/core/unocore/unocrsrhelper.cxx | 2 sw/source/filter/html/htmlplug.cxx | 6 sw/source/filter/indexing/IndexingExportFilter.cxx | 3 sw/source/filter/ww8/docxexportfilter.cxx | 1 sw/source/filter/ww8/rtfexportfilter.cxx | 3 sw/source/ui/uno/swdetect.cxx | 8 sw/source/writerfilter/dmapper/DomainMapper.cxx | 4 sw/source/writerfilter/dmapper/DomainMapper.hxx | 6 sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 2 sw/source/writerfilter/dmapper/DomainMapper_Impl.hxx | 2 sw/source/writerfilter/dmapper/OLEHandler.cxx | 4 sw/source/writerfilter/dmapper/domainmapperfactory.cxx | 3 sw/source/writerfilter/filter/RtfFilter.cxx | 4 sw/source/writerfilter/filter/WriterFilter.cxx | 3 sw/source/writerfilter/inc/dmapper/DomainMapperFactory.hxx | 6 sw/source/writerfilter/inc/rtftok/RTFDocument.hxx | 5 sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx | 6 sw/source/writerfilter/rtftok/rtfdocumentfactory.cxx | 4 sw/source/writerfilter/rtftok/rtfdocumentimpl.cxx | 3 sw/source/writerfilter/rtftok/rtfdocumentimpl.hxx | 4 test/source/unoapi_test.cxx | 3 unotools/source/misc/mediadescriptor.cxx | 672 +++++----- vbahelper/source/vbahelper/vbadocumentsbase.cxx | 5 vcl/qa/cppunit/pdfexport/PDFEncryptionTest.cxx | 4 vcl/qa/cppunit/pdfexport/pdfexport.cxx | 4 vcl/qa/cppunit/pdfexport/pdfexport2.cxx | 4 writerperfect/inc/ImportFilter.hxx | 5 writerperfect/qa/unit/DrawingImportTest.cxx | 4 writerperfect/qa/unit/EPUBExportTest.cxx | 4 writerperfect/qa/unit/ImportTest.cxx | 3 writerperfect/qa/unit/PresentationImportTest.cxx | 5 writerperfect/qa/unit/SpreadsheetImportTest.cxx | 5 writerperfect/qa/unit/TextImportTest.cxx | 4 writerperfect/source/calc/MSWorksCalcImportFilter.cxx | 5 writerperfect/source/calc/MSWorksCalcImportFilter.hxx | 3 writerperfect/source/calc/MWAWCalcImportFilter.cxx | 3 writerperfect/source/calc/MWAWCalcImportFilter.hxx | 3 writerperfect/source/calc/NumbersImportFilter.cxx | 2 writerperfect/source/calc/NumbersImportFilter.hxx | 3 writerperfect/source/calc/StarOfficeCalcImportFilter.cxx | 3 writerperfect/source/calc/StarOfficeCalcImportFilter.hxx | 3 writerperfect/source/draw/CDRImportFilter.cxx | 2 writerperfect/source/draw/CDRImportFilter.hxx | 3 writerperfect/source/draw/CMXImportFilter.cxx | 2 writerperfect/source/draw/CMXImportFilter.hxx | 3 writerperfect/source/draw/FreehandImportFilter.cxx | 3 writerperfect/source/draw/FreehandImportFilter.hxx | 3 writerperfect/source/draw/MSPUBImportFilter.cxx | 2 writerperfect/source/draw/MSPUBImportFilter.hxx | 3 writerperfect/source/draw/MWAWDrawImportFilter.cxx | 3 writerperfect/source/draw/MWAWDrawImportFilter.hxx | 3 writerperfect/source/draw/PageMakerImportFilter.cxx | 3 writerperfect/source/draw/PageMakerImportFilter.hxx | 3 writerperfect/source/draw/QXPImportFilter.cxx | 2 writerperfect/source/draw/QXPImportFilter.hxx | 3 writerperfect/source/draw/StarOfficeDrawImportFilter.cxx | 3 writerperfect/source/draw/StarOfficeDrawImportFilter.hxx | 3 writerperfect/source/draw/VisioImportFilter.cxx | 2 writerperfect/source/draw/VisioImportFilter.hxx | 3 writerperfect/source/draw/WPGImportFilter.cxx | 2 writerperfect/source/draw/WPGImportFilter.hxx | 3 writerperfect/source/draw/ZMFImportFilter.cxx | 2 writerperfect/source/draw/ZMFImportFilter.hxx | 3 writerperfect/source/impress/KeynoteImportFilter.cxx | 2 writerperfect/source/impress/KeynoteImportFilter.hxx | 3 writerperfect/source/impress/MWAWPresentationImportFilter.cxx | 3 writerperfect/source/impress/MWAWPresentationImportFilter.hxx | 3 writerperfect/source/impress/StarOfficePresentationImportFilter.cxx | 2 writerperfect/source/impress/StarOfficePresentationImportFilter.hxx | 3 writerperfect/source/writer/AbiWordImportFilter.cxx | 2 writerperfect/source/writer/AbiWordImportFilter.hxx | 3 writerperfect/source/writer/EBookImportFilter.cxx | 5 writerperfect/source/writer/EBookImportFilter.hxx | 2 writerperfect/source/writer/EPUBExportFilter.cxx | 3 writerperfect/source/writer/EPUBPackage.cxx | 3 writerperfect/source/writer/MSWorksImportFilter.cxx | 3 writerperfect/source/writer/MSWorksImportFilter.hxx | 3 writerperfect/source/writer/MWAWImportFilter.cxx | 2 writerperfect/source/writer/MWAWImportFilter.hxx | 3 writerperfect/source/writer/PagesImportFilter.cxx | 2 writerperfect/source/writer/PagesImportFilter.hxx | 2 writerperfect/source/writer/StarOfficeWriterImportFilter.cxx | 3 writerperfect/source/writer/StarOfficeWriterImportFilter.hxx | 3 xmloff/source/chart/SchXMLChartContext.cxx | 7 xmlsecurity/source/helper/pdfsignaturehelper.cxx | 4 153 files changed, 1008 insertions(+), 968 deletions(-)
New commits: commit 7f198b27f427f3cd3a19482ad971dc78a978d425 Author: Mike Kaganski <[email protected]> AuthorDate: Wed Dec 3 15:44:45 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Dec 6 18:18:32 2025 +0100 Drop class utl::MediaDescriptor, and use comphelper::SequenceAsHashMap utl::MediaDescriptor was just a SequenceAsHashMap with a few added methods. It made it more difficult to assign a SequenceAsHashMap to MediaDescriptor, without real upsides. In many places, the class was used not as media descriptor, but just as helper to create sequences. This change puts the string constants and the former methods into a namespace utl::MediaDescriptor. It would be also good to drop comphelper::NamedValueCollection, which is basically a twin of comphelper::SequenceAsHashMap (TODO). Change-Id: Ia9b69c5a2ad153ecc654944c419c1880252ed86e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195163 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/avmedia/source/framework/soundhandler.cxx b/avmedia/source/framework/soundhandler.cxx index 6b9045cc5efd..beb4a2e13548 100644 --- a/avmedia/source/framework/soundhandler.cxx +++ b/avmedia/source/framework/soundhandler.cxx @@ -19,6 +19,7 @@ #include "soundhandler.hxx" +#include <comphelper/sequenceashashmap.hxx> #include <unotools/mediadescriptor.hxx> #include <com/sun/star/io/XInputStream.hpp> @@ -108,7 +109,7 @@ void SAL_CALL SoundHandler::dispatchWithNotification(const css::util::URL& // SAFE { const std::unique_lock aLock(m_aMutex); - utl::MediaDescriptor aDescriptor(lDescriptor); + comphelper::SequenceAsHashMap aDescriptor(lDescriptor); { //close streams otherwise on windows we can't reopen the file in the @@ -184,7 +185,7 @@ OUString SAL_CALL SoundHandler::detect( css::uno::Sequence< css::beans::Property OUString sTypeName; // Analyze given descriptor to find filename or input stream or ... - utl::MediaDescriptor aDescriptor(lDescriptor); + comphelper::SequenceAsHashMap aDescriptor(lDescriptor); OUString sURL = aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_URL, OUString()); OUString sReferer = aDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_REFERRER, OUString()); diff --git a/chart2/source/controller/main/ChartFrameloader.cxx b/chart2/source/controller/main/ChartFrameloader.cxx index 91e18a982cbe..693183e57e76 100644 --- a/chart2/source/controller/main/ChartFrameloader.cxx +++ b/chart2/source/controller/main/ChartFrameloader.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/frame/XLoadable.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <comphelper/diagnose_ex.hxx> +#include <comphelper/sequenceashashmap.hxx> namespace chart { @@ -81,9 +82,9 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa uno::Reference< frame::XModel > xModel; bool bHaveLoadedModel = false; - utl::MediaDescriptor aMediaDescriptor(rMediaDescriptor); + comphelper::SequenceAsHashMap aMediaDescriptor(rMediaDescriptor); { - utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_MODEL)); + auto aIt(aMediaDescriptor.find(utl::MediaDescriptor::PROP_MODEL)); if( aIt != aMediaDescriptor.end()) { xModel.set( (*aIt).second.get< uno::Reference< frame::XModel > >()); @@ -119,7 +120,7 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa try { - utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_URL)); + auto aIt(aMediaDescriptor.find(utl::MediaDescriptor::PROP_URL)); if( aIt != aMediaDescriptor.end()) { OUString aURL( (*aIt).second.get< OUString >()); @@ -136,7 +137,7 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa { aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL] <<= aURL; } - aMediaDescriptor.addInputStream(); + utl::MediaDescriptor::addInputStream(aMediaDescriptor); uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor; aMediaDescriptor >> aCompleteMediaDescriptor; apphelper::MediaDescriptorHelper aMDHelper( aCompleteMediaDescriptor ); diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index c5adba18ebee..be3ed2d92c27 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -53,6 +53,7 @@ #include <comphelper/propertyvalue.hxx> #include <comphelper/sequence.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <comphelper/diagnose_ex.hxx> #include <tools/urlobj.hxx> #include <unotools/mediadescriptor.hxx> @@ -289,7 +290,7 @@ OUString getName(const Reference< XInterface > & xDoc) Reference< XModel > xModel( xDoc, UNO_QUERY ); if (!xModel) return OUString(); - utl::MediaDescriptor aMediaDesc( xModel->getArgs() ); + comphelper::SequenceAsHashMap aMediaDesc(xModel->getArgs()); OUString aDocService = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTSERVICE, OUString() ); if (aDocService == "com.sun.star.text.TextDocument") return u"Writer"_ustr; @@ -627,7 +628,7 @@ bool DispatchWatcher::executeDispatchRequests( Reference< XModel > xModel( xDoc, UNO_QUERY ); if ( xModel.is() ) { - utl::MediaDescriptor aMediaDesc( xModel->getArgs() ); + comphelper::SequenceAsHashMap aMediaDesc(xModel->getArgs()); aDocService = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTSERVICE, OUString() ); } aFilter = impl_GuessFilter( aOutFile, aDocService ); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d65872ae8cbb..0f583fc262aa 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3847,7 +3847,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha std::vector<OUString> aFilteredOptionVec; bool bTakeOwnership = false; bool bCreateFromTemplate = false; - MediaDescriptor aSaveMediaDescriptor; + comphelper::SequenceAsHashMap aSaveMediaDescriptor; for (const auto& rOption : aOptionSeq) { if (rOption == "TakeOwnership") @@ -5029,7 +5029,7 @@ static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu SvMemoryStream aOutStream; uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aOutStream); - utl::MediaDescriptor aMediaDescriptor; + comphelper::SequenceAsHashMap aMediaDescriptor; switch (doc_getDocumentType(pThis)) { case LOK_DOCTYPE_PRESENTATION: diff --git a/embeddedobj/source/commonembedding/persistence.cxx b/embeddedobj/source/commonembedding/persistence.cxx index 0a923f88c24a..62b8fa5233b3 100644 --- a/embeddedobj/source/commonembedding/persistence.cxx +++ b/embeddedobj/source/commonembedding/persistence.cxx @@ -53,6 +53,7 @@ #include <comphelper/namedvaluecollection.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/configuration.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <tools/urlobj.hxx> #include <unotools/mediadescriptor.hxx> #include <unotools/securityoptions.hxx> @@ -1312,7 +1313,7 @@ void SAL_CALL OCommonEmbeddedObject::storeAsEntry( const uno::Reference< embed:: throw lang::DisposedException(); // TODO bool AutoSaveEvent = false; - utl::MediaDescriptor lArgs(lObjArgs); + comphelper::SequenceAsHashMap lArgs(lObjArgs); lArgs[utl::MediaDescriptor::PROP_AUTOSAVEEVENT] >>= AutoSaveEvent; if ( m_nObjectState == -1 ) diff --git a/filter/qa/unit/svg.cxx b/filter/qa/unit/svg.cxx index 0faa7a59922e..b2f033adcca6 100644 --- a/filter/qa/unit/svg.cxx +++ b/filter/qa/unit/svg.cxx @@ -20,9 +20,9 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <comphelper/propertyvalue.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <o3tl/string_view.hxx> #include <unotools/streamwrap.hxx> -#include <unotools/mediadescriptor.hxx> #include <tools/stream.hxx> #include <libxml/xpathInternals.h> @@ -201,7 +201,7 @@ CPPUNIT_TEST_FIXTURE(SvgFilterTest, testShapeNographic) uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY_THROW); SvMemoryStream aStream; uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aStream); - utl::MediaDescriptor aMediaDescriptor; + comphelper::SequenceAsHashMap aMediaDescriptor; aMediaDescriptor[u"FilterName"_ustr] <<= u"impress_svg_Export"_ustr; aMediaDescriptor[u"OutputStream"_ustr] <<= xOut; diff --git a/filter/qa/unit/textfilterdetect.cxx b/filter/qa/unit/textfilterdetect.cxx index c47cfd91f33d..887581ce6a9d 100644 --- a/filter/qa/unit/textfilterdetect.cxx +++ b/filter/qa/unit/textfilterdetect.cxx @@ -19,10 +19,10 @@ #include <comphelper/configuration.hxx> #include <comphelper/propertyvalue.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <officecfg/Office/Common.hxx> #include <osl/file.hxx> #include <sfx2/docfac.hxx> -#include <unotools/mediadescriptor.hxx> #include <unotools/streamwrap.hxx> #include <tools/stream.hxx> @@ -65,7 +65,7 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testTdf114428_ignore_xml_declaration) comphelper::makePropertyValue(u"InputStream"_ustr, xStream), comphelper::makePropertyValue(u"TypeName"_ustr, u"generic_HTML"_ustr) }; xDetect->detect(aDescriptor); - utl::MediaDescriptor aMediaDesc(aDescriptor); + comphelper::SequenceAsHashMap aMediaDesc(aDescriptor); OUString aFilterName = aMediaDesc.getUnpackedValueOrDefault(u"FilterName"_ustr, OUString()); // This was empty, XML declaration caused HTML detect to not handle XHTML. CPPUNIT_ASSERT_EQUAL(u"HTML (StarWriter)"_ustr, aFilterName); @@ -266,7 +266,7 @@ CPPUNIT_TEST_FIXTURE(TextFilterDetectTest, testMarkdownDetect) comphelper::makePropertyValue(u"InputStream"_ustr, xStream), comphelper::makePropertyValue(u"TypeName"_ustr, u"generic_Markdown"_ustr) }; xDetect->detect(aDescriptor); - utl::MediaDescriptor aMediaDesc(aDescriptor); + comphelper::SequenceAsHashMap aMediaDesc(aDescriptor); OUString aFilterName = aMediaDesc.getUnpackedValueOrDefault(u"FilterName"_ustr, OUString()); CPPUNIT_ASSERT_EQUAL(u"Markdown"_ustr, aFilterName); } diff --git a/filter/source/config/cache/typedetection.cxx b/filter/source/config/cache/typedetection.cxx index 49efe1c1a9f8..0dc12b0ba884 100644 --- a/filter/source/config/cache/typedetection.cxx +++ b/filter/source/config/cache/typedetection.cxx @@ -39,6 +39,7 @@ #include <framework/interaction.hxx> #include <comphelper/diagnose_ex.hxx> #include <tools/urlobj.hxx> +#include <unotools/mediadescriptor.hxx> #include <comphelper/fileurl.hxx> #include <comphelper/lok.hxx> #include <comphelper/sequence.hxx> @@ -384,7 +385,7 @@ OUString SAL_CALL TypeDetection::queryTypeByDescriptor(css::uno::Sequence< css:: sal_Bool bAllowDeep ) { // make the descriptor more usable :-) - utl::MediaDescriptor stlDescriptor(lDescriptor); + comphelper::SequenceAsHashMap stlDescriptor(lDescriptor); OUString sType, sURL; try @@ -474,7 +475,7 @@ OUString SAL_CALL TypeDetection::queryTypeByDescriptor(css::uno::Sequence< css:: } -void TypeDetection::impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDescriptor, +void TypeDetection::impl_checkResultsAndAddBestFilter(comphelper::SequenceAsHashMap& rDescriptor, OUString& sType ) { // a) @@ -770,7 +771,7 @@ OUString TypeDetection::impl_getTypeFromFilter(std::unique_lock<std::mutex>& /*r void TypeDetection::impl_getAllFormatTypes( std::unique_lock<std::mutex>& rGuard, - const util::URL& aParsedURL, utl::MediaDescriptor const & rDescriptor, FlatDetection& rFlatTypes) + const util::URL& aParsedURL, comphelper::SequenceAsHashMap const & rDescriptor, FlatDetection& rFlatTypes) { rFlatTypes.clear(); @@ -911,7 +912,7 @@ static bool isBrokenZIP(const css::uno::Reference<css::io::XInputStream>& xStrea } -OUString TypeDetection::impl_detectTypeFlatAndDeep( utl::MediaDescriptor& rDescriptor , +OUString TypeDetection::impl_detectTypeFlatAndDeep(comphelper::SequenceAsHashMap& rDescriptor, const FlatDetection& lFlatTypes , bool bAllowDeep , OUString& rLastChance ) @@ -1060,7 +1061,7 @@ OUString TypeDetection::impl_detectTypeFlatAndDeep( utl::MediaDescriptor& r // <- SAFE ---------------------------------- } -void TypeDetection::impl_seekStreamToZero(utl::MediaDescriptor const & rDescriptor) +void TypeDetection::impl_seekStreamToZero(comphelper::SequenceAsHashMap const& rDescriptor) { // try to seek to 0 ... // But because XSeekable is an optional interface ... try it only .-) @@ -1085,7 +1086,7 @@ void TypeDetection::impl_seekStreamToZero(utl::MediaDescriptor const & rDescript } OUString TypeDetection::impl_askDetectService(const OUString& sDetectService, - utl::MediaDescriptor& rDescriptor ) + comphelper::SequenceAsHashMap& rDescriptor) { // Open the stream and add it to the media descriptor if this method is called for the first time. // All following requests to this method will detect, that there already exists a stream .-) @@ -1171,7 +1172,7 @@ OUString TypeDetection::impl_askDetectService(const OUString& sDet } -OUString TypeDetection::impl_askUserForTypeAndFilterIfAllowed(utl::MediaDescriptor& rDescriptor) +OUString TypeDetection::impl_askUserForTypeAndFilterIfAllowed(comphelper::SequenceAsHashMap& rDescriptor) { css::uno::Reference< css::task::XInteractionHandler > xInteraction = rDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_INTERACTIONHANDLER, @@ -1230,7 +1231,7 @@ OUString TypeDetection::impl_askUserForTypeAndFilterIfAllowed(utl::MediaDescript } -void TypeDetection::impl_openStream(utl::MediaDescriptor& rDescriptor) +void TypeDetection::impl_openStream(comphelper::SequenceAsHashMap& rDescriptor) { bool bSuccess = false; OUString sURL = rDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_URL, OUString() ); @@ -1238,10 +1239,10 @@ void TypeDetection::impl_openStream(utl::MediaDescriptor& rDescriptor) if ( comphelper::isFileUrl( sURL ) ) { // OOo uses own file locking mechanics in case of local file - bSuccess = rDescriptor.addInputStreamOwnLock(); + bSuccess = utl::MediaDescriptor::addInputStreamOwnLock(rDescriptor); } else - bSuccess = rDescriptor.addInputStream(); + bSuccess = utl::MediaDescriptor::addInputStream(rDescriptor); if ( !bSuccess ) throw css::uno::Exception( @@ -1259,10 +1260,10 @@ void TypeDetection::impl_openStream(utl::MediaDescriptor& rDescriptor) } -void TypeDetection::impl_removeTypeFilterFromDescriptor(utl::MediaDescriptor& rDescriptor) +void TypeDetection::impl_removeTypeFilterFromDescriptor(comphelper::SequenceAsHashMap& rDescriptor) { - utl::MediaDescriptor::iterator pItType = rDescriptor.find(utl::MediaDescriptor::PROP_TYPENAME ); - utl::MediaDescriptor::iterator pItFilter = rDescriptor.find(utl::MediaDescriptor::PROP_FILTERNAME); + auto pItType = rDescriptor.find(utl::MediaDescriptor::PROP_TYPENAME); + auto pItFilter = rDescriptor.find(utl::MediaDescriptor::PROP_FILTERNAME); if (pItType != rDescriptor.end()) rDescriptor.erase(pItType); if (pItFilter != rDescriptor.end()) @@ -1270,7 +1271,7 @@ void TypeDetection::impl_removeTypeFilterFromDescriptor(utl::MediaDescriptor& rD } -bool TypeDetection::impl_validateAndSetTypeOnDescriptor( utl::MediaDescriptor& rDescriptor, +bool TypeDetection::impl_validateAndSetTypeOnDescriptor(comphelper::SequenceAsHashMap& rDescriptor, const OUString& sType ) { if (GetTheFilterCache().hasItem(FilterCache::E_TYPE, sType)) @@ -1285,7 +1286,7 @@ bool TypeDetection::impl_validateAndSetTypeOnDescriptor( utl::MediaDescript } -bool TypeDetection::impl_validateAndSetFilterOnDescriptor( utl::MediaDescriptor& rDescriptor, +bool TypeDetection::impl_validateAndSetFilterOnDescriptor( comphelper::SequenceAsHashMap& rDescriptor, const OUString& sFilter ) { try diff --git a/filter/source/config/cache/typedetection.hxx b/filter/source/config/cache/typedetection.hxx index 6ff70e64eba4..698cf7b9ada6 100644 --- a/filter/source/config/cache/typedetection.hxx +++ b/filter/source/config/cache/typedetection.hxx @@ -21,7 +21,7 @@ #include "basecontainer.hxx" #include <com/sun/star/document/XTypeDetection.hpp> #include <com/sun/star/frame/XTerminateListener.hpp> -#include <unotools/mediadescriptor.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <cppuhelper/compbase.hxx> #include <cppuhelper/implbase.hxx> #include <comphelper/compbase.hxx> @@ -85,7 +85,7 @@ private: */ static void impl_getAllFormatTypes( std::unique_lock<std::mutex>& rGuard, - const css::util::URL& aParsedURL, utl::MediaDescriptor const & rDescriptor, + const css::util::URL& aParsedURL, comphelper::SequenceAsHashMap const & rDescriptor, FlatDetection& rFlatTypes); @@ -123,7 +123,7 @@ private: An empty value if detection failed. ... but see rLastChance for additional returns! */ - OUString impl_detectTypeFlatAndDeep( utl::MediaDescriptor& rDescriptor , + OUString impl_detectTypeFlatAndDeep(comphelper::SequenceAsHashMap& rDescriptor, const FlatDetection& lFlatTypes , bool bAllowDeep , OUString& rLastChance ); @@ -139,7 +139,7 @@ private: @param rDescriptor a stl representation of the MediaDescriptor as in/out parameter. */ - static void impl_seekStreamToZero(utl::MediaDescriptor const & rDescriptor); + static void impl_seekStreamToZero(comphelper::SequenceAsHashMap const& rDescriptor); /** @short make deep type detection for a specified @@ -160,7 +160,7 @@ private: a stl representation of the MediaDescriptor as in/out parameter. */ OUString impl_askDetectService(const OUString& sDetectService, - utl::MediaDescriptor& rDescriptor ); + comphelper::SequenceAsHashMap& rDescriptor); /** @short try to find an interaction handler and @@ -176,7 +176,7 @@ private: @return [string] a valid type name or an empty string if user canceled interaction. */ - static OUString impl_askUserForTypeAndFilterIfAllowed(utl::MediaDescriptor& rDescriptor); + static OUString impl_askUserForTypeAndFilterIfAllowed(comphelper::SequenceAsHashMap& rDescriptor); /** @short check if an input stream is already part of the @@ -212,7 +212,7 @@ private: Note: If an interactionHandler is part of the given descriptor too, it was already used. Means: let the exception pass through the top most interface method! */ - void impl_openStream(utl::MediaDescriptor& rDescriptor); + void impl_openStream(comphelper::SequenceAsHashMap& rDescriptor); /** @short validate the specified type and its relationships @@ -233,7 +233,7 @@ private: @return TRUE the specified type and its registrations was valid(!) and could be set on the descriptor. */ - static bool impl_validateAndSetTypeOnDescriptor( utl::MediaDescriptor& rDescriptor, + static bool impl_validateAndSetTypeOnDescriptor(comphelper::SequenceAsHashMap& rDescriptor, const OUString& sType ); @@ -254,8 +254,7 @@ private: @return TRUE the specified type and its registrations was valid(!) and could be set on the descriptor. */ - static bool impl_validateAndSetFilterOnDescriptor( - utl::MediaDescriptor& rDescriptor, + static bool impl_validateAndSetFilterOnDescriptor(comphelper::SequenceAsHashMap& rDescriptor, const OUString& sFilter ); @@ -270,7 +269,7 @@ private: reference to the MediaDescriptor (represented by an easy-to-use stl interface!), which should be patched. */ - static void impl_removeTypeFilterFromDescriptor(utl::MediaDescriptor& rDescriptor); + static void impl_removeTypeFilterFromDescriptor(comphelper::SequenceAsHashMap& rDescriptor); /** @short search the best suitable filter for the given type @@ -303,7 +302,7 @@ private: rDescriptor will be changed by selecting another filter. (see code) */ - void impl_checkResultsAndAddBestFilter(utl::MediaDescriptor& rDescriptor, + void impl_checkResultsAndAddBestFilter(comphelper::SequenceAsHashMap& rDescriptor, OUString& sType ); diff --git a/filter/source/storagefilterdetect/filterdetect.cxx b/filter/source/storagefilterdetect/filterdetect.cxx index cc4c8950d35f..02e5e249667e 100644 --- a/filter/source/storagefilterdetect/filterdetect.cxx +++ b/filter/source/storagefilterdetect/filterdetect.cxx @@ -21,6 +21,7 @@ #include <comphelper/documentconstants.hxx> #include <comphelper/storagehelper.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <cppuhelper/supportsservice.hxx> #include <unotools/mediadescriptor.hxx> #include <tools/urlobj.hxx> @@ -36,7 +37,6 @@ #include <comphelper/lok.hxx> using namespace ::com::sun::star; -using utl::MediaDescriptor; namespace { @@ -85,12 +85,12 @@ StorageFilterDetect::~StorageFilterDetect() {} OUString SAL_CALL StorageFilterDetect::detect(uno::Sequence<beans::PropertyValue>& rDescriptor) { - MediaDescriptor aMediaDesc( rDescriptor ); + comphelper::SequenceAsHashMap aMediaDesc(rDescriptor); OUString aTypeName; try { - uno::Reference< io::XInputStream > xInStream( aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM], uno::UNO_QUERY ); + uno::Reference< io::XInputStream > xInStream( aMediaDesc[utl::MediaDescriptor::PROP_INPUTSTREAM], uno::UNO_QUERY ); if ( !xInStream.is() ) return OUString(); @@ -117,12 +117,12 @@ OUString SAL_CALL StorageFilterDetect::detect(uno::Sequence<beans::PropertyValue packages::zip::ZipIOException aZipException; // We don't do any type detection on broken packages (f.e. because it might be impossible), // so for repairing we'll use the requested type, which was detected by the flat detection. - OUString aRequestedTypeName = aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_TYPENAME, OUString() ); + OUString aRequestedTypeName = aMediaDesc.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_TYPENAME, OUString() ); if ( ( aWrap.TargetException >>= aZipException ) && !aRequestedTypeName.isEmpty() ) { // The package is a broken one. INetURLObject aParser( - aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL, OUString())); + aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_URL, OUString())); OUString aDocumentTitle = aParser.getName(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset); bool bRepairPackage = aMediaDesc.getUnpackedValueOrDefault(u"RepairPackage"_ustr, false); @@ -130,7 +130,7 @@ OUString SAL_CALL StorageFilterDetect::detect(uno::Sequence<beans::PropertyValue if (!bRepairPackage && aMediaDesc.getUnpackedValueOrDefault(u"RepairAllowed"_ustr, true)) { uno::Reference< task::XInteractionHandler > xInteraction = - aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER, uno::Reference< task::XInteractionHandler >() ); + aMediaDesc.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_INTERACTIONHANDLER, uno::Reference< task::XInteractionHandler >() ); if ( xInteraction.is() ) { @@ -152,8 +152,8 @@ OUString SAL_CALL StorageFilterDetect::detect(uno::Sequence<beans::PropertyValue aTypeName = aRequestedTypeName; // lok: we want to overwrite file in jail, so don't use template flag const bool bIsLOK = comphelper::LibreOfficeKit::isActive(); - aMediaDesc[MediaDescriptor::PROP_DOCUMENTTITLE] <<= aDocumentTitle; - aMediaDesc[MediaDescriptor::PROP_ASTEMPLATE] <<= !bIsLOK; + aMediaDesc[utl::MediaDescriptor::PROP_DOCUMENTTITLE] <<= aDocumentTitle; + aMediaDesc[utl::MediaDescriptor::PROP_ASTEMPLATE] <<= !bIsLOK; aMediaDesc[u"RepairPackage"_ustr] <<= true; } diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index f4407aad9563..7cbebd0d82fe 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -37,6 +37,7 @@ #include <unotools/ucbstreamhelper.hxx> #include <tools/debug.hxx> #include <comphelper/diagnose_ex.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <tools/zcodec.hxx> #include <drawinglayer/primitive2d/baseprimitive2d.hxx> @@ -218,7 +219,7 @@ bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescripto { // Import. // use MediaDescriptor to get needed data out of Sequence< PropertyValue > - utl::MediaDescriptor aMediaDescriptor(rDescriptor); + comphelper::SequenceAsHashMap aMediaDescriptor(rDescriptor); uno::Reference<io::XInputStream> xInputStream; xInputStream.set(aMediaDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM], UNO_QUERY); @@ -774,7 +775,7 @@ public: OUString SAL_CALL SVGFilter::detect(Sequence<PropertyValue>& rDescriptor) { - utl::MediaDescriptor aMediaDescriptor(rDescriptor); + comphelper::SequenceAsHashMap aMediaDescriptor(rDescriptor); uno::Reference<io::XInputStream> xInput(aMediaDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM], UNO_QUERY); OUString aRetval; diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx index 7162933178a1..da606db92ffe 100644 --- a/filter/source/textfilterdetect/filterdetect.cxx +++ b/filter/source/textfilterdetect/filterdetect.cxx @@ -9,6 +9,7 @@ #include "filterdetect.hxx" +#include <comphelper/sequenceashashmap.hxx> #include <svtools/htmltokn.h> #include <tools/urlobj.hxx> #include <tools/zcodec.hxx> @@ -34,7 +35,6 @@ constexpr OUString WRITER_DOCSERVICE = u"com.sun.star.text.TextDocument"_ustr; constexpr OUString CALC_DOCSERVICE = u"com.sun.star.sheet.SpreadsheetDocument"_ustr; using namespace ::com::sun::star; -using utl::MediaDescriptor; namespace { @@ -137,45 +137,45 @@ PlainTextFilterDetect::~PlainTextFilterDetect() {} OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyValue>& lDescriptor) { - MediaDescriptor aMediaDesc(lDescriptor); + comphelper::SequenceAsHashMap aMediaDesc(lDescriptor); - OUString aType = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_TYPENAME, OUString() ); - OUString aDocService = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_DOCUMENTSERVICE, OUString() ); + OUString aType = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_TYPENAME, OUString() ); + OUString aDocService = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_DOCUMENTSERVICE, OUString() ); if ((aType == "generic_HTML") || (aType == "calc_HTML")) { - uno::Reference<io::XInputStream> xInStream(aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM], uno::UNO_QUERY); + uno::Reference<io::XInputStream> xInStream(aMediaDesc[utl::MediaDescriptor::PROP_INPUTSTREAM], uno::UNO_QUERY); if (!xInStream.is() || !IsHTMLStream(xInStream)) return OUString(); if ((aDocService == CALC_DOCSERVICE) || (aType == "calc_HTML")) - aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= OUString(CALC_HTML_FILTER); + aMediaDesc[utl::MediaDescriptor::PROP_FILTERNAME] <<= OUString(CALC_HTML_FILTER); else if (aDocService == WRITER_DOCSERVICE) - aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= OUString(WRITER_HTML_FILTER); + aMediaDesc[utl::MediaDescriptor::PROP_FILTERNAME] <<= OUString(WRITER_HTML_FILTER); else - aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= OUString(WEB_HTML_FILTER); + aMediaDesc[utl::MediaDescriptor::PROP_FILTERNAME] <<= OUString(WEB_HTML_FILTER); } else if(aType == "generic_Markdown") { - uno::Reference<io::XInputStream> xInStream(aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM], uno::UNO_QUERY); + uno::Reference<io::XInputStream> xInStream(aMediaDesc[utl::MediaDescriptor::PROP_INPUTSTREAM], uno::UNO_QUERY); if (!xInStream.is()) return OUString(); - INetURLObject aParser(aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL, OUString() ) ); + INetURLObject aParser(aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_URL, OUString() ) ); OUString aExt = aParser.getExtension(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset); aExt = aExt.toAsciiLowerCase(); if(aDocService == WRITER_DOCSERVICE) - aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= WRITER_MARKDOWN_FILTER; + aMediaDesc[utl::MediaDescriptor::PROP_FILTERNAME] <<= WRITER_MARKDOWN_FILTER; else if(aExt == "md" || aExt == "markdown") - aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= WRITER_MARKDOWN_FILTER; + aMediaDesc[utl::MediaDescriptor::PROP_FILTERNAME] <<= WRITER_MARKDOWN_FILTER; else return OUString(); } else if (aType == "generic_Text") { - uno::Reference<io::XStream> xStream(aMediaDesc[MediaDescriptor::PROP_STREAM], uno::UNO_QUERY); - uno::Reference<io::XInputStream> xInStream(aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM], uno::UNO_QUERY); + uno::Reference<io::XStream> xStream(aMediaDesc[utl::MediaDescriptor::PROP_STREAM], uno::UNO_QUERY); + uno::Reference<io::XInputStream> xInStream(aMediaDesc[utl::MediaDescriptor::PROP_INPUTSTREAM], uno::UNO_QUERY); if (xStream.is() || xInStream.is()) { ZCodec aCodecGZ; @@ -188,16 +188,16 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal if (aCodecGZ.AttemptDecompression(*pInStream, *pDecompressedStream)) { uno::Reference<io::XStream> xStreamDecompressed(new utl::OStreamWrapper(std::move(pDecompressedStream))); - aMediaDesc[MediaDescriptor::PROP_STREAM] <<= xStreamDecompressed; - aMediaDesc[MediaDescriptor::PROP_INPUTSTREAM] <<= xStreamDecompressed->getInputStream(); - OUString aURL = aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL, OUString() ); + aMediaDesc[utl::MediaDescriptor::PROP_STREAM] <<= xStreamDecompressed; + aMediaDesc[utl::MediaDescriptor::PROP_INPUTSTREAM] <<= xStreamDecompressed->getInputStream(); + OUString aURL = aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_URL, OUString() ); sal_Int32 nIdx = aURL.lastIndexOf(".gz"); if (nIdx != -1) - aMediaDesc[MediaDescriptor::PROP_URL] <<= aURL.copy(0, nIdx); + aMediaDesc[utl::MediaDescriptor::PROP_URL] <<= aURL.copy(0, nIdx); } } // Get the file name extension. - INetURLObject aParser(aMediaDesc.getUnpackedValueOrDefault(MediaDescriptor::PROP_URL, OUString() ) ); + INetURLObject aParser(aMediaDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_URL, OUString() ) ); OUString aExt = aParser.getExtension(INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset); aExt = aExt.toAsciiLowerCase(); OUString aName = aParser.getName().toAsciiLowerCase(); @@ -206,13 +206,13 @@ OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal // then on extension if that's not available. if (aDocService == CALC_DOCSERVICE) - aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= CALC_TEXT_FILTER; + aMediaDesc[utl::MediaDescriptor::PROP_FILTERNAME] <<= CALC_TEXT_FILTER; else if (aDocService == WRITER_DOCSERVICE) - aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= WRITER_TEXT_FILTER; + aMediaDesc[utl::MediaDescriptor::PROP_FILTERNAME] <<= WRITER_TEXT_FILTER; else if (aExt == "csv" || aExt == "tsv" || aExt == "tab" || aExt == "xls" || aName.endsWith(".csv.gz")) - aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= CALC_TEXT_FILTER; + aMediaDesc[utl::MediaDescriptor::PROP_FILTERNAME] <<= CALC_TEXT_FILTER; else - aMediaDesc[MediaDescriptor::PROP_FILTERNAME] <<= WRITER_TEXT_FILTER; + aMediaDesc[utl::MediaDescriptor::PROP_FILTERNAME] <<= WRITER_TEXT_FILTER; } else diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx index 6f74e5d8ac0a..30c763c7547b 100644 --- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx +++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx @@ -63,7 +63,7 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >& const OUString sXMLImportService = msUserData[2]; sal_Int32 nSteps= 0; - utl::MediaDescriptor aMediaMap(aDescriptor); + comphelper::SequenceAsHashMap aMediaMap(aDescriptor); Reference< XStatusIndicator > xStatusIndicator(aMediaMap.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_STATUSINDICATOR, Reference< XStatusIndicator >())); @@ -228,7 +228,7 @@ bool XmlFilterAdaptor::exportImpl( const Sequence< css::beans::PropertyValue >& // Status Bar sal_Int32 nSteps= 1; - utl::MediaDescriptor aMediaMap(aDescriptor); + comphelper::SequenceAsHashMap aMediaMap(aDescriptor); Reference< XStatusIndicator > xStatusIndicator(aMediaMap.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_STATUSINDICATOR, Reference< XStatusIndicator >())); diff --git a/framework/inc/classes/taskcreator.hxx b/framework/inc/classes/taskcreator.hxx index d57cc406e3b7..5b8e7a335124 100644 --- a/framework/inc/classes/taskcreator.hxx +++ b/framework/inc/classes/taskcreator.hxx @@ -24,7 +24,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <rtl/ustring.hxx> -#include <unotools/mediadescriptor.hxx> +#include <comphelper/sequenceashashmap.hxx> namespace framework{ @@ -51,7 +51,7 @@ class TaskCreator final TaskCreator( css::uno::Reference< css::uno::XComponentContext > xContext ); ~TaskCreator( ); - css::uno::Reference< css::frame::XFrame > createTask( const OUString& sName, const utl::MediaDescriptor& rDescriptor ); + css::uno::Reference< css::frame::XFrame > createTask( const OUString& sName, const comphelper::SequenceAsHashMap& rDescriptor ); }; // class TaskCreator diff --git a/framework/source/classes/taskcreator.cxx b/framework/source/classes/taskcreator.cxx index 167e345e051e..c9732d054cb8 100644 --- a/framework/source/classes/taskcreator.cxx +++ b/framework/source/classes/taskcreator.cxx @@ -26,6 +26,9 @@ #include <com/sun/star/frame/TaskCreator.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/beans/NamedValue.hpp> + +#include <rtl/ref.hxx> + #include <utility> namespace framework{ @@ -54,7 +57,7 @@ TaskCreator::~TaskCreator() /*-**************************************************************************************************** TODO document me *//*-*****************************************************************************************************/ -css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName, const utl::MediaDescriptor& rDescriptor ) +css::uno::Reference< css::frame::XFrame > TaskCreator::createTask( const OUString& sName, const comphelper::SequenceAsHashMap& rDescriptor ) { rtl::Reference< TaskCreatorService > xCreator = new TaskCreatorService(m_xContext); diff --git a/framework/source/dispatch/oxt_handler.cxx b/framework/source/dispatch/oxt_handler.cxx index 7d38224e4329..de47f9383b19 100644 --- a/framework/source/dispatch/oxt_handler.cxx +++ b/framework/source/dispatch/oxt_handler.cxx @@ -18,6 +18,8 @@ */ #include <dispatch/oxt_handler.hxx> + +#include <comphelper/sequenceashashmap.hxx> #include <unotools/mediadescriptor.hxx> #include <com/sun/star/frame/DispatchResultState.hpp> @@ -142,7 +144,7 @@ OUString SAL_CALL Oxt_Handler::detect( css::uno::Sequence< css::beans::PropertyV OUString sTypeName; // Analyze given descriptor to find filename or input stream or... - utl::MediaDescriptor aDescriptor( lDescriptor ); + comphelper::SequenceAsHashMap aDescriptor(lDescriptor); OUString sURL = aDescriptor.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_URL, OUString() ); tools::Long nLength = sURL.getLength(); diff --git a/framework/source/fwe/helper/titlehelper.cxx b/framework/source/fwe/helper/titlehelper.cxx index 422982ea629e..f2fa4bbb5482 100644 --- a/framework/source/fwe/helper/titlehelper.cxx +++ b/framework/source/fwe/helper/titlehelper.cxx @@ -341,7 +341,7 @@ void TitleHelper::impl_updateTitleForModel (const css::uno::Reference< css::fram OUString sTitle; - utl::MediaDescriptor aDescriptor( + comphelper::SequenceAsHashMap aDescriptor( xModel->getArgs2({ utl::MediaDescriptor::PROP_DOCUMENTTITLE, utl::MediaDescriptor::PROP_SUGGESTEDSAVEASNAME })); diff --git a/framework/source/helper/statusindicatorfactory.cxx b/framework/source/helper/statusindicatorfactory.cxx index 4787e48865bd..8351f1921667 100644 --- a/framework/source/helper/statusindicatorfactory.cxx +++ b/framework/source/helper/statusindicatorfactory.cxx @@ -365,7 +365,7 @@ void StatusIndicatorFactory::implts_makeParentVisibleIfAllowed() xModel = xController->getModel(); if (xModel.is()) { - utl::MediaDescriptor lDocArgs(xModel->getArgs()); + comphelper::SequenceAsHashMap lDocArgs(xModel->getArgs()); bHiddenDoc = lDocArgs.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_HIDDEN, false); diff --git a/framework/source/inc/loadenv/loadenv.hxx b/framework/source/inc/loadenv/loadenv.hxx index 3fba486c8161..38bfab20e393 100644 --- a/framework/source/inc/loadenv/loadenv.hxx +++ b/framework/source/inc/loadenv/loadenv.hxx @@ -25,7 +25,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/util/URL.hpp> #include <rtl/ref.hxx> -#include <unotools/mediadescriptor.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <o3tl/typed_flags_set.hxx> @@ -139,7 +139,7 @@ private: @descr Inside this struct e.g. the URL, its type and filter name, the stream or a model directly are saved. */ - utl::MediaDescriptor m_lMediaDescriptor; + comphelper::SequenceAsHashMap m_lMediaDescriptor; /** @short because the mediadescriptor contains the complete URL ... but some functionality need the structured version, we hold it twice :-(. @@ -338,7 +338,7 @@ public: /** TODO document me ... */ static void initializeUIDefaults( const css::uno::Reference< css::uno::XComponentContext >& i_rxContext, - utl::MediaDescriptor& io_lMediaDescriptor, + comphelper::SequenceAsHashMap& io_lMediaDescriptor, const bool _bUIMode, rtl::Reference<QuietInteraction>* o_ppQuiteInteraction ); diff --git a/framework/source/layoutmanager/helpers.cxx b/framework/source/layoutmanager/helpers.cxx index 6592b9b48d31..869526c921cf 100644 --- a/framework/source/layoutmanager/helpers.cxx +++ b/framework/source/layoutmanager/helpers.cxx @@ -30,6 +30,7 @@ #include <comphelper/lok.hxx> #include <comphelper/propertyvalue.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <unotools/mediadescriptor.hxx> #include <vcl/svapp.hxx> #include <o3tl/string_view.hxx> @@ -262,7 +263,7 @@ bool implts_isPreviewModel( const uno::Reference< frame::XModel >& xModel ) if ( xModel.is() ) { - utl::MediaDescriptor aDesc( xModel->getArgs() ); + comphelper::SequenceAsHashMap aDesc(xModel->getArgs()); return aDesc.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_PREVIEW, false); } else diff --git a/framework/source/loadenv/loadenv.cxx b/framework/source/loadenv/loadenv.cxx index 36c26f961194..d2008b7afff3 100644 --- a/framework/source/loadenv/loadenv.cxx +++ b/framework/source/loadenv/loadenv.cxx @@ -92,6 +92,7 @@ #include <comphelper/profilezone.hxx> #include <classes/taskcreator.hxx> #include <tools/fileutil.hxx> +#include <unotools/mediadescriptor.hxx> constexpr OUString PROP_TYPES = u"Types"_ustr; constexpr OUString PROP_NAME = u"Name"_ustr; @@ -214,15 +215,15 @@ css::uno::Reference< css::lang::XComponent > LoadEnv::loadComponentFromURL(const namespace { -utl::MediaDescriptor addModelArgs(const uno::Sequence<beans::PropertyValue>& rDescriptor) +comphelper::SequenceAsHashMap addModelArgs(const uno::Sequence<beans::PropertyValue>& rDescriptor) { - utl::MediaDescriptor rResult(rDescriptor); + comphelper::SequenceAsHashMap rResult(rDescriptor); uno::Reference<frame::XModel> xModel(rResult.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_MODEL, uno::Reference<frame::XModel>())); if (xModel.is()) { - utl::MediaDescriptor aModelArgs(xModel->getArgs()); - utl::MediaDescriptor::iterator pIt = aModelArgs.find( utl::MediaDescriptor::PROP_MACROEXECUTIONMODE); + comphelper::SequenceAsHashMap aModelArgs(xModel->getArgs()); + auto pIt = aModelArgs.find(utl::MediaDescriptor::PROP_MACROEXECUTIONMODE); if (pIt != aModelArgs.end()) rResult[utl::MediaDescriptor::PROP_MACROEXECUTIONMODE] = pIt->second; } @@ -283,7 +284,7 @@ void LoadEnv::startLoading(const OUString& sURL, const uno::Sequence<beans::Prop m_lMediaDescriptor[utl::MediaDescriptor::PROP_JUMPMARK] <<= m_aURL.Mark; // By the way: remove the old and deprecated value "FileName" from the descriptor! - utl::MediaDescriptor::iterator pIt = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_FILENAME); + auto pIt = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_FILENAME); if (pIt != m_lMediaDescriptor.end()) m_lMediaDescriptor.erase(pIt); @@ -313,7 +314,7 @@ void LoadEnv::startLoading(const OUString& sURL, const uno::Sequence<beans::Prop } void LoadEnv::initializeUIDefaults( const css::uno::Reference< css::uno::XComponentContext >& i_rxContext, - utl::MediaDescriptor& io_lMediaDescriptor, const bool i_bUIMode, + comphelper::SequenceAsHashMap& io_lMediaDescriptor, const bool i_bUIMode, rtl::Reference<QuietInteraction>* o_ppQuietInteraction ) { css::uno::Reference< css::task::XInteractionHandler > xInteractionHandler; @@ -591,11 +592,10 @@ LoadEnv::EContentType LoadEnv::classifyContent(const OUString& return E_CAN_BE_LOADED; // using of an existing input stream - utl::MediaDescriptor stlMediaDescriptor(lMediaDescriptor); - utl::MediaDescriptor::const_iterator pIt; + comphelper::SequenceAsHashMap stlMediaDescriptor(lMediaDescriptor); if (ProtocolCheck::isProtocol(sURL,EProtocol::PrivateStream)) { - pIt = stlMediaDescriptor.find(utl::MediaDescriptor::PROP_INPUTSTREAM); + auto pIt = stlMediaDescriptor.find(utl::MediaDescriptor::PROP_INPUTSTREAM); css::uno::Reference< css::io::XInputStream > xStream; if (pIt != stlMediaDescriptor.end()) pIt->second >>= xStream; @@ -608,7 +608,7 @@ LoadEnv::EContentType LoadEnv::classifyContent(const OUString& // using of a full featured document if (ProtocolCheck::isProtocol(sURL,EProtocol::PrivateObject)) { - pIt = stlMediaDescriptor.find(utl::MediaDescriptor::PROP_MODEL); + auto pIt = stlMediaDescriptor.find(utl::MediaDescriptor::PROP_MODEL); css::uno::Reference< css::frame::XModel > xModel; if (pIt != stlMediaDescriptor.end()) pIt->second >>= xModel; @@ -855,7 +855,7 @@ void LoadEnv::impl_detectTypeAndFilter() // SAFE -> aWriteLock.reset(); // Don't overwrite external decisions! See comments before ... - utl::MediaDescriptor::const_iterator pAsTemplateItem = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_ASTEMPLATE); + auto pAsTemplateItem = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_ASTEMPLATE); if (pAsTemplateItem == m_lMediaDescriptor.end()) m_lMediaDescriptor[utl::MediaDescriptor::PROP_ASTEMPLATE] <<= true; aWriteLock.clear(); @@ -1385,7 +1385,7 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchAlreadyLoaded() // and decide if it's really the same then the one will be. // It must be visible and must use the same file revision ... // or must not have any file revision set (-1 == -1!) - utl::MediaDescriptor lOldDocDescriptor; + comphelper::SequenceAsHashMap lOldDocDescriptor; if (xModel.is()) { lOldDocDescriptor = xModel->getArgs(); @@ -1572,7 +1572,7 @@ css::uno::Reference< css::frame::XFrame > LoadEnv::impl_searchRecycleTarget() css::uno::Reference< css::frame::XController > xOldDoc = xTask->getController(); if (xOldDoc.is()) { - utl::MediaDescriptor lOldDocDescriptor(xModel->getArgs()); + comphelper::SequenceAsHashMap lOldDocDescriptor(xModel->getArgs()); // replaceable document if (!lOldDocDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_REPLACEABLE, false)) @@ -1637,7 +1637,7 @@ void LoadEnv::impl_reactForLoadingState() // Note: Only if an existing property "FrameName" is given by this media descriptor, // it should be used. Otherwise we should do nothing. May be the outside code has already // set a frame name on the target! - utl::MediaDescriptor::const_iterator pFrameName = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_FRAMENAME); + auto pFrameName = m_lMediaDescriptor.find(utl::MediaDescriptor::PROP_FRAMENAME); if (pFrameName != m_lMediaDescriptor.end()) { OUString sFrameName; diff --git a/framework/source/services/autorecovery.cxx b/framework/source/services/autorecovery.cxx index 23076630e455..5182f1461b5e 100644 --- a/framework/source/services/autorecovery.cxx +++ b/framework/source/services/autorecovery.cxx @@ -831,12 +831,12 @@ private: // TODO document me void implts_openOneDoc(const OUString& sURL , - utl::MediaDescriptor& lDescriptor, + comphelper::SequenceAsHashMap& lDescriptor, AutoRecovery::TDocumentInfo& rInfo ); // TODO document me void implts_generateNewTempURL(const OUString& sBackupPath , - utl::MediaDescriptor& rMediaDescriptor, + comphelper::SequenceAsHashMap& rMediaDescriptor, AutoRecovery::TDocumentInfo& rInfo ); /** @short notifies all interested listener about the current state @@ -1016,11 +1016,11 @@ private: is used to set the new created progress as parameter on these set. */ static void impl_establishProgress(const AutoRecovery::TDocumentInfo& rInfo , - utl::MediaDescriptor& rArgs , + comphelper::SequenceAsHashMap& rArgs, const css::uno::Reference< css::frame::XFrame >& xNewFrame); static void impl_forgetProgress(const AutoRecovery::TDocumentInfo& rInfo , - utl::MediaDescriptor& rArgs , + comphelper::SequenceAsHashMap& rArgs, const css::uno::Reference< css::frame::XFrame >& xNewFrame); /** try to remove the specified file from disc. @@ -2466,7 +2466,7 @@ void AutoRecovery::implts_registerDocument(const css::uno::Reference< css::frame aCacheLock.unlock(); - utl::MediaDescriptor lDescriptor(xDocument->getArgs2( { utl::MediaDescriptor::PROP_FILTERNAME, utl::MediaDescriptor::PROP_NOAUTOSAVE } )); + comphelper::SequenceAsHashMap lDescriptor(xDocument->getArgs2( { utl::MediaDescriptor::PROP_FILTERNAME, utl::MediaDescriptor::PROP_NOAUTOSAVE } )); // check if this document must be ignored for recovery ! // Some use cases don't wish support for AutoSave/Recovery ... as e.g. OLE-Server / ActiveX Control etcpp. @@ -2716,7 +2716,7 @@ void AutoRecovery::implts_markDocumentAsSaved(const css::uno::Reference< css::fr aInfo.OldTempURL.clear(); aInfo.NewTempURL.clear(); - utl::MediaDescriptor lDescriptor(aInfo.Document->getArgs()); + comphelper::SequenceAsHashMap lDescriptor(aInfo.Document->getArgs()); aInfo.RealFilter = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_FILTERNAME, OUString()); css::uno::Reference< css::frame::XTitle > xDocTitle(xDocument, css::uno::UNO_QUERY); @@ -2886,7 +2886,7 @@ bool lc_checkIfSaveForbiddenByArguments(AutoRecovery::TDocumentInfo const & rInf if (! rInfo.Document.is()) return true; - utl::MediaDescriptor lDescriptor(rInfo.Document->getArgs()); + comphelper::SequenceAsHashMap lDescriptor(rInfo.Document->getArgs()); bool bNoAutoSave = lDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_NOAUTOSAVE, false); return bNoAutoSave; @@ -3080,12 +3080,12 @@ void AutoRecovery::implts_saveOneDoc(const OUString& if (!rInfo.Document.is()) return; - utl::MediaDescriptor lOldArgs(rInfo.Document->getArgs()); + comphelper::SequenceAsHashMap lOldArgs(rInfo.Document->getArgs()); implts_generateNewTempURL(sBackupPath, lOldArgs, rInfo); // if the document was loaded with a password, it should be // stored with password - utl::MediaDescriptor lNewArgs; + comphelper::SequenceAsHashMap lNewArgs; css::uno::Sequence< css::beans::NamedValue > aEncryptionData = lOldArgs.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_ENCRYPTIONDATA, css::uno::Sequence< css::beans::NamedValue >()); @@ -3287,7 +3287,7 @@ AutoRecovery::ETimerType AutoRecovery::implts_openDocs(const DispatchParams& aPa continue; } - utl::MediaDescriptor lDescriptor; + comphelper::SequenceAsHashMap lDescriptor; // it's a UI feature - so the "USER" itself must be set as referrer lDescriptor[utl::MediaDescriptor::PROP_REFERRER] <<= OUString(REFERRER_USER); @@ -3399,7 +3399,7 @@ AutoRecovery::ETimerType AutoRecovery::implts_openDocs(const DispatchParams& aPa if (!info.RealFilter.isEmpty()) { - utl::MediaDescriptor lPatchDescriptor(info.Document->getArgs()); + comphelper::SequenceAsHashMap lPatchDescriptor(info.Document->getArgs()); lPatchDescriptor[utl::MediaDescriptor::PROP_FILTERNAME] <<= info.RealFilter; info.Document->attachResource(info.Document->getURL(), lPatchDescriptor.getAsConstPropertyValueList()); // do *not* use sURL here. In case this points to the recovery file, it has already been passed @@ -3443,7 +3443,7 @@ AutoRecovery::ETimerType AutoRecovery::implts_openDocs(const DispatchParams& aPa } void AutoRecovery::implts_openOneDoc(const OUString& sURL , - utl::MediaDescriptor& lDescriptor, + comphelper::SequenceAsHashMap& lDescriptor, AutoRecovery::TDocumentInfo& rInfo ) { css::uno::Reference< css::frame::XDesktop2 > xDesktop = css::frame::Desktop::create(m_xContext); @@ -3578,7 +3578,7 @@ void AutoRecovery::implts_openOneDoc(const OUString& sURL , } void AutoRecovery::implts_generateNewTempURL(const OUString& sBackupPath , - utl::MediaDescriptor& /*rMediaDescriptor*/, + comphelper::SequenceAsHashMap& /*rMediaDescriptor*/, AutoRecovery::TDocumentInfo& rInfo ) { // specify URL for saving (which points to a temp file inside backup directory) @@ -4192,7 +4192,7 @@ void AutoRecovery::impl_showFullDiscError() // static void AutoRecovery::impl_establishProgress(const AutoRecovery::TDocumentInfo& rInfo , - utl::MediaDescriptor& rArgs , + comphelper::SequenceAsHashMap& rArgs, const css::uno::Reference< css::frame::XFrame >& xNewFrame) { // external well known frame must be preferred (because it was created by ourself @@ -4258,7 +4258,7 @@ void AutoRecovery::impl_establishProgress(const AutoRecovery::TDocumentInfo& // static void AutoRecovery::impl_forgetProgress(const AutoRecovery::TDocumentInfo& rInfo , - utl::MediaDescriptor& rArgs , + comphelper::SequenceAsHashMap& rArgs, const css::uno::Reference< css::frame::XFrame >& xNewFrame) { // external well known frame must be preferred (because it was created by ourself @@ -4283,7 +4283,7 @@ void AutoRecovery::impl_forgetProgress(const AutoRecovery::TDocumentInfo& xFrameProps->setPropertyValue(FramePropNames[FramePropHandle::IndicatorInterception], css::uno::Any(css::uno::Reference< css::task::XStatusIndicator >())); // forget progress inside list of arguments. - utl::MediaDescriptor::iterator pArg = rArgs.find(utl::MediaDescriptor::PROP_STATUSINDICATOR); + auto pArg = rArgs.find(utl::MediaDescriptor::PROP_STATUSINDICATOR); if (pArg != rArgs.end()) { rArgs.erase(pArg); diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx index 49115c708172..fc015370a551 100644 --- a/framework/source/services/desktop.cxx +++ b/framework/source/services/desktop.cxx @@ -574,7 +574,7 @@ css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::loadComponentFrom css::uno::Reference< css::frame::XComponentLoader > xThis(this); - utl::MediaDescriptor aDescriptor(lArguments); + comphelper::SequenceAsHashMap aDescriptor(lArguments); bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault(u"OnMainThread"_ustr, false); if (bOnMainThread) @@ -943,7 +943,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS if ( sTargetFrameName==SPECIALTARGET_BLANK ) { TaskCreator aCreator( m_xContext ); - xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor()); + xTarget = aCreator.createTask(sTargetFrameName, {}); } // I.II) "_top" @@ -1027,7 +1027,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL Desktop::findFrame( const OUS ) { TaskCreator aCreator( m_xContext ); - xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor()); + xTarget = aCreator.createTask(sTargetFrameName, {}); } } diff --git a/framework/source/services/dispatchhelper.cxx b/framework/source/services/dispatchhelper.cxx index b743e5b5ba4d..32854d7a37c1 100644 --- a/framework/source/services/dispatchhelper.cxx +++ b/framework/source/services/dispatchhelper.cxx @@ -24,7 +24,7 @@ #include <com/sun/star/util/XURLTransformer.hpp> #include <comphelper/profilezone.hxx> -#include <unotools/mediadescriptor.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <utility> #include <vcl/threadex.hxx> #include <cppuhelper/supportsservice.hxx> @@ -109,7 +109,7 @@ css::uno::Any SAL_CALL DispatchHelper::executeDispatch( css::uno::Reference<css::frame::XDispatch> xDispatch = xDispatchProvider->queryDispatch(aURL, sTargetFrameName, nSearchFlags); - utl::MediaDescriptor aDescriptor(lArguments); + comphelper::SequenceAsHashMap aDescriptor(lArguments); bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault(u"OnMainThread"_ustr, false); if (bOnMainThread) diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx index 441b25b57bef..0ab73de39035 100644 --- a/framework/source/services/frame.cxx +++ b/framework/source/services/frame.cxx @@ -573,7 +573,7 @@ css::uno::Reference< css::lang::XComponent > SAL_CALL XFrameImpl::loadComponentF css::uno::Reference< css::frame::XComponentLoader > xThis(this); - utl::MediaDescriptor aDescriptor(lArguments); + comphelper::SequenceAsHashMap aDescriptor(lArguments); bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault(u"OnMainThread"_ustr, false); if (bOnMainThread) @@ -981,7 +981,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL XFrameImpl::findFrame( const if ( sTargetFrameName==SPECIALTARGET_BLANK ) { TaskCreator aCreator(m_xContext); - xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor()); + xTarget = aCreator.createTask(sTargetFrameName, {}); } // I.II) "_parent" @@ -1180,7 +1180,7 @@ css::uno::Reference< css::frame::XFrame > SAL_CALL XFrameImpl::findFrame( const ) { TaskCreator aCreator(m_xContext); - xTarget = aCreator.createTask(sTargetFrameName, utl::MediaDescriptor()); + xTarget = aCreator.createTask(sTargetFrameName, {}); } } diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 701c31f7f561..a773c617ef4c 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -61,6 +61,7 @@ #include <unotools/mediadescriptor.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/propertysequence.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <svtools/miscopt.hxx> #include <svtools/imgdef.hxx> #include <utility> @@ -1805,7 +1806,7 @@ bool ToolBarManager::IsPluginMode() const if ( xModel.is() ) { Sequence< PropertyValue > aSeq = xModel->getArgs(); - utl::MediaDescriptor aMediaDescriptor( aSeq ); + comphelper::SequenceAsHashMap aMediaDescriptor(aSeq); bPluginMode = aMediaDescriptor.getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_VIEWONLY, false ); } } diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index 121183d4e7a2..ae507b62c4ce 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -31,6 +31,7 @@ #include <basegfx/numeric/ftools.hxx> #include <basegfx/point/b2dpoint.hxx> #include <comphelper/configuration.hxx> +#include <comphelper/sequenceashashmap.hxx> #include "fontmap.hxx" #include "formula.h" @@ -161,8 +162,8 @@ bool HwpReader::importHStream(std::unique_ptr<HStream> stream) sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor) { - utl::MediaDescriptor aDescriptor(rDescriptor); - aDescriptor.addInputStream(); + comphelper::SequenceAsHashMap aDescriptor(rDescriptor); + utl::MediaDescriptor::addInputStream(aDescriptor); Reference< XInputStream > xInputStream( aDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM], UNO_QUERY_THROW); @@ -4803,8 +4804,8 @@ OUString HwpImportFilter::detect( css::uno::Sequence< css::beans::PropertyValue { OUString sTypeName; - utl::MediaDescriptor aDescriptor(rDescriptor); - aDescriptor.addInputStream(); + comphelper::SequenceAsHashMap aDescriptor(rDescriptor); + utl::MediaDescriptor::addInputStream(aDescriptor); Reference< XInputStream > xInputStream( aDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM], UNO_QUERY); diff --git a/include/oox/core/filterbase.hxx b/include/oox/core/filterbase.hxx index b080fe5e2238..73af247ae6a2 100644 --- a/include/oox/core/filterbase.hxx +++ b/include/oox/core/filterbase.hxx @@ -51,9 +51,6 @@ namespace com::sun::star { namespace comphelper { class SequenceAsHashMap; } -namespace utl { - class MediaDescriptor; -} namespace oox { class GraphicHelper; @@ -137,7 +134,7 @@ public: ::comphelper::SequenceAsHashMap& getFilterData() const; /** Returns the media descriptor. */ - utl::MediaDescriptor& getMediaDescriptor() const; + comphelper::SequenceAsHashMap& getMediaDescriptor() const; /** Returns the URL of the imported or exported file. */ const OUString& getFileUrl() const; @@ -241,11 +238,11 @@ public: protected: virtual css::uno::Reference< css::io::XInputStream > - implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const; + implGetInputStream( comphelper::SequenceAsHashMap& rMediaDesc ) const; virtual css::uno::Reference< css::io::XStream > - implGetOutputStream( utl::MediaDescriptor& rMediaDesc ) const; + implGetOutputStream( comphelper::SequenceAsHashMap& rMediaDesc ) const; - virtual bool implFinalizeExport( utl::MediaDescriptor& rMediaDescriptor ); + virtual bool implFinalizeExport( comphelper::SequenceAsHashMap& rMediaDescriptor ); css::uno::Reference< css::io::XStream > const & getMainDocumentStream( ) const; diff --git a/include/oox/core/filterdetect.hxx b/include/oox/core/filterdetect.hxx index 89b71c603f09..2d2b50260b95 100644 --- a/include/oox/core/filterdetect.hxx +++ b/include/oox/core/filterdetect.hxx @@ -36,7 +36,7 @@ namespace com::sun::star { namespace uno { class XComponentContext; } } -namespace utl { class MediaDescriptor; } +namespace comphelper { class SequenceAsHashMap; } namespace oox { class AttributeList; } @@ -126,7 +126,7 @@ public: its input stream is returned. */ css::uno::Reference< css::io::XInputStream > - extractUnencryptedPackage( utl::MediaDescriptor& rMediaDesc ) const; + extractUnencryptedPackage( comphelper::SequenceAsHashMap& rMediaDesc ) const; // com.sun.star.lang.XServiceInfo interface ------------------------------- diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index fe69eb7f3c10..a89a4ad9818d 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -259,12 +259,12 @@ public: protected: virtual css::uno::Reference< css::io::XInputStream > - implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const override; + implGetInputStream( comphelper::SequenceAsHashMap& rMediaDesc ) const override; virtual css::uno::Reference< css::io::XStream > - implGetOutputStream( utl::MediaDescriptor& rMediaDesc ) const override; + implGetOutputStream( comphelper::SequenceAsHashMap& rMediaDesc ) const override; - virtual bool implFinalizeExport( utl::MediaDescriptor& rMediaDescriptor ) override; + virtual bool implFinalizeExport(comphelper::SequenceAsHashMap& rMediaDescriptor) override; private: virtual StorageRef implCreateStorage( diff --git a/include/unotools/mediadescriptor.hxx b/include/unotools/mediadescriptor.hxx index 07d678d588a3..e9b36a33a94a 100644 --- a/include/unotools/mediadescriptor.hxx +++ b/include/unotools/mediadescriptor.hxx @@ -25,314 +25,221 @@ #include <vector> #include <comphelper/docpasswordrequest.hxx> -#include <comphelper/sequenceashashmap.hxx> #include <rtl/ustring.hxx> #include <unotools/unotoolsdllapi.h> namespace com::sun::star::io { class XInputStream; } -namespace comphelper { class IDocPasswordVerifier; } +namespace com::sun::star::beans { + struct NamedValue; +} +namespace comphelper { class IDocPasswordVerifier; class SequenceAsHashMap; } -namespace utl { +namespace utl::MediaDescriptor { /** @short can be used to work with a css::document::MediaDescriptor struct. - @descr It wraps an unordered_map around the Sequence< css::beans::PropertyValue >, which - represent the MediaDescriptor item. - Further this helper defines often used functions (as e.g. open of the required streams, - consistent checks etcpp.) and it defines all usable property names. + @descr Defines often used functions (as e.g. open of the required streams, consistent checks + etcpp.) and all usable property names, for use with comphelper::SequenceAsHashMap, + which represent the MediaDescriptor item. + + @attention The functions aren't threadsafe and must be guarded from outside! + */ +constexpr inline OUString PROP_ABORTED = u"Aborted"_ustr; +constexpr inline OUString PROP_ASTEMPLATE = u"AsTemplate"_ustr; +constexpr inline OUString PROP_COMPONENTDATA = u"ComponentData"_ustr; +constexpr inline OUString PROP_DOCUMENTSERVICE = u"DocumentService"_ustr; +constexpr inline OUString PROP_ENCRYPTIONDATA = u"EncryptionData"_ustr; +constexpr inline OUString PROP_FILENAME = u"FileName"_ustr; +constexpr inline OUString PROP_FILTERNAME = u"FilterName"_ustr; +constexpr inline OUString PROP_FILTERPROVIDER = u"FilterProvider"_ustr; +constexpr inline OUString PROP_FILTEROPTIONS = u"FilterOptions"_ustr; +constexpr inline OUString PROP_FRAME = u"Frame"_ustr; +constexpr inline OUString PROP_FRAMENAME = u"FrameName"_ustr; +constexpr inline OUString PROP_HIDDEN = u"Hidden"_ustr; +constexpr inline OUString PROP_INPUTSTREAM = u"InputStream"_ustr; +constexpr inline OUString PROP_INTERACTIONHANDLER = u"InteractionHandler"_ustr; +constexpr inline OUString PROP_AUTHENTICATIONHANDLER = u"AuthenticationHandler"_ustr; +constexpr inline OUString PROP_JUMPMARK = u"JumpMark"_ustr; +constexpr inline OUString PROP_MACROEXECUTIONMODE = u"MacroExecutionMode"_ustr; +constexpr inline OUString PROP_MEDIATYPE = u"MediaType"_ustr; +constexpr inline OUString PROP_MINIMIZED = u"Minimized"_ustr; +constexpr inline OUString PROP_NOAUTOSAVE = u"NoAutoSave"_ustr; +constexpr inline OUString PROP_OPENNEWVIEW = u"OpenNewView"_ustr; +constexpr inline OUString PROP_OUTPUTSTREAM = u"OutputStream"_ustr; +constexpr inline OUString PROP_PASSWORD = u"Password"_ustr; +constexpr inline OUString PROP_POSTDATA = u"PostData"_ustr; +constexpr inline OUString PROP_PREVIEW = u"Preview"_ustr; +constexpr inline OUString PROP_READONLY = u"ReadOnly"_ustr; +constexpr inline OUString PROP_REFERRER = u"Referer"_ustr; +constexpr inline OUString PROP_REPLACEABLE = u"Replaceable"_ustr; +constexpr inline OUString PROP_SALVAGEDFILE = u"SalvagedFile"_ustr; +constexpr inline OUString PROP_SILENT = u"Silent"_ustr; +constexpr inline OUString PROP_STATUSINDICATOR = u"StatusIndicator"_ustr; +constexpr inline OUString PROP_STREAM = u"Stream"_ustr; +constexpr inline OUString PROP_STREAMFOROUTPUT = u"StreamForOutput"_ustr; +constexpr inline OUString PROP_TEMPLATENAME = u"TemplateName"_ustr; +constexpr inline OUString PROP_TITLE = u"Title"_ustr; +constexpr inline OUString PROP_TYPENAME = u"TypeName"_ustr; +constexpr inline OUString PROP_UCBCONTENT = u"UCBContent"_ustr; +constexpr inline OUString PROP_UPDATEDOCMODE = u"UpdateDocMode"_ustr; +constexpr inline OUString PROP_URL = u"URL"_ustr; +constexpr inline OUString PROP_VERSION = u"Version"_ustr; +constexpr inline OUString PROP_DOCUMENTTITLE = u"DocumentTitle"_ustr; +constexpr inline OUString PROP_MODEL = u"Model"_ustr; +constexpr inline OUString PROP_VIEWONLY = u"ViewOnly"_ustr; +constexpr inline OUString PROP_DOCUMENTBASEURL = u"DocumentBaseURL"_ustr; +constexpr inline OUString PROP_SUGGESTEDSAVEASNAME = u"SuggestedSaveAsName"_ustr; +constexpr inline OUString PROP_EXPORTDIRECTORY = u"ExportDirectory"_ustr; +constexpr inline OUString PROP_AUTOSAVEEVENT = u"AutoSaveEvent"_ustr; + +/** @short it checks if the descriptor already has a valid + InputStream item and creates a new one, if not. + + @descr This function uses the current items of this MediaDescriptor, + to open the stream (as e.g. URL, ReadOnly, PostData etcpp.). + It creates a seekable stream and put it into the descriptor. + + A might existing InteractionHandler will be used automatically, + to solve problems! + + In case of local file the system file locking is used. + + @return TRUE, if the stream was already part of the descriptor or could + be created as new item. FALSE otherwise. + */ +UNOTOOLS_DLLPUBLIC bool addInputStream(comphelper::SequenceAsHashMap& rMediaDescriptor); + +/** @short it checks if the descriptor already has a valid + InputStream item and creates a new one, if not. - @attention This class isn't threadsafe and must be guarded from outside! + @descr This function uses the current items of this MediaDescriptor, + to open the stream (as e.g. URL, ReadOnly, PostData etcpp.). + It creates a seekable stream and put it into the descriptor. + + A might existing InteractionHandler will be used automatically, + to solve problems! + + In case of local file the system file locking is used based on + configuration settings. + + @return TRUE, if the stream was already part of the descriptor or could + be created as new item. FALSE otherwise. */ -class UNOTOOLS_DLLPUBLIC MediaDescriptor : public comphelper::SequenceAsHashMap -{ - public: - - /** @short these methods can be used to get the different property names - as static const OUString values. - - @descr Because definition and declaration of static const class members - does not work as expected under windows (under unix it works as well) - these way must be used :-( - */ - static constexpr OUString PROP_ABORTED = u"Aborted"_ustr; - static constexpr OUString PROP_ASTEMPLATE = u"AsTemplate"_ustr; - static constexpr OUString PROP_COMPONENTDATA = u"ComponentData"_ustr; - static constexpr OUString PROP_DOCUMENTSERVICE = u"DocumentService"_ustr; - static constexpr OUString PROP_ENCRYPTIONDATA = u"EncryptionData"_ustr; - static constexpr OUString PROP_FILENAME = u"FileName"_ustr; - static constexpr OUString PROP_FILTERNAME = u"FilterName"_ustr; - static constexpr OUString PROP_FILTERPROVIDER = u"FilterProvider"_ustr; - static constexpr OUString PROP_FILTEROPTIONS = u"FilterOptions"_ustr; - static constexpr OUString PROP_FRAME = u"Frame"_ustr; - static constexpr OUString PROP_FRAMENAME = u"FrameName"_ustr; - static constexpr OUString PROP_HIDDEN = u"Hidden"_ustr; - static constexpr OUString PROP_INPUTSTREAM = u"InputStream"_ustr; - static constexpr OUString PROP_INTERACTIONHANDLER = u"InteractionHandler"_ustr; - static constexpr OUString PROP_AUTHENTICATIONHANDLER = u"AuthenticationHandler"_ustr; - static constexpr OUString PROP_JUMPMARK = u"JumpMark"_ustr; - static constexpr OUString PROP_MACROEXECUTIONMODE = u"MacroExecutionMode"_ustr; - static constexpr OUString PROP_MEDIATYPE = u"MediaType"_ustr; - static constexpr OUString PROP_MINIMIZED = u"Minimized"_ustr; - static constexpr OUString PROP_NOAUTOSAVE = u"NoAutoSave"_ustr; - static constexpr OUString PROP_OPENNEWVIEW = u"OpenNewView"_ustr; - static constexpr OUString PROP_OUTPUTSTREAM = u"OutputStream"_ustr; - static constexpr OUString PROP_PASSWORD = u"Password"_ustr; - static constexpr OUString PROP_POSTDATA = u"PostData"_ustr; - static constexpr OUString PROP_PREVIEW = u"Preview"_ustr; - static constexpr OUString PROP_READONLY = u"ReadOnly"_ustr; - static constexpr OUString PROP_REFERRER = u"Referer"_ustr; - static constexpr OUString PROP_REPLACEABLE = u"Replaceable"_ustr; - static constexpr OUString PROP_SALVAGEDFILE = u"SalvagedFile"_ustr; - static constexpr OUString PROP_SILENT = u"Silent"_ustr; - static constexpr OUString PROP_STATUSINDICATOR = u"StatusIndicator"_ustr; - static constexpr OUString PROP_STREAM = u"Stream"_ustr; - static constexpr OUString PROP_STREAMFOROUTPUT = u"StreamForOutput"_ustr; - static constexpr OUString PROP_TEMPLATENAME = u"TemplateName"_ustr; - static constexpr OUString PROP_TITLE = u"Title"_ustr; - static constexpr OUString PROP_TYPENAME = u"TypeName"_ustr; - static constexpr OUString PROP_UCBCONTENT = u"UCBContent"_ustr; - static constexpr OUString PROP_UPDATEDOCMODE = u"UpdateDocMode"_ustr; - static constexpr OUString PROP_URL = u"URL"_ustr; - static constexpr OUString PROP_VERSION = u"Version"_ustr; - static constexpr OUString PROP_DOCUMENTTITLE = u"DocumentTitle"_ustr; - static constexpr OUString PROP_MODEL = u"Model"_ustr; - static constexpr OUString PROP_VIEWONLY = u"ViewOnly"_ustr; - static constexpr OUString PROP_DOCUMENTBASEURL = u"DocumentBaseURL"_ustr; - static constexpr OUString PROP_SUGGESTEDSAVEASNAME = u"SuggestedSaveAsName"_ustr; - static constexpr OUString PROP_EXPORTDIRECTORY = u"ExportDirectory"_ustr; - static constexpr OUString PROP_AUTOSAVEEVENT = u"AutoSaveEvent"_ustr; - - // interface - public: - - /** @short these ctors do nothing - excepting that they forward - the given parameters to the base class ctors. - - @descr The ctors must be overwritten to resolve conflicts with - the default ctors of the compiler :-(. - */ - MediaDescriptor(); - MediaDescriptor(const css::uno::Sequence< css::beans::PropertyValue >& lSource); - - /** @short it checks if the descriptor already has a valid - InputStream item and creates a new one, if not. - - @descr This method uses the current items of this MediaDescriptor, - to open the stream (as e.g. URL, ReadOnly, PostData etcpp.). - It creates a seekable stream and put it into the descriptor. - - A might existing InteractionHandler will be used automatically, - to solve problems! - - In case of local file the system file locking is used. - - @return TRUE, if the stream was already part of the descriptor or could - be created as new item. FALSE otherwise. - */ - bool addInputStream(); - - /** @short it checks if the descriptor already has a valid - InputStream item and creates a new one, if not. - - @descr This method uses the current items of this MediaDescriptor, - to open the stream (as e.g. URL, ReadOnly, PostData etcpp.). - It creates a seekable stream and put it into the descriptor. - - A might existing InteractionHandler will be used automatically, - to solve problems! - - In case of local file the system file locking is used based on - configuration settings. - - @return TRUE, if the stream was already part of the descriptor or could - be created as new item. FALSE otherwise. - */ - bool addInputStreamOwnLock(); - - /** @short it checks if the descriptor describes a readonly stream. - - @descr The descriptor itself isn't changed doing so. - It's only checked if the stream seems to be based - of a real readonly file. - - @Attention - We don't check the property "ReadOnly" here. Because - this property can be set from outside and overwrites - the readonly state of the stream. - If e.g. the stream could be opened read/write ... - but "ReadOnly" property is set to TRUE, this means: - show a readonly UI on top of this read/write stream. - - @return TRUE, if the stream must be interpreted as readonly ... - FALSE otherwise. - */ - bool isStreamReadOnly() const; - - /** Returns a value from the sequence contained in the property - 'ComponentData' of this media descriptor. - - @descr The property 'ComponentData' should be empty, or should - contain a value of type sequence<com.sun.star.beans.NamedValue> - or sequence<com.sun.star.beans.PropertyValue>. - - @return The value with the specified name, if existing in the - sequence of the 'ComponentData' property, otherwise an empty - Any. - */ - css::uno::Any getComponentDataEntry( - const OUString& rName ) const; - - /** Inserts a value into the sequence contained in the property - 'ComponentData' of the media descriptor. - - @descr The property 'ComponentData' should be empty, or should - contain a value of type sequence<com.sun.star.beans.NamedValue> - or sequence<com.sun.star.beans.PropertyValue>. The passed value - will be inserted into the sequence, or, if already existing, - will be overwritten. - - @param rName The name of the value to be inserted into the - sequence of the 'ComponentData' property. - - @param rValue The value to be inserted into the sequence of the - 'ComponentData' property. - */ - void setComponentDataEntry( - const OUString& rName, - const css::uno::Any& rValue ); +UNOTOOLS_DLLPUBLIC bool addInputStreamOwnLock(comphelper::SequenceAsHashMap& rMediaDescriptor); - /** Removes a value from the sequence contained in the property - 'ComponentData' of the media descriptor. +/** @short it checks if the descriptor describes a readonly stream. - @descr The property 'ComponentData' should be empty, or should - contain a value of type sequence<com.sun.star.beans.NamedValue> - or sequence<com.sun.star.beans.PropertyValue>. The value with - the passed name will be removed from the sequence, if existing. - - @param rName The name of the value to be removed from the sequence - of the 'ComponentData' property. - */ - void clearComponentDataEntry( - const OUString& rName ); - - /** This helper function tries to find a password for the document - described by this media descriptor. - - First, the list of default passwords will be tried if provided. This - is needed by import filters for external file formats that have to - check a predefined password in some cases without asking the user - for a password. Every password is checked using the passed password - verifier. - - If not successful, this media descriptor is asked for a password, - that has been set e.g. by an API call to load a document. If - existing, the password is checked using the passed password - verifier. - - If still not successful, the interaction handler contained in this - media descriptor is used to request a password from the user. This - will be repeated until the passed password verifier validates the - entered password, or if the user chooses to cancel password input. - - If a valid password (that is not contained in the passed list of - default passwords) was found, it will be inserted into the - "Password" property of this descriptor. - - @param rVerifier - The password verifier used to check every processed password. - - @param eRequestType - The password request type that will be passed to the - DocPasswordRequest object created internally. See - docpasswordrequest.hxx for more details. - - @param pDefaultPasswords - If not null, contains default passwords that will be tried before a - password will be requested from the media descriptor or the user. - - @return - If not empty, contains the password that has been validated by the - passed password verifier. If empty, no valid password has been - found, or the user has chosen to cancel password input. - */ - css::uno::Sequence< css::beans::NamedValue > requestAndVerifyDocPassword( - comphelper::IDocPasswordVerifier& rVerifier, - comphelper::DocPasswordRequestType eRequestType, - const ::std::vector< OUString >* pDefaultPasswords ); - - // helper - private: - - /** @short tries to open a stream by using the given PostData stream. - - @descr The stream is used directly ... - - The MediaDescriptor itself is changed inside this method. - Means: the stream is added internal and not returned by a value. - - @param _rxPostData - the PostData stream. - - @return TRUE if the stream could be added successfully. - Note: If FALSE is returned, the error was already handled inside! - - @throw [css::uno::RuntimeException] - if the MediaDescriptor seems to be invalid! - - @throw [css::lang::IllegalArgumentException] - if the given PostData stream is <NULL/>. - */ - SAL_DLLPRIVATE bool impl_openStreamWithPostData( - const css::uno::Reference< css::io::XInputStream >& _rxPostData - ); - - /** @short tries to open a stream by using the given URL. - - @descr First it tries to open the content in r/w mode (if its - allowed to do so). Only in case it's not allowed or it failed - the stream will be tried to open in readonly mode. - - The MediaDescriptor itself is changed inside this method. - Means: the stream is added internal and not returned by a value. - - @param sURL - the URL for open. - - @param bLockFile - specifies whether the file should be locked + @descr The descriptor itself isn't changed doing so. + It's only checked if the stream seems to be based + of a real readonly file. - @return TRUE if the stream could be added successfully. - Note: If FALSE is returned, the error was already handled inside! + @Attention + We don't check the property "ReadOnly" here. Because + this property can be set from outside and overwrites + the readonly state of the stream. + If e.g. the stream could be opened read/write ... + but "ReadOnly" property is set to TRUE, this means: + show a readonly UI on top of this read/write stream. - @throw [css::uno::RuntimeException] - if the MediaDescriptor seems to be invalid! - */ - SAL_DLLPRIVATE bool impl_openStreamWithURL( - const OUString& sURL, - bool bLockFile - ); + @return TRUE, if the stream must be interpreted as readonly ... + FALSE otherwise. + */ +UNOTOOLS_DLLPUBLIC bool isStreamReadOnly(const comphelper::SequenceAsHashMap& rMediaDescriptor); - /** @short it checks if the descriptor already has a valid - InputStream item and creates a new one, if not. +/** Returns a value from the sequence contained in the property + 'ComponentData' of this media descriptor. - @descr This method uses the current items of this MediaDescriptor, - to open the stream (as e.g. URL, ReadOnly, PostData etcpp.). - It creates a seekable stream and put it into the descriptor. - - A might existing InteractionHandler will be used automatically, - to solve problems! + @descr The property 'ComponentData' should be empty, or should + contain a value of type sequence<com.sun.star.beans.NamedValue> + or sequence<com.sun.star.beans.PropertyValue>. - @param bLockFile - specifies whether the file should be locked + @return The value with the specified name, if existing in the + sequence of the 'ComponentData' property, otherwise an empty + Any. + */ +UNOTOOLS_DLLPUBLIC css::uno::Any +getComponentDataEntry(const comphelper::SequenceAsHashMap& rMediaDescriptor, const OUString& rName); - @return TRUE, if the stream was already part of the descriptor or could - be created as new item. FALSE otherwise. - */ - SAL_DLLPRIVATE bool impl_addInputStream( bool bLockFile ); -}; +/** Inserts a value into the sequence contained in the property + 'ComponentData' of the media descriptor. + + @descr The property 'ComponentData' should be empty, or should + contain a value of type sequence<com.sun.star.beans.NamedValue> + or sequence<com.sun.star.beans.PropertyValue>. The passed value + will be inserted into the sequence, or, if already existing, + will be overwritten. + + @param rName The name of the value to be inserted into the + sequence of the 'ComponentData' property. + + @param rValue The value to be inserted into the sequence of the + 'ComponentData' property. + */ +UNOTOOLS_DLLPUBLIC void setComponentDataEntry(comphelper::SequenceAsHashMap& rMediaDescriptor, + const OUString& rName, const css::uno::Any& rValue); + +/** Removes a value from the sequence contained in the property + 'ComponentData' of the media descriptor. + + @descr The property 'ComponentData' should be empty, or should + contain a value of type sequence<com.sun.star.beans.NamedValue> + or sequence<com.sun.star.beans.PropertyValue>. The value with + the passed name will be removed from the sequence, if existing. + + @param rName The name of the value to be removed from the sequence + of the 'ComponentData' property. + */ +UNOTOOLS_DLLPUBLIC void clearComponentDataEntry(comphelper::SequenceAsHashMap& rMediaDescriptor, + const OUString& rName); + +/** This helper function tries to find a password for the document + described by this media descriptor. + + First, the list of default passwords will be tried if provided. This + is needed by import filters for external file formats that have to + check a predefined password in some cases without asking the user + for a password. Every password is checked using the passed password + verifier. + + If not successful, this media descriptor is asked for a password, + that has been set e.g. by an API call to load a document. If + existing, the password is checked using the passed password + verifier. + + If still not successful, the interaction handler contained in this + media descriptor is used to request a password from the user. This + will be repeated until the passed password verifier validates the + entered password, or if the user chooses to cancel password input. + + If a valid password (that is not contained in the passed list of + default passwords) was found, it will be inserted into the + "Password" property of this descriptor. + + @param rVerifier + The password verifier used to check every processed password. + + @param eRequestType + The password request type that will be passed to the + DocPasswordRequest object created internally. See + docpasswordrequest.hxx for more details. + + @param pDefaultPasswords + If not null, contains default passwords that will be tried before a + password will be requested from the media descriptor or the user. + + @return + If not empty, contains the password that has been validated by the + passed password verifier. If empty, no valid password has been + found, or the user has chosen to cancel password input. + */ +UNOTOOLS_DLLPUBLIC css::uno::Sequence<css::beans::NamedValue> +requestAndVerifyDocPassword(comphelper::SequenceAsHashMap& rMediaDescriptor, + comphelper::IDocPasswordVerifier& rVerifier, + comphelper::DocPasswordRequestType eRequestType, + const ::std::vector<OUString>* pDefaultPasswords); } diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx index 849665bbd4cf..2a40fadd3dc1 100644 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -31,6 +31,7 @@ #include <comphelper/documentconstants.hxx> #include <comphelper/sequence.hxx> #include <comphelper/scopeguard.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <unotools/mediadescriptor.hxx> #include <osl/diagnose.h> #include <rtl/uri.hxx> @@ -57,7 +58,6 @@ using namespace ::com::sun::star::task; using namespace ::com::sun::star::uno; using ::com::sun::star::container::XNameAccess; -using utl::MediaDescriptor; using ::comphelper::SequenceAsHashMap; using ::oox::ole::OleObjectHelper; using ::oox::ole::VbaProject; @@ -132,7 +132,7 @@ struct FilterBaseImpl FilterDirection meDirection; SequenceAsHashMap maArguments; SequenceAsHashMap maFilterData; - MediaDescriptor maMediaDesc; + SequenceAsHashMap maMediaDesc; OUString maFileUrl; StorageRef mxStorage; OoxmlVersion meVersion; @@ -235,7 +235,7 @@ const Reference< XStatusIndicator >& FilterBase::getStatusIndicator() const return mxImpl->mxStatusIndicator; } -MediaDescriptor& FilterBase::getMediaDescriptor() const +SequenceAsHashMap& FilterBase::getMediaDescriptor() const { return mxImpl->maMediaDesc; } @@ -503,17 +503,17 @@ void SAL_CALL FilterBase::cancel() // protected -Reference< XInputStream > FilterBase::implGetInputStream( MediaDescriptor& rMediaDesc ) const +Reference< XInputStream > FilterBase::implGetInputStream( SequenceAsHashMap& rMediaDesc ) const { - return rMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INPUTSTREAM, Reference< XInputStream >() ); + return rMediaDesc.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_INPUTSTREAM, Reference< XInputStream >() ); } -Reference< XStream > FilterBase::implGetOutputStream( MediaDescriptor& rMediaDesc ) const +Reference< XStream > FilterBase::implGetOutputStream( SequenceAsHashMap& rMediaDesc ) const { - return rMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STREAMFOROUTPUT, Reference< XStream >() ); + return rMediaDesc.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_STREAMFOROUTPUT, Reference< XStream >() ); } -bool FilterBase::implFinalizeExport( MediaDescriptor& /*rMediaDescriptor*/ ) +bool FilterBase::implFinalizeExport( SequenceAsHashMap& /*rMediaDescriptor*/ ) { return true; } @@ -535,7 +535,7 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc OSL_FAIL( "FilterBase::setMediaDescriptor - invalid filter direction" ); break; case FILTERDIRECTION_IMPORT: - mxImpl->maMediaDesc.addInputStream(); + utl::MediaDescriptor::addInputStream(mxImpl->maMediaDesc); mxImpl->mxInStream = implGetInputStream( mxImpl->maMediaDesc ); OSL_ENSURE( mxImpl->mxInStream.is(), "FilterBase::setMediaDescriptor - missing input stream" ); break; @@ -545,9 +545,9 @@ void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDesc break; } - mxImpl->maFileUrl = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL, OUString() ); - mxImpl->mxTargetFrame = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FRAME, Reference< XFrame >() ); - mxImpl->mxStatusIndicator = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STATUSINDICATOR, Reference< XStatusIndicator >() ); + mxImpl->maFileUrl = mxImpl->maMediaDesc.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_URL, OUString() ); + mxImpl->mxTargetFrame = mxImpl->maMediaDesc.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_FRAME, Reference< XFrame >() ); + mxImpl->mxStatusIndicator = mxImpl->maMediaDesc.getUnpackedValueOrDefault( utl::MediaDescriptor::PROP_STATUSINDICATOR, Reference< XStatusIndicator >() ); mxImpl->mxParentShape = mxImpl->maMediaDesc.getUnpackedValueOrDefault( u"ParentShape"_ustr, mxImpl->mxParentShape ); mxImpl->maFilterData = mxImpl->maMediaDesc.getUnpackedValueOrDefault( u"FilterData"_ustr, Sequence< PropertyValue >() ); diff --git a/oox/source/core/filterdetect.cxx b/oox/source/core/filterdetect.cxx index b48df147673b..8ee4fc1a179b 100644 --- a/oox/source/core/filterdetect.cxx +++ b/oox/source/core/filterdetect.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/io/XStream.hpp> #include <comphelper/docpasswordhelper.hxx> #include <comphelper/memorystream.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <unotools/mediadescriptor.hxx> #include <cppuhelper/supportsservice.hxx> @@ -50,7 +51,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::uri; -using utl::MediaDescriptor; using comphelper::IDocPasswordVerifier; using comphelper::DocPasswordVerifierResult; @@ -335,16 +335,16 @@ comphelper::DocPasswordVerifierResult PasswordVerifier::verifyEncryptionData( co } // namespace -Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescriptor& rMediaDescriptor ) const +Reference< XInputStream > FilterDetect::extractUnencryptedPackage( comphelper::SequenceAsHashMap& rMediaDescriptor ) const { const bool bRepairPackage(rMediaDescriptor.getUnpackedValueOrDefault(u"RepairPackage"_ustr, false)); // try the plain input stream - Reference<XInputStream> xInputStream( rMediaDescriptor[ MediaDescriptor::PROP_INPUTSTREAM ], UNO_QUERY ); + Reference<XInputStream> xInputStream( rMediaDescriptor[ utl::MediaDescriptor::PROP_INPUTSTREAM ], UNO_QUERY ); if (!xInputStream.is() || lclIsZipPackage(mxContext, xInputStream, bRepairPackage)) return xInputStream; // check if a temporary file is passed in the 'ComponentData' property - Reference<XStream> xDecrypted( rMediaDescriptor.getComponentDataEntry( u"DecryptedPackage"_ustr ), UNO_QUERY ); + Reference<XStream> xDecrypted( utl::MediaDescriptor::getComponentDataEntry(rMediaDescriptor, u"DecryptedPackage"_ustr ), UNO_QUERY ); if( xDecrypted.is() ) { Reference<XInputStream> xDecryptedInputStream = xDecrypted->getInputStream(); @@ -374,14 +374,15 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript (according to the verifier), or with an empty string if user has cancelled the password input dialog. */ PasswordVerifier aVerifier( aDecryptor ); - Sequence<NamedValue> aEncryptionData = rMediaDescriptor.requestAndVerifyDocPassword( + Sequence<NamedValue> aEncryptionData = utl::MediaDescriptor::requestAndVerifyDocPassword( + rMediaDescriptor, aVerifier, comphelper::DocPasswordRequestType::MS, &aDefaultPasswords ); if( !aEncryptionData.hasElements() ) { - rMediaDescriptor[ MediaDescriptor::PROP_ABORTED ] <<= true; + rMediaDescriptor[ utl::MediaDescriptor::PROP_ABORTED ] <<= true; } else { @@ -391,12 +392,12 @@ Reference< XInputStream > FilterDetect::extractUnencryptedPackage( MediaDescript // if decryption was unsuccessful (corrupted file or any other reason) if (!aDecryptor.decrypt(xTempStream)) { - rMediaDescriptor[ MediaDescriptor::PROP_ABORTED ] <<= true; + rMediaDescriptor[ utl::MediaDescriptor::PROP_ABORTED ] <<= true; } -e ... etc. - the rest is truncated
