summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-02-06 17:23:58 -0500
committerAndras Timar <andras.timar@collabora.com>2018-03-25 19:58:21 +0200
commite49b343c11883ac1f75238087698e7f6a9e6abcb (patch)
tree89b0d9daf9934a6b6318b62ecb4f7c3a391d16e7
parent75d222c9bc1ffecf38dece206be5fdb7f51766e0 (diff)
oox: cosmetic cleanup
Change-Id: Ifafd7338ddfec8b707b5ddf4acb39512faf186da Reviewed-on: https://gerrit.libreoffice.org/49325 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com> (cherry picked from commit 97a73d2772a86e26369fc32e25a59c0d5a274c01)
-rw-r--r--comphelper/source/xml/ofopxmlhelper.cxx18
-rw-r--r--include/oox/core/xmlfilterbase.hxx7
-rw-r--r--oox/source/core/xmlfilterbase.cxx4
-rw-r--r--package/inc/ZipPackageEntry.hxx10
-rw-r--r--package/source/zippackage/ZipPackage.cxx10
-rw-r--r--sw/source/filter/ww8/docxexport.cxx14
-rw-r--r--writerfilter/source/ooxml/OOXMLDocumentImpl.cxx60
7 files changed, 56 insertions, 67 deletions
diff --git a/comphelper/source/xml/ofopxmlhelper.cxx b/comphelper/source/xml/ofopxmlhelper.cxx
index 205b8883c0d3..d3ce7b0dc65d 100644
--- a/comphelper/source/xml/ofopxmlhelper.cxx
+++ b/comphelper/source/xml/ofopxmlhelper.cxx
@@ -180,12 +180,12 @@ void WriteContentSequence(
xWriter->setOutputStream( xOutStream );
- OUString aTypesElement( "Types" );
- OUString aDefaultElement( "Default" );
- OUString aOverrideElement( "Override" );
- OUString aContentTypeAttr( "ContentType" );
- OUString aCDATAString( "CDATA" );
- OUString aWhiteSpace( " " );
+ static const OUString aTypesElement("Types");
+ static const OUString aDefaultElement("Default");
+ static const OUString aOverrideElement("Override");
+ static const OUString aContentTypeAttr("ContentType");
+ static const OUString aCDATAString("CDATA");
+ static const OUString aWhiteSpace(" ");
// write the namespace
AttributeList* pRootAttrList = new AttributeList;
@@ -380,15 +380,15 @@ void SAL_CALL OFOPXMLHelper_Impl::startElement( const OUString& aName, const uno
if ( m_aResultSeq.getLength() != 2 )
throw uno::RuntimeException();
- OUString aExtensionValue = xAttribs->getValueByName( m_aExtensionAttr );
+ const OUString aExtensionValue = xAttribs->getValueByName( m_aExtensionAttr );
if ( aExtensionValue.isEmpty() )
throw css::xml::sax::SAXException(); // TODO: the Extension value must present
- OUString aContentTypeValue = xAttribs->getValueByName( m_aContentTypeAttr );
+ const OUString aContentTypeValue = xAttribs->getValueByName( m_aContentTypeAttr );
if ( aContentTypeValue.isEmpty() )
throw css::xml::sax::SAXException(); // TODO: the ContentType value must present
- sal_Int32 nNewResultLen = m_aResultSeq[0].getLength() + 1;
+ const sal_Int32 nNewResultLen = m_aResultSeq[0].getLength() + 1;
m_aResultSeq[0].realloc( nNewResultLen );
m_aResultSeq[0][nNewResultLen-1].First = aExtensionValue;
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index 51e6e496ea6a..75fc03920b79 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -90,8 +90,7 @@ public:
virtual ~XmlFilterBase() override;
/** Has to be implemented by each filter, returns the current theme. */
- virtual const ::oox::drawingml::Theme*
- getCurrentTheme() const = 0;
+ virtual const ::oox::drawingml::Theme* getCurrentTheme() const = 0;
/** Has to be implemented by each filter to return the collection of VML shapes. */
virtual ::oox::vml::Drawing* getVmlDrawing() = 0;
@@ -101,13 +100,13 @@ public:
virtual ::oox::drawingml::chart::ChartConverter* getChartConverter() = 0;
/** Helper to switch chart data table - specifically for xlsx imports */
- virtual void useInternalChartDataTable( bool /*bInternal*/ ) { }
+ virtual void useInternalChartDataTable( bool /*bInternal*/ ) { }
/** Has to be implemented by each filter to return the table style list. */
virtual const ::oox::drawingml::table::TableStyleListPtr getTableStyles() = 0;
- OUString getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rPart );
+ OUString getFragmentPathFromFirstTypeFromOfficeDoc( const OUString& rPart );
/** Imports a fragment using the passed fragment handler, which contains
the full path to the fragment stream.
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index d0a61070ecd5..2746492a60ea 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -341,7 +341,7 @@ bool XmlFilterBase::importFragment( const rtl::Reference<FragmentHandler>& rxHan
return false;
// fragment handler must contain path to fragment stream
- OUString aFragmentPath = rxHandler->getFragmentPath();
+ const OUString aFragmentPath = rxHandler->getFragmentPath();
OSL_ENSURE( !aFragmentPath.isEmpty(), "XmlFilterBase::importFragment - missing fragment path" );
if( aFragmentPath.isEmpty() )
return false;
@@ -483,7 +483,7 @@ Reference< XOutputStream > XmlFilterBase::openFragmentStream( const OUString& rS
FSHelperPtr XmlFilterBase::openFragmentStreamWithSerializer( const OUString& rStreamName, const OUString& rMediaType )
{
- bool bWriteHeader = rMediaType.indexOf( "vml" ) < 0 || rMediaType.indexOf( "+xml" ) >= 0;
+ const bool bWriteHeader = rMediaType.indexOf( "vml" ) < 0 || rMediaType.indexOf( "+xml" ) >= 0;
return std::make_shared<FastSerializerHelper>( openFragmentStream( rStreamName, rMediaType ), bWriteHeader );
}
diff --git a/package/inc/ZipPackageEntry.hxx b/package/inc/ZipPackageEntry.hxx
index 5e0064f9bf7e..0fa479cb8465 100644
--- a/package/inc/ZipPackageEntry.hxx
+++ b/package/inc/ZipPackageEntry.hxx
@@ -59,11 +59,11 @@ public:
ZipPackageEntry();
virtual ~ZipPackageEntry() override;
- const OUString& GetMediaType () const { return msMediaType; }
- void SetMediaType ( const OUString & sNewType) { msMediaType = sNewType; }
- void doSetParent ( ZipPackageFolder * pNewParent );
- bool IsFolder ( ) { return mbIsFolder; }
- void SetFolder ( bool bSetFolder ) { mbIsFolder = bSetFolder; }
+ const OUString& GetMediaType() const { return msMediaType; }
+ void SetMediaType(const OUString & sNewType) { msMediaType = sNewType; }
+ void doSetParent(ZipPackageFolder * pNewParent);
+ bool IsFolder() const { return mbIsFolder; }
+ void SetFolder(const bool bSetFolder) { mbIsFolder = bSetFolder; }
virtual bool saveChild( const OUString &rPath,
std::vector < css::uno::Sequence < css::beans::PropertyValue > > &rManList,
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 2649c1189d22..3d2c0ff00e4a 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -1224,7 +1224,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
// Remove the old manifest.xml file as the
// manifest will be re-generated and the
// META-INF directory implicitly created if does not exist
- const OUString sMeta ("META-INF");
+ static const OUString sMeta ("META-INF");
if ( m_xRootFolder->hasByName( sMeta ) )
{
@@ -1246,7 +1246,7 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
// Remove the old [Content_Types].xml file as the
// file will be re-generated
- const OUString aContentTypes("[Content_Types].xml");
+ static const OUString aContentTypes("[Content_Types].xml");
if ( m_xRootFolder->hasByName( aContentTypes ) )
m_xRootFolder->removeByName( aContentTypes );
@@ -1255,9 +1255,9 @@ uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
// Create a vector to store data for the manifest.xml file
vector < uno::Sequence < PropertyValue > > aManList;
- const OUString sMediaType ("MediaType");
- const OUString sVersion ("Version");
- const OUString sFullPath ("FullPath");
+ static const OUString sMediaType("MediaType");
+ static const OUString sVersion("Version");
+ static const OUString sFullPath("FullPath");
const bool bIsGpgEncrypt = m_aGpgProps.hasElements();
if ( m_nFormat == embed::StorageFormats::PACKAGE )
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index 2a76ae0cfc40..17c77c4ae776 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -1225,7 +1225,7 @@ void DocxExport::WriteCustomXml()
uno::Reference< beans::XPropertySet > xPropSet( m_pDoc->GetDocShell()->GetBaseModel(), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
- OUString aName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
+ static const OUString aName = UNO_NAME_MISC_OBJ_INTEROPGRABBAG;
if ( !xPropSetInfo->hasPropertyByName( aName ) )
return;
@@ -1235,7 +1235,7 @@ void DocxExport::WriteCustomXml()
xPropSet->getPropertyValue( aName ) >>= propList;
for ( sal_Int32 nProp=0; nProp < propList.getLength(); ++nProp )
{
- OUString propName = propList[nProp].Name;
+ const OUString propName = propList[nProp].Name;
if ( propName == "OOXCustomXml" )
{
propList[nProp].Value >>= customXmlDomlist;
@@ -1253,11 +1253,11 @@ void DocxExport::WriteCustomXml()
}
}
- for (sal_Int32 j = 0; j < customXmlDomlist.getLength(); j++) {
-
+ for (sal_Int32 j = 0; j < customXmlDomlist.getLength(); j++)
+ {
uno::Reference<xml::dom::XDocument> customXmlDom = customXmlDomlist[j];
uno::Reference<xml::dom::XDocument> customXmlDomProps = customXmlDomPropslist[j];
- if ( customXmlDom.is() )
+ if (customXmlDom.is())
{
m_pFilter->addRelation( m_pDocumentFS->getOutputStream(),
oox::getRelationship(Relationship::CUSTOMXML),
@@ -1271,9 +1271,8 @@ void DocxExport::WriteCustomXml()
uno::Sequence< beans::StringPair >() );
}
- if ( customXmlDomProps.is() )
+ if (customXmlDomProps.is())
{
-
uno::Reference< xml::sax::XSAXSerializable > serializer( customXmlDomProps, uno::UNO_QUERY );
uno::Reference< xml::sax::XWriter > writer = xml::sax::Writer::create( comphelper::getProcessComponentContext() );
writer->setOutputStream( GetFilter().openFragmentStream( "customXml/itemProps"+OUString::number((j+1))+".xml",
@@ -1286,7 +1285,6 @@ void DocxExport::WriteCustomXml()
"application/xml" ) ,
oox::getRelationship(Relationship::CUSTOMXMLPROPS),
"itemProps"+OUString::number((j+1))+".xml" );
-
}
}
}
diff --git a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
index c23aa86b464a..6cf6e7489466 100644
--- a/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
+++ b/writerfilter/source/ooxml/OOXMLDocumentImpl.cxx
@@ -90,25 +90,21 @@ void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler,
OOXMLStream::Pointer_t savedStream = mpStream;
mpStream = pStream;
- uno::Reference< xml::sax::XFastParser > xParser
- (mpStream->getFastParser());
+ uno::Reference<xml::sax::XFastParser> xParser(mpStream->getFastParser());
if (xParser.is())
{
uno::Reference<uno::XComponentContext> xContext(mpStream->getContext());
OOXMLFastDocumentHandler * pDocHandler =
- new OOXMLFastDocumentHandler(
- xContext, &rStreamHandler, this, mnXNoteId );
+ new OOXMLFastDocumentHandler(xContext, &rStreamHandler, this, mnXNoteId);
- uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler
- (pDocHandler);
- uno::Reference < xml::sax::XFastTokenHandler > xTokenHandler(mpStream->getFastTokenHandler());
+ uno::Reference<xml::sax::XFastDocumentHandler> xDocumentHandler(pDocHandler);
+ uno::Reference<xml::sax::XFastTokenHandler> xTokenHandler(mpStream->getFastTokenHandler());
xParser->setFastDocumentHandler(xDocumentHandler);
xParser->setTokenHandler(xTokenHandler);
- uno::Reference<io::XInputStream> xInputStream =
- pStream->getDocumentStream();
+ uno::Reference<io::XInputStream> xInputStream = pStream->getDocumentStream();
if (xInputStream.is())
{
@@ -124,8 +120,8 @@ void OOXMLDocumentImpl::resolveFastSubStream(Stream & rStreamHandler,
}
void OOXMLDocumentImpl::resolveFastSubStreamWithId(Stream & rStream,
- const writerfilter::Reference<Stream>::Pointer_t& pStream,
- sal_uInt32 nId)
+ const writerfilter::Reference<Stream>::Pointer_t& pStream,
+ sal_uInt32 nId)
{
rStream.substream(nId, pStream);
}
@@ -146,9 +142,7 @@ uno::Reference<xml::dom::XDocument> OOXMLDocumentImpl::importSubStream(OOXMLStre
return xRet;
}
- uno::Reference<io::XInputStream> xInputStream =
- pStream->getDocumentStream();
-
+ uno::Reference<io::XInputStream> xInputStream = pStream->getDocumentStream();
if (xInputStream.is())
{
try
@@ -165,11 +159,11 @@ uno::Reference<xml::dom::XDocument> OOXMLDocumentImpl::importSubStream(OOXMLStre
}
}
- if(OOXMLStream::CUSTOMXML == nType)
+ if (OOXMLStream::CUSTOMXML == nType)
{
importSubStreamRelations(pStream, OOXMLStream::CUSTOMXMLPROPS);
}
- if(OOXMLStream::CHARTS == nType)
+ else if (OOXMLStream::CHARTS == nType)
{
importSubStreamRelations(pStream, OOXMLStream::EMBEDDINGS);
}
@@ -193,13 +187,12 @@ void OOXMLDocumentImpl::importSubStreamRelations(const OOXMLStream::Pointer_t& p
return;
}
- uno::Reference<io::XInputStream> xcpInputStream =
- cStream->getDocumentStream();
+ uno::Reference<io::XInputStream> xcpInputStream = cStream->getDocumentStream();
if (xcpInputStream.is())
{
// importing itemprops files for item.xml from customXml.
- if(OOXMLStream::CUSTOMXMLPROPS == nType)
+ if (OOXMLStream::CUSTOMXMLPROPS == nType)
{
try
{
@@ -447,8 +440,7 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
return;
}
- uno::Reference< xml::sax::XFastParser > xParser
- (mpStream->getFastParser());
+ uno::Reference<xml::sax::XFastParser> xParser(mpStream->getFastParser());
if (mxModel.is())
{
@@ -478,11 +470,9 @@ void OOXMLDocumentImpl::resolve(Stream & rStream)
uno::Reference<uno::XComponentContext> xContext(mpStream->getContext());
OOXMLFastDocumentHandler * pDocHandler =
- new OOXMLFastDocumentHandler(
- xContext, &rStream, this, mnXNoteId );
+ new OOXMLFastDocumentHandler(xContext, &rStream, this, mnXNoteId);
pDocHandler->setIsSubstream( mbIsSubstream );
- uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler
- (pDocHandler);
+ uno::Reference < xml::sax::XFastDocumentHandler > xDocumentHandler(pDocHandler);
uno::Reference < xml::sax::XFastTokenHandler > xTokenHandler(mpStream->getFastTokenHandler());
resolveFastSubStream(rStream, OOXMLStream::SETTINGS);
@@ -564,39 +554,41 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream)
static const char sCustomTypeStrict[] = "http://purl.oclc.org/ooxml/officeDocument/relationships/customXml";
bool bFound = false;
sal_Int32 counter = 0;
- uno::Sequence< uno::Sequence< beans::StringPair > >aSeqs = xRelationshipAccess->getAllRelationships();
- std::vector< uno::Reference<xml::dom::XDocument> > aCustomXmlDomList;
- std::vector< uno::Reference<xml::dom::XDocument> > aCustomXmlDomPropsList;
+ uno::Sequence<uno::Sequence< beans::StringPair>> aSeqs = xRelationshipAccess->getAllRelationships();
+ std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomList;
+ std::vector<uno::Reference<xml::dom::XDocument>> aCustomXmlDomPropsList;
for (sal_Int32 j = 0; j < aSeqs.getLength(); j++)
{
- uno::Sequence< beans::StringPair > aSeq = aSeqs[j];
+ const uno::Sequence<beans::StringPair>& aSeq = aSeqs[j];
for (sal_Int32 i = 0; i < aSeq.getLength(); i++)
{
- beans::StringPair aPair = aSeq[i];
+ const beans::StringPair& aPair = aSeq[i];
// Need to resolve only customxml files from document relationships.
// Skipping other files.
if (aPair.Second == sCustomType ||
- aPair.Second == sCustomTypeStrict)
+ aPair.Second == sCustomTypeStrict)
bFound = true;
- else if(aPair.First == "Target" && bFound)
+ else if (aPair.First == "Target" && bFound)
{
// Adding value to extern variable customTarget. It will be used in ooxmlstreamimpl
// to ensure customxml target is visited in lcl_getTarget.
customTarget = aPair.Second;
}
}
- if(bFound)
+
+ if (bFound)
{
uno::Reference<xml::dom::XDocument> customXmlTemp = importSubStream(OOXMLStream::CUSTOMXML);
// This will add all item[n].xml with its relationship file i.e itemprops.xml to
// grabbag list.
- if(mxCustomXmlProsDom.is() && customXmlTemp.is())
+ if (mxCustomXmlProsDom.is() && customXmlTemp.is())
{
aCustomXmlDomList.push_back(customXmlTemp);
aCustomXmlDomPropsList.push_back(mxCustomXmlProsDom);
counter++;
resolveFastSubStream(rStream, OOXMLStream::CUSTOMXML);
}
+
bFound = false;
}
}