Permalink
Browse files

loplugin:oncevar in sd..svgio

Change-Id: I58565460fcc3279c9771c6e1272d0af540b2c87c
Reviewed-on: https://gerrit.libreoffice.org/30459
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
  • Loading branch information...
1 parent 49c7bc5 commit 9bdec0831afc45af45ea6d9350ef3372188b45cb Noel Grandin committed Nov 1, 2016
@@ -3033,12 +3033,8 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, Esc
{
try
{
- static const char sModel[] = "Model";
- static const char sWidth[] = "Width";
- static const char sHeight[] = "Height";
-
uno::Reference< table::XTable > xTable;
- if ( mXPropSet->getPropertyValue( sModel ) >>= xTable )
+ if ( mXPropSet->getPropertyValue( "Model" ) >>= xTable )
{
uno::Reference< table::XColumnRowRange > xColumnRowRange( xTable, uno::UNO_QUERY_THROW );
uno::Reference< container::XIndexAccess > xColumns( xColumnRowRange->getColumns(), uno::UNO_QUERY_THROW );
@@ -3055,7 +3051,7 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, Esc
{
uno::Reference< beans::XPropertySet > xPropSet( xColumns->getByIndex( x ), uno::UNO_QUERY_THROW );
awt::Size aS( 0, 0 );
- xPropSet->getPropertyValue( sWidth ) >>= aS.Width;
+ xPropSet->getPropertyValue( "Width" ) >>= aS.Width;
awt::Size aM( MapSize( aS ) );
aColumns.push_back( std::pair< sal_Int32, sal_Int32 >( nPosition, aM.Width ) );
nPosition += aM.Width;
@@ -3068,7 +3064,7 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, Esc
{
uno::Reference< beans::XPropertySet > xPropSet( xRows->getByIndex( y ), uno::UNO_QUERY_THROW );
awt::Size aS( 0, 0 );
- xPropSet->getPropertyValue( sHeight ) >>= aS.Height;
+ xPropSet->getPropertyValue( "Height" ) >>= aS.Height;
awt::Size aM( MapSize( aS ) );
aRows.push_back( std::pair< sal_Int32, sal_Int32 >( nPosition, aM.Height ) );
nPosition += aM.Height;
@@ -3174,11 +3170,6 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, Esc
}
}
- static const char sTopBorder[] = "TopBorder";
- static const char sBottomBorder[] = "BottomBorder";
- static const char sLeftBorder[] = "LeftBorder";
- static const char sRightBorder[] = "RightBorder";
-
// creating horz lines
for( sal_Int32 nLine = 0; nLine < ( xRows->getCount() + 1 ); nLine++ )
{
@@ -3196,7 +3187,7 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, Esc
{
uno::Reference< beans::XPropertySet > xPropSet2( xCell, uno::UNO_QUERY_THROW );
table::BorderLine aBorderLine;
- if ( xPropSet2->getPropertyValue( sTopBorder ) >>= aBorderLine )
+ if ( xPropSet2->getPropertyValue( "TopBorder" ) >>= aBorderLine )
aCellBorder.maCellBorder = aBorderLine;
sal_Int32 nRight = GetCellRight( nColumn, maRect,aColumns,xCell );
bTop = ImplCreateCellBorder( &aCellBorder, aCellBorder.mnPos,
@@ -3222,7 +3213,7 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, Esc
uno::Reference< table::XMergeableCell > xCellOwn( xCellRange->getCellByPosition( nColumn, nRow - 1 ), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xPropSet2( xCellOwn, uno::UNO_QUERY_THROW );
table::BorderLine aBorderLine;
- if ( xPropSet2->getPropertyValue( sBottomBorder ) >>= aBorderLine )
+ if ( xPropSet2->getPropertyValue( "BottomBorder" ) >>= aBorderLine )
aCellBorder.maCellBorder = aBorderLine;
ImplCreateCellBorder( &aCellBorder, aCellBorder.mnPos,
nBottom, nRight, nBottom);
@@ -3253,7 +3244,7 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, Esc
{
uno::Reference< beans::XPropertySet > xCellSet( xCell, uno::UNO_QUERY_THROW );
table::BorderLine aBorderLine;
- if ( xCellSet->getPropertyValue( sLeftBorder ) >>= aBorderLine )
+ if ( xCellSet->getPropertyValue( "LeftBorder" ) >>= aBorderLine )
aCellBorder.maCellBorder = aBorderLine;
sal_Int32 nBottom = GetCellBottom( nRow, maRect, aRows,xCell );
bLeft = ImplCreateCellBorder( &aCellBorder, aColumns[nLine].first, aCellBorder.mnPos,
@@ -3275,7 +3266,7 @@ void PPTWriter::ImplCreateTable( uno::Reference< drawing::XShape >& rXShape, Esc
uno::Reference< table::XMergeableCell > xCellOwn( xCellRange->getCellByPosition( nColumn - 1, nRow ), uno::UNO_QUERY_THROW );
uno::Reference< beans::XPropertySet > xCellSet( xCellOwn, uno::UNO_QUERY_THROW );
table::BorderLine aBorderLine;
- if ( xCellSet->getPropertyValue( sRightBorder ) >>= aBorderLine )
+ if ( xCellSet->getPropertyValue( "RightBorder" ) >>= aBorderLine )
aCellBorder.maCellBorder = aBorderLine;
ImplCreateCellBorder( &aCellBorder, nRight, aCellBorder.mnPos,
nRight, nBottom );
@@ -78,11 +78,6 @@ using namespace comphelper;
#define SD_XML_READERROR 1234
-char const sXML_metaStreamName[] = "meta.xml";
-char const sXML_styleStreamName[] = "styles.xml";
-char const sXML_contentStreamName[] = "content.xml";
-char const sXML_settingsStreamName[] = "settings.xml";
-
char const sXML_export_impress_meta_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisMetaExporter";
char const sXML_export_impress_styles_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisStylesExporter";
char const sXML_export_impress_content_oasis_service[] = "com.sun.star.comp.Impress.XMLOasisContentExporter";
@@ -918,18 +913,18 @@ bool SdXMLFilter::Export()
XML_SERVICEMAP aServices[5]; sal_uInt16 i = 0;
aServices[i ].mpService = pServiceNames->mpStyles;
- aServices[i++].mpStream = sXML_styleStreamName;
+ aServices[i++].mpStream = "styles.xml";
aServices[i ].mpService = pServiceNames->mpContent;
- aServices[i++].mpStream = sXML_contentStreamName;
+ aServices[i++].mpStream = "content.xml";
aServices[i ].mpService = pServiceNames->mpSettings;
- aServices[i++].mpStream = sXML_settingsStreamName;
+ aServices[i++].mpStream = "settings.xml";
if( mrDocShell.GetCreateMode() != SfxObjectCreateMode::EMBEDDED )
{
aServices[i ].mpService = pServiceNames->mpMeta;
- aServices[i++].mpStream = sXML_metaStreamName;
+ aServices[i++].mpStream = "meta.xml";
};
aServices[i].mpService = nullptr;
@@ -44,17 +44,6 @@ using namespace ::com::sun::star::uno;
namespace {
const char TITLE[] = "Title";
-const char TARGET_DIR_URL[] = "TargetDirURL";
-const char DESCRIPTION[] = "TypeDescription";
-const char TARGET_URL[] = "TargetURL";
-
-// These strings are used to find impress templates in the tree of
-// template files. Should probably be determined dynamically.
-const char IMPRESS_BIN_TEMPLATE[] = "application/vnd.stardivision.impress";
-const char IMPRESS_XML_TEMPLATE[] = MIMETYPE_VND_SUN_XML_IMPRESS_ASCII;
-// The following id comes from the bugdoc in #i2764#.
-const char IMPRESS_XML_TEMPLATE_B[] = "Impress 2.0";
-const char IMPRESS_XML_TEMPLATE_OASIS[] = MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII;
class FolderDescriptor
{
@@ -211,8 +200,8 @@ TemplateScanner::State TemplateScanner::InitializeEntryScanning()
// its URL, and its content type.
Sequence<OUString> aProps (3);
aProps[0] = TITLE;
- aProps[1] = TARGET_URL;
- aProps[2] = DESCRIPTION;
+ aProps[1] = "TargetURL";
+ aProps[2] = "TypeDescription";
// Create a cursor to iterate over the templates in this folders.
::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_DOCUMENTS_ONLY;
@@ -246,11 +235,14 @@ TemplateScanner::State TemplateScanner::ScanEntry()
// Check whether the entry is an impress template. If so
// add a new entry to the resulting list (which is created
// first if necessary).
+ // These strings are used to find impress templates in the tree of
+ // template files. Should probably be determined dynamically.
if ( (sContentType == MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE_ASCII)
- || (sContentType == IMPRESS_XML_TEMPLATE_OASIS)
- || (sContentType == IMPRESS_BIN_TEMPLATE)
- || (sContentType == IMPRESS_XML_TEMPLATE)
- || (sContentType == IMPRESS_XML_TEMPLATE_B))
+ || (sContentType == MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII)
+ || (sContentType == "application/vnd.stardivision.impress")
+ || (sContentType == MIMETYPE_VND_SUN_XML_IMPRESS_ASCII)
+ // The following id comes from the bugdoc in #i2764#.
+ || (sContentType == "Impress 2.0"))
{
OUString sLocalisedTitle = SfxDocumentTemplates::ConvertResourceString(
STR_TEMPLATE_NAME1_DEF, STR_TEMPLATE_NAME1, NUM_TEMPLATE_NAMES, sTitle );
@@ -298,7 +290,7 @@ TemplateScanner::State TemplateScanner::InitializeFolderScanning()
// Define the list of properties we are interested in.
Sequence<OUString> aProps (2);
aProps[0] = TITLE;
- aProps[1] = TARGET_DIR_URL;
+ aProps[1] = "TargetDirURL";
// Create an cursor to iterate over the template folders.
::ucbhelper::ResultSetInclude eInclude = ::ucbhelper::INCLUDE_FOLDERS_ONLY;
@@ -82,27 +82,23 @@ ::std::unique_ptr<CacheCompactor> CacheCompactor::Create (
sal_Int32 nMaximalCacheSize)
{
static const char sNone[] = "None";
- static const char sCompress[] = "Compress";
- static const char sErase[] = "Erase";
- static const char sResolution[] = "ResolutionReduction";
- static const char sPNGCompression[] = "PNGCompression";
std::shared_ptr<BitmapCompressor> pCompressor;
- OUString sCompressionPolicy(sPNGCompression);
+ OUString sCompressionPolicy("PNGCompression");
Any aCompressionPolicy (CacheConfiguration::Instance()->GetValue("CompressionPolicy"));
if (aCompressionPolicy.has<OUString>())
aCompressionPolicy >>= sCompressionPolicy;
if (sCompressionPolicy == sNone)
pCompressor.reset(new NoBitmapCompression());
- else if (sCompressionPolicy == sErase)
+ else if (sCompressionPolicy == "Erase")
pCompressor.reset(new CompressionByDeletion());
- else if (sCompressionPolicy == sResolution)
+ else if (sCompressionPolicy == "ResolutionReduction")
pCompressor.reset(new ResolutionReduction());
else
pCompressor.reset(new PngCompression());
::std::unique_ptr<CacheCompactor> pCompactor;
- OUString sCompactionPolicy(sCompress);
+ OUString sCompactionPolicy("Compress");
Any aCompactionPolicy (CacheConfiguration::Instance()->GetValue("CompactionPolicy"));
if (aCompactionPolicy.has<OUString>())
aCompactionPolicy >>= sCompactionPolicy;
@@ -451,10 +451,7 @@ void SAL_CALL Listener::propertyChange (
static_cast<uno::XWeak*>(this));
}
- static const char sCurrentPagePropertyName[] = "CurrentPage";
- static const char sEditModePropertyName[] = "IsMasterPageMode";
-
- if (rEvent.PropertyName == sCurrentPagePropertyName)
+ if (rEvent.PropertyName == "CurrentPage")
{
Any aCurrentPage = rEvent.NewValue;
Reference<beans::XPropertySet> xPageSet (aCurrentPage, UNO_QUERY);
@@ -483,7 +480,7 @@ void SAL_CALL Listener::propertyChange (
}
}
}
- else if (rEvent.PropertyName == sEditModePropertyName)
+ else if (rEvent.PropertyName == "IsMasterPageMode")
{
bool bIsMasterPageMode = false;
rEvent.NewValue >>= bIsMasterPageMode;
@@ -2947,7 +2947,6 @@ void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPag
}
// XServiceInfo
-const char pSdDrawPagesAccessService[] = "com.sun.star.drawing.DrawPages";
OUString SAL_CALL SdDrawPagesAccess::getImplementationName( ) throw(uno::RuntimeException, std::exception)
{
@@ -2961,7 +2960,7 @@ sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceNam
uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException, std::exception)
{
- OUString aService( pSdDrawPagesAccessService );
+ OUString aService( "com.sun.star.drawing.DrawPages" );
uno::Sequence< OUString > aSeq( &aService, 1 );
return aSeq;
}
@@ -3213,7 +3212,6 @@ void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawP
}
// XServiceInfo
-const char pSdMasterPagesAccessService[] = "com.sun.star.drawing.MasterPages";
OUString SAL_CALL SdMasterPagesAccess::getImplementationName( ) throw(uno::RuntimeException, std::exception)
{
@@ -3227,7 +3225,7 @@ sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceN
uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException, std::exception)
{
- OUString aService( pSdMasterPagesAccessService );
+ OUString aService( "com.sun.star.drawing.MasterPages" );
uno::Sequence< OUString > aSeq( &aService, 1 );
return aSeq;
}
@@ -685,29 +685,20 @@ void Parser::readFont()
uno::Sequence<beans::PropertyValue> Parser::readImageImpl()
{
- static const char aJpegMarker[] = "JPEG";
- static const char aPbmMarker[] = "PBM";
- static const char aPpmMarker[] = "PPM";
- static const char aPngMarker[] = "PNG";
- static const char aJpegFile[] = "DUMMY.JPEG";
- static const char aPbmFile[] = "DUMMY.PBM";
- static const char aPpmFile[] = "DUMMY.PPM";
- static const char aPngFile[] = "DUMMY.PNG";
-
OString aToken = readNextToken();
const sal_Int32 nImageSize( readInt32() );
OUString aFileName;
- if( aToken == aPngMarker )
- aFileName = aPngFile;
- else if( aToken == aJpegMarker )
- aFileName = aJpegFile;
- else if( aToken == aPbmMarker )
- aFileName = aPbmFile;
+ if( aToken == "PNG" )
+ aFileName = "DUMMY.PNG";
+ else if( aToken == "JPEG" )
+ aFileName = "DUMMY.JPEG";
+ else if( aToken == "PBM" )
+ aFileName = "DUMMY.PBM";
else
{
- SAL_WARN_IF(aToken != aPpmMarker,"sdext.pdfimport","Invalid bitmap format");
- aFileName = aPpmFile;
+ SAL_WARN_IF(aToken != "PPM","sdext.pdfimport","Invalid bitmap format");
+ aFileName = "DUMMY.PPM";
}
uno::Sequence<sal_Int8> aDataSequence(nImageSize);
@@ -129,15 +129,13 @@ static char const sViewOnly[] = "ViewOnly";
static char const sDontEdit[] = "DontEdit";
static char const sSilent[] = "Silent";
static char const sJumpMark[] = "JumpMark";
-static char const sFileName[] = "FileName";
static char const sSalvagedFile[] = "SalvagedFile";
static char const sStatusInd[] = "StatusIndicator";
static char const sModel[] = "Model";
static char const sFrame[] = "Frame";
static char const sViewData[] = "ViewData";
static char const sFilterData[] = "FilterData";
static char const sSelectionOnly[] = "SelectionOnly";
-static char const sFilterFlags[] = "FilterFlags";
static char const sMacroExecMode[] = "MacroExecutionMode";
static char const sUpdateDocMode[] = "UpdateDocMode";
static char const sMinimized[] = "Minimized";
@@ -690,7 +688,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert
rSet.Put( stringList );
}
}
- else if ( aName == sFileName )
+ else if ( aName == "FileName" )
{
OUString sVal;
bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
@@ -762,7 +760,7 @@ void TransformParameters( sal_uInt16 nSlotId, const uno::Sequence<beans::Propert
if (bOK)
rSet.Put( SfxStringItem( SID_CHARSET, sVal ) );
}
- else if ( aName == sFilterFlags )
+ else if ( aName == "FilterFlags" )
{
OUString sVal;
bool bOK = ((rProp.Value >>= sVal) && !sVal.isEmpty());
@@ -51,7 +51,6 @@ using namespace ::com::sun::star;
static sal_Char const sHTML_SC_yes[] = "YES";
static sal_Char const sHTML_SC_no[] = "NO";
-static sal_Char const sHTML_MIME_text_html[] = "text/html; charset=";
void SfxFrameHTMLWriter::OutMeta( SvStream& rStrm,
const sal_Char *pIndent,
@@ -89,8 +88,7 @@ void SfxFrameHTMLWriter::Out_DocInfo( SvStream& rStrm, const OUString& rBaseURL,
if( pCharSet )
{
- OUString aContentType(sHTML_MIME_text_html);
- aContentType += OUString(pCharSet, strlen(pCharSet), RTL_TEXTENCODING_UTF8);
+ OUString aContentType = "text/html; charset=" + OUString(pCharSet, strlen(pCharSet), RTL_TEXTENCODING_UTF8);
OutMeta( rStrm, pIndent, OOO_STRING_SVTOOLS_HTML_META_content_type, aContentType, true,
eDestEnc, pNonConvertableChars );
}
@@ -46,10 +46,6 @@
using namespace ::com::sun::star;
-const sal_Char sHTML_MIME_text[] = "text/";
-const sal_Char sHTML_MIME_application[] = "application/";
-const sal_Char sHTML_MIME_experimental[] = "x-";
-
// <INPUT TYPE=xxx>
static HTMLOptionEnum const aAreaShapeOptEnums[] =
{
@@ -279,14 +275,14 @@ void SfxHTMLParser::GetScriptType_Impl( SvKeyValueIterator *pHTTPHeader )
if( !aKV.GetValue().isEmpty() )
{
OUString aTmp( aKV.GetValue() );
- if( aTmp.startsWithIgnoreAsciiCase( sHTML_MIME_text ) )
+ if( aTmp.startsWithIgnoreAsciiCase( "text/" ) )
aTmp = aTmp.copy( 5 );
- else if( aTmp.startsWithIgnoreAsciiCase( sHTML_MIME_application ) )
+ else if( aTmp.startsWithIgnoreAsciiCase( "application/" ) )
aTmp = aTmp.copy( 12 );
else
break;
- if( aTmp.startsWithIgnoreAsciiCase( sHTML_MIME_experimental ) )
+ if( aTmp.startsWithIgnoreAsciiCase( "x-" ) ) // MIME-experimental
{
aTmp = aTmp.copy( 2 );
}
Oops, something went wrong.

0 comments on commit 9bdec08

Please sign in to comment.