remove StringListResource in favour of ResStringArray...

and turn local resources used as lists of strings into
string array resources

Change-Id: I9d67a790659963bca87aacba1c052d7b244b4e21
This commit is contained in:
Caolán McNamara
2016-10-12 13:24:04 +01:00
parent dca5f8ad02
commit ad067cb0c7
9 changed files with 206 additions and 232 deletions

View File

@@ -95,10 +95,10 @@
#include <svx/svxids.hrc>
#include <toolkit/helper/vclunohelper.hxx>
#include <tools/diagnose_ex.h>
#include <tools/resary.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/stdtext.hxx>
#include <vcl/wrkwin.hxx>
#include <tools/StringListResource.hxx>
#include <sal/macros.h>
#include <limits>
@@ -545,10 +545,9 @@ namespace pcr
OUString sControlValue;
OSL_VERIFY( _rControlValue >>= sControlValue );
::std::vector< OUString > aListEntries;
tools::StringListResource aRes( PcrRes( RID_RSC_ENUM_SHOWHIDE ), aListEntries );
OSL_ENSURE( aListEntries.size() == 2, "FormComponentPropertyHandler::convertToPropertyValue: broken resource for Show/Hide!" );
bool bShow = ( aListEntries.size() < 2 ) || ( sControlValue == aListEntries[1] );
ResStringArray aListEntries(PcrRes(RID_RSC_ENUM_SHOWHIDE));
OSL_ENSURE( aListEntries.Count() == 2, "FormComponentPropertyHandler::convertToPropertyValue: broken resource for Show/Hide!" );
bool bShow = ( aListEntries.Count() < 2 ) || ( sControlValue == aListEntries.GetString(1) );
aPropertyValue <<= bShow;
}
@@ -651,15 +650,14 @@ namespace pcr
case PROPERTY_ID_SHOW_RECORDACTIONS:
case PROPERTY_ID_SHOW_FILTERSORT:
{
::std::vector< OUString > aListEntries;
tools::StringListResource aRes( PcrRes( RID_RSC_ENUM_SHOWHIDE ), aListEntries );
OSL_ENSURE( aListEntries.size() == 2, "FormComponentPropertyHandler::convertToControlValue: broken resource for Show/Hide!" );
ResStringArray aListEntries(PcrRes(RID_RSC_ENUM_SHOWHIDE));
OSL_ENSURE( aListEntries.Count() == 2, "FormComponentPropertyHandler::convertToControlValue: broken resource for Show/Hide!" );
if ( aListEntries.size() == 2 )
if (aListEntries.Count() == 2)
{
OUString sControlValue = ::comphelper::getBOOL( _rPropertyValue )
? aListEntries[1]
: aListEntries[0];
? aListEntries.GetString(1)
: aListEntries.GetString(0);
aControlValue <<= sControlValue;
}
}
@@ -1252,8 +1250,8 @@ namespace pcr
)
nResId = RID_RSC_ENUM_SHOWHIDE;
::std::vector< OUString > aListEntries;
tools::StringListResource aRes(PcrRes(nResId),aListEntries);
PcrRes aRes(nResId);
ResStringArray aListEntries(aRes);
aDescriptor.Control = PropertyHandlerHelper::createListBoxControl(_rxControlFactory, aListEntries, false, false);
bNeedDefaultStringIfVoidAllowed = true;
}

View File

@@ -1226,17 +1226,15 @@ String RID_STR_TEXTTYPE
Text [ en-US ] = "Text type";
};
Resource RID_RSC_ENUM_SHOWHIDE
StringArray RID_RSC_ENUM_SHOWHIDE
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "Hide" ;
};
String 2
{
Text [ en-US ] = "Show" ;
< "Hide" ; >;
< "Show" ; >;
};
};
String RID_STR_XML_DATA_MODEL
{
Text [ en-US ] = "XML data model";

View File

@@ -35,7 +35,7 @@
#include <com/sun/star/inspection/XStringListControl.hpp>
#include <com/sun/star/inspection/XNumericControl.hpp>
#include <tools/diagnose_ex.h>
#include <tools/StringListResource.hxx>
#include <tools/resary.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <algorithm>
@@ -72,8 +72,7 @@ namespace pcr
// special handling for booleans (this will become a list)
if ( _rProperty.Type.getTypeClass() == TypeClass_BOOLEAN )
{
::std::vector< OUString > aListEntries;
tools::StringListResource aRes(PcrRes(RID_RSC_ENUM_YESNO),aListEntries);
ResStringArray aListEntries(PcrRes(RID_RSC_ENUM_YESNO));
_out_rDescriptor.Control = createListBoxControl(_rxControlFactory, aListEntries, bReadOnlyControl, false);
return;
}
@@ -141,13 +140,20 @@ namespace pcr
}
}
Reference< XPropertyControl > PropertyHandlerHelper::createListBoxControl( const Reference< XPropertyControlFactory >& _rxControlFactory,
const ::std::vector< OUString >& _rInitialListEntries, bool _bReadOnlyControl, bool _bSorted )
{
return lcl_implCreateListLikeControl(_rxControlFactory, _rInitialListEntries, _bReadOnlyControl, _bSorted, true);
}
Reference< XPropertyControl > PropertyHandlerHelper::createListBoxControl( const Reference< XPropertyControlFactory >& _rxControlFactory,
const ResStringArray& _rInitialListEntries, bool _bReadOnlyControl, bool _bSorted )
{
std::vector<OUString> aInitialListEntries;
for (sal_uInt32 i = 0; i < _rInitialListEntries.Count(); ++i)
aInitialListEntries.push_back(_rInitialListEntries.GetString(i));
return lcl_implCreateListLikeControl(_rxControlFactory, aInitialListEntries, _bReadOnlyControl, _bSorted, true);
}
Reference< XPropertyControl > PropertyHandlerHelper::createComboBoxControl( const Reference< XPropertyControlFactory >& _rxControlFactory,
const ::std::vector< OUString >& _rInitialListEntries, bool _bReadOnlyControl, bool _bSorted )

View File

@@ -37,6 +37,8 @@ namespace com { namespace sun { namespace star {
}
} } }
class ResStringArray;
namespace pcr
{
@@ -97,6 +99,32 @@ namespace pcr
bool _bSorted
);
/** creates an <member scope="css::inspection">PropertyControlType::ListBox</member>-type control
and fills it with initial values
@param _rxControlFactory
A control factory. Must not be <NULL/>.
@param _rInitialListEntries
the initial values of the control
@param _bReadOnlyControl
determines whether the control should be read-only
@param _bSorted
determines whether the list entries should be sorted
@return
the newly created control
*/
static css::uno::Reference< css::inspection::XPropertyControl >
createListBoxControl(
const css::uno::Reference< css::inspection::XPropertyControlFactory >& _rxControlFactory,
const ResStringArray& _rInitialListEntries,
bool _bReadOnlyControl,
bool _bSorted
);
/** creates an <member scope="css::inspection">PropertyControlType::ComboBox</member>-type control
and fills it with initial values

View File

@@ -32,15 +32,12 @@ String RID_STR_PROPPAGE_DATA
{
Text [ en-US ] = "Data" ;
};
Resource RID_RSC_ENUM_YESNO
StringArray RID_RSC_ENUM_YESNO
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "No" ;
};
String 2
{
Text [ en-US ] = "Yes" ;
< "No" ; >;
< "Yes" ; >;
};
};
String RID_STR_HELP_SECTION_LABEL

View File

@@ -35,9 +35,9 @@
#include <com/sun/star/util/Time.hpp>
#include <comphelper/sequence.hxx>
#include <connectivity/dbconversion.hxx>
#include <tools/resary.hxx>
#include "formresid.hrc"
#include "pcrservices.hxx"
#include <tools/StringListResource.hxx>
#include <comphelper/types.hxx>
#include "modulepcr.hxx"
@@ -378,11 +378,11 @@ bool StringRepresentation::convertGenericValueToString( const uno::Any& _rValue,
case uno::TypeClass_BOOLEAN:
{
::std::vector< OUString > aListEntries;
tools::StringListResource aRes(PcrRes(RID_RSC_ENUM_YESNO),aListEntries);
ResStringArray aListEntries(PcrRes(RID_RSC_ENUM_YESNO));
bool bValue = false;
_rValue >>= bValue;
_rStringRep = bValue ? aListEntries[1] : aListEntries[0];
_rStringRep = bValue ? aListEntries.GetString(1)
: aListEntries.GetString(0);
}
break;
@@ -517,9 +517,8 @@ bool StringRepresentation::convertStringToGenericValue( const OUString& _rString
case uno::TypeClass_BOOLEAN:
{
::std::vector< OUString > aListEntries;
tools::StringListResource aRes(PcrRes(RID_RSC_ENUM_YESNO),aListEntries);
_rValue <<= aListEntries[0] != _rStringRep;
ResStringArray aListEntries(PcrRes(RID_RSC_ENUM_YESNO));
_rValue <<= aListEntries.GetString(0) != _rStringRep;
}
break;

View File

@@ -1,49 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_TOOLS_STRINGLISTRESOURCE_HXX
#define INCLUDED_TOOLS_STRINGLISTRESOURCE_HXX
#include <vector>
#include <tools/resid.hxx>
#include <tools/rcid.h>
#include <tools/rc.hxx>
namespace tools
{
class StringListResource : public Resource
{
public:
StringListResource(const ResId& _aResId,::std::vector< OUString>& _rToFill ) : Resource(_aResId)
{
sal_uInt16 i = 1;
while( IsAvailableRes(ResId(i,*m_pResMgr).SetRT(RSC_STRING)) )
{
_rToFill.push_back(ResId(i,*m_pResMgr).toString());
++i;
}
}
~StringListResource()
{
FreeResource();
}
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -38,7 +38,7 @@
#include <toolkit/helper/vclunohelper.hxx>
#include <unotools/syslocale.hxx>
#include <tools/diagnose_ex.h>
#include <tools/StringListResource.hxx>
#include <tools/resary.hxx>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/form/inspection/FormComponentPropertyHandler.hpp>
#include <com/sun/star/inspection/StringRepresentation.hpp>
@@ -676,9 +676,11 @@ void GeometryHandler::implCreateListLikeControl(
,bool _bTrueIfListBoxFalseIfComboBox
)
{
::std::vector< OUString > aList;
tools::StringListResource aRes(ModuleRes(_nResId),aList);
ModuleRes aRes(_nResId);
ResStringArray aResList(aRes);
std::vector<OUString> aList;
for (sal_uInt32 i = 0; i < aResList.Count(); ++i)
aList.push_back(aResList.GetString(i));
implCreateListLikeControl(_rxControlFactory, out_Descriptor, aList, _bReadOnlyControl, _bTrueIfListBoxFalseIfComboBox);
}
@@ -931,9 +933,12 @@ beans::Property GeometryHandler::getProperty(const OUString & PropertyName)
}
uno::Any GeometryHandler::getConstantValue(bool _bToControlValue,sal_uInt16 _nResId,const uno::Any& _aValue,const OUString& _sConstantName,const OUString & PropertyName )
{
::std::vector< OUString > aList;
tools::StringListResource aRes(ModuleRes(_nResId),aList);
uno::Sequence< OUString > aSeq(comphelper::containerToSequence(aList));
ModuleRes aRes(_nResId);
ResStringArray aResList(aRes);
std::vector<OUString> aList;
uno::Sequence< OUString > aSeq(aResList.Count());
for (sal_uInt32 i = 0; i < aResList.Count(); ++i)
aSeq[i] = aResList.GetString(i);
uno::Reference< inspection::XStringRepresentation > xConversionHelper = inspection::StringRepresentation::createConstant( m_xContext,m_xTypeConverter,_sConstantName,aSeq);
if ( _bToControlValue )
@@ -1068,11 +1073,19 @@ uno::Any SAL_CALL GeometryHandler::convertToPropertyValue(const OUString & Prope
{
OUString sValue;
_rControlValue >>= sValue;
::std::vector< OUString > aList;
tools::StringListResource aRes(ModuleRes(RID_STR_TYPE_CONST),aList);
::std::vector< OUString >::const_iterator aFind = ::std::find(aList.begin(),aList.end(),sValue);
if ( aFind != aList.end() )
aPropertyValue <<= static_cast<sal_uInt32>(aFind - aList.begin());
ModuleRes aRes(RID_STR_TYPE_CONST);
ResStringArray aResList(aRes);
sal_uInt32 nFound(RESARRAY_INDEX_NOTFOUND);
for (sal_uInt32 i = 0; i < aResList.Count(); ++i)
{
if (aResList.GetString(i) == sValue)
{
nFound = i;
break;
}
}
if (nFound != RESARRAY_INDEX_NOTFOUND)
aPropertyValue <<= nFound;
}
break;
case PROPERTY_ID_MIMETYPE:
@@ -1082,22 +1095,38 @@ uno::Any SAL_CALL GeometryHandler::convertToPropertyValue(const OUString & Prope
{
OUString sValue;
_rControlValue >>= sValue;
::std::vector< OUString > aList;
tools::StringListResource aRes(ModuleRes(RID_STR_VERTICAL_ALIGN_CONST),aList);
::std::vector< OUString >::const_iterator aFind = ::std::find(aList.begin(),aList.end(),sValue);
if ( aFind != aList.end() )
aPropertyValue <<= static_cast<style::VerticalAlignment>(aFind - aList.begin());
ModuleRes aRes(RID_STR_VERTICAL_ALIGN_CONST);
ResStringArray aResList(aRes);
sal_uInt32 nFound(RESARRAY_INDEX_NOTFOUND);
for (sal_uInt32 i = 0; i < aResList.Count(); ++i)
{
if (aResList.GetString(i) == sValue)
{
nFound = i;
break;
}
}
if (nFound != RESARRAY_INDEX_NOTFOUND)
aPropertyValue <<= static_cast<style::VerticalAlignment>(nFound);
}
break;
case PROPERTY_ID_PARAADJUST:
{
OUString sValue;
_rControlValue >>= sValue;
::std::vector< OUString > aList;
tools::StringListResource aRes(ModuleRes(RID_STR_PARAADJUST_CONST),aList);
::std::vector< OUString >::const_iterator aFind = ::std::find(aList.begin(),aList.end(),sValue);
if ( aFind != aList.end() )
aPropertyValue <<= static_cast<sal_Int16>(aFind - aList.begin());
ModuleRes aRes(RID_STR_PARAADJUST_CONST);
ResStringArray aResList(aRes);
sal_uInt32 nFound(RESARRAY_INDEX_NOTFOUND);
for (sal_uInt32 i = 0; i < aResList.Count(); ++i)
{
if (aResList.GetString(i) == sValue)
{
nFound = i;
break;
}
}
if (nFound != RESARRAY_INDEX_NOTFOUND)
aPropertyValue <<= static_cast<sal_Int16>(nFound);
}
break;
default:
@@ -1211,30 +1240,30 @@ uno::Any SAL_CALL GeometryHandler::convertToControlValue(const OUString & Proper
break;
case PROPERTY_ID_TYPE:
{
::std::vector< OUString > aList;
tools::StringListResource aRes(ModuleRes(RID_STR_TYPE_CONST),aList);
if ( m_nDataFieldType < aList.size() )
aControlValue <<= aList[m_nDataFieldType];
ModuleRes aRes(RID_STR_TYPE_CONST);
ResStringArray aResList(aRes);
if (m_nDataFieldType < aResList.Count())
aControlValue <<= aResList.GetString(m_nDataFieldType);
}
break;
case PROPERTY_ID_VERTICALALIGN:
{
style::VerticalAlignment nParagraphVertAlign = style::VerticalAlignment_TOP;
aPropertyValue >>= nParagraphVertAlign;
::std::vector< OUString > aList;
tools::StringListResource aRes(ModuleRes(RID_STR_VERTICAL_ALIGN_CONST),aList);
if ( static_cast<sal_Int16>(nParagraphVertAlign) < static_cast<sal_Int16>(aList.size()) )
aControlValue <<= aList[nParagraphVertAlign];
ModuleRes aRes(RID_STR_VERTICAL_ALIGN_CONST);
ResStringArray aResList(aRes);
if (nParagraphVertAlign < aResList.Count())
aControlValue <<= aResList.GetString(nParagraphVertAlign);
}
break;
case PROPERTY_ID_PARAADJUST:
{
sal_Int16 nParagraphAdjust = style::ParagraphAdjust_LEFT;
aPropertyValue >>= nParagraphAdjust;
::std::vector< OUString > aList;
tools::StringListResource aRes(ModuleRes(RID_STR_PARAADJUST_CONST),aList);
if ( nParagraphAdjust < static_cast<sal_Int16>(aList.size()) )
aControlValue <<= aList[nParagraphAdjust];
ModuleRes aRes(RID_STR_PARAADJUST_CONST);
ResStringArray aResList(aRes);
if (static_cast<sal_uInt32>(nParagraphAdjust) < aResList.Count())
aControlValue <<= aResList.GetString(nParagraphAdjust);
}
break;
case PROPERTY_ID_BACKCOLOR:

View File

@@ -24,65 +24,54 @@ String RID_STR_PROPPAGE_DEFAULT
{
Text [ en-US ] = "General" ;
};
String RID_STR_PROPPAGE_DATA
{
Text [ en-US ] = "Data" ;
};
Resource RID_STR_BOOL
StringArray RID_STR_BOOL
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "No" ;
};
String 2
{
Text [ en-US ] = "Yes" ;
< "No" ; >;
< "Yes" ; >;
};
};
String RID_STR_FORCENEWPAGE
{
Text [ en-US ] = "Force New Page" ;
};
Resource RID_STR_FORCENEWPAGE_CONST
StringArray RID_STR_FORCENEWPAGE_CONST
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "None" ;
};
String 2
{
Text [ en-US ] = "Before Section" ;
};
String 3
{
Text [ en-US ] = "After Section" ;
};
String 4
{
Text [ en-US ] = "Before & After Section" ;
< "None" ; >;
< "Before Section" ; >;
< "After Section" ; >;
< "Before & After Section" ; >;
};
};
String RID_STR_NEWROWORCOL
{
Text [ en-US ] = "New Row Or Column" ;
};
String RID_STR_KEEPTOGETHER
{
Text [ en-US ] = "Keep Together" ;
};
Resource RID_STR_KEEPTOGETHER_CONST
StringArray RID_STR_KEEPTOGETHER_CONST
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "No" ;
};
String 2
{
Text [ en-US ] = "Whole Group" ;
};
String 3
{
Text [ en-US ] = "With First Detail" ;
< "No" ; >;
< "Whole Group" ; >;
< "With First Detail" ; >;
};
};
String RID_STR_CANGROW
@@ -133,57 +122,44 @@ String RID_STR_GROUPKEEPTOGETHER
{
Text [ en-US ] = "Group keep together" ;
};
Resource RID_STR_GROUPKEEPTOGETHER_CONST
StringArray RID_STR_GROUPKEEPTOGETHER_CONST
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "Per Page" ;
};
String 2
{
Text [ en-US ] = "Per Column" ;
< "Per Page" ; >;
< "Per Column" ; >;
};
};
Resource RID_STR_SECTIONPAGEBREAK_CONST
StringArray RID_STR_SECTIONPAGEBREAK_CONST
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "None" ;
};
String 2
{
Text [ en-US ] = "Section" ;
};
String 3
{
Text [ en-US ] = "Automatic" ;
< "None" ; >;
< "Section" ; >;
< "Automatic" ; >;
};
};
String RID_STR_PAGEHEADEROPTION
{
Text [ en-US ] = "Page header" ;
};
String RID_STR_PAGEFOOTEROPTION
{
Text [ en-US ] = "Page footer" ;
};
Resource RID_STR_REPORTPRINTOPTION_CONST
StringArray RID_STR_REPORTPRINTOPTION_CONST
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "All Pages" ;
};
String 2
{
Text [ en-US ] = "Not With Report Header" ;
};
String 3
{
Text [ en-US ] = "Not With Report Footer" ;
};
String 4
{
Text [ en-US ] = "Not With Report Header/Footer" ;
< "All Pages" ; >;
< "Not With Report Header" ; >;
< "Not With Report Footer" ; >;
< "Not With Report Header/Footer" ; >;
};
};
String RID_STR_DEEPTRAVERSING
@@ -266,41 +242,38 @@ String RID_STR_TYPE
{
Text [ en-US ] = "Data Field Type";
};
Resource RID_STR_TYPE_CONST
StringArray RID_STR_TYPE_CONST
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "Field or Formula";
};
String 2
{
Text [ en-US ] = "Function";
};
String 3
{
Text [ en-US ] = "Counter";
};
String 4
{
Text [ en-US ] = "User defined Function";
< "Field or Formula"; >;
< "Function"; >;
< "Counter"; >;
< "User defined Function"; >;
};
};
String RID_STR_MASTERFIELDS
{
Text [ en-US ] = "Link master fields" ;
};
String RID_STR_DETAILFIELDS
{
Text [ en-US ] = "Link slave fields" ;
};
String RID_STR_EXPLANATION
{
Text [ en-US ] = "Charts can be used to display detailed data about the current record of the report. To do this, you can specify which columns in the chart match which columns in the report.";
};
String RID_STR_DETAILLABEL
{
Text [ en-US ] = "Chart" ;
};
String RID_STR_MASTERLABEL
{
Text [ en-US ] = "Report" ;
@@ -310,68 +283,63 @@ String RID_STR_PREVIEW_COUNT
{
Text [ en-US ] = "Preview Row(s)" ;
};
String RID_STR_AREA
{
Text [ en-US ] = "Area" ;
};
String RID_STR_MIMETYPE
{
Text [ en-US ] = "Report Output Format" ;
};
String RID_STR_VERTICALALIGN
{
Text [ en-US ] = "Vert. Alignment" ;
};
Resource RID_STR_VERTICAL_ALIGN_CONST
StringArray RID_STR_VERTICAL_ALIGN_CONST
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "Top";
};
String 2
{
Text [ en-US ] = "Middle";
};
String 3
{
Text [ en-US ] = "Bottom";
< "Top"; >;
< "Middle"; >;
< "Bottom"; >;
};
};
String RID_STR_PARAADJUST
{
Text [ en-US ] = "Horz. Alignment" ;
};
Resource RID_STR_PARAADJUST_CONST
StringArray RID_STR_PARAADJUST_CONST
{
String 1
ItemList [ en-US ] =
{
Text [ en-US ] = "Left";
};
String 2
{
Text [ en-US ] = "Right";
};
String 3
{
Text [ en-US ] = "Block";
};
String 4
{
Text [ en-US ] = "Center";
< "Left"; >;
< "Right"; >;
< "Block"; >;
< "Center"; >;
};
};
String RID_STR_F_COUNTER
{
Text [ en-US ] = "Counter" ;
};
String RID_STR_F_ACCUMULATION
{
Text [ en-US ] = "Accumulation" ;
};
String RID_STR_F_MINIMUM
{
Text [ en-US ] = "Minimum" ;
};
String RID_STR_F_MAXIMUM
{
Text [ en-US ] = "Maximum" ;