Kaydet (Commit) cffcdd09 authored tarafından Matteo Casalin's avatar Matteo Casalin

OUString: reduce temporaries and constify

Change-Id: I6bbc57ce1b899925463106e52945ac5acc2c370b
üst b4d36ef4
...@@ -155,8 +155,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >& ...@@ -155,8 +155,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
comphelper::GenericPropertySet_CreateInstance( comphelper::GenericPropertySet_CreateInstance(
new comphelper::PropertySetInfo( aInfoMap ) ) ); new comphelper::PropertySetInfo( aInfoMap ) ) );
const OUString sTargetStorage("TargetStorage"); xInfoSet->setPropertyValue( "TargetStorage", Any( xStg ) );
xInfoSet->setPropertyValue( sTargetStorage, Any( xStg ) );
uno::Any aAny; uno::Any aAny;
if (bShowProgress) if (bShowProgress)
...@@ -169,22 +168,19 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >& ...@@ -169,22 +168,19 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
nProgressRange); nProgressRange);
} }
aAny <<= nProgressRange; aAny <<= nProgressRange;
OUString sProgressRange("ProgressRange"); xInfoSet->setPropertyValue("ProgressRange", aAny);
xInfoSet->setPropertyValue(sProgressRange, aAny);
aAny <<= static_cast < sal_Int32 >( -1 ); aAny <<= static_cast < sal_Int32 >( -1 );
OUString sProgressMax("ProgressMax"); xInfoSet->setPropertyValue("ProgressMax", aAny);
xInfoSet->setPropertyValue(sProgressMax, aAny);
} }
SvtSaveOptions aSaveOpt; SvtSaveOptions aSaveOpt;
OUString sUsePrettyPrinting("UsePrettyPrinting");
sal_Bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() ); sal_Bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() );
aAny.setValue( &bUsePrettyPrinting, ::getBooleanCppuType() ); aAny.setValue( &bUsePrettyPrinting, ::getBooleanCppuType() );
xInfoSet->setPropertyValue( sUsePrettyPrinting, aAny ); xInfoSet->setPropertyValue( "UsePrettyPrinting", aAny );
// save show redline mode ... // save show redline mode ...
OUString sShowChanges("ShowChanges"); const OUString sShowChanges("ShowChanges");
sal_uInt16 nRedlineMode = pDoc->GetRedlineMode(); sal_uInt16 nRedlineMode = pDoc->GetRedlineMode();
sal_Bool bShowChanges( IDocumentRedlineAccess::IsShowChanges( nRedlineMode ) ); sal_Bool bShowChanges( IDocumentRedlineAccess::IsShowChanges( nRedlineMode ) );
aAny.setValue( &bShowChanges, ::getBooleanCppuType() ); aAny.setValue( &bShowChanges, ::getBooleanCppuType() );
...@@ -195,28 +191,23 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >& ...@@ -195,28 +191,23 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
pDoc->SetRedlineMode((RedlineMode_t)( nRedlineMode )); pDoc->SetRedlineMode((RedlineMode_t)( nRedlineMode ));
// Set base URI // Set base URI
OUString sPropName("BaseURI"); xInfoSet->setPropertyValue( "BaseURI", makeAny( GetBaseURL() ) );
xInfoSet->setPropertyValue( sPropName, makeAny( OUString( GetBaseURL() ) ) );
if( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocShell()->GetCreateMode() ) if( SFX_CREATE_MODE_EMBEDDED == pDoc->GetDocShell()->GetCreateMode() )
{ {
OUString aName; const OUString aName( !aDocHierarchicalName.isEmpty()
if ( !aDocHierarchicalName.isEmpty() ) ? aDocHierarchicalName
aName = aDocHierarchicalName; : OUString( "dummyObjectName" ) );
else
aName = "dummyObjectName"; xInfoSet->setPropertyValue( "StreamRelPath", makeAny( aName ) );
sPropName = "StreamRelPath";
xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
} }
if( bBlock ) if( bBlock )
{ {
OUString sAutoTextMode("AutoTextMode");
sal_Bool bTmp = sal_True; sal_Bool bTmp = sal_True;
Any aAny2; Any aAny2;
aAny2.setValue( &bTmp, ::getBooleanCppuType() ); aAny2.setValue( &bTmp, ::getBooleanCppuType() );
xInfoSet->setPropertyValue( sAutoTextMode, aAny2 ); xInfoSet->setPropertyValue( "AutoTextMode", aAny2 );
} }
// #i69627# // #i69627#
...@@ -224,8 +215,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >& ...@@ -224,8 +215,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
if ( bOASIS && if ( bOASIS &&
docfunc::HasOutlineStyleToBeWrittenAsNormalListStyle( *pDoc ) ) docfunc::HasOutlineStyleToBeWrittenAsNormalListStyle( *pDoc ) )
{ {
OUString sOutlineStyleAsNormalListStyle("OutlineStyleAsNormalListStyle"); xInfoSet->setPropertyValue( "OutlineStyleAsNormalListStyle", makeAny( sal_True ) );
xInfoSet->setPropertyValue( sOutlineStyleAsNormalListStyle, makeAny( sal_True ) );
} }
// filter arguments // filter arguments
...@@ -274,7 +264,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >& ...@@ -274,7 +264,7 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
{ {
PropertyValue *pProps = aProps.getArray(); PropertyValue *pProps = aProps.getArray();
pProps->Name = "FileName"; pProps->Name = "FileName";
(pProps++)->Value <<= OUString( *pOrigFileName ); (pProps++)->Value <<= *pOrigFileName;
} }
// export sub streams for package, else full stream into a file // export sub streams for package, else full stream into a file
...@@ -286,14 +276,13 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >& ...@@ -286,14 +276,13 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
{ {
const uno::Reference<beans::XPropertySet> xPropSet(xStg, const uno::Reference<beans::XPropertySet> xPropSet(xStg,
uno::UNO_QUERY_THROW); uno::UNO_QUERY_THROW);
const OUString VersionProp("Version");
try try
{ {
OUString Version; OUString Version;
// ODF >= 1.2 // ODF >= 1.2
if ((xPropSet->getPropertyValue(VersionProp) >>= Version) if ((xPropSet->getPropertyValue("Version") >>= Version)
&& !Version.equals(ODFVER_010_TEXT) && Version != ODFVER_010_TEXT
&& !Version.equals(ODFVER_011_TEXT)) && Version != ODFVER_011_TEXT)
{ {
const uno::Reference<rdf::XDocumentMetadataAccess> xDMA( const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(
xModelComp, uno::UNO_QUERY_THROW); xModelComp, uno::UNO_QUERY_THROW);
...@@ -316,8 +305,10 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >& ...@@ -316,8 +305,10 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
Reference< frame::XModule > xModule( xModelComp, UNO_QUERY ); Reference< frame::XModule > xModule( xModelComp, UNO_QUERY );
if ( xModule.is() ) if ( xModule.is() )
{ {
OUString aModuleID = xModule->getIdentifier(); const OUString aModuleID = xModule->getIdentifier();
bStoreMeta = ( !aModuleID.isEmpty() && ( aModuleID == "com.sun.star.sdb.FormDesign" || aModuleID == "com.sun.star.sdb.TextReportDesign" ) ); bStoreMeta = !aModuleID.isEmpty() &&
( aModuleID == "com.sun.star.sdb.FormDesign" ||
aModuleID == "com.sun.star.sdb.TextReportDesign" );
} }
} }
catch( uno::Exception& ) catch( uno::Exception& )
...@@ -384,17 +375,15 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >& ...@@ -384,17 +375,15 @@ sal_uInt32 SwXMLWriter::_Write( const uno::Reference < task::XStatusIndicator >&
if( pDoc->GetCurrentViewShell() && pDoc->GetDocStat().nPage > 1 && if( pDoc->GetCurrentViewShell() && pDoc->GetDocStat().nPage > 1 &&
!(bOrganizerMode || bBlock || bErr) ) !(bOrganizerMode || bBlock || bErr) )
{ {
OUString sStreamName("layout-cache");
try try
{ {
uno::Reference < io::XStream > xStm = xStg->openStreamElement( sStreamName, embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ); uno::Reference < io::XStream > xStm = xStg->openStreamElement( "layout-cache", embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
SvStream* pStream = utl::UcbStreamHelper::CreateStream( xStm ); SvStream* pStream = utl::UcbStreamHelper::CreateStream( xStm );
if( !pStream->GetError() ) if( !pStream->GetError() )
{ {
uno::Reference < beans::XPropertySet > xSet( xStm, UNO_QUERY ); uno::Reference < beans::XPropertySet > xSet( xStm, UNO_QUERY );
OUString aMime("application/binary");
uno::Any aAny2; uno::Any aAny2;
aAny2 <<= aMime; aAny2 <<= OUString("application/binary");
xSet->setPropertyValue("MediaType", aAny2 ); xSet->setPropertyValue("MediaType", aAny2 );
pDoc->WriteLayoutCache( *pStream ); pDoc->WriteLayoutCache( *pStream );
} }
...@@ -492,7 +481,7 @@ bool SwXMLWriter::WriteThroughComponent( ...@@ -492,7 +481,7 @@ bool SwXMLWriter::WriteThroughComponent(
bool bRet = false; bool bRet = false;
try try
{ {
OUString sStreamName = OUString::createFromAscii( pStreamName ); const OUString sStreamName = OUString::createFromAscii( pStreamName );
uno::Reference<io::XStream> xStream = uno::Reference<io::XStream> xStream =
xStg->openStreamElement( sStreamName, xStg->openStreamElement( sStreamName,
embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ); embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
...@@ -501,17 +490,14 @@ bool SwXMLWriter::WriteThroughComponent( ...@@ -501,17 +490,14 @@ bool SwXMLWriter::WriteThroughComponent(
if( !xSet.is() ) if( !xSet.is() )
return false; return false;
OUString aMime("text/xml");
uno::Any aAny; uno::Any aAny;
aAny <<= aMime; aAny <<= OUString("text/xml");
xSet->setPropertyValue("MediaType", aAny ); xSet->setPropertyValue("MediaType", aAny );
OUString aUseCommonPassPropName("UseCommonStoragePasswordEncryption");
// even plain stream should be encrypted in encrypted documents // even plain stream should be encrypted in encrypted documents
sal_Bool bTrue = sal_True; sal_Bool bTrue = sal_True;
aAny.setValue( &bTrue, ::getBooleanCppuType() ); aAny.setValue( &bTrue, ::getBooleanCppuType() );
xSet->setPropertyValue( aUseCommonPassPropName, aAny ); xSet->setPropertyValue( "UseCommonStoragePasswordEncryption", aAny );
// set buffer and create outputstream // set buffer and create outputstream
uno::Reference< io::XOutputStream > xOutputStream = xStream->getOutputStream(); uno::Reference< io::XOutputStream > xOutputStream = xStream->getOutputStream();
...@@ -523,8 +509,7 @@ bool SwXMLWriter::WriteThroughComponent( ...@@ -523,8 +509,7 @@ bool SwXMLWriter::WriteThroughComponent(
OSL_ENSURE( xInfoSet.is(), "missing property set" ); OSL_ENSURE( xInfoSet.is(), "missing property set" );
if( xInfoSet.is() ) if( xInfoSet.is() )
{ {
OUString sPropName("StreamName"); xInfoSet->setPropertyValue( "StreamName", makeAny( sStreamName ) );
xInfoSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
} }
// write the stuff // write the stuff
......
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