summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-13 15:00:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-17 10:52:39 +0200
commit05db125c57ea3c8f04a304561209c32cc5c45a67 (patch)
treeb145bc06aefb426e9b92fe9b4defea02a5ee4abe
parentbe9b83445ec19346a4d5c830c955ed573469591a (diff)
loplugin:staticconstfield improvements
Change-Id: Ia0a19736dfd4500bb17b04c072710f8ee8744031 Reviewed-on: https://gerrit.libreoffice.org/60526 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--compilerplugins/clang/staticconstfield.cxx66
-rw-r--r--compilerplugins/clang/test/staticconstfield.cxx71
-rw-r--r--cppcanvas/source/mtfrenderer/transparencygroupaction.cxx29
-rw-r--r--desktop/source/splash/splash.cxx4
-rw-r--r--include/vcl/opengl/OpenGLContext.hxx1
-rw-r--r--sc/source/ui/dbgui/tpsubt.cxx2
-rw-r--r--sc/source/ui/inc/tpsubt.hxx2
-rw-r--r--sd/source/ui/sidebar/PreviewValueSet.cxx9
-rw-r--r--sd/source/ui/sidebar/PreviewValueSet.hxx2
-rw-r--r--sw/source/core/inc/frmtool.hxx1
-rw-r--r--sw/source/core/layout/frmtool.cxx11
-rw-r--r--uui/source/secmacrowarnings.cxx3
-rw-r--r--uui/source/secmacrowarnings.hxx1
-rw-r--r--vcl/backendtest/VisualBackendTest.cxx21
-rw-r--r--vcl/inc/unx/glyphcache.hxx2
-rw-r--r--vcl/opengl/win/gdiimpl.cxx6
-rw-r--r--vcl/opengl/x11/gdiimpl.cxx2
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx10
-rw-r--r--vcl/source/gdi/pdfwriter_impl.hxx6
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx1
-rw-r--r--vcl/unx/generic/glyphs/glyphcache.cxx7
-rw-r--r--vcl/unx/generic/print/bitmap_gfx.cxx9
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx12
-rw-r--r--vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx4
-rw-r--r--writerfilter/source/dmapper/GraphicImport.cxx9
25 files changed, 184 insertions, 107 deletions
diff --git a/compilerplugins/clang/staticconstfield.cxx b/compilerplugins/clang/staticconstfield.cxx
index 7276d7e05c49..bfc32a8c059f 100644
--- a/compilerplugins/clang/staticconstfield.cxx
+++ b/compilerplugins/clang/staticconstfield.cxx
@@ -33,22 +33,66 @@ bool StaticConstField::TraverseConstructorInitializer(CXXCtorInitializer* init)
return true;
if (!init->getMember())
return true;
- auto tc = loplugin::TypeCheck(init->getMember()->getType());
- if (!tc.Const().Class("OUString").Namespace("rtl").GlobalNamespace()
- && !tc.Const().Class("OString").Namespace("rtl").GlobalNamespace())
+ auto type = init->getMember()->getType();
+ auto tc = loplugin::TypeCheck(type);
+ bool found = false;
+ if (!tc.Const())
return true;
- if (auto constructExpr = dyn_cast<CXXConstructExpr>(init->getInit()))
+ if (tc.Const().Class("OUString").Namespace("rtl").GlobalNamespace()
+ || tc.Const().Class("OString").Namespace("rtl").GlobalNamespace())
{
- if (constructExpr->getNumArgs() >= 1 && isa<clang::StringLiteral>(constructExpr->getArg(0)))
+ if (auto constructExpr = dyn_cast<CXXConstructExpr>(init->getInit()))
{
- report(DiagnosticsEngine::Warning, "string field can be static const",
- init->getSourceLocation())
- << init->getSourceRange();
- report(DiagnosticsEngine::Note, "field here", init->getMember()->getLocation())
- << init->getMember()->getSourceRange();
+ if (constructExpr->getNumArgs() >= 1
+ && isa<clang::StringLiteral>(constructExpr->getArg(0)))
+ found = true;
}
}
- return RecursiveASTVisitor::TraverseConstructorInitializer(init);
+ else if (type->isIntegerType())
+ {
+ if (isa<IntegerLiteral>(init->getInit()->IgnoreParenImpCasts()))
+ found = true;
+ // isIntegerType includes bool
+ else if (isa<CXXBoolLiteralExpr>(init->getInit()->IgnoreParenImpCasts()))
+ found = true;
+ }
+ else if (type->isFloatingType())
+ {
+ if (isa<FloatingLiteral>(init->getInit()->IgnoreParenImpCasts()))
+ found = true;
+ }
+ else if (type->isEnumeralType())
+ {
+ if (auto declRefExpr = dyn_cast<DeclRefExpr>(init->getInit()->IgnoreParenImpCasts()))
+ {
+ if (isa<EnumConstantDecl>(declRefExpr->getDecl()))
+ found = true;
+ }
+ }
+
+ // If we find more than one non-copy-move constructor, we can't say for sure if a member can be static
+ // because it could be initialised differently in each constructor.
+ if (auto cxxRecordDecl = dyn_cast<CXXRecordDecl>(init->getMember()->getParent()))
+ {
+ int cnt = 0;
+ for (auto it = cxxRecordDecl->ctor_begin(); it != cxxRecordDecl->ctor_end(); ++it)
+ {
+ if (!it->isCopyOrMoveConstructor())
+ cnt++;
+ }
+ if (cnt > 1)
+ return true;
+ }
+
+ if (found)
+ {
+ report(DiagnosticsEngine::Warning, "field can be static const", init->getSourceLocation())
+ << init->getSourceRange();
+ report(DiagnosticsEngine::Note, "field here", init->getMember()->getLocation())
+ << init->getMember()->getSourceRange();
+ }
+
+ return true;
}
loplugin::Plugin::Registration<StaticConstField> X("staticconstfield", true);
diff --git a/compilerplugins/clang/test/staticconstfield.cxx b/compilerplugins/clang/test/staticconstfield.cxx
index 49b326f7d76e..03708fcaa9fd 100644
--- a/compilerplugins/clang/test/staticconstfield.cxx
+++ b/compilerplugins/clang/test/staticconstfield.cxx
@@ -15,7 +15,7 @@ class Class1
OUString const m_field1; // expected-note {{field here [loplugin:staticconstfield]}}
Class1()
: m_field1("xxxx")
- // expected-error@-1 {{string field can be static const [loplugin:staticconstfield]}}
+ // expected-error@-1 {{field can be static const [loplugin:staticconstfield]}}
{
(void)m_field1;
}
@@ -26,7 +26,7 @@ class Class2
OString const m_field1; // expected-note {{field here [loplugin:staticconstfield]}}
Class2()
: m_field1("xxxx")
- // expected-error@-1 {{string field can be static const [loplugin:staticconstfield]}}
+ // expected-error@-1 {{field can be static const [loplugin:staticconstfield]}}
{
(void)m_field1;
}
@@ -43,4 +43,71 @@ class Class4
}
};
+class Class5
+{
+ enum class Enum
+ {
+ ONE
+ };
+ float const m_field1; // expected-note {{field here [loplugin:staticconstfield]}}
+ int const m_field2; // expected-note {{field here [loplugin:staticconstfield]}}
+ bool const m_field3; // expected-note {{field here [loplugin:staticconstfield]}}
+ Enum const m_field4; // expected-note {{field here [loplugin:staticconstfield]}}
+ Class5()
+ : m_field1(1.0)
+ // expected-error@-1 {{field can be static const [loplugin:staticconstfield]}}
+ , m_field2(1)
+ // expected-error@-1 {{field can be static const [loplugin:staticconstfield]}}
+ , m_field3(true)
+ // expected-error@-1 {{field can be static const [loplugin:staticconstfield]}}
+ , m_field4(Enum::ONE)
+ // expected-error@-1 {{field can be static const [loplugin:staticconstfield]}}
+ {
+ (void)m_field1;
+ (void)m_field2;
+ (void)m_field3;
+ (void)m_field4;
+ }
+};
+
+// no warning expected
+class Class6
+{
+ enum class Enum
+ {
+ ONE
+ };
+ float m_field1;
+ int m_field2;
+ bool m_field3;
+ Enum m_field4;
+ Class6()
+ : m_field1(1.0)
+ , m_field2(1)
+ , m_field3(true)
+ , m_field4(Enum::ONE)
+ {
+ (void)m_field1;
+ (void)m_field2;
+ (void)m_field3;
+ (void)m_field4;
+ }
+};
+
+// no warning expected, checking for assigning to const field from multiple constructors
+class Class7
+{
+ bool const m_field1;
+ Class7()
+ : m_field1(true)
+ {
+ (void)m_field1;
+ }
+ Class7(bool b)
+ : m_field1(b)
+ {
+ (void)m_field1;
+ }
+};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx
index c7cd718fc805..8fdfca98a39e 100644
--- a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx
+++ b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx
@@ -120,7 +120,6 @@ namespace cppcanvas
// mxBufferBitmap content
CanvasSharedPtr mpCanvas;
rendering::RenderState maState;
- const double mnAlpha;
};
@@ -151,8 +150,7 @@ namespace cppcanvas
mxBufferBitmap(),
maLastTransformation(),
mpCanvas( rCanvas ),
- maState(),
- mnAlpha( 1.0 )
+ maState()
{
tools::initRenderState(maState,rState);
implSetupTransform( maState, rDstPoint );
@@ -400,27 +398,10 @@ namespace cppcanvas
aLocalState.DeviceColor = maState.DeviceColor;
#endif
- if( ::rtl::math::approxEqual(mnAlpha, 1.0) )
- {
- // no further alpha changes necessary -> draw directly
- mpCanvas->getUNOCanvas()->drawBitmap( mxBufferBitmap,
- mpCanvas->getViewState(),
- aLocalState );
- }
- else
- {
- // add alpha modulation value to DeviceColor
- uno::Sequence<rendering::ARGBColor> aCols(1);
- aCols[0] = rendering::ARGBColor( mnAlpha, 1.0, 1.0, 1.0);
- aLocalState.DeviceColor =
- mpCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace()->convertFromARGB(
- aCols);
-
- mpCanvas->getUNOCanvas()->drawBitmapModulated( mxBufferBitmap,
- mpCanvas->getViewState(),
- aLocalState );
- }
-
+ // no further alpha changes necessary -> draw directly
+ mpCanvas->getUNOCanvas()->drawBitmap( mxBufferBitmap,
+ mpCanvas->getViewState(),
+ aLocalState );
return true;
}
diff --git a/desktop/source/splash/splash.cxx b/desktop/source/splash/splash.cxx
index b7724ec1e636..336601a6d80f 100644
--- a/desktop/source/splash/splash.cxx
+++ b/desktop/source/splash/splash.cxx
@@ -99,7 +99,7 @@ private:
long _barheight, _barspace, _textBaseline;
double _fXPos, _fYPos;
double _fWidth, _fHeight;
- const long _xoffset, _yoffset;
+ static constexpr long _xoffset = 12, _yoffset = 18;
public:
SplashScreen();
@@ -172,8 +172,6 @@ SplashScreen::SplashScreen()
, _fYPos(-1.0)
, _fWidth(-1.0)
, _fHeight(-1.0)
- , _xoffset(12)
- , _yoffset(18)
{
loadConfig();
}
diff --git a/include/vcl/opengl/OpenGLContext.hxx b/include/vcl/opengl/OpenGLContext.hxx
index a5493c0d6927..1253a4f02091 100644
--- a/include/vcl/opengl/OpenGLContext.hxx
+++ b/include/vcl/opengl/OpenGLContext.hxx
@@ -168,7 +168,6 @@ protected:
bool mbInitialized;
int mnRefCount;
bool mbRequestLegacyContext;
- bool const mbUseDoubleBufferedRendering;
bool mbVCLOnly;
int mnFramebufferCount;
diff --git a/sc/source/ui/dbgui/tpsubt.cxx b/sc/source/ui/dbgui/tpsubt.cxx
index dc1ed43b0954..8ff412d68191 100644
--- a/sc/source/ui/dbgui/tpsubt.cxx
+++ b/sc/source/ui/dbgui/tpsubt.cxx
@@ -275,7 +275,7 @@ void ScTpSubTotalGroup::FillListBoxes()
i++;
}
// subsequent initialization of the constant:
- const_cast<sal_uInt16&>(nFieldCount) = i;
+ nFieldCount = i;
}
}
diff --git a/sc/source/ui/inc/tpsubt.hxx b/sc/source/ui/inc/tpsubt.hxx
index 8b2bfee98e15..a88d608fd92d 100644
--- a/sc/source/ui/inc/tpsubt.hxx
+++ b/sc/source/ui/inc/tpsubt.hxx
@@ -60,7 +60,7 @@ protected:
const sal_uInt16 nWhichSubTotals;
const ScSubTotalParam& rSubTotalData;
SCCOL nFieldArr[SC_MAXFIELDS];
- const sal_uInt16 nFieldCount;
+ sal_uInt16 nFieldCount;
private:
void Init ();
diff --git a/sd/source/ui/sidebar/PreviewValueSet.cxx b/sd/source/ui/sidebar/PreviewValueSet.cxx
index c145cb25ef1b..429411e5a754 100644
--- a/sd/source/ui/sidebar/PreviewValueSet.cxx
+++ b/sd/source/ui/sidebar/PreviewValueSet.cxx
@@ -22,11 +22,12 @@
namespace sd { namespace sidebar {
+static const int gnBorderWidth(3);
+static const int gnBorderHeight(3);
+
PreviewValueSet::PreviewValueSet (vcl::Window* pParent)
: ValueSet (pParent, WB_TABSTOP),
maPreviewSize(10,10),
- mnBorderWidth(3),
- mnBorderHeight(3),
mnMaxColumnCount(-1)
{
SetStyle (
@@ -88,7 +89,7 @@ sal_uInt16 PreviewValueSet::CalculateColumnCount (int nWidth) const
int nColumnCount = 0;
if (nWidth > 0)
{
- nColumnCount = nWidth / (maPreviewSize.Width() + 2*mnBorderWidth);
+ nColumnCount = nWidth / (maPreviewSize.Width() + 2*gnBorderWidth);
if (nColumnCount < 1)
nColumnCount = 1;
else if (mnMaxColumnCount>0 && nColumnCount>mnMaxColumnCount)
@@ -116,7 +117,7 @@ sal_Int32 PreviewValueSet::GetPreferredHeight (sal_Int32 nWidth)
int nRowCount (CalculateRowCount(CalculateColumnCount(nWidth)));
int nItemHeight (maPreviewSize.Height());
- return nRowCount * (nItemHeight + 2*mnBorderHeight);
+ return nRowCount * (nItemHeight + 2*gnBorderHeight);
}
} } // end of namespace sd::sidebar
diff --git a/sd/source/ui/sidebar/PreviewValueSet.hxx b/sd/source/ui/sidebar/PreviewValueSet.hxx
index 41d5a8fac54e..8cf4c17b9d7f 100644
--- a/sd/source/ui/sidebar/PreviewValueSet.hxx
+++ b/sd/source/ui/sidebar/PreviewValueSet.hxx
@@ -51,8 +51,6 @@ protected:
private:
Link<const MouseEvent&,void> maRightMouseClickHandler;
Size maPreviewSize;
- const int mnBorderWidth;
- const int mnBorderHeight;
const int mnMaxColumnCount;
sal_uInt16 CalculateColumnCount (int nWidth) const;
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index ab4aaa90faeb..1da214488941 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -387,7 +387,6 @@ class SwOrderIter
{
const SwPageFrame *m_pPage;
const SdrObject *m_pCurrent;
- const bool m_bFlysOnly;
public:
SwOrderIter( const SwPageFrame *pPage );
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index da6d31b63d96..ed566d0dd1d9 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2242,8 +2242,7 @@ SwBorderAttrs *SwBorderAttrAccess::Get()
SwOrderIter::SwOrderIter( const SwPageFrame *pPg ) :
m_pPage( pPg ),
- m_pCurrent( nullptr ),
- m_bFlysOnly( true )
+ m_pCurrent( nullptr )
{
}
@@ -2260,7 +2259,7 @@ void SwOrderIter::Top()
for (SwAnchoredObject* i : *pObjs)
{
const SdrObject* pObj = i->GetDrawObj();
- if ( m_bFlysOnly && dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
+ if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
continue;
sal_uInt32 nTmp = pObj->GetOrdNumDirect();
if ( nTmp >= nTopOrd )
@@ -2286,7 +2285,7 @@ const SdrObject *SwOrderIter::Bottom()
for (SwAnchoredObject* i : *pObjs)
{
const SdrObject* pObj = i->GetDrawObj();
- if ( m_bFlysOnly && dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
+ if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
continue;
sal_uInt32 nTmp = pObj->GetOrdNumDirect();
if ( nTmp < nBotOrd )
@@ -2314,7 +2313,7 @@ const SdrObject *SwOrderIter::Next()
for (SwAnchoredObject* i : *pObjs)
{
const SdrObject* pObj = i->GetDrawObj();
- if ( m_bFlysOnly && dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
+ if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
continue;
sal_uInt32 nTmp = pObj->GetOrdNumDirect();
if ( nTmp > nCurOrd && nTmp < nOrd )
@@ -2342,7 +2341,7 @@ void SwOrderIter::Prev()
for (SwAnchoredObject* i : *pObjs)
{
const SdrObject* pObj = i->GetDrawObj();
- if ( m_bFlysOnly && dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
+ if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
continue;
sal_uInt32 nTmp = pObj->GetOrdNumDirect();
if ( nTmp < nCurOrd && nTmp >= nOrd )
diff --git a/uui/source/secmacrowarnings.cxx b/uui/source/secmacrowarnings.cxx
index 3030ab92520a..c8953b5977e6 100644
--- a/uui/source/secmacrowarnings.cxx
+++ b/uui/source/secmacrowarnings.cxx
@@ -69,7 +69,6 @@ MacroWarning::MacroWarning(weld::Window* pParent, bool _bWithSignatures)
, mxEnableBtn(m_xBuilder->weld_button("ok"))
, mxDisableBtn(m_xBuilder->weld_button("cancel"))
, mpInfos ( nullptr )
- , mbSignedMode ( true )
, mbShowSignatures ( _bWithSignatures )
, mnActSecLevel ( 0 )
{
@@ -105,7 +104,7 @@ IMPL_LINK_NOARG(MacroWarning, ViewSignsBtnHdl, weld::Button&, void)
IMPL_LINK_NOARG(MacroWarning, EnableBtnHdl, weld::Button&, void)
{
- if (mbSignedMode && mxAlwaysTrustCB->get_active())
+ if (mxAlwaysTrustCB->get_active())
{ // insert path into trusted path list
uno::Reference< security::XDocumentDigitalSignatures > xD(
security::DocumentDigitalSignatures::createWithVersion(comphelper::getProcessComponentContext(), maODFVersion));
diff --git a/uui/source/secmacrowarnings.hxx b/uui/source/secmacrowarnings.hxx
index fbaf55751f5e..b5e3c9a450b9 100644
--- a/uui/source/secmacrowarnings.hxx
+++ b/uui/source/secmacrowarnings.hxx
@@ -46,7 +46,6 @@ private:
OUString maODFVersion;
const css::uno::Sequence< css::security::DocumentSignatureInformation >* mpInfos;
- const bool mbSignedMode; // mode of dialog (signed / unsigned macros)
const bool mbShowSignatures;
sal_Int32 mnActSecLevel;
diff --git a/vcl/backendtest/VisualBackendTest.cxx b/vcl/backendtest/VisualBackendTest.cxx
index 239f47bd7ead..07aa218cf137 100644
--- a/vcl/backendtest/VisualBackendTest.cxx
+++ b/vcl/backendtest/VisualBackendTest.cxx
@@ -105,7 +105,7 @@ class VisualBackendTestWindow : public WorkWindow
private:
Timer maUpdateTimer;
std::vector<std::chrono::high_resolution_clock::time_point> mTimePoints;
- unsigned char const mnNumberOfTests;
+ static constexpr unsigned char gnNumberOfTests = 6;
unsigned char mnTest;
bool mbAnimate;
ScopedVclPtr<VirtualDevice> mpVDev;
@@ -113,9 +113,8 @@ private:
public:
VisualBackendTestWindow()
: WorkWindow(nullptr, WB_APP | WB_STDWORK)
- , mnNumberOfTests(6)
- , mnTest(10 * mnNumberOfTests)
- , mbAnimate(mnTest % mnNumberOfTests == mnNumberOfTests - 1)
+ , mnTest(10 * gnNumberOfTests)
+ , mbAnimate(mnTest % gnNumberOfTests == gnNumberOfTests - 1)
, mpVDev(VclPtr<VirtualDevice>::Create())
{
maUpdateTimer.SetInvokeHandler(LINK(this, VisualBackendTestWindow, updateHdl));
@@ -145,7 +144,7 @@ public:
if (nCode == KEY_BACKSPACE || nCode == KEY_SPACE)
{
- if (mnTest % mnNumberOfTests == mnNumberOfTests - 1)
+ if (mnTest % gnNumberOfTests == gnNumberOfTests - 1)
{
mbAnimate = true;
maUpdateTimer.Start();
@@ -377,7 +376,7 @@ public:
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) override
{
- if (mnTest % mnNumberOfTests == mnNumberOfTests - 1)
+ if (mnTest % gnNumberOfTests == gnNumberOfTests - 1)
{
rRenderContext.SetBackground(Wallpaper(COL_GREEN));
@@ -449,23 +448,23 @@ public:
tools::Rectangle aRectangle;
size_t index = 0;
- if (mnTest % mnNumberOfTests == 0)
+ if (mnTest % gnNumberOfTests == 0)
{
testRectangles(rRenderContext, nWidth, nHeight);
}
- else if (mnTest % mnNumberOfTests == 1)
+ else if (mnTest % gnNumberOfTests == 1)
{
testFilledRectangles(rRenderContext, nWidth, nHeight);
}
- else if (mnTest % mnNumberOfTests == 2)
+ else if (mnTest % gnNumberOfTests == 2)
{
testLines(rRenderContext, nWidth, nHeight);
}
- else if (mnTest % mnNumberOfTests == 3)
+ else if (mnTest % gnNumberOfTests == 3)
{
testBitmaps(rRenderContext, nWidth, nHeight);
}
- else if (mnTest % mnNumberOfTests == 4)
+ else if (mnTest % gnNumberOfTests == 4)
{
std::vector<tools::Rectangle> aRegions = setupRegions(3, 2, nWidth, nHeight);
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index 38e63cbd9b1e..9d0be13e3a6d 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -88,7 +88,7 @@ private:
typedef std::unordered_map<rtl::Reference<LogicalFontInstance>,std::unique_ptr<FreetypeFont>,IFSD_Hash,IFSD_Equal > FontList;
FontList maFontList;
- sal_uLong const mnMaxSize; // max overall cache size in bytes
+ static constexpr sal_uLong gnMaxSize = 1500000; // max overall cache size in bytes
mutable sal_uLong mnBytesUsed;
mutable long mnLruIndex;
mutable int mnGlyphCount;
diff --git a/vcl/opengl/win/gdiimpl.cxx b/vcl/opengl/win/gdiimpl.cxx
index 0c622bb51d85..58ec8f730c29 100644
--- a/vcl/opengl/win/gdiimpl.cxx
+++ b/vcl/opengl/win/gdiimpl.cxx
@@ -529,9 +529,7 @@ bool WinOpenGLContext::ImplInit()
0, 0, 0 // Layer Masks Ignored
};
- if (mbUseDoubleBufferedRendering)
- PixelFormatFront.dwFlags |= PFD_DOUBLEBUFFER;
-
+ PixelFormatFront.dwFlags |= PFD_DOUBLEBUFFER;
PixelFormatFront.dwFlags |= PFD_DRAW_TO_WINDOW;
// we must check whether can set the MSAA
@@ -539,7 +537,7 @@ bool WinOpenGLContext::ImplInit()
bool bMultiSampleSupport = false;
if (!mbVCLOnly)
- bMultiSampleSupport = InitMultisample(PixelFormatFront, WindowPix, mbUseDoubleBufferedRendering, false);
+ bMultiSampleSupport = InitMultisample(PixelFormatFront, WindowPix, /*bUseDoubleBufferedRendering*/true, false);
else
VCL_GL_INFO("Skipping multisample detection for VCL.");
diff --git a/vcl/opengl/x11/gdiimpl.cxx b/vcl/opengl/x11/gdiimpl.cxx
index 6f230ce81360..98eb604fd1b3 100644
--- a/vcl/opengl/x11/gdiimpl.cxx
+++ b/vcl/opengl/x11/gdiimpl.cxx
@@ -302,7 +302,7 @@ bool X11OpenGLContext::ImplInit()
if (hasCreateContextAttribsARB && !mbRequestLegacyContext)
{
int best_fbc = -1;
- GLXFBConfig* pFBC = getFBConfig(m_aGLWin.dpy, m_aGLWin.win, best_fbc, mbUseDoubleBufferedRendering);
+ GLXFBConfig* pFBC = getFBConfig(m_aGLWin.dpy, m_aGLWin.win, best_fbc, /*bUseDoubleBufferedRendering*/true);
if (pFBC && best_fbc != -1)
{
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 1a3e67d366d7..ef04535ba2c4 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1690,8 +1690,6 @@ void PDFWriterImpl::PDFPage::appendWaveLine( sal_Int32 nWidth, sal_Int32 nY, sal
m_nCurrentStructElement( 0 ),
m_bEmitStructure( true ),
m_nNextFID( 1 ),
- m_nInheritedPageWidth( 595 ), // default A4
- m_nInheritedPageHeight( 842 ), // default A4
m_nCurrentPage( -1 ),
m_nCatalogObject(0),
m_nSignatureObject( -1 ),
@@ -4992,8 +4990,8 @@ bool PDFWriterImpl::emitCatalog()
sal_Int32 nMediaBoxHeight = 0;
if( m_aPages.empty() ) // sanity check, this should not happen
{
- nMediaBoxWidth = m_nInheritedPageWidth;
- nMediaBoxHeight = m_nInheritedPageHeight;
+ nMediaBoxWidth = g_nInheritedPageWidth;
+ nMediaBoxHeight = g_nInheritedPageHeight;
}
else
{
@@ -5109,14 +5107,14 @@ bool PDFWriterImpl::emitCatalog()
aLine.append( "/OpenAction[" );
aLine.append( aInitPageRef.makeStringAndClear() );
aLine.append( " /FitH " );
- aLine.append( m_nInheritedPageHeight );//Open fit width
+ aLine.append( g_nInheritedPageHeight );//Open fit width
aLine.append( "]\n" );
break;
case PDFWriter::FitVisible :
aLine.append( "/OpenAction[" );
aLine.append( aInitPageRef.makeStringAndClear() );
aLine.append( " /FitBH " );
- aLine.append( m_nInheritedPageHeight );//Open fit visible
+ aLine.append( g_nInheritedPageHeight );//Open fit visible
aLine.append( "]\n" );
break;
case PDFWriter::ActionZoom :
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 3656fe50ceca..e18860592ecb 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -188,7 +188,7 @@ public:
// appends a horizontal waveline with vertical offset (helper for drawWaveLine)
void appendWaveLine( sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, OStringBuffer& rBuffer ) const;
- double getHeight() const { return m_nPageHeight ? m_nPageHeight : m_pWriter->m_nInheritedPageHeight; }
+ double getHeight() const { return m_nPageHeight ? m_nPageHeight : PDFWriterImpl::g_nInheritedPageHeight; }
};
friend struct PDFPage;
@@ -693,8 +693,8 @@ private:
sal_Int32 m_nNextFID;
PDFFontCache m_aFontCache;
- sal_Int32 const m_nInheritedPageWidth; // in inch/72
- sal_Int32 const m_nInheritedPageHeight; // in inch/72
+ static constexpr sal_Int32 g_nInheritedPageWidth = 595; // default A4 in inch/72
+ static constexpr sal_Int32 g_nInheritedPageHeight = 842; // default A4 in inch/72
sal_Int32 m_nCurrentPage;
sal_Int32 m_nCatalogObject;
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index 875589e00df1..07f5491a11c9 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -55,7 +55,6 @@ OpenGLContext::OpenGLContext():
mbInitialized(false),
mnRefCount(0),
mbRequestLegacyContext(false),
- mbUseDoubleBufferedRendering(true),
mbVCLOnly(false),
mnFramebufferCount(0),
mpCurrentFramebuffer(nullptr),
diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx
index c802df0e3cc0..3ce24ece848c 100644
--- a/vcl/unx/generic/glyphs/glyphcache.cxx
+++ b/vcl/unx/generic/glyphs/glyphcache.cxx
@@ -33,8 +33,7 @@
static GlyphCache* pInstance = nullptr;
GlyphCache::GlyphCache()
-: mnMaxSize( 1500000 ),
- mnBytesUsed(sizeof(GlyphCache)),
+: mnBytesUsed(sizeof(GlyphCache)),
mnLruIndex(0),
mnGlyphCount(0),
mpCurrentGCFont(nullptr)
@@ -226,7 +225,7 @@ FreetypeFont* GlyphCache::CacheFont(LogicalFontInstance* pFontInstance)
void GlyphCache::UncacheFont( FreetypeFont& rFreetypeFont )
{
- if( (rFreetypeFont.Release() <= 0) && (mnMaxSize <= mnBytesUsed) )
+ if( (rFreetypeFont.Release() <= 0) && (gnMaxSize <= mnBytesUsed) )
{
mpCurrentGCFont = &rFreetypeFont;
GarbageCollect();
@@ -290,7 +289,7 @@ inline void GlyphCache::AddedGlyph( GlyphData& rGlyphData )
++mnGlyphCount;
mnBytesUsed += sizeof( rGlyphData );
UsingGlyph( rGlyphData );
- if( mnBytesUsed > mnMaxSize )
+ if( mnBytesUsed > gnMaxSize )
GarbageCollect();
}
diff --git a/vcl/unx/generic/print/bitmap_gfx.cxx b/vcl/unx/generic/print/bitmap_gfx.cxx
index b34bdfd511d9..04ce1fd3ba96 100644
--- a/vcl/unx/generic/print/bitmap_gfx.cxx
+++ b/vcl/unx/generic/print/bitmap_gfx.cxx
@@ -277,7 +277,7 @@ private:
std::array<LZWCTreeNode, 4096>
mpTable; // LZW compression data
LZWCTreeNode* mpPrefix; // the compression is as same as the TIFF compression
- sal_uInt16 const mnDataSize;
+ static constexpr sal_uInt16 gnDataSize = 8;
sal_uInt16 const mnClearCode;
sal_uInt16 const mnEOICode;
sal_uInt16 mnTableSize;
@@ -298,11 +298,10 @@ public:
LZWEncoder::LZWEncoder(osl::File* pOutputFile) :
Ascii85Encoder (pOutputFile),
mpPrefix(nullptr),
- mnDataSize(8),
- mnClearCode(1 << mnDataSize),
+ mnClearCode(1 << gnDataSize),
mnEOICode(mnClearCode + 1),
mnTableSize(mnEOICode + 1),
- mnCodeSize(mnDataSize + 1),
+ mnCodeSize(gnDataSize + 1),
mnOffset(32), // free bits in dwShift
mdwShift(0)
{
@@ -375,7 +374,7 @@ LZWEncoder::EncodeByte (sal_uInt8 nByte )
for (i = 0; i < mnClearCode; i++)
mpTable[i].mpFirstChild = nullptr;
- mnCodeSize = mnDataSize + 1;
+ mnCodeSize = gnDataSize + 1;
mnTableSize = mnEOICode + 1;
}
else
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
index f3e8e1ab7f39..016c3d6cf49f 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx
@@ -90,9 +90,7 @@ SalGtkFilePicker::SalGtkFilePicker( const uno::Reference< uno::XComponentContext
mbPreviewState( false ),
mHID_Preview( 0 ),
m_pPreview( nullptr ),
- m_pPseudoFilter( nullptr ),
- m_PreviewImageWidth( 256 ),
- m_PreviewImageHeight( 256 )
+ m_pPseudoFilter( nullptr )
{
int i;
@@ -1414,7 +1412,7 @@ sal_Int32 SAL_CALL SalGtkFilePicker::getAvailableWidth()
OSL_ASSERT( m_pDialog != nullptr );
- return m_PreviewImageWidth;
+ return g_PreviewImageWidth;
}
sal_Int32 SAL_CALL SalGtkFilePicker::getAvailableHeight()
@@ -1423,7 +1421,7 @@ sal_Int32 SAL_CALL SalGtkFilePicker::getAvailableHeight()
OSL_ASSERT( m_pDialog != nullptr );
- return m_PreviewImageHeight;
+ return g_PreviewImageHeight;
}
void SAL_CALL SalGtkFilePicker::setImage( sal_Int16 /*aImageFormat*/, const uno::Any& /*aImage*/ )
@@ -1509,8 +1507,8 @@ void SalGtkFilePicker::update_preview_cb( GtkFileChooser *file_chooser, SalGtkFi
{
pixbuf = gdk_pixbuf_new_from_file_at_size(
filename,
- pobjFP->m_PreviewImageWidth,
- pobjFP->m_PreviewImageHeight, nullptr );
+ g_PreviewImageWidth,
+ g_PreviewImageHeight, nullptr );
have_preview = ( pixbuf != nullptr );
diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx
index d5db18d6fcf4..d6265702f314 100644
--- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx
+++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.hxx
@@ -202,8 +202,8 @@ class SalGtkFilePicker : public SalGtkPicker, public SalGtkFilePicker_Base
gulong mHID_Preview;
GtkWidget* m_pPreview;
GtkFileFilter* m_pPseudoFilter;
- sal_Int32 const m_PreviewImageWidth;
- sal_Int32 const m_PreviewImageHeight;
+ static constexpr sal_Int32 g_PreviewImageWidth = 256;
+ static constexpr sal_Int32 g_PreviewImageHeight = 256;
GtkWidget *getWidget( sal_Int16 nControlId, GType *pType = nullptr);
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 2df49c4dbe57..d0dbb8fd4463 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -200,7 +200,7 @@ public:
sal_Int32 nBrightness;
double const fGamma;
- sal_Int32 const nFillColor;
+ static constexpr sal_Int32 nFillColor = 0xffffffff;
drawing::ColorMode eColorMode;
@@ -260,7 +260,6 @@ public:
,nContrast(0)
,nBrightness(0)
,fGamma( -1.0 )
- ,nFillColor( 0xffffffff )
,eColorMode( drawing::ColorMode_STANDARD )
,nCurrentBorderLine(BORDER_TOP)
,bIsGraphic(false)
@@ -388,6 +387,10 @@ public:
}
};
+#if !HAVE_CPP_INLINE_VARIABLES
+constexpr sal_Int32 GraphicImport_Impl::nFillColor;
+#endif
+
GraphicImport::GraphicImport(uno::Reference<uno::XComponentContext> const& xComponentContext,
uno::Reference<lang::XMultiServiceFactory> const& xTextFactory,
DomainMapper& rDMapper,
@@ -1276,7 +1279,7 @@ uno::Reference<text::XTextContent> GraphicImport::createGraphicObject(uno::Refer
uno::makeAny(m_pImpl->fGamma ));
xGraphicObjectProperties->setPropertyValue(getPropertyName( PROP_BACK_COLOR ),
- uno::makeAny( m_pImpl->nFillColor ));
+ uno::makeAny( GraphicImport_Impl::nFillColor ));
m_pImpl->applyZOrder(xGraphicObjectProperties);