2010-10-12 15:53:47 +02:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2004-02-25 16:55:57 +00:00
/*************************************************************************
*
2008-04-11 08:27:39 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2004-02-25 16:55:57 +00:00
*
2010-02-12 15:01:35 +01:00
* Copyright 2000 , 2010 Oracle and / or its affiliates .
2004-02-25 16:55:57 +00:00
*
2008-04-11 08:27:39 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2004-02-25 16:55:57 +00:00
*
2008-04-11 08:27:39 +00:00
* This file is part of OpenOffice . org .
2004-02-25 16:55:57 +00:00
*
2008-04-11 08:27:39 +00:00
* OpenOffice . org is free software : you can redistribute it and / or modify
* it under the terms of the GNU Lesser General Public License version 3
* only , as published by the Free Software Foundation .
2004-02-25 16:55:57 +00:00
*
2008-04-11 08:27:39 +00:00
* OpenOffice . org is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Lesser General Public License version 3 for more details
* ( a copy is included in the LICENSE file that accompanied this code ) .
2004-02-25 16:55:57 +00:00
*
2008-04-11 08:27:39 +00:00
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice . org . If not , see
* < http : //www.openoffice.org/license.html>
* for a copy of the LGPLv3 License .
2004-02-25 16:55:57 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-16 13:31:53 +00:00
// MARKER(update_precomp.py): autogen include statement, do not remove
# include "precompiled_framework.hxx"
2004-02-25 16:55:57 +00:00
# include <stdio.h>
# include <threadhelp/resetableguard.hxx>
# include <xml/toolboxdocumenthandler.hxx>
# include <macros/debug.hxx>
# include <xml/toolboxconfigurationdefines.hxx>
# include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
2005-03-01 18:48:44 +00:00
# include <com/sun/star/ui/ItemType.hpp>
# include <com/sun/star/ui/ItemStyle.hpp>
2004-07-06 16:04:15 +00:00
# include <com/sun/star/beans/XPropertySet.hpp>
2004-02-25 16:55:57 +00:00
# include <sal/config.h>
2010-10-14 22:33:33 +01:00
# include <sal/macros.h>
2004-02-25 16:55:57 +00:00
# include <vcl/svapp.hxx>
# include <vcl/toolbox.hxx>
# include <rtl/ustrbuf.hxx>
INTEGRATION: CWS xmlfix2 (1.14.50); FILE MERGED
2008/05/15 17:21:04 mst 1.14.50.2: RESYNC: (1.14-1.15); FILE MERGED
2008/03/31 15:32:49 mst 1.14.50.1: remove duplicated XAttributeList implementations
- framework/inc/services/attributelist.hxx,
framework/source/services/attributelist.cxx,
framework/inc/xml/attributelist.hxx,
framework/source/xml/attributelist.cxx:
+ removed
- framework/source/xml/makefile.mk, framework/util/makefile.mk:
+ remove attributelist.cxx
- framework/source/xml/{acceleratorconfigurationwriter.cxx,
eventsdocumenthandler.cxx,imagesdocumenthandler.cxx,
menudocumenthandler.cxx,saxnamespacefilter.cxx,
statusbardocumenthandler.cxx,toolboxdocumenthandler.cxx,
toolboxlayoutdocumenthandler.cxx}
+ use comphelper/attributelist.hxx
2008-06-06 11:02:25 +00:00
# include <comphelper/attributelist.hxx>
2004-02-25 16:55:57 +00:00
//_________________________________________________________________________________________________________________
// namespace
//_________________________________________________________________________________________________________________
using namespace : : com : : sun : : star : : uno ;
2004-07-06 16:04:15 +00:00
using namespace : : com : : sun : : star : : beans ;
using namespace : : com : : sun : : star : : container ;
2004-02-25 16:55:57 +00:00
using namespace : : com : : sun : : star : : xml : : sax ;
# define TOOLBAR_DOCTYPE "<!DOCTYPE toolbar:toolbar PUBLIC \"- //OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"toolbar.dtd\">"
namespace framework
{
2004-07-06 16:04:15 +00:00
// Property names of a menu/menu item ItemDescriptor
static const char ITEM_DESCRIPTOR_COMMANDURL [ ] = " CommandURL " ;
static const char ITEM_DESCRIPTOR_HELPURL [ ] = " HelpURL " ;
2009-11-18 11:25:15 +00:00
static const char ITEM_DESCRIPTOR_TOOLTIP [ ] = " Tooltip " ;
2004-07-06 16:04:15 +00:00
static const char ITEM_DESCRIPTOR_LABEL [ ] = " Label " ;
static const char ITEM_DESCRIPTOR_TYPE [ ] = " Type " ;
static const char ITEM_DESCRIPTOR_STYLE [ ] = " Style " ;
static const char ITEM_DESCRIPTOR_VISIBLE [ ] = " IsVisible " ;
2004-11-16 13:57:26 +00:00
static const char ITEM_DESCRIPTOR_WIDTH [ ] = " Width " ;
2004-07-06 16:04:15 +00:00
static void ExtractToolbarParameters ( const Sequence < PropertyValue > rProp ,
2008-06-24 16:07:34 +00:00
: : rtl : : OUString & rCommandURL ,
: : rtl : : OUString & rLabel ,
: : rtl : : OUString & rHelpURL ,
2009-11-18 11:25:15 +00:00
: : rtl : : OUString & rTooltip ,
sal_Int16 & rStyle ,
2004-11-16 13:57:26 +00:00
sal_Int16 & rWidth ,
2004-07-06 16:04:15 +00:00
sal_Bool & rVisible ,
sal_Int16 & rType )
{
for ( sal_Int32 i = 0 ; i < rProp . getLength ( ) ; i + + )
{
if ( rProp [ i ] . Name . equalsAscii ( ITEM_DESCRIPTOR_COMMANDURL ) )
2007-04-03 12:51:15 +00:00
{
2004-07-06 16:04:15 +00:00
rProp [ i ] . Value > > = rCommandURL ;
2007-04-03 12:51:15 +00:00
rCommandURL = rCommandURL . intern ( ) ;
}
2004-07-06 16:04:15 +00:00
else if ( rProp [ i ] . Name . equalsAscii ( ITEM_DESCRIPTOR_HELPURL ) )
rProp [ i ] . Value > > = rHelpURL ;
2009-11-18 11:25:15 +00:00
else if ( rProp [ i ] . Name . equalsAscii ( ITEM_DESCRIPTOR_TOOLTIP ) )
rProp [ i ] . Value > > = rTooltip ;
2004-07-06 16:04:15 +00:00
else if ( rProp [ i ] . Name . equalsAscii ( ITEM_DESCRIPTOR_LABEL ) )
rProp [ i ] . Value > > = rLabel ;
else if ( rProp [ i ] . Name . equalsAscii ( ITEM_DESCRIPTOR_TYPE ) )
rProp [ i ] . Value > > = rType ;
else if ( rProp [ i ] . Name . equalsAscii ( ITEM_DESCRIPTOR_VISIBLE ) )
rProp [ i ] . Value > > = rVisible ;
2004-11-16 13:57:26 +00:00
else if ( rProp [ i ] . Name . equalsAscii ( ITEM_DESCRIPTOR_WIDTH ) )
rProp [ i ] . Value > > = rWidth ;
2009-11-18 11:25:15 +00:00
else if ( rProp [ i ] . Name . equalsAscii ( ITEM_DESCRIPTOR_STYLE ) )
rProp [ i ] . Value > > = rStyle ;
2004-07-06 16:04:15 +00:00
}
}
2009-11-18 11:25:15 +00:00
struct ToolboxStyleItem
{
sal_Int16 nBit ;
const char * attrName ;
} ;
ToolboxStyleItem Styles [ ] = {
{ : : com : : sun : : star : : ui : : ItemStyle : : RADIO_CHECK , ATTRIBUTE_ITEMSTYLE_RADIO } ,
{ : : com : : sun : : star : : ui : : ItemStyle : : ALIGN_LEFT , ATTRIBUTE_ITEMSTYLE_LEFT } ,
{ : : com : : sun : : star : : ui : : ItemStyle : : AUTO_SIZE , ATTRIBUTE_ITEMSTYLE_AUTO } ,
{ : : com : : sun : : star : : ui : : ItemStyle : : REPEAT , ATTRIBUTE_ITEMSTYLE_REPEAT } ,
{ : : com : : sun : : star : : ui : : ItemStyle : : DROPDOWN_ONLY , ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY } ,
{ : : com : : sun : : star : : ui : : ItemStyle : : DROP_DOWN , ATTRIBUTE_ITEMSTYLE_DROPDOWN } ,
{ : : com : : sun : : star : : ui : : ItemStyle : : ICON , ATTRIBUTE_ITEMSTYLE_IMAGE } ,
{ : : com : : sun : : star : : ui : : ItemStyle : : TEXT , ATTRIBUTE_ITEMSTYLE_TEXT } ,
} ;
2010-10-14 21:14:52 +01:00
sal_Int32 nStyleItemEntries = SAL_N_ELEMENTS ( Styles ) ;
2009-11-18 11:25:15 +00:00
2004-02-25 16:55:57 +00:00
struct ToolBarEntryProperty
{
OReadToolBoxDocumentHandler : : ToolBox_XML_Namespace nNamespace ;
char aEntryName [ 20 ] ;
} ;
ToolBarEntryProperty ToolBoxEntries [ OReadToolBoxDocumentHandler : : TB_XML_ENTRY_COUNT ] =
{
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ELEMENT_TOOLBAR } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ELEMENT_TOOLBARITEM } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ELEMENT_TOOLBARSPACE } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ELEMENT_TOOLBARBREAK } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ELEMENT_TOOLBARSEPARATOR } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_TEXT } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_BITMAP } ,
{ OReadToolBoxDocumentHandler : : TB_NS_XLINK , ATTRIBUTE_URL } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_ITEMBITS } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_VISIBLE } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_WIDTH } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_USER } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_HELPID } ,
2004-07-06 16:04:15 +00:00
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_ITEMSTYLE } ,
2009-11-18 11:25:15 +00:00
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_UINAME } ,
{ OReadToolBoxDocumentHandler : : TB_NS_TOOLBAR , ATTRIBUTE_TOOLTIP } ,
2004-02-25 16:55:57 +00:00
} ;
2004-07-06 16:04:15 +00:00
OReadToolBoxDocumentHandler : : OReadToolBoxDocumentHandler ( const Reference < XIndexContainer > & rItemContainer ) :
ThreadHelpBase ( & Application : : GetSolarMutex ( ) ) ,
2006-10-13 08:43:49 +00:00
m_rItemContainer ( rItemContainer ) ,
m_aType ( RTL_CONSTASCII_USTRINGPARAM ( ITEM_DESCRIPTOR_TYPE ) ) ,
m_aLabel ( RTL_CONSTASCII_USTRINGPARAM ( ITEM_DESCRIPTOR_LABEL ) ) ,
m_aStyle ( RTL_CONSTASCII_USTRINGPARAM ( ITEM_DESCRIPTOR_STYLE ) ) ,
m_aHelpURL ( RTL_CONSTASCII_USTRINGPARAM ( ITEM_DESCRIPTOR_HELPURL ) ) ,
2009-11-18 11:25:15 +00:00
m_aTooltip ( RTL_CONSTASCII_USTRINGPARAM ( ITEM_DESCRIPTOR_TOOLTIP ) ) ,
2006-10-13 08:43:49 +00:00
m_aIsVisible ( RTL_CONSTASCII_USTRINGPARAM ( ITEM_DESCRIPTOR_VISIBLE ) ) ,
m_aCommandURL ( RTL_CONSTASCII_USTRINGPARAM ( ITEM_DESCRIPTOR_COMMANDURL ) )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aNamespaceToolBar ( RTL_CONSTASCII_USTRINGPARAM ( XMLNS_TOOLBAR ) ) ;
: : rtl : : OUString aNamespaceXLink ( RTL_CONSTASCII_USTRINGPARAM ( XMLNS_XLINK ) ) ;
: : rtl : : OUString aSeparator ( RTL_CONSTASCII_USTRINGPARAM ( XMLNS_FILTER_SEPARATOR ) ) ;
2004-02-25 16:55:57 +00:00
// create hash map
2005-07-12 13:16:31 +00:00
for ( int i = 0 ; i < ( int ) TB_XML_ENTRY_COUNT ; i + + )
2004-02-25 16:55:57 +00:00
{
if ( ToolBoxEntries [ i ] . nNamespace = = TB_NS_TOOLBAR )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString temp ( aNamespaceToolBar ) ;
2004-02-25 16:55:57 +00:00
temp + = aSeparator ;
2008-06-24 16:07:34 +00:00
temp + = : : rtl : : OUString : : createFromAscii ( ToolBoxEntries [ i ] . aEntryName ) ;
2004-02-25 16:55:57 +00:00
m_aToolBoxMap . insert ( ToolBoxHashMap : : value_type ( temp , ( ToolBox_XML_Entry ) i ) ) ;
}
else
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString temp ( aNamespaceXLink ) ;
2004-02-25 16:55:57 +00:00
temp + = aSeparator ;
2008-06-24 16:07:34 +00:00
temp + = : : rtl : : OUString : : createFromAscii ( ToolBoxEntries [ i ] . aEntryName ) ;
2004-02-25 16:55:57 +00:00
m_aToolBoxMap . insert ( ToolBoxHashMap : : value_type ( temp , ( ToolBox_XML_Entry ) i ) ) ;
}
}
// pre-calculate a hash code for all style strings to speed up xml read process
2010-11-20 14:10:32 +01:00
m_nHashCode_Style_Radio = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE_RADIO ) ) . hashCode ( ) ;
m_nHashCode_Style_Auto = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE_AUTO ) ) . hashCode ( ) ;
m_nHashCode_Style_Left = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE_LEFT ) ) . hashCode ( ) ;
m_nHashCode_Style_AutoSize = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE_AUTOSIZE ) ) . hashCode ( ) ;
m_nHashCode_Style_DropDown = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE_DROPDOWN ) ) . hashCode ( ) ;
m_nHashCode_Style_Repeat = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE_REPEAT ) ) . hashCode ( ) ;
m_nHashCode_Style_DropDownOnly = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE_DROPDOWNONLY ) ) . hashCode ( ) ;
m_nHashCode_Style_Text = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE_TEXT ) ) . hashCode ( ) ;
m_nHashCode_Style_Image = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE_IMAGE ) ) . hashCode ( ) ;
2004-02-25 16:55:57 +00:00
m_bToolBarStartFound = sal_False ;
m_bToolBarEndFound = sal_False ;
m_bToolBarItemStartFound = sal_False ;
m_bToolBarSpaceStartFound = sal_False ;
m_bToolBarBreakStartFound = sal_False ;
m_bToolBarSeparatorStartFound = sal_False ;
}
OReadToolBoxDocumentHandler : : ~ OReadToolBoxDocumentHandler ( )
{
}
// XDocumentHandler
void SAL_CALL OReadToolBoxDocumentHandler : : startDocument ( void )
throw ( SAXException , RuntimeException )
{
}
void SAL_CALL OReadToolBoxDocumentHandler : : endDocument ( void )
throw ( SAXException , RuntimeException )
{
ResetableGuard aGuard ( m_aLock ) ;
if ( ( m_bToolBarStartFound & & ! m_bToolBarEndFound ) | |
( ! m_bToolBarStartFound & & m_bToolBarEndFound ) )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " No matching start or end element 'toolbar' found! " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
}
void SAL_CALL OReadToolBoxDocumentHandler : : startElement (
2008-06-24 16:07:34 +00:00
const : : rtl : : OUString & aName , const Reference < XAttributeList > & xAttribs )
2004-02-25 16:55:57 +00:00
throw ( SAXException , RuntimeException )
{
ResetableGuard aGuard ( m_aLock ) ;
ToolBoxHashMap : : const_iterator pToolBoxEntry = m_aToolBoxMap . find ( aName ) ;
if ( pToolBoxEntry ! = m_aToolBoxMap . end ( ) )
{
switch ( pToolBoxEntry - > second )
{
case TB_ELEMENT_TOOLBAR :
{
if ( m_bToolBarStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Element 'toolbar:toolbar' cannot be embeded into 'toolbar:toolbar'! " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
2006-06-19 10:47:28 +00:00
else
{
// Check if we have a UI name set in our XML file
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aUIName ;
2006-10-12 09:45:09 +00:00
for ( sal_Int16 n = 0 ; n < xAttribs - > getLength ( ) ; n + + )
2006-06-19 10:47:28 +00:00
{
2004-07-06 16:04:15 +00:00
pToolBoxEntry = m_aToolBoxMap . find ( xAttribs - > getNameByIndex ( n ) ) ;
if ( pToolBoxEntry ! = m_aToolBoxMap . end ( ) )
{
2006-06-19 10:47:28 +00:00
switch ( pToolBoxEntry - > second )
{
case TB_ATTRIBUTE_UINAME :
2004-07-06 16:04:15 +00:00
aUIName = xAttribs - > getValueByIndex ( n ) ;
2006-06-19 10:47:28 +00:00
break ;
default :
break ;
}
}
2004-07-06 16:04:15 +00:00
}
2006-06-19 10:47:28 +00:00
if ( aUIName . getLength ( ) > 0 )
2004-07-06 16:04:15 +00:00
{
2006-06-19 10:47:28 +00:00
// Try to set UI name as a container property
Reference < XPropertySet > xPropSet ( m_rItemContainer , UNO_QUERY ) ;
if ( xPropSet . is ( ) )
{
try
{
2008-06-24 16:07:34 +00:00
xPropSet - > setPropertyValue ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " UIName " ) ) , makeAny ( aUIName ) ) ;
2006-06-19 10:47:28 +00:00
}
catch ( UnknownPropertyException & )
{
}
}
2004-07-06 16:04:15 +00:00
}
}
2004-02-25 16:55:57 +00:00
m_bToolBarStartFound = sal_True ;
}
break ;
case TB_ELEMENT_TOOLBARITEM :
{
if ( ! m_bToolBarStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Element 'toolbar:toolbaritem' must be embeded into element 'toolbar:toolbar'! " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
if ( m_bToolBarSeparatorStartFound | |
m_bToolBarBreakStartFound | |
m_bToolBarSpaceStartFound | |
m_bToolBarItemStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Element toolbar:toolbaritem is not a container! " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aAttribute ;
2004-02-25 16:55:57 +00:00
sal_Bool bAttributeURL = sal_False ;
m_bToolBarItemStartFound = sal_True ;
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aLabel ;
: : rtl : : OUString aCommandURL ;
: : rtl : : OUString aHelpURL ;
2009-11-18 11:25:15 +00:00
: : rtl : : OUString aTooltip ;
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aBitmapName ;
2004-07-06 16:04:15 +00:00
sal_uInt16 nItemBits ( 0 ) ;
sal_Bool bVisible ( sal_True ) ;
2004-02-25 16:55:57 +00:00
2006-10-12 09:45:09 +00:00
for ( sal_Int16 n = 0 ; n < xAttribs - > getLength ( ) ; n + + )
2004-02-25 16:55:57 +00:00
{
pToolBoxEntry = m_aToolBoxMap . find ( xAttribs - > getNameByIndex ( n ) ) ;
if ( pToolBoxEntry ! = m_aToolBoxMap . end ( ) )
{
switch ( pToolBoxEntry - > second )
{
case TB_ATTRIBUTE_TEXT :
{
2004-07-06 16:04:15 +00:00
aLabel = xAttribs - > getValueByIndex ( n ) ;
2004-02-25 16:55:57 +00:00
}
break ;
case TB_ATTRIBUTE_BITMAP :
{
2004-07-06 16:04:15 +00:00
aBitmapName = xAttribs - > getValueByIndex ( n ) ;
2004-02-25 16:55:57 +00:00
}
break ;
case TB_ATTRIBUTE_URL :
{
bAttributeURL = sal_True ;
2007-04-03 12:51:15 +00:00
aCommandURL = xAttribs - > getValueByIndex ( n ) . intern ( ) ;
2004-02-25 16:55:57 +00:00
}
break ;
case TB_ATTRIBUTE_ITEMBITS :
{
2010-11-05 10:31:15 +08:00
nItemBits = ( sal_uInt16 ) ( xAttribs - > getValueByIndex ( n ) . toInt32 ( ) ) ;
2004-02-25 16:55:57 +00:00
}
break ;
case TB_ATTRIBUTE_VISIBLE :
{
if ( xAttribs - > getValueByIndex ( n ) . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( ATTRIBUTE_BOOLEAN_TRUE ) ) )
2004-07-06 16:04:15 +00:00
bVisible = sal_True ;
2004-02-25 16:55:57 +00:00
else if ( xAttribs - > getValueByIndex ( n ) . equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( ATTRIBUTE_BOOLEAN_FALSE ) ) )
2004-07-06 16:04:15 +00:00
bVisible = sal_False ;
2004-02-25 16:55:57 +00:00
else
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Attribute toolbar:visible must have value 'true' or 'false'! " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
}
break ;
case TB_ATTRIBUTE_HELPID :
{
2004-07-06 16:04:15 +00:00
aHelpURL = xAttribs - > getValueByIndex ( n ) ;
2004-02-25 16:55:57 +00:00
}
break ;
2009-11-18 11:25:15 +00:00
case TB_ATTRIBUTE_TOOLTIP :
{
aTooltip = xAttribs - > getValueByIndex ( n ) ;
}
break ;
2004-02-25 16:55:57 +00:00
case TB_ATTRIBUTE_STYLE :
{
// read space seperated item style list
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aTemp = xAttribs - > getValueByIndex ( n ) ;
2004-02-25 16:55:57 +00:00
sal_Int32 nIndex = 0 ;
do
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aToken = aTemp . getToken ( 0 , ' ' , nIndex ) ;
2004-02-25 16:55:57 +00:00
if ( aToken . getLength ( ) > 0 )
{
sal_Int32 nHashCode = aToken . hashCode ( ) ;
if ( nHashCode = = m_nHashCode_Style_Radio )
2005-03-01 18:48:44 +00:00
nItemBits | = : : com : : sun : : star : : ui : : ItemStyle : : RADIO_CHECK ;
2004-02-25 16:55:57 +00:00
else if ( nHashCode = = m_nHashCode_Style_Left )
2005-03-01 18:48:44 +00:00
nItemBits | = : : com : : sun : : star : : ui : : ItemStyle : : ALIGN_LEFT ;
2004-02-25 16:55:57 +00:00
else if ( nHashCode = = m_nHashCode_Style_AutoSize )
2005-03-01 18:48:44 +00:00
nItemBits | = : : com : : sun : : star : : ui : : ItemStyle : : AUTO_SIZE ;
2004-02-25 16:55:57 +00:00
else if ( nHashCode = = m_nHashCode_Style_DropDown )
2005-03-01 18:48:44 +00:00
nItemBits | = : : com : : sun : : star : : ui : : ItemStyle : : DROP_DOWN ;
2004-02-25 16:55:57 +00:00
else if ( nHashCode = = m_nHashCode_Style_Repeat )
2005-03-01 18:48:44 +00:00
nItemBits | = : : com : : sun : : star : : ui : : ItemStyle : : REPEAT ;
2005-03-15 08:35:29 +00:00
else if ( nHashCode = = m_nHashCode_Style_DropDownOnly )
nItemBits | = : : com : : sun : : star : : ui : : ItemStyle : : DROPDOWN_ONLY ;
2009-11-18 11:25:15 +00:00
else if ( nHashCode = = m_nHashCode_Style_DropDown )
nItemBits | = : : com : : sun : : star : : ui : : ItemStyle : : DROP_DOWN ;
else if ( nHashCode = = m_nHashCode_Style_Text )
nItemBits | = : : com : : sun : : star : : ui : : ItemStyle : : TEXT ;
else if ( nHashCode = = m_nHashCode_Style_Image )
nItemBits | = : : com : : sun : : star : : ui : : ItemStyle : : ICON ;
2004-02-25 16:55:57 +00:00
}
}
while ( nIndex > = 0 ) ;
}
break ;
2011-02-14 08:50:22 +00:00
case TB_ATTRIBUTE_USER :
case TB_ATTRIBUTE_WIDTH :
default :
break ;
2004-02-25 16:55:57 +00:00
}
}
} // for
if ( ! bAttributeURL )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Required attribute toolbar:url must have a value! " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
2004-07-06 16:04:15 +00:00
if ( aCommandURL . getLength ( ) > 0 )
{
2009-11-18 11:25:15 +00:00
Sequence < PropertyValue > aToolbarItemProp ( 7 ) ;
2006-10-13 08:43:49 +00:00
aToolbarItemProp [ 0 ] . Name = m_aCommandURL ;
aToolbarItemProp [ 1 ] . Name = m_aHelpURL ;
aToolbarItemProp [ 2 ] . Name = m_aLabel ;
aToolbarItemProp [ 3 ] . Name = m_aType ;
aToolbarItemProp [ 4 ] . Name = m_aStyle ;
aToolbarItemProp [ 5 ] . Name = m_aIsVisible ;
2009-11-18 11:25:15 +00:00
aToolbarItemProp [ 6 ] . Name = m_aTooltip ;
2004-07-06 16:04:15 +00:00
2009-09-08 04:57:32 +00:00
aToolbarItemProp [ 0 ] . Value < < = aCommandURL ;
aToolbarItemProp [ 1 ] . Value < < = aHelpURL ;
aToolbarItemProp [ 2 ] . Value < < = aLabel ;
2005-03-01 18:48:44 +00:00
aToolbarItemProp [ 3 ] . Value = makeAny ( : : com : : sun : : star : : ui : : ItemType : : DEFAULT ) ;
2009-09-08 04:57:32 +00:00
aToolbarItemProp [ 4 ] . Value < < = nItemBits ;
aToolbarItemProp [ 5 ] . Value < < = bVisible ;
2009-11-18 11:25:15 +00:00
aToolbarItemProp [ 6 ] . Value < < = aTooltip ;
2004-07-06 16:04:15 +00:00
m_rItemContainer - > insertByIndex ( m_rItemContainer - > getCount ( ) , makeAny ( aToolbarItemProp ) ) ;
}
2004-02-25 16:55:57 +00:00
}
break ;
case TB_ELEMENT_TOOLBARSPACE :
{
if ( m_bToolBarSeparatorStartFound | |
m_bToolBarBreakStartFound | |
m_bToolBarSpaceStartFound | |
m_bToolBarItemStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Element toolbar:toolbarspace is not a container! " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
m_bToolBarSpaceStartFound = sal_True ;
2004-07-06 16:04:15 +00:00
Sequence < PropertyValue > aToolbarItemProp ( 2 ) ;
2006-10-13 08:43:49 +00:00
aToolbarItemProp [ 0 ] . Name = m_aCommandURL ;
aToolbarItemProp [ 1 ] . Name = m_aType ;
2004-07-06 16:04:15 +00:00
aToolbarItemProp [ 0 ] . Value < < = rtl : : OUString ( ) ;
2005-03-01 18:48:44 +00:00
aToolbarItemProp [ 1 ] . Value < < = : : com : : sun : : star : : ui : : ItemType : : SEPARATOR_SPACE ;
2004-07-06 16:04:15 +00:00
m_rItemContainer - > insertByIndex ( m_rItemContainer - > getCount ( ) , makeAny ( aToolbarItemProp ) ) ;
2004-02-25 16:55:57 +00:00
}
break ;
case TB_ELEMENT_TOOLBARBREAK :
{
if ( m_bToolBarSeparatorStartFound | |
m_bToolBarBreakStartFound | |
m_bToolBarSpaceStartFound | |
m_bToolBarItemStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Element toolbar:toolbarbreak is not a container! " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
m_bToolBarBreakStartFound = sal_True ;
2004-07-06 16:04:15 +00:00
Sequence < PropertyValue > aToolbarItemProp ( 2 ) ;
2006-10-13 08:43:49 +00:00
aToolbarItemProp [ 0 ] . Name = m_aCommandURL ;
aToolbarItemProp [ 1 ] . Name = m_aType ;
2004-07-06 16:04:15 +00:00
aToolbarItemProp [ 0 ] . Value < < = rtl : : OUString ( ) ;
2005-03-01 18:48:44 +00:00
aToolbarItemProp [ 1 ] . Value < < = : : com : : sun : : star : : ui : : ItemType : : SEPARATOR_LINEBREAK ;
2004-07-06 16:04:15 +00:00
m_rItemContainer - > insertByIndex ( m_rItemContainer - > getCount ( ) , makeAny ( aToolbarItemProp ) ) ;
2004-02-25 16:55:57 +00:00
}
break ;
case TB_ELEMENT_TOOLBARSEPARATOR :
{
if ( m_bToolBarSeparatorStartFound | |
m_bToolBarBreakStartFound | |
m_bToolBarSpaceStartFound | |
m_bToolBarItemStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " Element toolbar:toolbarseparator is not a container! " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
m_bToolBarSeparatorStartFound = sal_True ;
2004-07-06 16:04:15 +00:00
Sequence < PropertyValue > aToolbarItemProp ( 2 ) ;
2006-10-13 08:43:49 +00:00
aToolbarItemProp [ 0 ] . Name = m_aCommandURL ;
aToolbarItemProp [ 1 ] . Name = m_aType ;
2004-07-06 16:04:15 +00:00
aToolbarItemProp [ 0 ] . Value < < = rtl : : OUString ( ) ;
2005-03-01 18:48:44 +00:00
aToolbarItemProp [ 1 ] . Value < < = : : com : : sun : : star : : ui : : ItemType : : SEPARATOR_LINE ;
2004-07-06 16:04:15 +00:00
m_rItemContainer - > insertByIndex ( m_rItemContainer - > getCount ( ) , makeAny ( aToolbarItemProp ) ) ;
2004-02-25 16:55:57 +00:00
}
break ;
2006-06-19 10:47:28 +00:00
default :
break ;
2004-02-25 16:55:57 +00:00
}
}
}
2008-06-24 16:07:34 +00:00
void SAL_CALL OReadToolBoxDocumentHandler : : endElement ( const : : rtl : : OUString & aName )
2004-02-25 16:55:57 +00:00
throw ( SAXException , RuntimeException )
{
ResetableGuard aGuard ( m_aLock ) ;
ToolBoxHashMap : : const_iterator pToolBoxEntry = m_aToolBoxMap . find ( aName ) ;
if ( pToolBoxEntry ! = m_aToolBoxMap . end ( ) )
{
switch ( pToolBoxEntry - > second )
{
case TB_ELEMENT_TOOLBAR :
{
if ( ! m_bToolBarStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " End element 'toolbar' found, but no start element 'toolbar' " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
m_bToolBarStartFound = sal_False ;
}
break ;
case TB_ELEMENT_TOOLBARITEM :
{
if ( ! m_bToolBarItemStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " End element 'toolbar:toolbaritem' found, but no start element 'toolbar:toolbaritem' " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
m_bToolBarItemStartFound = sal_False ;
}
break ;
case TB_ELEMENT_TOOLBARBREAK :
{
if ( ! m_bToolBarBreakStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " End element 'toolbar:toolbarbreak' found, but no start element 'toolbar:toolbarbreak' " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
m_bToolBarBreakStartFound = sal_False ;
}
break ;
case TB_ELEMENT_TOOLBARSPACE :
{
if ( ! m_bToolBarSpaceStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " End element 'toolbar:toolbarspace' found, but no start element 'toolbar:toolbarspace' " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
m_bToolBarSpaceStartFound = sal_False ;
}
break ;
case TB_ELEMENT_TOOLBARSEPARATOR :
{
if ( ! m_bToolBarSeparatorStartFound )
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aErrorMessage = getErrorLineString ( ) ;
aErrorMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " End element 'toolbar:toolbarseparator' found, but no start element 'toolbar:toolbarseparator' " ) ) ;
2004-02-25 16:55:57 +00:00
throw SAXException ( aErrorMessage , Reference < XInterface > ( ) , Any ( ) ) ;
}
m_bToolBarSeparatorStartFound = sal_False ;
}
break ;
2006-06-19 10:47:28 +00:00
default :
break ;
2004-02-25 16:55:57 +00:00
}
}
}
2008-06-24 16:07:34 +00:00
void SAL_CALL OReadToolBoxDocumentHandler : : characters ( const : : rtl : : OUString & )
2004-02-25 16:55:57 +00:00
throw ( SAXException , RuntimeException )
{
}
2008-06-24 16:07:34 +00:00
void SAL_CALL OReadToolBoxDocumentHandler : : ignorableWhitespace ( const : : rtl : : OUString & )
2004-02-25 16:55:57 +00:00
throw ( SAXException , RuntimeException )
{
}
void SAL_CALL OReadToolBoxDocumentHandler : : processingInstruction (
2008-06-24 16:07:34 +00:00
const : : rtl : : OUString & /*aTarget*/ , const : : rtl : : OUString & /*aData*/ )
2004-02-25 16:55:57 +00:00
throw ( SAXException , RuntimeException )
{
}
void SAL_CALL OReadToolBoxDocumentHandler : : setDocumentLocator (
const Reference < XLocator > & xLocator )
throw ( SAXException , RuntimeException )
{
ResetableGuard aGuard ( m_aLock ) ;
m_xLocator = xLocator ;
}
: : rtl : : OUString OReadToolBoxDocumentHandler : : getErrorLineString ( )
{
ResetableGuard aGuard ( m_aLock ) ;
char buffer [ 32 ] ;
if ( m_xLocator . is ( ) )
{
2008-01-04 15:24:40 +00:00
snprintf ( buffer , sizeof ( buffer ) , " Line: %ld - " , static_cast < long > ( m_xLocator - > getLineNumber ( ) ) ) ;
2008-06-24 16:07:34 +00:00
return : : rtl : : OUString : : createFromAscii ( buffer ) ;
2004-02-25 16:55:57 +00:00
}
else
2008-06-24 16:07:34 +00:00
return : : rtl : : OUString ( ) ;
2004-02-25 16:55:57 +00:00
}
//_________________________________________________________________________________________________________________
// OWriteToolBoxDocumentHandler
//_________________________________________________________________________________________________________________
OWriteToolBoxDocumentHandler : : OWriteToolBoxDocumentHandler (
2004-07-06 16:04:15 +00:00
const Reference < XIndexAccess > & rItemAccess ,
Reference < XDocumentHandler > & rWriteDocumentHandler ) :
2004-02-25 16:55:57 +00:00
ThreadHelpBase ( & Application : : GetSolarMutex ( ) ) ,
2006-06-19 10:47:28 +00:00
m_xWriteDocumentHandler ( rWriteDocumentHandler ) ,
m_rItemAccess ( rItemAccess )
2004-02-25 16:55:57 +00:00
{
INTEGRATION: CWS xmlfix2 (1.14.50); FILE MERGED
2008/05/15 17:21:04 mst 1.14.50.2: RESYNC: (1.14-1.15); FILE MERGED
2008/03/31 15:32:49 mst 1.14.50.1: remove duplicated XAttributeList implementations
- framework/inc/services/attributelist.hxx,
framework/source/services/attributelist.cxx,
framework/inc/xml/attributelist.hxx,
framework/source/xml/attributelist.cxx:
+ removed
- framework/source/xml/makefile.mk, framework/util/makefile.mk:
+ remove attributelist.cxx
- framework/source/xml/{acceleratorconfigurationwriter.cxx,
eventsdocumenthandler.cxx,imagesdocumenthandler.cxx,
menudocumenthandler.cxx,saxnamespacefilter.cxx,
statusbardocumenthandler.cxx,toolboxdocumenthandler.cxx,
toolboxlayoutdocumenthandler.cxx}
+ use comphelper/attributelist.hxx
2008-06-06 11:02:25 +00:00
: : comphelper : : AttributeList * pList = new : : comphelper : : AttributeList ;
m_xEmptyList = Reference < XAttributeList > ( ( XAttributeList * ) pList , UNO_QUERY ) ;
2008-06-24 16:07:34 +00:00
m_aAttributeType = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_TYPE_CDATA ) ) ;
m_aXMLXlinkNS = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( XMLNS_XLINK_PREFIX ) ) ;
m_aXMLToolbarNS = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( XMLNS_TOOLBAR_PREFIX ) ) ;
2004-02-25 16:55:57 +00:00
}
OWriteToolBoxDocumentHandler : : ~ OWriteToolBoxDocumentHandler ( )
{
}
void OWriteToolBoxDocumentHandler : : WriteToolBoxDocument ( ) throw
( SAXException , RuntimeException )
{
ResetableGuard aGuard ( m_aLock ) ;
m_xWriteDocumentHandler - > startDocument ( ) ;
// write DOCTYPE line!
Reference < XExtendedDocumentHandler > xExtendedDocHandler ( m_xWriteDocumentHandler , UNO_QUERY ) ;
if ( xExtendedDocHandler . is ( ) )
{
2008-06-24 16:07:34 +00:00
xExtendedDocHandler - > unknown ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( TOOLBAR_DOCTYPE ) ) ) ;
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
2004-02-25 16:55:57 +00:00
}
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aUIName ;
2004-07-06 16:04:15 +00:00
Reference < XPropertySet > xPropSet ( m_rItemAccess , UNO_QUERY ) ;
if ( xPropSet . is ( ) )
{
try
{
2009-09-08 04:57:32 +00:00
xPropSet - > getPropertyValue ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " UIName " ) ) ) > > = aUIName ;
2004-07-06 16:04:15 +00:00
}
catch ( UnknownPropertyException & )
{
}
}
INTEGRATION: CWS xmlfix2 (1.14.50); FILE MERGED
2008/05/15 17:21:04 mst 1.14.50.2: RESYNC: (1.14-1.15); FILE MERGED
2008/03/31 15:32:49 mst 1.14.50.1: remove duplicated XAttributeList implementations
- framework/inc/services/attributelist.hxx,
framework/source/services/attributelist.cxx,
framework/inc/xml/attributelist.hxx,
framework/source/xml/attributelist.cxx:
+ removed
- framework/source/xml/makefile.mk, framework/util/makefile.mk:
+ remove attributelist.cxx
- framework/source/xml/{acceleratorconfigurationwriter.cxx,
eventsdocumenthandler.cxx,imagesdocumenthandler.cxx,
menudocumenthandler.cxx,saxnamespacefilter.cxx,
statusbardocumenthandler.cxx,toolboxdocumenthandler.cxx,
toolboxlayoutdocumenthandler.cxx}
+ use comphelper/attributelist.hxx
2008-06-06 11:02:25 +00:00
: : comphelper : : AttributeList * pList = new : : comphelper : : AttributeList ;
2004-02-25 16:55:57 +00:00
Reference < XAttributeList > xList ( ( XAttributeList * ) pList , UNO_QUERY ) ;
2008-06-24 16:07:34 +00:00
pList - > AddAttribute ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_XMLNS_TOOLBAR ) ) ,
2004-02-25 16:55:57 +00:00
m_aAttributeType ,
2008-06-24 16:07:34 +00:00
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( XMLNS_TOOLBAR ) ) ) ;
2004-02-25 16:55:57 +00:00
2008-06-24 16:07:34 +00:00
pList - > AddAttribute ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_XMLNS_XLINK ) ) ,
2004-02-25 16:55:57 +00:00
m_aAttributeType ,
2008-06-24 16:07:34 +00:00
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( XMLNS_XLINK ) ) ) ;
2004-02-25 16:55:57 +00:00
2004-07-06 16:04:15 +00:00
if ( aUIName . getLength ( ) > 0 )
2008-06-24 16:07:34 +00:00
pList - > AddAttribute ( m_aXMLToolbarNS + : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_UINAME ) ) ,
2004-07-06 16:04:15 +00:00
m_aAttributeType ,
aUIName ) ;
2008-06-24 16:07:34 +00:00
m_xWriteDocumentHandler - > startElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBAR ) ) , pList ) ;
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
2004-02-25 16:55:57 +00:00
2004-07-06 16:04:15 +00:00
sal_Int32 nItemCount = m_rItemAccess - > getCount ( ) ;
Any aAny ;
for ( sal_Int32 nItemPos = 0 ; nItemPos < nItemCount ; nItemPos + + )
2004-02-25 16:55:57 +00:00
{
2004-07-06 16:04:15 +00:00
Sequence < PropertyValue > aProps ;
aAny = m_rItemAccess - > getByIndex ( nItemPos ) ;
if ( aAny > > = aProps )
2004-02-25 16:55:57 +00:00
{
2008-06-24 16:07:34 +00:00
: : rtl : : OUString aCommandURL ;
: : rtl : : OUString aLabel ;
: : rtl : : OUString aHelpURL ;
2009-11-18 11:25:15 +00:00
: : rtl : : OUString aTooltip ;
2004-07-06 16:04:15 +00:00
sal_Bool bVisible ( sal_True ) ;
2005-03-01 18:48:44 +00:00
sal_Int16 nType ( : : com : : sun : : star : : ui : : ItemType : : DEFAULT ) ;
2004-11-16 13:57:26 +00:00
sal_Int16 nWidth ( 0 ) ;
2009-11-18 11:25:15 +00:00
sal_Int16 nStyle ( 0 ) ;
2004-07-06 16:04:15 +00:00
2009-11-18 11:25:15 +00:00
ExtractToolbarParameters ( aProps , aCommandURL , aLabel , aHelpURL , aTooltip , nStyle , nWidth , bVisible , nType ) ;
2005-03-01 18:48:44 +00:00
if ( nType = = : : com : : sun : : star : : ui : : ItemType : : DEFAULT )
2009-11-18 11:25:15 +00:00
WriteToolBoxItem ( aCommandURL , aLabel , aHelpURL , aTooltip , nStyle , nWidth , bVisible ) ;
2005-03-01 18:48:44 +00:00
else if ( nType = = : : com : : sun : : star : : ui : : ItemType : : SEPARATOR_SPACE )
2004-02-25 16:55:57 +00:00
WriteToolBoxSpace ( ) ;
2005-03-01 18:48:44 +00:00
else if ( nType = = : : com : : sun : : star : : ui : : ItemType : : SEPARATOR_LINE )
2004-02-25 16:55:57 +00:00
WriteToolBoxSeparator ( ) ;
2005-03-01 18:48:44 +00:00
else if ( nType = = : : com : : sun : : star : : ui : : ItemType : : SEPARATOR_LINEBREAK )
2004-02-25 16:55:57 +00:00
WriteToolBoxBreak ( ) ;
}
}
2008-06-24 16:07:34 +00:00
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
m_xWriteDocumentHandler - > endElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBAR ) ) ) ;
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
2004-02-25 16:55:57 +00:00
m_xWriteDocumentHandler - > endDocument ( ) ;
}
//_________________________________________________________________________________________________________________
// protected member functions
//_________________________________________________________________________________________________________________
2004-07-06 16:04:15 +00:00
void OWriteToolBoxDocumentHandler : : WriteToolBoxItem (
2008-06-24 16:07:34 +00:00
const : : rtl : : OUString & rCommandURL ,
const : : rtl : : OUString & rLabel ,
const : : rtl : : OUString & rHelpURL ,
2009-11-18 11:25:15 +00:00
const : : rtl : : OUString & rTooltip ,
sal_Int16 nStyle ,
2004-11-16 13:57:26 +00:00
sal_Int16 nWidth ,
2004-07-06 16:04:15 +00:00
sal_Bool bVisible )
throw ( SAXException , RuntimeException )
2004-02-25 16:55:57 +00:00
{
INTEGRATION: CWS xmlfix2 (1.14.50); FILE MERGED
2008/05/15 17:21:04 mst 1.14.50.2: RESYNC: (1.14-1.15); FILE MERGED
2008/03/31 15:32:49 mst 1.14.50.1: remove duplicated XAttributeList implementations
- framework/inc/services/attributelist.hxx,
framework/source/services/attributelist.cxx,
framework/inc/xml/attributelist.hxx,
framework/source/xml/attributelist.cxx:
+ removed
- framework/source/xml/makefile.mk, framework/util/makefile.mk:
+ remove attributelist.cxx
- framework/source/xml/{acceleratorconfigurationwriter.cxx,
eventsdocumenthandler.cxx,imagesdocumenthandler.cxx,
menudocumenthandler.cxx,saxnamespacefilter.cxx,
statusbardocumenthandler.cxx,toolboxdocumenthandler.cxx,
toolboxlayoutdocumenthandler.cxx}
+ use comphelper/attributelist.hxx
2008-06-06 11:02:25 +00:00
: : comphelper : : AttributeList * pList = new : : comphelper : : AttributeList ;
2004-02-25 16:55:57 +00:00
Reference < XAttributeList > xList ( ( XAttributeList * ) pList , UNO_QUERY ) ;
if ( m_aAttributeURL . getLength ( ) = = 0 )
{
m_aAttributeURL = m_aXMLXlinkNS ;
2008-06-24 16:07:34 +00:00
m_aAttributeURL + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_URL ) ) ;
2004-02-25 16:55:57 +00:00
}
// save required attribute (URL)
INTEGRATION: CWS xmlfix2 (1.14.50); FILE MERGED
2008/05/15 17:21:04 mst 1.14.50.2: RESYNC: (1.14-1.15); FILE MERGED
2008/03/31 15:32:49 mst 1.14.50.1: remove duplicated XAttributeList implementations
- framework/inc/services/attributelist.hxx,
framework/source/services/attributelist.cxx,
framework/inc/xml/attributelist.hxx,
framework/source/xml/attributelist.cxx:
+ removed
- framework/source/xml/makefile.mk, framework/util/makefile.mk:
+ remove attributelist.cxx
- framework/source/xml/{acceleratorconfigurationwriter.cxx,
eventsdocumenthandler.cxx,imagesdocumenthandler.cxx,
menudocumenthandler.cxx,saxnamespacefilter.cxx,
statusbardocumenthandler.cxx,toolboxdocumenthandler.cxx,
toolboxlayoutdocumenthandler.cxx}
+ use comphelper/attributelist.hxx
2008-06-06 11:02:25 +00:00
pList - > AddAttribute ( m_aAttributeURL , m_aAttributeType , rCommandURL ) ;
2004-02-25 16:55:57 +00:00
2004-07-06 16:04:15 +00:00
if ( rLabel . getLength ( ) > 0 )
2004-02-25 16:55:57 +00:00
{
2008-06-24 16:07:34 +00:00
pList - > AddAttribute ( m_aXMLToolbarNS + : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_TEXT ) ) ,
2004-02-25 16:55:57 +00:00
m_aAttributeType ,
2004-07-06 16:04:15 +00:00
rLabel ) ;
2004-02-25 16:55:57 +00:00
}
2004-07-06 16:04:15 +00:00
if ( bVisible = = sal_False )
2004-02-25 16:55:57 +00:00
{
2008-06-24 16:07:34 +00:00
pList - > AddAttribute ( m_aXMLToolbarNS + : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_VISIBLE ) ) ,
2004-02-25 16:55:57 +00:00
m_aAttributeType ,
2008-06-24 16:07:34 +00:00
: : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_BOOLEAN_FALSE ) ) ) ;
2004-02-25 16:55:57 +00:00
}
2004-07-06 16:04:15 +00:00
if ( rHelpURL . getLength ( ) > 0 )
2004-02-25 16:55:57 +00:00
{
2008-06-24 16:07:34 +00:00
pList - > AddAttribute ( m_aXMLToolbarNS + : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_HELPID ) ) ,
2004-02-25 16:55:57 +00:00
m_aAttributeType ,
2004-07-06 16:04:15 +00:00
rHelpURL ) ;
2004-02-25 16:55:57 +00:00
}
2009-11-18 11:25:15 +00:00
if ( rTooltip . getLength ( ) > 0 )
{
pList - > AddAttribute ( m_aXMLToolbarNS + : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_TOOLTIP ) ) ,
m_aAttributeType ,
rTooltip ) ;
}
if ( nStyle > 0 )
{
rtl : : OUString aValue ;
ToolboxStyleItem * pStyle = Styles ;
for ( sal_Int32 nIndex = 0 ; nIndex < nStyleItemEntries ; + + nIndex , + + pStyle )
{
if ( nStyle & pStyle - > nBit )
{
if ( aValue . getLength ( ) )
aValue = aValue . concat ( rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " " ) ) ) ;
aValue + = rtl : : OUString : : createFromAscii ( pStyle - > attrName ) ;
}
}
pList - > AddAttribute ( m_aXMLToolbarNS + : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_ITEMSTYLE ) ) ,
m_aAttributeType ,
aValue ) ;
}
2004-11-16 13:57:26 +00:00
if ( nWidth > 0 )
{
2008-06-24 16:07:34 +00:00
pList - > AddAttribute ( m_aXMLToolbarNS + : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ATTRIBUTE_WIDTH ) ) ,
2004-11-16 13:57:26 +00:00
m_aAttributeType ,
2008-06-24 16:07:34 +00:00
: : rtl : : OUString : : valueOf ( sal_Int32 ( nWidth ) ) ) ;
2004-11-16 13:57:26 +00:00
}
2008-06-24 16:07:34 +00:00
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
m_xWriteDocumentHandler - > startElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBARITEM ) ) , xList ) ;
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
m_xWriteDocumentHandler - > endElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBARITEM ) ) ) ;
2004-02-25 16:55:57 +00:00
}
void OWriteToolBoxDocumentHandler : : WriteToolBoxSpace ( ) throw
( SAXException , RuntimeException )
{
2008-06-24 16:07:34 +00:00
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
m_xWriteDocumentHandler - > startElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBARSPACE ) ) , m_xEmptyList ) ;
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
m_xWriteDocumentHandler - > endElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBARSPACE ) ) ) ;
2004-02-25 16:55:57 +00:00
}
void OWriteToolBoxDocumentHandler : : WriteToolBoxBreak ( ) throw
( SAXException , RuntimeException )
{
2008-06-24 16:07:34 +00:00
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
m_xWriteDocumentHandler - > startElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBARBREAK ) ) , m_xEmptyList ) ;
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
m_xWriteDocumentHandler - > endElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBARBREAK ) ) ) ;
2004-02-25 16:55:57 +00:00
}
void OWriteToolBoxDocumentHandler : : WriteToolBoxSeparator ( ) throw
( SAXException , RuntimeException )
{
2008-06-24 16:07:34 +00:00
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
m_xWriteDocumentHandler - > startElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBARSEPARATOR ) ) , m_xEmptyList ) ;
m_xWriteDocumentHandler - > ignorableWhitespace ( : : rtl : : OUString ( ) ) ;
m_xWriteDocumentHandler - > endElement ( : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( ELEMENT_NS_TOOLBARSEPARATOR ) ) ) ;
2004-02-25 16:55:57 +00:00
}
} // namespace framework
2008-06-24 16:07:34 +00:00
2010-10-12 15:53:47 +02:00
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */