summaryrefslogtreecommitdiff
path: root/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx')
-rw-r--r--filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx77
1 files changed, 35 insertions, 42 deletions
diff --git a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx
index 4e62aba199e7..4af3f7224b3e 100644
--- a/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx
+++ b/filter/source/xmlfilteradaptor/XmlFilterAdaptor.cxx
@@ -20,7 +20,7 @@
#include <iostream>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/urlobj.hxx>
#include "XmlFilterAdaptor.hxx"
#include <com/sun/star/io/XActiveDataSource.hpp>
@@ -43,10 +43,11 @@
#include <unotools/pathoptions.hxx>
#include <xmloff/xmlimp.hxx>
+#include <strings.hrc>
+
using namespace comphelper;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
-using namespace com::sun::star::io;
using namespace com::sun::star::beans;
using namespace com::sun::star::container;
using namespace com::sun::star::document;
@@ -64,15 +65,14 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >&
utl::MediaDescriptor aMediaMap(aDescriptor);
Reference< XStatusIndicator > xStatusIndicator(aMediaMap.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_STATUSINDICATOR(), Reference< XStatusIndicator >()));
+ utl::MediaDescriptor::PROP_STATUSINDICATOR, Reference< XStatusIndicator >()));
if (xStatusIndicator.is()){
- xStatusIndicator->start( "Loading :", 4);
+ xStatusIndicator->start(FilterResId(STR_FILTER_DOC_LOADING), 4);
}
- Sequence< Any > aAnys(1);
OUString aBaseURI;
- if (aMediaMap.find(OUString( "URL" ))->second >>= aBaseURI)
+ if (aMediaMap.find(u"URL"_ustr)->second >>= aBaseURI)
{
INetURLObject aURLObj(aBaseURI);
// base URI in this case is the URI of the actual saving location
@@ -81,30 +81,28 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >&
}
// create an XProperty set to configure the exporter for pretty printing
- PropertyMapEntry aImportInfoMap[] =
+ static const PropertyMapEntry aImportInfoMap[] =
{
- { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0},
- { OUString("BuildId"), 0, ::cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0 },
- { OUString("DefaultDocumentSettings"), 0,
+ { u"BaseURI"_ustr, 0, ::cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0},
+ { u"BuildId"_ustr, 0, ::cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0 },
+ { u"DefaultDocumentSettings"_ustr, 0,
::cppu::UnoType<Sequence<PropertyValue>>::get(), PropertyAttribute::MAYBEVOID, 0 },
- { OUString(), 0, css::uno::Type(), 0, 0 }
};
Reference< XPropertySet > xInfoSet(
GenericPropertySet_CreateInstance( new PropertySetInfo( aImportInfoMap ) ) );
- xInfoSet->setPropertyValue( "BaseURI", makeAny( aBaseURI ));
+ xInfoSet->setPropertyValue( u"BaseURI"_ustr, Any( aBaseURI ));
OUString aFilterName;
- auto It = aMediaMap.find(OUString("FilterName"));
+ auto It = aMediaMap.find(u"FilterName"_ustr);
if (It != aMediaMap.end() && (It->second >>= aFilterName)
&& aFilterName == "OpenDocument Text Flat XML")
{
- PropertyValue EmptyDbFieldHidesPara("EmptyDbFieldHidesPara", 0, Any(false),
- PropertyState::PropertyState_DIRECT_VALUE);
- Sequence<PropertyValue> aSettings{ EmptyDbFieldHidesPara };
- xInfoSet->setPropertyValue("DefaultDocumentSettings", makeAny(aSettings));
+ Sequence<PropertyValue> aSettings{ PropertyValue(u"EmptyDbFieldHidesPara"_ustr, 0,
+ Any(false), PropertyState::PropertyState_DIRECT_VALUE) };
+ xInfoSet->setPropertyValue(u"DefaultDocumentSettings"_ustr, Any(aSettings));
}
- aAnys[0] <<= xInfoSet;
+ Sequence< Any > aAnys{ Any(xInfoSet) };
// the underlying SvXMLImport implements XFastParser, XImporter, XFastDocumentHandler
@@ -156,7 +154,7 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >&
if(!comphelper::isFileUrl(msTemplateName))
{
SvtPathOptions aOptions;
- msTemplateName = aOptions.SubstituteVariable("$(progurl)") + "/" + msTemplateName;
+ msTemplateName = aOptions.SubstituteVariable(u"$(progurl)"_ustr) + "/" + msTemplateName;
}
xstyleLoader->loadStylesFromURL(msTemplateName,aValue);
@@ -191,8 +189,7 @@ bool XmlFilterAdaptor::importImpl( const Sequence< css::beans::PropertyValue >&
}
else if (xConverter1 && xFastParser)
{
- auto pImport = dynamic_cast<SvXMLImport*>(xFastParser.get());
- assert(pImport);
+ auto pImport = static_cast<SvXMLImport*>(xFastParser.get());
Reference<XDocumentHandler> xLegacyDocHandler = new SvXMLLegacyToFastDocHandler(pImport);
if (!xConverter1->importer(aDescriptor,xLegacyDocHandler,msUserData)) {
if (xStatusIndicator.is())
@@ -233,10 +230,10 @@ bool XmlFilterAdaptor::exportImpl( const Sequence< css::beans::PropertyValue >&
sal_Int32 nSteps= 1;
utl::MediaDescriptor aMediaMap(aDescriptor);
Reference< XStatusIndicator > xStatusIndicator(aMediaMap.getUnpackedValueOrDefault(
- utl::MediaDescriptor::PROP_STATUSINDICATOR(), Reference< XStatusIndicator >()));
+ utl::MediaDescriptor::PROP_STATUSINDICATOR, Reference< XStatusIndicator >()));
if (xStatusIndicator.is())
- xStatusIndicator->start( "Saving :", 3);
+ xStatusIndicator->start(FilterResId(STR_FILTER_DOC_SAVING), 3);
// Set up converter bridge.
Reference< css::xml::XExportFilter > xConverter(mxContext->getServiceManager()->createInstanceWithContext( udConvertClass, mxContext ), UNO_QUERY);
@@ -260,9 +257,6 @@ bool XmlFilterAdaptor::exportImpl( const Sequence< css::beans::PropertyValue >&
try{
// create the xml exporter service and supply the converter component
// which implements the document handler
- Sequence < Any > aAnys (2);
- aAnys[0] <<= xConverter;
-
// pretty printing is confusing for some filters so it is disabled by default
bool bPrettyPrint =
@@ -276,7 +270,7 @@ bool XmlFilterAdaptor::exportImpl( const Sequence< css::beans::PropertyValue >&
// get the base URI, so we can use relative links
OUString aBaseURI;
- if (aMediaMap.find(OUString( "URL" ))->second >>= aBaseURI)
+ if (aMediaMap.find(u"URL"_ustr)->second >>= aBaseURI)
{
INetURLObject aURLObj(aBaseURI);
// base URI in this case is the URI of the actual saving location
@@ -285,22 +279,21 @@ bool XmlFilterAdaptor::exportImpl( const Sequence< css::beans::PropertyValue >&
}
// create an XProperty set to configure the exporter for pretty printing
- PropertyMapEntry aImportInfoMap[] =
+ static const PropertyMapEntry aImportInfoMap[] =
{
- { OUString("UsePrettyPrinting"), 0, cppu::UnoType<sal_Bool>::get(), PropertyAttribute::MAYBEVOID, 0},
- { OUString("ExportTextNumberElement"), 0, cppu::UnoType<sal_Bool>::get(), PropertyAttribute::MAYBEVOID, 0},
- { OUString("BaseURI"), 0, ::cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0},
- { OUString(), 0, css::uno::Type(), 0, 0 }
+ { u"UsePrettyPrinting"_ustr, 0, cppu::UnoType<sal_Bool>::get(), PropertyAttribute::MAYBEVOID, 0},
+ { u"ExportTextNumberElement"_ustr, 0, cppu::UnoType<sal_Bool>::get(), PropertyAttribute::MAYBEVOID, 0},
+ { u"BaseURI"_ustr, 0, ::cppu::UnoType<OUString>::get(), PropertyAttribute::MAYBEVOID, 0},
};
Reference< XPropertySet > xInfoSet(
GenericPropertySet_CreateInstance( new PropertySetInfo( aImportInfoMap ) ) );
- xInfoSet->setPropertyValue("UsePrettyPrinting", makeAny( bPrettyPrint ));
+ xInfoSet->setPropertyValue(u"UsePrettyPrinting"_ustr, Any( bPrettyPrint ));
xInfoSet->setPropertyValue(
- "ExportTextNumberElement",
- makeAny( bExportTextNumberElementForListItems ));
- xInfoSet->setPropertyValue("BaseURI", makeAny( aBaseURI ));
- aAnys[1] <<= xInfoSet;
+ u"ExportTextNumberElement"_ustr,
+ Any( bExportTextNumberElementForListItems ));
+ xInfoSet->setPropertyValue(u"BaseURI"_ustr, Any( aBaseURI ));
+ Sequence < Any > aAnys{ Any(xConverter), Any(xInfoSet) };
Reference< XExporter > xExporter( mxContext->getServiceManager()->createInstanceWithArgumentsAndContext(
udExport, aAnys, mxContext ), UNO_QUERY_THROW );
@@ -364,18 +357,18 @@ void SAL_CALL XmlFilterAdaptor::initialize( const Sequence< Any >& aArguments )
{
comphelper::SequenceAsHashMap aMap(aAnySeq);
msFilterName = aMap.getUnpackedValueOrDefault(
- "Type", OUString());
+ u"Type"_ustr, OUString());
msUserData = aMap.getUnpackedValueOrDefault(
- "UserData", Sequence< OUString >());
+ u"UserData"_ustr, Sequence< OUString >());
msTemplateName = aMap.getUnpackedValueOrDefault(
- "TemplateName", OUString());
+ u"TemplateName"_ustr, OUString());
}
}
// XServiceInfo
OUString SAL_CALL XmlFilterAdaptor::getImplementationName( )
{
- return "com.sun.star.comp.Writer.XmlFilterAdaptor";
+ return u"com.sun.star.comp.Writer.XmlFilterAdaptor"_ustr;
}
sal_Bool SAL_CALL XmlFilterAdaptor::supportsService( const OUString& rServiceName )
@@ -385,7 +378,7 @@ sal_Bool SAL_CALL XmlFilterAdaptor::supportsService( const OUString& rServiceNam
Sequence< OUString > SAL_CALL XmlFilterAdaptor::getSupportedServiceNames( )
{
- return { "com.sun.star.document.ExportFilter", "com.sun.star.document.ImportFilter" };
+ return { u"com.sun.star.document.ExportFilter"_ustr, u"com.sun.star.document.ImportFilter"_ustr };
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*