loplugin:oncevar in sw

Change-Id: I81cd59b2a24bca533a27cc4138f1ac3acff65090
Reviewed-on: https://gerrit.libreoffice.org/30437
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2016-10-31 12:39:06 +02:00
parent 785a4d56e6
commit c8b09c0024
14 changed files with 34 additions and 79 deletions

View File

@ -50,7 +50,6 @@ using namespace ::com::sun::star;
using namespace ::com::sun::star::accessibility;
using namespace sw::access;
const sal_Char sServiceName[] = "com.sun.star.table.AccessibleCellView";
const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleCellView";
bool SwAccessibleCell::IsSelected()
@ -258,7 +257,7 @@ uno::Sequence< OUString > SAL_CALL SwAccessibleCell::getSupportedServiceNames()
{
uno::Sequence< OUString > aRet(2);
OUString* pArray = aRet.getArray();
pArray[0] = sServiceName;
pArray[0] = "com.sun.star.table.AccessibleCellView";
pArray[1] = sAccessibleServiceName;
return aRet;
}

View File

@ -37,8 +37,6 @@ using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::accessibility;
const sal_Char sServiceNameFootnote[] = "com.sun.star.text.AccessibleFootnoteView";
const sal_Char sServiceNameEndnote[] = "com.sun.star.text.AccessibleEndnoteView";
const sal_Char sImplementationNameFootnote[] = "com.sun.star.comp.Writer.SwAccessibleFootnoteView";
const sal_Char sImplementationNameEndnote[] = "com.sun.star.comp.Writer.SwAccessibleEndnoteView";
@ -115,9 +113,9 @@ Sequence< OUString > SAL_CALL SwAccessibleFootnote::getSupportedServiceNames()
Sequence< OUString > aRet(2);
OUString* pArray = aRet.getArray();
if( AccessibleRole::END_NOTE == GetRole() )
pArray[0] = sServiceNameEndnote;
pArray[0] = "com.sun.star.text.AccessibleEndnoteView";
else
pArray[0] = sServiceNameFootnote;
pArray[0] = "com.sun.star.text.AccessibleFootnoteView";
pArray[1] = sAccessibleServiceName;
return aRet;
}

View File

@ -35,7 +35,6 @@ using namespace ::com::sun::star::accessibility;
using uno::RuntimeException;
using uno::Sequence;
const sal_Char sServiceName[] = "com.sun.star.text.AccessiblePageView";
const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessiblePageView";
bool SwAccessiblePage::IsSelected()
@ -152,7 +151,7 @@ Sequence<OUString> SwAccessiblePage::getSupportedServiceNames( )
{
Sequence< OUString > aRet(2);
OUString* pArray = aRet.getArray();
pArray[0] = sServiceName;
pArray[0] = "com.sun.star.text.AccessiblePageView";
pArray[1] = sAccessibleServiceName;
return aRet;
}

View File

@ -126,13 +126,6 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::document;
const sal_Char sFrameFormatStr[] = "Frameformat";
const sal_Char sEmptyPageStr[] = "Empty Page";
const sal_Char sColumnCntStr[] = "Columncontainer";
const sal_Char sCharFormatStr[] = "Character style";
const sal_Char sTextCollStr[] = "Paragraph style";
const sal_Char sGrfCollStr[] = "Graphikformatvorlage";
/*
* global functions...
*/
@ -226,12 +219,12 @@ SwDoc::SwDoc()
m_pDocumentLayoutManager( new ::sw::DocumentLayoutManager( *this ) ),
m_pDocumentStylePoolManager( new ::sw::DocumentStylePoolManager( *this ) ),
m_pDocumentExternalDataManager( new ::sw::DocumentExternalDataManager() ),
mpDfltFrameFormat( new SwFrameFormat( GetAttrPool(), sFrameFormatStr, nullptr ) ),
mpEmptyPageFormat( new SwFrameFormat( GetAttrPool(), sEmptyPageStr, mpDfltFrameFormat ) ),
mpColumnContFormat( new SwFrameFormat( GetAttrPool(), sColumnCntStr, mpDfltFrameFormat ) ),
mpDfltCharFormat( new SwCharFormat( GetAttrPool(), sCharFormatStr, nullptr ) ),
mpDfltTextFormatColl( new SwTextFormatColl( GetAttrPool(), sTextCollStr ) ),
mpDfltGrfFormatColl( new SwGrfFormatColl( GetAttrPool(), sGrfCollStr ) ),
mpDfltFrameFormat( new SwFrameFormat( GetAttrPool(), "Frameformat", nullptr ) ),
mpEmptyPageFormat( new SwFrameFormat( GetAttrPool(), "Empty Page", mpDfltFrameFormat ) ),
mpColumnContFormat( new SwFrameFormat( GetAttrPool(), "Columncontainer", mpDfltFrameFormat ) ),
mpDfltCharFormat( new SwCharFormat( GetAttrPool(), "Character style", nullptr ) ),
mpDfltTextFormatColl( new SwTextFormatColl( GetAttrPool(), "Paragraph style" ) ),
mpDfltGrfFormatColl( new SwGrfFormatColl( GetAttrPool(), "Graphikformatvorlage" ) ),
mpFrameFormatTable( new SwFrameFormats() ),
mpCharFormatTable( new SwCharFormats() ),
mpSpzFrameFormatTable( new SwFrameFormats() ),

View File

@ -2576,15 +2576,13 @@ static OUString OldNameToNewName_Impl( const OUString &rOld )
{
static const char aOldNamePart1[] = ".TextField.DocInfo.";
static const char aOldNamePart2[] = ".TextField.";
static const char aNewNamePart1[] = ".textfield.docinfo.";
static const char aNewNamePart2[] = ".textfield.";
OUString sServiceNameCC( rOld );
sal_Int32 nIdx = sServiceNameCC.indexOf( aOldNamePart1 );
if (nIdx >= 0)
sServiceNameCC = sServiceNameCC.replaceAt( nIdx, strlen(aOldNamePart1), aNewNamePart1 );
sServiceNameCC = sServiceNameCC.replaceAt( nIdx, strlen(aOldNamePart1), ".textfield.docinfo." );
nIdx = sServiceNameCC.indexOf( aOldNamePart2 );
if (nIdx >= 0)
sServiceNameCC = sServiceNameCC.replaceAt( nIdx, strlen(aOldNamePart2), aNewNamePart2 );
sServiceNameCC = sServiceNameCC.replaceAt( nIdx, strlen(aOldNamePart2), ".textfield." );
return sServiceNameCC;
}

View File

@ -1717,13 +1717,6 @@ throw (uno::RuntimeException, std::exception)
return ::sw::UnoTunnelImpl<SwXDocumentIndexMark>(rId, this);
}
static const sal_Char cBaseMark[] = "com.sun.star.text.BaseIndexMark";
static const sal_Char cContentMark[] = "com.sun.star.text.ContentIndexMark";
static const sal_Char cIdxMark[] = "com.sun.star.text.DocumentIndexMark";
static const sal_Char cIdxMarkAsian[] = "com.sun.star.text.DocumentIndexMarkAsian";
static const sal_Char cUserMark[] = "com.sun.star.text.UserIndexMark";
static const sal_Char cTextContent[] = "com.sun.star.text.TextContent";
OUString SAL_CALL
SwXDocumentIndexMark::getImplementationName() throw (uno::RuntimeException, std::exception)
{
@ -1744,19 +1737,19 @@ SwXDocumentIndexMark::getSupportedServiceNames() throw (uno::RuntimeException, s
const sal_Int32 nCnt = (m_pImpl->m_eTOXType == TOX_INDEX) ? 4 : 3;
uno::Sequence< OUString > aRet(nCnt);
OUString* pArray = aRet.getArray();
pArray[0] = cBaseMark;
pArray[1] = cTextContent;
pArray[0] = "com.sun.star.text.BaseIndexMark";
pArray[1] = "com.sun.star.text.TextContent";
switch (m_pImpl->m_eTOXType)
{
case TOX_USER:
pArray[2] = cUserMark;
pArray[2] = "com.sun.star.text.UserIndexMark";
break;
case TOX_CONTENT:
pArray[2] = cContentMark;
pArray[2] = "com.sun.star.text.ContentIndexMark";
break;
case TOX_INDEX:
pArray[2] = cIdxMark;
pArray[3] = cIdxMarkAsian;
pArray[2] = "com.sun.star.text.DocumentIndexMark";
pArray[3] = "com.sun.star.text.DocumentIndexMarkAsian";
break;
default:

View File

@ -71,11 +71,6 @@ using namespace com::sun::star;
#define HTML_DFLT_APPLET_WIDTH ((MM50*5)/2)
#define HTML_DFLT_APPLET_HEIGHT ((MM50*5)/2)
namespace {
static char const sHTML_O_Hidden_False[] = "FALSE";
}
const sal_uLong HTML_FRMOPTS_EMBED_ALL =
HTML_FRMOPT_ALT |
@ -370,7 +365,7 @@ void SwHTMLParser::InsertEmbed()
OOO_STRING_SW_HTML_O_Hidden))
{
bHidden = !rOption.GetString().equalsIgnoreAsciiCase(
sHTML_O_Hidden_False);
"FALSE");
}
break;
}

View File

@ -64,9 +64,6 @@ using table::XCell;
using std::vector;
using std::advance;
// string constants for table cell export
static const char g_sNumberFormat[] = "NumberFormat";
static const char g_sIsProtected[] = "IsProtected";
class SwXMLTableColumn_Impl : public SwWriteTableCol
{
@ -823,7 +820,7 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
if (xCellPropertySet.is())
{
sal_Int32 nNumberFormat = 0;
Any aAny = xCellPropertySet->getPropertyValue(g_sNumberFormat);
Any aAny = xCellPropertySet->getPropertyValue("NumberFormat");
aAny >>= nNumberFormat;
if (css::util::NumberFormat::TEXT == nNumberFormat)
@ -843,7 +840,7 @@ void SwXMLExport::ExportTableBox( const SwTableBox& rBox,
// else: invalid key; ignore
// cell protection
aAny = xCellPropertySet->getPropertyValue(g_sIsProtected);
aAny = xCellPropertySet->getPropertyValue("IsProtected");
if (*o3tl::doAccess<bool>(aAny))
{
AddAttribute( XML_NAMESPACE_TABLE, XML_PROTECTED,

View File

@ -30,10 +30,6 @@ using namespace ::com::sun::star;
static const sal_Int32 LIST_LEVEL_COUNT = 9;
static const char WORD_BULLET_GALLERY[] = "WdBullet";
static const char WORD_NUMBER_GALLERY[] = "WdNumber";
static const char WORD_OUTLINE_NUMBER_GALLERY[] = "WdOutlineNumber";
static const char UNO_NAME_PARENT_NUMBERING[] = "ParentNumbering";
static const char UNO_NAME_PREFIX[] = "Prefix";
static const char UNO_NAME_SUFFIX[] = "Suffix";
@ -62,17 +58,17 @@ void SwVbaListHelper::Init() throw( css::uno::RuntimeException )
{
case word::WdListGalleryType::wdBulletGallery:
{
msStyleName = WORD_BULLET_GALLERY;
msStyleName = "WdBullet";
break;
}
case word::WdListGalleryType::wdNumberGallery:
{
msStyleName = WORD_NUMBER_GALLERY;
msStyleName = "WdNumber";
break;
}
case word::WdListGalleryType::wdOutlineNumberGallery:
{
msStyleName = WORD_OUTLINE_NUMBER_GALLERY;
msStyleName = "WdOutlineNumber";
break;
}
default:

View File

@ -67,8 +67,6 @@ Color SwViewOption::m_aHeaderFooterMarkColor(COL_BLUE);
ViewOptFlags SwViewOption::m_nAppearanceFlags = ViewOptFlags::DocBoundaries|ViewOptFlags::ObjectBoundaries;
sal_uInt16 SwViewOption::m_nPixelTwips = 0; // one pixel on the screen
static const char aPostItStr[] = " ";
bool SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const
{
return m_nCoreOptions == rOpt.m_nCoreOptions
@ -131,7 +129,7 @@ void SwViewOption::DrawRectPrinter( OutputDevice *pOut,
sal_uInt16 SwViewOption::GetPostItsWidth( const OutputDevice *pOut )
{
assert(pOut && "no Outdev");
return sal_uInt16(pOut->GetTextWidth( aPostItStr));
return sal_uInt16(pOut->GetTextWidth(" "));
}
void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect, bool bIsScript )

View File

@ -148,13 +148,6 @@ using namespace ::com::sun::star;
#define DB_SEP_RETURN 2
#define DB_SEP_NEWLINE 3
const sal_Char cCursor[] = "Cursor";
const sal_Char cCommand[] = "Command";
const sal_Char cCommandType[] = "CommandType";
const sal_Char cDataSourceName[] = "DataSourceName";
const sal_Char cSelection[] = "Selection";
const sal_Char cActiveConnection[] = "ActiveConnection";
namespace {
void rescheduleGui() {
@ -2924,17 +2917,17 @@ void SwDBManager::InsertText(SwWrtShell& rSh,
uno::Reference< sdbc::XConnection> xConnection;
for(sal_Int32 nPos = 0; nPos < rProperties.getLength(); nPos++)
{
if ( pValues[nPos].Name == cDataSourceName )
if ( pValues[nPos].Name == "DataSourceName" )
pValues[nPos].Value >>= sDataSource;
else if ( pValues[nPos].Name == cCommand )
else if ( pValues[nPos].Name == "Command" )
pValues[nPos].Value >>= sDataTableOrQuery;
else if ( pValues[nPos].Name == cCursor )
else if ( pValues[nPos].Name == "Cursor" )
pValues[nPos].Value >>= xResSet;
else if ( pValues[nPos].Name == cSelection )
else if ( pValues[nPos].Name == "Selection" )
pValues[nPos].Value >>= aSelection;
else if ( pValues[nPos].Name == cCommandType )
else if ( pValues[nPos].Name == "CommandType" )
pValues[nPos].Value >>= nCmdType;
else if ( pValues[nPos].Name == cActiveConnection )
else if ( pValues[nPos].Name == "ActiveConnection" )
pValues[nPos].Value >>= xConnection;
}
if(sDataSource.isEmpty() || sDataTableOrQuery.isEmpty() || !xResSet.is())

View File

@ -151,7 +151,6 @@
#include <memory>
const char sStatusDelim[] = " : ";
const char sStatusComma[] = " , ";
using namespace sfx2;
using namespace ::com::sun::star;
@ -1576,7 +1575,7 @@ void SwView::StateStatusLine(SfxItemSet &rSet)
if( nOutlineLevel != 0 )
{
if (!sStr.isEmpty())
sStr += sStatusComma;
sStr += " , ";
if( bOutlineNum )
{
sStr += SW_RESSTR(STR_OUTLINE_NUMBERING);

View File

@ -67,8 +67,6 @@ void SwAttrSet::GetPresentation(
MapUnit ePresMetric,
OUString &rText ) const
{
static sal_Char const sComma[] = ", ";
rText.clear();
OUString aStr;
if( Count() )
@ -82,7 +80,7 @@ void SwAttrSet::GetPresentation(
ePresMetric, aStr,
&rInt );
if( rText.getLength() && aStr.getLength() )
rText += sComma;
rText += ", ";
rText += aStr;
if( aIter.IsAtEnd() )
break;

View File

@ -57,7 +57,6 @@
using namespace ::com::sun::star;
const sal_Char cFrameControl[] = "com.sun.star.frame.FrameControl";
const sal_Char cFactory[] = "private:factory/swriter";
bool SwOneExampleFrame::bShowServiceNotAvailableMessage = true;
@ -96,7 +95,7 @@ void SwOneExampleFrame::CreateErrorMessage()
if(SwOneExampleFrame::bShowServiceNotAvailableMessage)
{
OUString sInfo(SW_RES(STR_SERVICE_UNAVAILABLE));
sInfo += cFrameControl;
sInfo += "com.sun.star.frame.FrameControl";
ScopedVclPtrInstance<InfoBox>(nullptr, sInfo)->Execute();
SwOneExampleFrame::bShowServiceNotAvailableMessage = false;
}