Kaydet (Commit) 97a73d27 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

oox: cosmetic cleanup

Change-Id: Ifafd7338ddfec8b707b5ddf4acb39512faf186da
Reviewed-on: https://gerrit.libreoffice.org/49325Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
Tested-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 335a2b80
......@@ -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;
......
......@@ -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.
......
......@@ -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 );
}
......
......@@ -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,
......
......@@ -1223,7 +1223,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 ) )
{
......@@ -1245,7 +1245,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 );
......@@ -1254,9 +1254,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 )
......
......@@ -1221,7 +1221,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;
......@@ -1231,7 +1231,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;
......@@ -1249,11 +1249,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),
......@@ -1267,9 +1267,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",
......@@ -1282,7 +1281,6 @@ void DocxExport::WriteCustomXml()
"application/xml" ) ,
oox::getRelationship(Relationship::CUSTOMXMLPROPS),
"itemProps"+OUString::number((j+1))+".xml" );
}
}
}
......
......@@ -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;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment