vcl: prefer passing OUString and OString by reference

Change-Id: I6c2c6f597ca62c004ad7dc606cef3a3b10e810b6
This commit is contained in:
Noel Grandin 2014-03-13 08:38:29 +02:00
parent 39c7532933
commit 78a2020846
17 changed files with 50 additions and 49 deletions

View File

@ -28,7 +28,7 @@ class VCL_DLLPUBLIC GraphicNativeTransform
bool rotateBitmapOnly (sal_uInt16 aRotation);
bool rotateJPEG (sal_uInt16 aRotation);
bool rotateGeneric (sal_uInt16 aRotation, OUString aType);
bool rotateGeneric (sal_uInt16 aRotation, const OUString& aType);
public:
GraphicNativeTransform(Graphic& rGraphic);

View File

@ -145,15 +145,15 @@ private:
typedef std::vector<OString> row;
std::vector<row> m_aEntries;
};
const ListStore* get_model_by_name(OString sID) const;
const ListStore* get_model_by_name(const OString& sID) const;
static void mungeModel(ListBox &rTarget, const ListStore &rStore, sal_uInt16 nActiveId);
typedef stringmap TextBuffer;
const TextBuffer* get_buffer_by_name(OString sID) const;
const TextBuffer* get_buffer_by_name(const OString& sID) const;
static void mungeTextBuffer(VclMultiLineEdit &rTarget, const TextBuffer &rTextBuffer);
typedef stringmap Adjustment;
const Adjustment *get_adjustment_by_name(OString sID) const;
const Adjustment *get_adjustment_by_name(const OString& sID) const;
static void mungeAdjustment(NumericFormatter &rTarget, const Adjustment &rAdjustment);
static void mungeAdjustment(DateField &rTarget, const Adjustment &rAdjustment);
static void mungeAdjustment(TimeField &rTarget, const Adjustment &rAdjustment);
@ -236,8 +236,8 @@ private:
bool m_bToplevelParentFound;
ParserState *m_pParserState;
::Window *get_by_name(OString sID);
void delete_by_name(OString sID);
::Window *get_by_name(const OString& sID);
void delete_by_name(const OString& sID);
class sortIntoBestTabTraversalOrder
: public std::binary_function<const ::Window*, const ::Window*, bool>
@ -255,13 +255,13 @@ private:
css::uno::Reference<css::frame::XFrame> m_xFrame;
public:
VclBuilder(::Window *pParent, OUString sUIRootDir, OUString sUIFile,
OString sID = OString(),
VclBuilder(::Window *pParent, const OUString& sUIRootDir, const OUString& sUIFile,
const OString& sID = OString(),
const com::sun::star::uno::Reference<com::sun::star::frame::XFrame> &rFrame = com::sun::star::uno::Reference<com::sun::star::frame::XFrame>());
~VclBuilder();
::Window *get_widget_root();
//sID must exist and be of type T
template <typename T> T* get(T*& ret, OString sID)
template <typename T> T* get(T*& ret, const OString& sID)
{
::Window *w = get_by_name(sID);
SAL_WARN_IF(!w, "vcl.layout", "widget \"" << sID.getStr() << "\" not found in .ui");
@ -271,7 +271,7 @@ public:
ret = static_cast<T*>(w);
return ret;
}
PopupMenu* get_menu(PopupMenu*& ret, OString sID)
PopupMenu* get_menu(PopupMenu*& ret, const OString& sID)
{
ret = get_menu(sID);
SAL_WARN_IF(!ret, "vcl.layout", "menu \"" << sID.getStr() << "\" not found in .ui");
@ -279,7 +279,7 @@ public:
return ret;
}
//sID may not exist, but must be of type T if it does
template <typename T /*= ::Window if we had c++11*/> T* get(OString sID)
template <typename T /*= ::Window if we had c++11*/> T* get(const OString& sID)
{
::Window *w = get_by_name(sID);
SAL_WARN_IF(w && !dynamic_cast<T*>(w),
@ -288,7 +288,7 @@ public:
return static_cast<T*>(w);
}
//sID may not exist
PopupMenu* get_menu(OString sID);
PopupMenu* get_menu(const OString& sID);
//given an sID return the response value for that widget
short get_response(const ::Window *pWindow) const;
@ -378,7 +378,7 @@ private:
::Window* prepareWidgetOwnScrolling(::Window *pParent, WinBits &rWinStyle);
void cleanupWidgetOwnScrolling(::Window *pScrollParent, ::Window *pWindow, stringmap &rMap);
void set_response(OString sID, short nResponse);
void set_response(const OString& sID, short nResponse);
};
@ -403,19 +403,19 @@ public:
static OUString getUIRootDir();
bool hasBuilder() const { return m_pUIBuilder != NULL; }
css::uno::Reference<css::frame::XFrame> getFrame() { return m_pUIBuilder->getFrame(); }
template <typename T> T* get(T*& ret, OString sID)
template <typename T> T* get(T*& ret, const OString& sID)
{
return m_pUIBuilder->get<T>(ret, sID);
}
template <typename T /*= ::Window if we had c++11*/> T* get(OString sID)
template <typename T /*= ::Window if we had c++11*/> T* get(const OString & sID)
{
return m_pUIBuilder->get<T>(sID);
}
PopupMenu* get_menu(PopupMenu*& ret, OString sID)
PopupMenu* get_menu(PopupMenu*& ret, const OString & sID)
{
return m_pUIBuilder->get_menu(ret, sID);
}
PopupMenu* get_menu(OString sID)
PopupMenu* get_menu(const OString & sID)
{
return m_pUIBuilder->get_menu(sID);
}

View File

@ -1463,7 +1463,7 @@ public:
const Rectangle& rControlRegion,
ControlState nState,
const ImplControlValue& aValue,
OUString aCaption );
const OUString& aCaption );
// Query the native control's actual drawing region (including adornment)
bool GetNativeControlRegion( ControlType nType,
@ -1471,7 +1471,7 @@ public:
const Rectangle& rControlRegion,
ControlState nState,
const ImplControlValue& aValue,
OUString aCaption,
const OUString& aCaption,
Rectangle &rNativeBoundingRegion,
Rectangle &rNativeContentRegion ) const;

View File

@ -41,8 +41,8 @@ namespace grutils
static const char FEAT_PREFIX;
static const char FEAT_SEPARATOR;
static const char FEAT_ID_VALUE_SEPARATOR;
GrFeatureParser(const gr_face * face, const OString features, const OString lang);
GrFeatureParser(const gr_face * face, const OString lang);
GrFeatureParser(const gr_face * face, const OString& features, const OString& lang);
GrFeatureParser(const gr_face * face, const OString& lang);
~GrFeatureParser();
//size_t getFontFeatures(gr::FeatureSetting settings[MAX_FEATURES]) const;
bool parseErrors() { return mbErrors; };

View File

@ -61,9 +61,9 @@ public: // TODO: create matching interface class
FontPitch GetPitch() const { return mePitch; }
FontWidth GetWidthType() const { return meWidthType; }
bool IsSymbolFont() const { return mbSymbolFlag; }
void SetFamilyName(const OUString sFamilyName) { maName = sFamilyName; }
void SetStyleName( const OUString sStyleName) { maStyleName = sStyleName; }
void SetFamilyType(const FontFamily eFontFamily) { meFamily = eFontFamily; }
void SetFamilyName(const OUString& sFamilyName) { maName = sFamilyName; }
void SetStyleName( const OUString& sStyleName) { maStyleName = sStyleName; }
void SetFamilyType(const FontFamily eFontFamily) { meFamily = eFontFamily; }
void SetPitch(const FontPitch ePitch ) { mePitch = ePitch; }
void SetItalic(const FontItalic eItalic ) { meItalic = eItalic; }
void SetWeight(const FontWeight eWeight ) { meWeight = eWeight; }

View File

@ -409,7 +409,7 @@ public:
// get foreign key names
namespace vcl_sal {
OUString getKeysymReplacementName(
OUString pLang,
const OUString& pLang,
KeySym nSymbol );
}

View File

@ -34,7 +34,7 @@ public:
const OUString &rURL, const OUString &,
unsigned int, unsigned int, unsigned int);
void checkExportImport(OUString aFilterShortName);
void checkExportImport(const OUString& aFilterShortName);
/**
* Ensure CVEs remain unbroken
@ -77,7 +77,7 @@ void VclFiltersTest::testScaling()
}
}
void VclFiltersTest::checkExportImport(OUString aFilterShortName)
void VclFiltersTest::checkExportImport(const OUString& aFilterShortName)
{
Bitmap aBitmap( Size( 100, 100 ), 24 );
aBitmap.Erase(COL_WHITE);

View File

@ -104,7 +104,7 @@ bool GraphicNativeTransform::rotateBitmapOnly(sal_uInt16 aRotation)
return true;
}
bool GraphicNativeTransform::rotateGeneric(sal_uInt16 aRotation, OUString aType)
bool GraphicNativeTransform::rotateGeneric(sal_uInt16 aRotation, const OUString& aType)
{
// Can't rotate animations yet
if (mrGraphic.IsAnimated())

View File

@ -872,7 +872,7 @@ void EMFWriter::ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt,
}
}
void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString rText, const sal_Int32* pDXArray, sal_uInt32 nWidth )
void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, const sal_Int32* pDXArray, sal_uInt32 nWidth )
{
sal_Int32 nLen = rText.getLength(), i;

View File

@ -79,7 +79,7 @@ private:
void ImplWritePolygonRecord( const Polygon& rPoly, bool bClose );
void ImplWritePolyPolygonRecord( const PolyPolygon& rPolyPoly );
void ImplWriteBmpRecord( const Bitmap& rBmp, const Point& rPt, const Size& rSz, sal_uInt32 nROP );
void ImplWriteTextRecord( const Point& rPos, const OUString rText, const sal_Int32* pDXArray, sal_uInt32 nWidth );
void ImplWriteTextRecord( const Point& rPos, const OUString& rText, const sal_Int32* pDXArray, sal_uInt32 nWidth );
void Impl_handleLineInfoPolyPolygons(const LineInfo& rInfo, const basegfx::B2DPolygon& rLinePolygon);
void ImplWrite( const GDIMetaFile& rMtf );

View File

@ -2341,7 +2341,7 @@ ImplFontEntry* ImplFontCache::GetFontEntry( ImplDevFontList* pFontList,
namespace
{
OUString stripCharSetFromName(OUString aName)
OUString stripCharSetFromName(const OUString& _aName)
{
// I worry that someone will have a font which *does* have
// e.g. "Greek" legitimately at the end of its name :-(
@ -2358,6 +2358,7 @@ namespace
" (vietnamese)"
};
OUString aName = _aName;
// These can be crazily piled up, e.g. Times New Roman CYR Greek
bool bFinished = false;
while (!bFinished)

View File

@ -268,7 +268,7 @@ bool OutputDevice::DrawNativeControl( ControlType nType,
const Rectangle& rControlRegion,
ControlState nState,
const ImplControlValue& aValue,
OUString aCaption )
const OUString& aCaption )
{
if( !lcl_enableNativeWidget( *this ) )
return false;
@ -310,7 +310,7 @@ bool OutputDevice::GetNativeControlRegion( ControlType nType,
const Rectangle& rControlRegion,
ControlState nState,
const ImplControlValue& aValue,
OUString aCaption,
const OUString& aCaption,
Rectangle &rNativeBoundingRegion,
Rectangle &rNativeContentRegion ) const
{

View File

@ -38,14 +38,14 @@ const char GrFeatureParser::FEAT_PREFIX = ':';
const char GrFeatureParser::FEAT_SEPARATOR = '&';
const char GrFeatureParser::FEAT_ID_VALUE_SEPARATOR = '=';
GrFeatureParser::GrFeatureParser(const gr_face * pFace, const OString lang)
GrFeatureParser::GrFeatureParser(const gr_face * pFace, const OString& lang)
: mnNumSettings(0), mbErrors(false), mpSettings(NULL)
{
maLang.label[0] = maLang.label[1] = maLang.label[2] = maLang.label[3] = '\0';
setLang(pFace, lang);
}
GrFeatureParser::GrFeatureParser(const gr_face * pFace, const OString features, const OString lang)
GrFeatureParser::GrFeatureParser(const gr_face * pFace, const OString& features, const OString& lang)
: mnNumSettings(0), mbErrors(false), mpSettings(NULL)
{
sal_Int32 nEquals = 0;

View File

@ -45,7 +45,7 @@ using namespace com::sun::star;
namespace
{
sal_uInt16 mapStockToImageResource(OString sType)
sal_uInt16 mapStockToImageResource(const OString& sType)
{
sal_uInt16 nRet = 0;
if (sType == "gtk-index")
@ -55,7 +55,7 @@ namespace
return nRet;
}
SymbolType mapStockToSymbol(OString sType)
SymbolType mapStockToSymbol(const OString& sType)
{
SymbolType eRet = SYMBOL_NOSYMBOL;
if (sType == "gtk-media-next")
@ -167,7 +167,7 @@ namespace
}
#endif
VclBuilder::VclBuilder(Window *pParent, OUString sUIDir, OUString sUIFile, OString sID, const uno::Reference<frame::XFrame>& rFrame)
VclBuilder::VclBuilder(Window *pParent, const OUString& sUIDir, const OUString& sUIFile, const OString& sID, const uno::Reference<frame::XFrame>& rFrame)
: m_sID(sID)
, m_sHelpRoot(OUStringToOString(sUIFile, RTL_TEXTENCODING_UTF8))
, m_pStringReplace(ResMgr::GetReadStringHook())
@ -851,7 +851,7 @@ namespace
return nDigits;
}
FieldUnit detectMetricUnit(OString sUnit)
FieldUnit detectMetricUnit(const OString& sUnit)
{
FieldUnit eUnit = FUNIT_NONE;
@ -2906,7 +2906,7 @@ Window *VclBuilder::get_widget_root()
return m_aChildren.empty() ? NULL : m_aChildren[0].m_pWindow;
}
Window *VclBuilder::get_by_name(OString sID)
Window *VclBuilder::get_by_name(const OString& sID)
{
for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
aEnd = m_aChildren.end(); aI != aEnd; ++aI)
@ -2918,7 +2918,7 @@ Window *VclBuilder::get_by_name(OString sID)
return NULL;
}
PopupMenu *VclBuilder::get_menu(OString sID)
PopupMenu *VclBuilder::get_menu(const OString& sID)
{
for (std::vector<MenuAndId>::iterator aI = m_aMenus.begin(),
aEnd = m_aMenus.end(); aI != aEnd; ++aI)
@ -2946,7 +2946,7 @@ short VclBuilder::get_response(const Window *pWindow) const
return RET_CANCEL;
}
void VclBuilder::set_response(OString sID, short nResponse)
void VclBuilder::set_response(const OString& sID, short nResponse)
{
for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
aEnd = m_aChildren.end(); aI != aEnd; ++aI)
@ -2962,7 +2962,7 @@ void VclBuilder::set_response(OString sID, short nResponse)
assert(false);
}
void VclBuilder::delete_by_name(OString sID)
void VclBuilder::delete_by_name(const OString& sID)
{
for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
aEnd = m_aChildren.end(); aI != aEnd; ++aI)
@ -3031,7 +3031,7 @@ void VclBuilder::set_window_packing_position(const Window *pWindow, sal_Int32 nP
}
}
const VclBuilder::ListStore *VclBuilder::get_model_by_name(OString sID) const
const VclBuilder::ListStore *VclBuilder::get_model_by_name(const OString& sID) const
{
std::map<OString, ListStore>::const_iterator aI = m_pParserState->m_aModels.find(sID);
if (aI != m_pParserState->m_aModels.end())
@ -3039,7 +3039,7 @@ const VclBuilder::ListStore *VclBuilder::get_model_by_name(OString sID) const
return NULL;
}
const VclBuilder::TextBuffer *VclBuilder::get_buffer_by_name(OString sID) const
const VclBuilder::TextBuffer *VclBuilder::get_buffer_by_name(const OString& sID) const
{
std::map<OString, TextBuffer>::const_iterator aI = m_pParserState->m_aTextBuffers.find(sID);
if (aI != m_pParserState->m_aTextBuffers.end())
@ -3047,7 +3047,7 @@ const VclBuilder::TextBuffer *VclBuilder::get_buffer_by_name(OString sID) const
return NULL;
}
const VclBuilder::Adjustment *VclBuilder::get_adjustment_by_name(OString sID) const
const VclBuilder::Adjustment *VclBuilder::get_adjustment_by_name(const OString& sID) const
{
std::map<OString, Adjustment>::const_iterator aI = m_pParserState->m_aAdjustments.find(sID);
if (aI != m_pParserState->m_aAdjustments.end())

View File

@ -474,7 +474,7 @@ namespace vcl_sal {
};
// translate keycodes, used within the displayed menu shortcuts
OUString getKeysymReplacementName( OUString pLang, KeySym nSymbol )
OUString getKeysymReplacementName( const OUString& pLang, KeySym nSymbol )
{
for( unsigned int n = 0; n < SAL_N_ELEMENTS(aKeyboards); n++ )
{

View File

@ -28,7 +28,7 @@ using namespace ::com::sun::star;
// FIXME
static G_CONST_RETURN gchar *
getAsConst( OUString rString )
getAsConst( const OUString& rString )
{
static const int nMax = 10;
static OString aUgly[nMax];

View File

@ -45,7 +45,7 @@ atk_object_wrapper_conditional_ref( const uno::Reference< accessibility::XAccess
// FIXME
static G_CONST_RETURN gchar *
getAsConst( OUString rString )
getAsConst( const OUString& rString )
{
static const int nMax = 10;
static OString aUgly[nMax];