summaryrefslogtreecommitdiffstats
path: root/framework/source/fwe/xml/toolboxdocumenthandler.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source/fwe/xml/toolboxdocumenthandler.cxx')
-rw-r--r--framework/source/fwe/xml/toolboxdocumenthandler.cxx77
1 files changed, 28 insertions, 49 deletions
diff --git a/framework/source/fwe/xml/toolboxdocumenthandler.cxx b/framework/source/fwe/xml/toolboxdocumenthandler.cxx
index 9efcc76db60c..7464939e1e03 100644
--- a/framework/source/fwe/xml/toolboxdocumenthandler.cxx
+++ b/framework/source/fwe/xml/toolboxdocumenthandler.cxx
@@ -49,11 +49,11 @@ namespace framework
{
// Property names of a menu/menu item ItemDescriptor
-constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_LABEL = u"Label";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE = u"Type";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE = u"Style";
-constexpr OUStringLiteral ITEM_DESCRIPTOR_VISIBLE = u"IsVisible";
+constexpr OUString ITEM_DESCRIPTOR_COMMANDURL = u"CommandURL"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_LABEL = u"Label"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_TYPE = u"Type"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_STYLE = u"Style"_ustr;
+constexpr OUString ITEM_DESCRIPTOR_VISIBLE = u"IsVisible"_ustr;
static void ExtractToolbarParameters( const Sequence< PropertyValue >& rProp,
OUString& rCommandURL,
@@ -65,10 +65,7 @@ static void ExtractToolbarParameters( const Sequence< PropertyValue >& rProp,
for ( const PropertyValue& rEntry : rProp )
{
if ( rEntry.Name == ITEM_DESCRIPTOR_COMMANDURL )
- {
rEntry.Value >>= rCommandURL;
- rCommandURL = rCommandURL.intern();
- }
else if ( rEntry.Name == ITEM_DESCRIPTOR_LABEL )
rEntry.Value >>= rLabel;
else if ( rEntry.Name == ITEM_DESCRIPTOR_TYPE )
@@ -85,7 +82,7 @@ namespace {
struct ToolboxStyleItem
{
sal_Int16 nBit;
- rtl::OUStringConstExpr attrName;
+ OUString attrName;
};
}
@@ -136,7 +133,7 @@ OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XInde
m_aCommandURL( ITEM_DESCRIPTOR_COMMANDURL )
{
// create hash map
- for ( int i = 0; i < int(TB_XML_ENTRY_COUNT); i++ )
+ for ( int i = 0; i < TB_XML_ENTRY_COUNT; i++ )
{
if ( ToolBoxEntries[i].nNamespace == TB_NS_TOOLBAR )
{
@@ -152,16 +149,6 @@ OReadToolBoxDocumentHandler::OReadToolBoxDocumentHandler( const Reference< XInde
}
}
- // pre-calculate a hash code for all style strings to speed up xml read process
- m_nHashCode_Style_Radio = OUString( ATTRIBUTE_ITEMSTYLE_RADIO ).hashCode();
- m_nHashCode_Style_Left = OUString( ATTRIBUTE_ITEMSTYLE_LEFT ).hashCode();
- m_nHashCode_Style_AutoSize = OUString( ATTRIBUTE_ITEMSTYLE_AUTOSIZE ).hashCode();
- m_nHashCode_Style_DropDown = OUString( ATTRIBUTE_ITEMSTYLE_DROPDOWN ).hashCode();
- m_nHashCode_Style_Repeat = OUString( ATTRIBUTE_ITEMSTYLE_REPEAT ).hashCode();
- m_nHashCode_Style_DropDownOnly = OUString( ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY ).hashCode();
- m_nHashCode_Style_Text = OUString( ATTRIBUTE_ITEMSTYLE_TEXT ).hashCode();
- m_nHashCode_Style_Image = OUString( ATTRIBUTE_ITEMSTYLE_IMAGE ).hashCode();
-
m_bToolBarStartFound = false;
m_bToolBarItemStartFound = false;
m_bToolBarSpaceStartFound = false;
@@ -230,7 +217,7 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
{
try
{
- xPropSet->setPropertyValue("UIName", makeAny( aUIName ) );
+ xPropSet->setPropertyValue("UIName", Any( aUIName ) );
}
catch ( const UnknownPropertyException& )
{
@@ -284,7 +271,7 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
case TB_ATTRIBUTE_URL:
{
bAttributeURL = true;
- aCommandURL = xAttribs->getValueByIndex( n ).intern();
+ aCommandURL = xAttribs->getValueByIndex( n );
}
break;
@@ -313,22 +300,21 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
OUString aToken = aTemp.getToken( 0, ' ', nIndex );
if ( !aToken.isEmpty() )
{
- sal_Int32 nHashCode = aToken.hashCode();
- if ( nHashCode == m_nHashCode_Style_Radio )
+ if ( aToken == ATTRIBUTE_ITEMSTYLE_RADIO )
nItemBits |= css::ui::ItemStyle::RADIO_CHECK;
- else if ( nHashCode == m_nHashCode_Style_Left )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_LEFT )
nItemBits |= css::ui::ItemStyle::ALIGN_LEFT;
- else if ( nHashCode == m_nHashCode_Style_AutoSize )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_AUTOSIZE )
nItemBits |= css::ui::ItemStyle::AUTO_SIZE;
- else if ( nHashCode == m_nHashCode_Style_Repeat )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_REPEAT )
nItemBits |= css::ui::ItemStyle::REPEAT;
- else if ( nHashCode == m_nHashCode_Style_DropDownOnly )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY )
nItemBits |= css::ui::ItemStyle::DROPDOWN_ONLY;
- else if ( nHashCode == m_nHashCode_Style_DropDown )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_DROPDOWN )
nItemBits |= css::ui::ItemStyle::DROP_DOWN;
- else if ( nHashCode == m_nHashCode_Style_Text )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_TEXT )
nItemBits |= css::ui::ItemStyle::TEXT;
- else if ( nHashCode == m_nHashCode_Style_Image )
+ else if ( aToken == ATTRIBUTE_ITEMSTYLE_IMAGE )
nItemBits |= css::ui::ItemStyle::ICON;
}
}
@@ -372,14 +358,14 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
}
auto aToolbarItemProp( comphelper::InitPropertySequence( {
- { m_aCommandURL, css::uno::makeAny( aCommandURL ) },
- { m_aLabel, css::uno::makeAny( aLabel ) },
- { m_aType, css::uno::makeAny( css::ui::ItemType::DEFAULT ) },
- { m_aStyle, css::uno::makeAny( nItemBits ) },
- { m_aIsVisible, css::uno::makeAny( bVisible ) },
+ { m_aCommandURL, css::uno::Any( aCommandURL ) },
+ { m_aLabel, css::uno::Any( aLabel ) },
+ { m_aType, css::uno::Any( css::ui::ItemType::DEFAULT ) },
+ { m_aStyle, css::uno::Any( nItemBits ) },
+ { m_aIsVisible, css::uno::Any( bVisible ) },
} ) );
- m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
+ m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), Any( aToolbarItemProp ) );
}
}
break;
@@ -402,7 +388,7 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
comphelper::makePropertyValue(m_aType, css::ui::ItemType::SEPARATOR_SPACE)
};
- m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
+ m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), Any( aToolbarItemProp ) );
}
break;
@@ -424,7 +410,7 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
comphelper::makePropertyValue(m_aType, css::ui::ItemType::SEPARATOR_LINEBREAK)
};
- m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
+ m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), Any( aToolbarItemProp ) );
}
break;
@@ -446,7 +432,7 @@ void SAL_CALL OReadToolBoxDocumentHandler::startElement(
comphelper::makePropertyValue(m_aType, css::ui::ItemType::SEPARATOR_LINE)
};
- m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), makeAny( aToolbarItemProp ) );
+ m_rItemContainer->insertByIndex( m_rItemContainer->getCount(), Any( aToolbarItemProp ) );
}
break;
@@ -563,7 +549,6 @@ OWriteToolBoxDocumentHandler::OWriteToolBoxDocumentHandler(
m_rItemAccess( rItemAccess )
{
m_xEmptyList = new ::comphelper::AttributeList;
- m_aAttributeType = ATTRIBUTE_TYPE_CDATA;
m_aXMLXlinkNS = XMLNS_XLINK_PREFIX;
m_aXMLToolbarNS = XMLNS_TOOLBAR_PREFIX;
}
@@ -600,16 +585,13 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxDocument()
rtl::Reference<::comphelper::AttributeList> pList = new ::comphelper::AttributeList;
pList->AddAttribute( ATTRIBUTE_XMLNS_TOOLBAR,
- m_aAttributeType,
XMLNS_TOOLBAR );
pList->AddAttribute( ATTRIBUTE_XMLNS_XLINK,
- m_aAttributeType,
XMLNS_XLINK );
if ( !aUIName.isEmpty() )
pList->AddAttribute( m_aXMLToolbarNS + ATTRIBUTE_UINAME,
- m_aAttributeType,
aUIName );
m_xWriteDocumentHandler->startElement( ELEMENT_NS_TOOLBAR, pList );
@@ -664,19 +646,17 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxItem(
}
// save required attribute (URL)
- pList->AddAttribute( m_aAttributeURL, m_aAttributeType, rCommandURL );
+ pList->AddAttribute( m_aAttributeURL, rCommandURL );
if ( !rLabel.isEmpty() )
{
pList->AddAttribute( m_aXMLToolbarNS + ATTRIBUTE_TEXT,
- m_aAttributeType,
rLabel );
}
if ( !bVisible )
{
pList->AddAttribute( m_aXMLToolbarNS + ATTRIBUTE_VISIBLE,
- m_aAttributeType,
ATTRIBUTE_BOOLEAN_FALSE );
}
@@ -691,11 +671,10 @@ void OWriteToolBoxDocumentHandler::WriteToolBoxItem(
{
if ( !aValue.isEmpty() )
aValue.append(" ");
- aValue.append( OUString(pStyle->attrName) );
+ aValue.append( pStyle->attrName );
}
}
pList->AddAttribute( m_aXMLToolbarNS + ATTRIBUTE_ITEMSTYLE,
- m_aAttributeType,
aValue.makeStringAndClear() );
}