summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-04-15 09:39:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-04-15 13:54:53 +0200
commit46ce0d28b4c765076c7871358375c4e85e44534b (patch)
treeb17378d5258a51185001eac455a764897e6dda11
parentsd: use hexadecimal representation for colors (diff)
downloadcore-46ce0d28b4c765076c7871358375c4e85e44534b.tar.gz
core-46ce0d28b4c765076c7871358375c4e85e44534b.zip
loplugin:stringliteralvar look for assignments
to O[U]String from char array literals, we can convert the char literals to O[U]StringLiteral and avoid a runtime allocation Change-Id: I15d8dddb2cd428b90740e39f20daf98e0941aa6d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114125 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--compilerplugins/clang/stringliteralvar.cxx52
-rw-r--r--compilerplugins/clang/test/stringliteralvar.cxx14
-rw-r--r--connectivity/source/drivers/mysql_jdbc/YDriver.cxx2
-rw-r--r--cui/source/customize/macropg.cxx6
-rw-r--r--cui/source/inc/cfg.hxx12
-rw-r--r--dbaccess/source/ui/dlg/tablespage.cxx2
-rw-r--r--desktop/source/app/app.cxx4
-rw-r--r--framework/source/dispatch/closedispatcher.cxx4
-rw-r--r--framework/source/fwe/xml/statusbardocumenthandler.cxx12
-rw-r--r--sc/source/ui/unoobj/dispuno.cxx2
-rw-r--r--scaddins/source/analysis/analysis.cxx2
-rw-r--r--scripting/source/provider/URIHelper.cxx8
-rw-r--r--scripting/source/stringresource/stringresource.cxx2
-rw-r--r--sd/source/filter/html/htmlex.cxx12
-rw-r--r--sd/source/ui/dlg/TemplateScanner.cxx2
-rw-r--r--sd/source/ui/inc/unokywds.hxx14
-rw-r--r--sfx2/source/appl/appuno.cxx120
-rw-r--r--svtools/source/uno/unoevent.cxx6
-rw-r--r--svx/source/dialog/rubydialog.cxx10
-rw-r--r--sw/source/core/access/accpara.cxx2
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx52
-rw-r--r--sw/source/core/unocore/unoidx.cxx4
-rw-r--r--sw/source/core/unocore/unosett.cxx2
-rw-r--r--sw/source/core/unocore/unotext.cxx2
-rw-r--r--sw/source/ui/vba/vbalisthelper.cxx16
-rw-r--r--ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx26
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarhelper.hxx10
-rw-r--r--xmloff/source/text/txtfldi.cxx2
28 files changed, 233 insertions, 169 deletions
diff --git a/compilerplugins/clang/stringliteralvar.cxx b/compilerplugins/clang/stringliteralvar.cxx
index bf06f47f5089..f8dfe916cc5b 100644
--- a/compilerplugins/clang/stringliteralvar.cxx
+++ b/compilerplugins/clang/stringliteralvar.cxx
@@ -7,8 +7,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-// Find constant character array variables that are passed into O[U]String constructors and should
-// thus be turned into O[U]StringLiteral variables.
+// Find constant character array variables that are either
+// (a) passed into O[U]String constructors
+// (b) assigned to O[U]String
+// and should thus be turned into O[U]StringLiteral variables.
//
// Such a variable may have been used in multiple places, not all of which would be compatible with
// changing the variable's type to O[U]StringLiteral. However, this plugin is aggressive and
@@ -155,6 +157,52 @@ public:
return true;
}
+ bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const* expr)
+ {
+ if (ignoreLocation(expr))
+ {
+ return true;
+ }
+ if (expr->getOperator() != OO_Equal)
+ {
+ return true;
+ }
+ loplugin::TypeCheck const tc(expr->getType());
+ if (!(tc.Class("OString").Namespace("rtl").GlobalNamespace()
+ || tc.Class("OUString").Namespace("rtl").GlobalNamespace()))
+ {
+ return true;
+ }
+ if (expr->getNumArgs() != 2)
+ {
+ return true;
+ }
+ auto const e = dyn_cast<DeclRefExpr>(expr->getArg(1)->IgnoreParenImpCasts());
+ if (e == nullptr)
+ {
+ return true;
+ }
+ auto const t = e->getType();
+ if (!(t.isConstQualified() && t->isConstantArrayType()))
+ {
+ return true;
+ }
+ auto const d = e->getDecl();
+ if (!reportedArray_.insert(d).second)
+ {
+ return true;
+ }
+ report(DiagnosticsEngine::Warning,
+ "change type of variable %0 from constant character array (%1) to "
+ "%select{OStringLiteral|OUStringLiteral}2%select{|, and make it static}3",
+ d->getLocation())
+ << d << d->getType() << (tc.Class("OString").Namespace("rtl").GlobalNamespace() ? 0 : 1)
+ << isAutomaticVariable(cast<VarDecl>(d)) << d->getSourceRange();
+ report(DiagnosticsEngine::Note, "first assigned here", compat::getBeginLoc(expr))
+ << expr->getSourceRange();
+ return true;
+ }
+
bool VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr const* expr)
{
if (ignoreLocation(expr))
diff --git a/compilerplugins/clang/test/stringliteralvar.cxx b/compilerplugins/clang/test/stringliteralvar.cxx
index 535f0e36ee72..b34274c45219 100644
--- a/compilerplugins/clang/test/stringliteralvar.cxx
+++ b/compilerplugins/clang/test/stringliteralvar.cxx
@@ -95,4 +95,18 @@ void f10()
f(OUString(literal, 3));
}
+void f11(int nStreamType)
+{
+ // expected-error@+1 {{change type of variable 'sDocumentType' from constant character array ('const char [4]') to OUStringLiteral, and make it static [loplugin:stringliteralvar]}}
+ const char sDocumentType[] = "foo";
+ OUString sStreamType;
+ switch (nStreamType)
+ {
+ case 1:
+ // expected-note@+1 {{first assigned here [loplugin:stringliteralvar]}}
+ sStreamType = sDocumentType;
+ break;
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
index d575ad874995..e88da37c53f7 100644
--- a/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
+++ b/connectivity/source/drivers/mysql_jdbc/YDriver.cxx
@@ -236,7 +236,7 @@ Reference<XConnection> SAL_CALL ODriverDelegator::connect(const OUString& url,
OUString sAdd;
if (RTL_TEXTENCODING_UTF8 == (*aLookup).getEncoding())
{
- static const char s_sCharSetOp[] = "useUnicode=true&";
+ static constexpr OUStringLiteral s_sCharSetOp = u"useUnicode=true&";
if (!sCuttedUrl.matchIgnoreAsciiCase(s_sCharSetOp))
{
sAdd = s_sCharSetOp;
diff --git a/cui/source/customize/macropg.cxx b/cui/source/customize/macropg.cxx
index b6e4694dddac..c6bfd2966b6f 100644
--- a/cui/source/customize/macropg.cxx
+++ b/cui/source/customize/macropg.cxx
@@ -35,7 +35,7 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
-const char aVndSunStarUNO[] = "vnd.sun.star.UNO:";
+constexpr OUStringLiteral aVndSunStarUNO = u"vnd.sun.star.UNO:";
SvxMacroTabPage_Impl::SvxMacroTabPage_Impl( const SfxItemSet& rAttrSet )
: bReadOnly(false)
@@ -277,7 +277,7 @@ namespace
OUString aPureMethod;
if (bUNO)
{
- aPureMethod = rURL.copy(strlen(aVndSunStarUNO));
+ aPureMethod = rURL.copy(aVndSunStarUNO.getLength());
}
else
{
@@ -630,7 +630,7 @@ AssignComponentDialog::AssignComponentDialog(weld::Window* pParent, const OUStri
OUString aMethodName;
if( maURL.startsWith( aVndSunStarUNO ) )
{
- aMethodName = maURL.copy( strlen(aVndSunStarUNO) );
+ aMethodName = maURL.copy( aVndSunStarUNO.getLength() );
}
mxMethodEdit->set_text(aMethodName);
mxMethodEdit->select_region(0, -1);
diff --git a/cui/source/inc/cfg.hxx b/cui/source/inc/cfg.hxx
index ecefed6578d6..c5b7c4848933 100644
--- a/cui/source/inc/cfg.hxx
+++ b/cui/source/inc/cfg.hxx
@@ -42,17 +42,17 @@
#define notebookbarTabScope "notebookbarTabScope"
-const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
+inline constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL";
inline constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER = u"ItemDescriptorContainer";
-const char ITEM_DESCRIPTOR_LABEL[] = "Label";
-const char ITEM_DESCRIPTOR_TYPE[] = "Type";
-const char ITEM_DESCRIPTOR_STYLE[] = "Style";
-const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible";
+inline constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL = u"Label";
+inline constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE = u"Type";
+inline constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE = u"Style";
+inline constexpr OUStringLiteral ITEM_DESCRIPTOR_ISVISIBLE = u"IsVisible";
const char ITEM_DESCRIPTOR_RESOURCEURL[] = "ResourceURL";
inline constexpr OUStringLiteral ITEM_DESCRIPTOR_UINAME = u"UIName";
inline constexpr OUStringLiteral ITEM_MENUBAR_URL = u"private:resource/menubar/menubar";
-constexpr char16_t ITEM_TOOLBAR_URL[] = u"private:resource/toolbar/";
+inline constexpr OUStringLiteral ITEM_TOOLBAR_URL = u"private:resource/toolbar/";
inline constexpr OUStringLiteral CUSTOM_TOOLBAR_STR = u"custom_toolbar_";
diff --git a/dbaccess/source/ui/dlg/tablespage.cxx b/dbaccess/source/ui/dlg/tablespage.cxx
index 180d84eacdd4..8162126a3749 100644
--- a/dbaccess/source/ui/dlg/tablespage.cxx
+++ b/dbaccess/source/ui/dlg/tablespage.cxx
@@ -335,7 +335,7 @@ namespace dbaui
Sequence< OUString > OTableSubscriptionPage::collectDetailedSelection() const
{
Sequence< OUString > aTableFilter;
- static const char sWildcard[] = "%";
+ constexpr OUStringLiteral sWildcard = u"%";
std::unique_ptr<weld::TreeIter> xAllObjectsEntry(m_xTablesList->getAllObjectsEntry());
if (!xAllObjectsEntry)
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 8b4d7b34f4d4..b0c4fac53e10 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -960,8 +960,8 @@ struct RefClearGuard
bool impl_callRecoveryUI(bool bEmergencySave ,
bool bExistsRecoveryData)
{
- static const char COMMAND_EMERGENCYSAVE[] = "vnd.sun.star.autorecovery:/doEmergencySave";
- static const char COMMAND_RECOVERY[] = "vnd.sun.star.autorecovery:/doAutoRecovery";
+ constexpr OUStringLiteral COMMAND_EMERGENCYSAVE = u"vnd.sun.star.autorecovery:/doEmergencySave";
+ constexpr OUStringLiteral COMMAND_RECOVERY = u"vnd.sun.star.autorecovery:/doAutoRecovery";
css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
diff --git a/framework/source/dispatch/closedispatcher.cxx b/framework/source/dispatch/closedispatcher.cxx
index 2dc4795abdc4..d4fa824c11e0 100644
--- a/framework/source/dispatch/closedispatcher.cxx
+++ b/framework/source/dispatch/closedispatcher.cxx
@@ -50,8 +50,8 @@ namespace framework{
#endif
namespace fpf = ::framework::pattern::frame;
-const char URL_CLOSEDOC[] = ".uno:CloseDoc";
-const char URL_CLOSEWIN[] = ".uno:CloseWin";
+constexpr OUStringLiteral URL_CLOSEDOC = u".uno:CloseDoc";
+constexpr OUStringLiteral URL_CLOSEWIN = u".uno:CloseWin";
const char URL_CLOSEFRAME[] = ".uno:CloseFrame";
CloseDispatcher::CloseDispatcher(const css::uno::Reference< css::uno::XComponentContext >& rxContext ,
diff --git a/framework/source/fwe/xml/statusbardocumenthandler.cxx b/framework/source/fwe/xml/statusbardocumenthandler.cxx
index a6f157ba21b9..f75bd1e720c0 100644
--- a/framework/source/fwe/xml/statusbardocumenthandler.cxx
+++ b/framework/source/fwe/xml/statusbardocumenthandler.cxx
@@ -83,12 +83,12 @@ namespace framework
{
// Property names of a menu/menu item ItemDescriptor
-const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
-const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
-const char ITEM_DESCRIPTOR_OFFSET[] = "Offset";
-const char ITEM_DESCRIPTOR_STYLE[] = "Style";
-const char ITEM_DESCRIPTOR_WIDTH[] = "Width";
-const char ITEM_DESCRIPTOR_TYPE[] = "Type";
+constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL";
+constexpr OUStringLiteral ITEM_DESCRIPTOR_HELPURL = u"HelpURL";
+constexpr OUStringLiteral ITEM_DESCRIPTOR_OFFSET = u"Offset";
+constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE = u"Style";
+constexpr OUStringLiteral ITEM_DESCRIPTOR_WIDTH = u"Width";
+constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE = u"Type";
static void ExtractStatusbarItemParameters(
const Sequence< PropertyValue >& rProp,
diff --git a/sc/source/ui/unoobj/dispuno.cxx b/sc/source/ui/unoobj/dispuno.cxx
index 533bcd8024ba..0a5d29c2a467 100644
--- a/sc/source/ui/unoobj/dispuno.cxx
+++ b/sc/source/ui/unoobj/dispuno.cxx
@@ -34,7 +34,7 @@
using namespace com::sun::star;
const char cURLInsertColumns[] = ".uno:DataSourceBrowser/InsertColumns"; //data into text
-const char cURLDocDataSource[] = ".uno:DataSourceBrowser/DocumentDataSource";
+constexpr OUStringLiteral cURLDocDataSource = u".uno:DataSourceBrowser/DocumentDataSource";
static uno::Reference<view::XSelectionSupplier> lcl_GetSelectionSupplier( const SfxViewShell* pViewShell )
{
diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx
index c6f83dab0305..b89fb2137d44 100644
--- a/scaddins/source/analysis/analysis.cxx
+++ b/scaddins/source/analysis/analysis.cxx
@@ -232,7 +232,7 @@ OUString SAL_CALL AnalysisAddIn::getArgumentDescription( const OUString& aName,
return aRet;
}
-const char pDefCatName[] = "Add-In";
+constexpr OUStringLiteral pDefCatName = u"Add-In";
OUString SAL_CALL AnalysisAddIn::getProgrammaticCategoryName( const OUString& aName )
{
diff --git a/scripting/source/provider/URIHelper.cxx b/scripting/source/provider/URIHelper.cxx
index 09fedf5762fd..94d0e1fd041c 100644
--- a/scripting/source/provider/URIHelper.cxx
+++ b/scripting/source/provider/URIHelper.cxx
@@ -35,12 +35,12 @@ namespace ucb = ::com::sun::star::ucb;
namespace lang = ::com::sun::star::lang;
namespace uri = ::com::sun::star::uri;
-const char SHARE[] = "share";
+constexpr OUStringLiteral SHARE = u"share";
-const char SHARE_UNO_PACKAGES_URI[] =
- "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE";
+constexpr OUStringLiteral SHARE_UNO_PACKAGES_URI =
+ u"vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE";
-const char USER[] = "user";
+constexpr OUStringLiteral USER = u"user";
constexpr OUStringLiteral USER_URI =
u"vnd.sun.star.expand:${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE( "bootstrap") "::UserInstallation}";
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index bcbb02bb8bbd..f2b9dcd37757 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -684,7 +684,7 @@ Sequence< OUString > StringResourcePersistenceImpl::getSupportedServiceNames( )
// XInitialization base functionality for derived classes
-const char aNameBaseDefaultStr[] = "strings";
+constexpr OUStringLiteral aNameBaseDefaultStr = u"strings";
void StringResourcePersistenceImpl::implInitializeCommonParameters
( const Sequence< Any >& aArguments )
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index 774edd93b396..bd3d772ca80b 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -2242,8 +2242,8 @@ constexpr OUStringLiteral JS_NavigateAbs =
" }\r\n"
"}\r\n\r\n";
-const char JS_NavigateRel[] =
- "function NavigateRel( nDelta )\r\n"
+constexpr OUStringLiteral JS_NavigateRel =
+ u"function NavigateRel( nDelta )\r\n"
"{\r\n"
" var nPage = parseInt(nCurrentPage) + parseInt(nDelta);\r\n"
" if( (nPage >= 0) && (nPage < nPageCount) )\r\n"
@@ -2252,15 +2252,15 @@ const char JS_NavigateRel[] =
" }\r\n"
"}\r\n\r\n";
-const char JS_ExpandOutline[] =
- "function ExpandOutline()\r\n"
+constexpr OUStringLiteral JS_ExpandOutline =
+ u"function ExpandOutline()\r\n"
"{\r\n"
" frames[\"navbar2\"].location.href = \"navbar4.$EXT\";\r\n"
" frames[\"outline\"].location.href = \"outline1.$EXT\";\r\n"
"}\r\n\r\n";
-const char JS_CollapseOutline[] =
- "function CollapseOutline()\r\n"
+constexpr OUStringLiteral JS_CollapseOutline =
+ u"function CollapseOutline()\r\n"
"{\r\n"
" frames[\"navbar2\"].location.href = \"navbar3.$EXT\";\r\n"
" frames[\"outline\"].location.href = \"outline0.$EXT\";\r\n"
diff --git a/sd/source/ui/dlg/TemplateScanner.cxx b/sd/source/ui/dlg/TemplateScanner.cxx
index f125afacc280..4afc801df5f2 100644
--- a/sd/source/ui/dlg/TemplateScanner.cxx
+++ b/sd/source/ui/dlg/TemplateScanner.cxx
@@ -36,7 +36,7 @@ using namespace ::com::sun::star::uno;
namespace {
-const char TITLE[] = "Title";
+constexpr OUStringLiteral TITLE = u"Title";
class FolderDescriptor
{
diff --git a/sd/source/ui/inc/unokywds.hxx b/sd/source/ui/inc/unokywds.hxx
index eefd2167ab78..41384cf08371 100644
--- a/sd/source/ui/inc/unokywds.hxx
+++ b/sd/source/ui/inc/unokywds.hxx
@@ -36,10 +36,12 @@ inline constexpr OUStringLiteral sUNO_Service_FillProperties
= u"com.sun.star.drawing.FillProperties";
inline constexpr OUStringLiteral sUNO_Service_PageBackground
= u"com.sun.star.drawing.PageBackground";
-inline const char sUNO_Service_ImageMapRectangleObject[]
- = "com.sun.star.image.ImageMapRectangleObject";
-inline const char sUNO_Service_ImageMapCircleObject[] = "com.sun.star.image.ImageMapCircleObject";
-inline const char sUNO_Service_ImageMapPolygonObject[] = "com.sun.star.image.ImageMapPolygonObject";
+inline constexpr OUStringLiteral sUNO_Service_ImageMapRectangleObject
+ = u"com.sun.star.image.ImageMapRectangleObject";
+inline constexpr OUStringLiteral sUNO_Service_ImageMapCircleObject
+ = u"com.sun.star.image.ImageMapCircleObject";
+inline constexpr OUStringLiteral sUNO_Service_ImageMapPolygonObject
+ = u"com.sun.star.image.ImageMapPolygonObject";
// properties
inline const char16_t sUNO_Prop_ForbiddenCharacters[] = u"ForbiddenCharacters";
@@ -58,7 +60,7 @@ inline const char16_t sUNO_Prop_HasValidSignatures[] = u"HasValidSignatures";
inline const char16_t sUNO_Prop_InteropGrabBag[] = u"InteropGrabBag";
// view settings
-inline const char sUNO_View_ViewId[] = "ViewId";
+inline constexpr OUStringLiteral sUNO_View_ViewId = u"ViewId";
inline constexpr OUStringLiteral sUNO_View_SnapLinesDrawing = u"SnapLinesDrawing";
inline constexpr OUStringLiteral sUNO_View_SnapLinesNotes = u"SnapLinesNotes";
inline constexpr OUStringLiteral sUNO_View_SnapLinesHandout = u"SnapLinesHandout";
@@ -109,6 +111,6 @@ inline constexpr OUStringLiteral sUNO_View_VisibleAreaLeft = u"VisibleAreaLeft";
inline constexpr OUStringLiteral sUNO_View_VisibleAreaWidth = u"VisibleAreaWidth";
inline constexpr OUStringLiteral sUNO_View_VisibleAreaHeight = u"VisibleAreaHeight";
-inline const char sUNO_View_ZoomOnPage[] = "ZoomOnPage";
+inline constexpr OUStringLiteral sUNO_View_ZoomOnPage = u"ZoomOnPage";
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx
index 413dd7d41736..c02f164de836 100644
--- a/sfx2/source/appl/appuno.cxx
+++ b/sfx2/source/appl/appuno.cxx
@@ -95,66 +95,66 @@ SfxFormalArgument const aFormalArgs[] = {
sal_uInt16 const nMediaArgsCount = SAL_N_ELEMENTS(aFormalArgs);
-char const sTemplateRegionName[] = "TemplateRegionName";
-char const sTemplateName[] = "TemplateName";
-char const sAsTemplate[] = "AsTemplate";
-char const sOpenNewView[] = "OpenNewView";
-char const sViewId[] = "ViewId";
-char const sPluginMode[] = "PluginMode";
-char const sReadOnly[] = "ReadOnly";
-char const sDdeReconnect[] = "DDEReconnect";
-char const sStartPresentation[] = "StartPresentation";
-char const sFrameName[] = "FrameName";
-char const sMediaType[] = "MediaType";
-char const sPostData[] = "PostData";
-char const sCharacterSet[] = "CharacterSet";
-char const sInputStream[] = "InputStream";
-char const sStream[] = "Stream";
-char const sOutputStream[] = "OutputStream";
-char const sHidden[] = "Hidden";
-char const sPreview[] = "Preview";
-char const sViewOnly[] = "ViewOnly";
-char const sDontEdit[] = "DontEdit";
-char const sSilent[] = "Silent";
-char const sJumpMark[] = "JumpMark";
-char const sSalvagedFile[] = "SalvagedFile";
-char const sStatusInd[] = "StatusIndicator";
-char const sModel[] = "Model";
-char const sFrame[] = "Frame";
-char const sViewData[] = "ViewData";
-char const sFilterData[] = "FilterData";
-char const sSelectionOnly[] = "SelectionOnly";
-char const sMacroExecMode[] = "MacroExecutionMode";
-char const sUpdateDocMode[] = "UpdateDocMode";
-char const sMinimized[] = "Minimized";
-char const sInteractionHdl[] = "InteractionHandler";
-char const sUCBContent[] = "UCBContent";
-char const sRepairPackage[] = "RepairPackage";
-char const sDocumentTitle[] = "DocumentTitle";
-char const sComponentData[] = "ComponentData";
-char const sComponentContext[] = "ComponentContext";
-char const sDocumentBaseURL[] = "DocumentBaseURL";
-char const sHierarchicalDocumentName[] = "HierarchicalDocumentName";
-char const sCopyStreamIfPossible[] = "CopyStreamIfPossible";
-char const sNoAutoSave[] = "NoAutoSave";
-char const sFolderName[] = "FolderName";
-char const sUseSystemDialog[] = "UseSystemDialog";
-char const sStandardDir[] = "StandardDir";
-char const sDenyList[] = "DenyList";
-char const sModifyPasswordInfo[] = "ModifyPasswordInfo";
-char const sSuggestedSaveAsDir[] = "SuggestedSaveAsDir";
-char const sSuggestedSaveAsName[] = "SuggestedSaveAsName";
-char const sEncryptionData[] = "EncryptionData";
-char const sFailOnWarning[] = "FailOnWarning";
-char const sDocumentService[] = "DocumentService";
-char const sFilterProvider[] = "FilterProvider";
-char const sImageFilter[] = "ImageFilter";
-char const sLockContentExtraction[] = "LockContentExtraction";
-char const sLockExport[] = "LockExport";
-char const sLockPrint[] = "LockPrint";
-char const sLockSave[] = "LockSave";
-char const sLockEditDoc[] = "LockEditDoc";
-char const sReplaceable[] = "Replaceable";
+constexpr OUStringLiteral sTemplateRegionName = u"TemplateRegionName";
+constexpr OUStringLiteral sTemplateName = u"TemplateName";
+constexpr OUStringLiteral sAsTemplate = u"AsTemplate";
+constexpr OUStringLiteral sOpenNewView = u"OpenNewView";
+constexpr OUStringLiteral sViewId = u"ViewId";
+constexpr OUStringLiteral sPluginMode = u"PluginMode";
+constexpr OUStringLiteral sReadOnly = u"ReadOnly";
+constexpr OUStringLiteral sDdeReconnect = u"DDEReconnect";
+constexpr OUStringLiteral sStartPresentation = u"StartPresentation";
+constexpr OUStringLiteral sFrameName = u"FrameName";
+constexpr OUStringLiteral sMediaType = u"MediaType";
+constexpr OUStringLiteral sPostData = u"PostData";
+constexpr OUStringLiteral sCharacterSet = u"CharacterSet";
+constexpr OUStringLiteral sInputStream = u"InputStream";
+constexpr OUStringLiteral sStream = u"Stream";
+constexpr OUStringLiteral sOutputStream = u"OutputStream";
+constexpr OUStringLiteral sHidden = u"Hidden";
+constexpr OUStringLiteral sPreview = u"Preview";
+constexpr OUStringLiteral sViewOnly = u"ViewOnly";
+constexpr OUStringLiteral sDontEdit = u"DontEdit";
+constexpr OUStringLiteral sSilent = u"Silent";
+constexpr OUStringLiteral sJumpMark = u"JumpMark";
+constexpr OUStringLiteral sSalvagedFile = u"SalvagedFile";
+constexpr OUStringLiteral sStatusInd = u"StatusIndicator";
+constexpr OUStringLiteral sModel = u"Model";
+constexpr OUStringLiteral sFrame = u"Frame";
+constexpr OUStringLiteral sViewData = u"ViewData";
+constexpr OUStringLiteral sFilterData = u"FilterData";
+constexpr OUStringLiteral sSelectionOnly = u"SelectionOnly";
+constexpr OUStringLiteral sMacroExecMode = u"MacroExecutionMode";
+constexpr OUStringLiteral sUpdateDocMode = u"UpdateDocMode";
+constexpr OUStringLiteral sMinimized = u"Minimized";
+constexpr OUStringLiteral sInteractionHdl = u"InteractionHandler";
+constexpr OUStringLiteral sUCBContent = u"UCBContent";
+constexpr OUStringLiteral sRepairPackage = u"RepairPackage";
+constexpr OUStringLiteral sDocumentTitle = u"DocumentTitle";
+constexpr OUStringLiteral sComponentData = u"ComponentData";
+constexpr OUStringLiteral sComponentContext = u"ComponentContext";
+constexpr OUStringLiteral sDocumentBaseURL = u"DocumentBaseURL";
+constexpr OUStringLiteral sHierarchicalDocumentName = u"HierarchicalDocumentName";
+constexpr OUStringLiteral sCopyStreamIfPossible = u"CopyStreamIfPossible";
+constexpr OUStringLiteral sNoAutoSave = u"NoAutoSave";
+constexpr OUStringLiteral sFolderName = u"FolderName";
+constexpr OUStringLiteral sUseSystemDialog = u"UseSystemDialog";
+constexpr OUStringLiteral sStandardDir = u"StandardDir";
+constexpr OUStringLiteral sDenyList = u"DenyList";
+constexpr OUStringLiteral sModifyPasswordInfo = u"ModifyPasswordInfo";
+constexpr OUStringLiteral sSuggestedSaveAsDir = u"SuggestedSaveAsDir";
+constexpr OUStringLiteral sSuggestedSaveAsName = u"SuggestedSaveAsName";
+constexpr OUStringLiteral sEncryptionData = u"EncryptionData";
+constexpr OUStringLiteral sFailOnWarning = u"FailOnWarning";
+constexpr OUStringLiteral sDocumentService = u"DocumentService";
+constexpr OUStringLiteral sFilterProvider = u"FilterProvider";
+constexpr OUStringLiteral sImageFilter = u"ImageFilter";
+constexpr OUStringLiteral sLockContentExtraction = u"LockContentExtraction";
+constexpr OUStringLiteral sLockExport = u"LockExport";
+constexpr OUStringLiteral sLockPrint = u"LockPrint";
+constexpr OUStringLiteral sLockSave = u"LockSave";
+constexpr OUStringLiteral sLockEditDoc = u"LockEditDoc";
+constexpr OUStringLiteral sReplaceable = u"Replaceable";
static bool isMediaDescriptor( sal_uInt16 nSlotId )
{
diff --git a/svtools/source/uno/unoevent.cxx b/svtools/source/uno/unoevent.cxx
index 3ec1408ebfe5..873ef4132300 100644
--- a/svtools/source/uno/unoevent.cxx
+++ b/svtools/source/uno/unoevent.cxx
@@ -34,9 +34,9 @@ using css::beans::PropertyValue;
constexpr OUStringLiteral sAPI_ServiceName = u"com.sun.star.container.XNameReplace";
-const char sEventType[] = "EventType";
-const char sMacroName[] = "MacroName";
-const char sLibrary[] = "Library";
+constexpr OUStringLiteral sEventType = u"EventType";
+constexpr OUStringLiteral sMacroName = u"MacroName";
+constexpr OUStringLiteral sLibrary = u"Library";
constexpr OUStringLiteral sStarBasic = u"StarBasic";
constexpr OUStringLiteral sScript = u"Script";
constexpr OUStringLiteral sNone = u"None";
diff --git a/svx/source/dialog/rubydialog.cxx b/svx/source/dialog/rubydialog.cxx
index 4302d4f6b41d..439b4fbab178 100644
--- a/svx/source/dialog/rubydialog.cxx
+++ b/svx/source/dialog/rubydialog.cxx
@@ -57,11 +57,11 @@ SFX_IMPL_CHILDWINDOW(SvxRubyChildWindow, SID_RUBY_DIALOG);
namespace
{
-const char cRubyBaseText[] = "RubyBaseText";
-const char cRubyText[] = "RubyText";
-const char cRubyAdjust[] = "RubyAdjust";
-const char cRubyPosition[] = "RubyPosition";
-const char cRubyCharStyleName[] = "RubyCharStyleName";
+constexpr OUStringLiteral cRubyBaseText = u"RubyBaseText";
+constexpr OUStringLiteral cRubyText = u"RubyText";
+constexpr OUStringLiteral cRubyAdjust = u"RubyAdjust";
+constexpr OUStringLiteral cRubyPosition = u"RubyPosition";
+constexpr OUStringLiteral cRubyCharStyleName = u"RubyCharStyleName";
} // end anonymous namespace
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index e4008dc10a41..3939e274021e 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -1599,7 +1599,7 @@ uno::Sequence< PropertyValue > SwAccessibleParagraph::getDefaultAttributes(
_getDefaultAttributesImpl( aRequestedAttributes, aDefAttrSeq );
// #i92233#
- static const char sMMToPixelRatio[] = "MMToPixelRatio";
+ constexpr OUStringLiteral sMMToPixelRatio = u"MMToPixelRatio";
bool bProvideMMToPixelRatio( !aRequestedAttributes.hasElements() ||
(comphelper::findValue(aRequestedAttributes, sMMToPixelRatio) != -1) );
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 51785be1a1c4..088f21c00b10 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -136,36 +136,36 @@ const char aQuotation[] = "Quotation";
const char aSourceText[] = "Source Text";
// PDF Tag Names:
-const char aDocumentString[] = "Document";
-const char aDivString[] = "Div";
-const char aSectString[] = "Sect";
-const char aHString[] = "H";
-const char aH1String[] = "H1";
-const char aH2String[] = "H2";
-const char aH3String[] = "H3";
-const char aH4String[] = "H4";
-const char aH5String[] = "H5";
-const char aH6String[] = "H6";
+constexpr OUStringLiteral aDocumentString = u"Document";
+constexpr OUStringLiteral aDivString = u"Div";
+constexpr OUStringLiteral aSectString = u"Sect";
+constexpr OUStringLiteral aHString = u"H";
+constexpr OUStringLiteral aH1String = u"H1";
+constexpr OUStringLiteral aH2String = u"H2";
+constexpr OUStringLiteral aH3String = u"H3";
+constexpr OUStringLiteral aH4String = u"H4";
+constexpr OUStringLiteral aH5String = u"H5";
+constexpr OUStringLiteral aH6String = u"H6";
constexpr OUStringLiteral aListString = u"L";
constexpr OUStringLiteral aListItemString = u"LI";
constexpr OUStringLiteral aListBodyString = u"LBody";
-const char aBlockQuoteString[] = "BlockQuote";
-const char aCaptionString[] = "Caption";
-const char aIndexString[] = "Index";
-const char aTOCString[] = "TOC";
+constexpr OUStringLiteral aBlockQuoteString = u"BlockQuote";
+constexpr OUStringLiteral aCaptionString = u"Caption";
+constexpr OUStringLiteral aIndexString = u"Index";
+constexpr OUStringLiteral aTOCString = u"TOC";
constexpr OUStringLiteral aTOCIString = u"TOCI";
-const char aTableString[] = "Table";
-const char aTRString[] = "TR";
-const char aTDString[] = "TD";
-const char aTHString[] = "TH";
-const char aBibEntryString[] = "BibEntry";
-const char aQuoteString[] = "Quote";
-const char aSpanString[] = "Span";
-const char aCodeString[] = "Code";
-const char aFigureString[] = "Figure";
-const char aFormulaString[] = "Formula";
-const char aLinkString[] = "Link";
-const char aNoteString[] = "Note";
+constexpr OUStringLiteral aTableString = u"Table";
+constexpr OUStringLiteral aTRString = u"TR";
+constexpr OUStringLiteral aTDString = u"TD";
+constexpr OUStringLiteral aTHString = u"TH";
+constexpr OUStringLiteral aBibEntryString = u"BibEntry";
+constexpr OUStringLiteral aQuoteString = u"Quote";
+constexpr OUStringLiteral aSpanString = u"Span";
+constexpr OUStringLiteral aCodeString = u"Code";
+constexpr OUStringLiteral aFigureString = u"Figure";
+constexpr OUStringLiteral aFormulaString = u"Formula";
+constexpr OUStringLiteral aLinkString = u"Link";
+constexpr OUStringLiteral aNoteString = u"Note";
// returns true if first paragraph in cell frame has 'table heading' style
bool lcl_IsHeadlineCell( const SwCellFrame& rCellFrame )
diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx
index c916dca531de..697f57358d5c 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -119,7 +119,7 @@ lcl_ReAssignTOXType(SwDoc& rDoc, SwTOXBase& rTOXBase, const OUString& rNewName)
rTOXBase.RegisterToTOXType( *const_cast<SwTOXType*>(pNewType) );
}
-const char cUserDefined[] = "User-Defined";
+constexpr OUStringLiteral cUserDefined = u"User-Defined";
const char cUserSuffix[] = " (user)";
#define USER_LEN 12
#define USER_AND_SUFFIXLEN 19
@@ -152,7 +152,7 @@ lcl_ConvertTOUNameToUserName(OUString& rTmp)
USER_AND_SUFFIXLEN == rTmp.getLength())
{
//make sure that in non-English versions the " (user)" suffix is removed
- if (rTmp.matchAsciiL(cUserDefined, sizeof(cUserDefined)) &&
+ if (rTmp.match(cUserDefined) &&
rTmp.matchAsciiL(cUserSuffix, sizeof(cUserSuffix), USER_LEN))
{
rTmp = cUserDefined;
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 61d081918736..a79e4d57e62f 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1003,7 +1003,7 @@ void SwXLineNumberingProperties::removeVetoableChangeListener(const OUString& /*
OSL_FAIL("not implemented");
}
-const char16_t aInvalidStyle[] = u"__XXX___invalid";
+constexpr OUStringLiteral aInvalidStyle = u"__XXX___invalid";
class SwXNumberingRules::Impl
: public SvtListener
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 1857706ca06e..6542d96ca277 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -73,7 +73,7 @@
using namespace ::com::sun::star;
-const char cInvalidObject[] = "this object is invalid";
+constexpr OUStringLiteral cInvalidObject = u"this object is invalid";
class SwXText::Impl
{
diff --git a/sw/source/ui/vba/vbalisthelper.cxx b/sw/source/ui/vba/vbalisthelper.cxx
index a6597a539145..fa7d69a23d20 100644
--- a/sw/source/ui/vba/vbalisthelper.cxx
+++ b/sw/source/ui/vba/vbalisthelper.cxx
@@ -38,14 +38,14 @@ constexpr OUStringLiteral UNO_NAME_CHAR_STYLE_NAME = u"CharStyleName";
constexpr OUStringLiteral UNO_NAME_NUMBERING_TYPE = u"NumberingType";
constexpr OUStringLiteral UNO_NAME_BULLET_CHAR = u"BulletChar";
-const sal_Unicode CHAR_CLOSED_DOT[] = u"\u2022";
-const char CHAR_EMPTY_DOT[] = "o";
-const sal_Unicode CHAR_SQUARE[] = u"\u2540";
-const sal_Unicode CHAR_STAR_SYMBOL[] = u"\u272A";
-const sal_Unicode CHAR_FOUR_DIAMONDS[] = u"\u2756";
-const sal_Unicode CHAR_DIAMOND[] = u"\u2726";
-const sal_Unicode CHAR_ARROW[] = u"\u27A2";
-const sal_Unicode CHAR_CHECK_MARK[] = u"\u2713";
+constexpr OUStringLiteral CHAR_CLOSED_DOT = u"\u2022";
+constexpr OUStringLiteral CHAR_EMPTY_DOT = u"o";
+constexpr OUStringLiteral CHAR_SQUARE = u"\u2540";
+constexpr OUStringLiteral CHAR_STAR_SYMBOL = u"\u272A";
+constexpr OUStringLiteral CHAR_FOUR_DIAMONDS = u"\u2756";
+constexpr OUStringLiteral CHAR_DIAMOND = u"\u2726";
+constexpr OUStringLiteral CHAR_ARROW = u"\u27A2";
+constexpr OUStringLiteral CHAR_CHECK_MARK = u"\u2713";
SwVbaListHelper::SwVbaListHelper( const css::uno::Reference< css::text::XTextDocument >& xTextDoc, sal_Int32 nGalleryType, sal_Int32 nTemplateType ) : mxTextDocument( xTextDoc ), mnGalleryType( nGalleryType ), mnTemplateType( nTemplateType )
{
diff --git a/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx b/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx
index 497c700ec04a..967d1f36debe 100644
--- a/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx
+++ b/ucb/source/ucp/webdav-neon/UCBDeadPropertyValue.cxx
@@ -49,19 +49,19 @@ struct UCBDeadPropertyValueParseContext
}
-const char aTypeString[] = "string";
-const char aTypeLong[] = "long";
-const char aTypeShort[] = "short";
-const char aTypeBoolean[] = "boolean";
-const char aTypeChar[] = "char";
-const char aTypeByte[] = "byte";
-const char aTypeHyper[] = "hyper";
-const char aTypeFloat[] = "float";
-const char aTypeDouble[] = "double";
-
-const char aXMLPre[] = "<ucbprop><type>";
-const char aXMLMid[] = "</type><value>";
-const char aXMLEnd[] = "</value></ucbprop>";
+constexpr OUStringLiteral aTypeString = u"string";
+constexpr OUStringLiteral aTypeLong = u"long";
+constexpr OUStringLiteral aTypeShort = u"short";
+constexpr OUStringLiteral aTypeBoolean = u"boolean";
+constexpr OUStringLiteral aTypeChar = u"char";
+constexpr OUStringLiteral aTypeByte = u"byte";
+constexpr OUStringLiteral aTypeHyper = u"hyper";
+constexpr OUStringLiteral aTypeFloat = u"float";
+constexpr OUStringLiteral aTypeDouble = u"double";
+
+constexpr OUStringLiteral aXMLPre = u"<ucbprop><type>";
+constexpr OUStringLiteral aXMLMid = u"</type><value>";
+constexpr OUStringLiteral aXMLEnd = u"</value></ucbprop>";
#define STATE_TOP (1)
diff --git a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
index cdd44c6ca09c..8eda1dbafc3e 100644
--- a/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
+++ b/vbahelper/source/vbahelper/vbacommandbarhelper.hxx
@@ -27,17 +27,17 @@
#include <com/sun/star/frame/XLayoutManager.hpp>
#include <memory>
-const char ITEM_DESCRIPTOR_COMMANDURL[] = "CommandURL";
-const char ITEM_DESCRIPTOR_HELPURL[] = "HelpURL";
+inline constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL";
+inline constexpr OUStringLiteral ITEM_DESCRIPTOR_HELPURL = u"HelpURL";
inline constexpr OUStringLiteral ITEM_DESCRIPTOR_CONTAINER = u"ItemDescriptorContainer";
inline constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL = u"Label";
-const char ITEM_DESCRIPTOR_TYPE[] = "Type";
-const char ITEM_DESCRIPTOR_STYLE[] = "Style";
+inline constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE = u"Type";
+inline constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE = u"Style";
inline constexpr OUStringLiteral ITEM_DESCRIPTOR_ISVISIBLE = u"IsVisible";
inline constexpr OUStringLiteral ITEM_DESCRIPTOR_UINAME = u"UIName";
inline constexpr OUStringLiteral ITEM_DESCRIPTOR_ENABLED = u"Enabled";
-const char ITEM_MENUBAR_URL[] = "private:resource/menubar/menubar";
+inline constexpr OUStringLiteral ITEM_MENUBAR_URL = u"private:resource/menubar/menubar";
constexpr char16_t ITEM_TOOLBAR_URL[] = u"private:resource/toolbar/";
const char CUSTOM_TOOLBAR_STR[] = "custom_toolbar_";
diff --git a/xmloff/source/text/txtfldi.cxx b/xmloff/source/text/txtfldi.cxx
index f2a56cba30de..3e8e660dc030 100644
--- a/xmloff/source/text/txtfldi.cxx
+++ b/xmloff/source/text/txtfldi.cxx
@@ -88,7 +88,7 @@ using namespace ::xmloff::token;
// service prefix and service names
constexpr OUStringLiteral sAPI_textfield_prefix = u"com.sun.star.text.TextField.";
constexpr char16_t sAPI_fieldmaster_prefix[] = u"com.sun.star.text.FieldMaster.";
-const char sAPI_presentation_prefix[] = "com.sun.star.presentation.TextField.";
+constexpr OUStringLiteral sAPI_presentation_prefix = u"com.sun.star.presentation.TextField.";
constexpr OUStringLiteral sAPI_date_time = u"DateTime";
constexpr OUStringLiteral sAPI_page_number = u"PageNumber";