xref: /AOO41X/main/framework/source/fwe/xml/statusbardocumenthandler.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <stdio.h>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir //	my own includes
35*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
38*cdf0e10cSrcweir #include <xml/statusbardocumenthandler.hxx>
39*cdf0e10cSrcweir #include <macros/debug.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
42*cdf0e10cSrcweir //	interface includes
43*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir #ifndef __COM_SUN_STAR_XML_SAX_XEXTENDEDDOCUMENTHANDLER_HPP_
46*cdf0e10cSrcweir #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
47*cdf0e10cSrcweir #endif
48*cdf0e10cSrcweir #include <com/sun/star/ui/ItemStyle.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/ui/ItemType.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
53*cdf0e10cSrcweir //	other includes
54*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
55*cdf0e10cSrcweir #include <vcl/svapp.hxx>
56*cdf0e10cSrcweir #include <vcl/status.hxx>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir #include <comphelper/attributelist.hxx>
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
61*cdf0e10cSrcweir //	namespace
62*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
65*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
66*cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
67*cdf0e10cSrcweir using namespace ::com::sun::star::ui;
68*cdf0e10cSrcweir using namespace ::com::sun::star::container;
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir #define XMLNS_STATUSBAR				"http://openoffice.org/2001/statusbar"
71*cdf0e10cSrcweir #define XMLNS_XLINK					"http://www.w3.org/1999/xlink"
72*cdf0e10cSrcweir #define XMLNS_STATUSBAR_PREFIX		"statusbar:"
73*cdf0e10cSrcweir #define XMLNS_XLINK_PREFIX			"xlink:"
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir #define XMLNS_FILTER_SEPARATOR		"^"
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir #define ELEMENT_STATUSBAR			"statusbar"
78*cdf0e10cSrcweir #define ELEMENT_STATUSBARITEM		"statusbaritem"
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir #define ATTRIBUTE_ALIGN				"align"
81*cdf0e10cSrcweir #define ATTRIBUTE_STYLE				"style"
82*cdf0e10cSrcweir #define ATTRIBUTE_URL				"href"
83*cdf0e10cSrcweir #define ATTRIBUTE_WIDTH				"width"
84*cdf0e10cSrcweir #define ATTRIBUTE_OFFSET			"offset"
85*cdf0e10cSrcweir #define ATTRIBUTE_AUTOSIZE			"autosize"
86*cdf0e10cSrcweir #define ATTRIBUTE_OWNERDRAW			"ownerdraw"
87*cdf0e10cSrcweir #define ATTRIBUTE_HELPURL           "helpid"
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir #define ELEMENT_NS_STATUSBAR		"statusbar:statusbar"
90*cdf0e10cSrcweir #define ELEMENT_NS_STATUSBARITEM	"statusbar:statusbaritem"
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir #define ATTRIBUTE_XMLNS_STATUSBAR	"xmlns:statusbar"
93*cdf0e10cSrcweir #define ATTRIBUTE_XMLNS_XLINK		"xmlns:xlink"
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir #define ATTRIBUTE_TYPE_CDATA		"CDATA"
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir #define ATTRIBUTE_BOOLEAN_TRUE		"true"
98*cdf0e10cSrcweir #define ATTRIBUTE_BOOLEAN_FALSE		"false"
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir #define ATTRIBUTE_ALIGN_LEFT		"left"
101*cdf0e10cSrcweir #define ATTRIBUTE_ALIGN_RIGHT		"right"
102*cdf0e10cSrcweir #define ATTRIBUTE_ALIGN_CENTER		"center"
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir #define ATTRIBUTE_STYLE_IN			"in"
105*cdf0e10cSrcweir #define ATTRIBUTE_STYLE_OUT			"out"
106*cdf0e10cSrcweir #define ATTRIBUTE_STYLE_FLAT		"flat"
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir #define STATUSBAR_DOCTYPE			"<!DOCTYPE statusbar:statusbar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"statusbar.dtd\">"
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir namespace framework
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir // Property names of a menu/menu item ItemDescriptor
114*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_COMMANDURL[]  = "CommandURL";
115*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_HELPURL[]     = "HelpURL";
116*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_OFFSET[]      = "Offset";
117*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_STYLE[]       = "Style";
118*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_WIDTH[]       = "Width";
119*cdf0e10cSrcweir static const char ITEM_DESCRIPTOR_TYPE[]        = "Type";
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir static void ExtractStatusbarItemParameters(
122*cdf0e10cSrcweir     const Sequence< PropertyValue > rProp,
123*cdf0e10cSrcweir     ::rtl::OUString&                       rCommandURL,
124*cdf0e10cSrcweir     ::rtl::OUString&                       rHelpURL,
125*cdf0e10cSrcweir     sal_Int16&                      rOffset,
126*cdf0e10cSrcweir     sal_Int16&                      rStyle,
127*cdf0e10cSrcweir     sal_Int16&                      rWidth )
128*cdf0e10cSrcweir {
129*cdf0e10cSrcweir     for ( sal_Int32 i = 0; i < rProp.getLength(); i++ )
130*cdf0e10cSrcweir     {
131*cdf0e10cSrcweir         if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_COMMANDURL ))
132*cdf0e10cSrcweir         {
133*cdf0e10cSrcweir             rProp[i].Value >>= rCommandURL;
134*cdf0e10cSrcweir             rCommandURL = rCommandURL.intern();
135*cdf0e10cSrcweir         }
136*cdf0e10cSrcweir         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_HELPURL ))
137*cdf0e10cSrcweir         {
138*cdf0e10cSrcweir             rProp[i].Value >>= rHelpURL;
139*cdf0e10cSrcweir         }
140*cdf0e10cSrcweir         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_OFFSET ))
141*cdf0e10cSrcweir         {
142*cdf0e10cSrcweir             rProp[i].Value >>= rOffset;
143*cdf0e10cSrcweir         }
144*cdf0e10cSrcweir         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_STYLE ))
145*cdf0e10cSrcweir         {
146*cdf0e10cSrcweir             rProp[i].Value >>= rStyle;
147*cdf0e10cSrcweir         }
148*cdf0e10cSrcweir         else if ( rProp[i].Name.equalsAscii( ITEM_DESCRIPTOR_WIDTH ))
149*cdf0e10cSrcweir         {
150*cdf0e10cSrcweir             rProp[i].Value >>= rWidth;
151*cdf0e10cSrcweir         }
152*cdf0e10cSrcweir     }
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir struct StatusBarEntryProperty
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir 	OReadStatusBarDocumentHandler::StatusBar_XML_Namespace	nNamespace;
158*cdf0e10cSrcweir 	char													aEntryName[20];
159*cdf0e10cSrcweir };
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir StatusBarEntryProperty StatusBarEntries[OReadStatusBarDocumentHandler::SB_XML_ENTRY_COUNT] =
162*cdf0e10cSrcweir {
163*cdf0e10cSrcweir 	{ OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,	ELEMENT_STATUSBAR		},
164*cdf0e10cSrcweir 	{ OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,	ELEMENT_STATUSBARITEM	},
165*cdf0e10cSrcweir 	{ OReadStatusBarDocumentHandler::SB_NS_XLINK,		ATTRIBUTE_URL			},
166*cdf0e10cSrcweir 	{ OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,	ATTRIBUTE_ALIGN			},
167*cdf0e10cSrcweir 	{ OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,	ATTRIBUTE_STYLE			},
168*cdf0e10cSrcweir 	{ OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,	ATTRIBUTE_AUTOSIZE		},
169*cdf0e10cSrcweir 	{ OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,	ATTRIBUTE_OWNERDRAW		},
170*cdf0e10cSrcweir 	{ OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,	ATTRIBUTE_WIDTH			},
171*cdf0e10cSrcweir 	{ OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,	ATTRIBUTE_OFFSET		},
172*cdf0e10cSrcweir     { OReadStatusBarDocumentHandler::SB_NS_STATUSBAR,   ATTRIBUTE_HELPURL       }
173*cdf0e10cSrcweir };
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir OReadStatusBarDocumentHandler::OReadStatusBarDocumentHandler(
177*cdf0e10cSrcweir     const Reference< XIndexContainer >& rStatusBarItems ) :
178*cdf0e10cSrcweir 	ThreadHelpBase( &Application::GetSolarMutex() ),
179*cdf0e10cSrcweir     m_aStatusBarItems( rStatusBarItems )
180*cdf0e10cSrcweir {
181*cdf0e10cSrcweir 	::rtl::OUString aNamespaceStatusBar( RTL_CONSTASCII_USTRINGPARAM( XMLNS_STATUSBAR ));
182*cdf0e10cSrcweir 	::rtl::OUString aNamespaceXLink( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK ));
183*cdf0e10cSrcweir 	::rtl::OUString aSeparator( RTL_CONSTASCII_USTRINGPARAM( XMLNS_FILTER_SEPARATOR ));
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 	// create hash map
186*cdf0e10cSrcweir 	for ( int i = 0; i < (int)SB_XML_ENTRY_COUNT; i++ )
187*cdf0e10cSrcweir 	{
188*cdf0e10cSrcweir 		if ( StatusBarEntries[i].nNamespace == SB_NS_STATUSBAR )
189*cdf0e10cSrcweir 		{
190*cdf0e10cSrcweir 			::rtl::OUString temp( aNamespaceStatusBar );
191*cdf0e10cSrcweir 			temp += aSeparator;
192*cdf0e10cSrcweir 			temp += ::rtl::OUString::createFromAscii( StatusBarEntries[i].aEntryName );
193*cdf0e10cSrcweir 			m_aStatusBarMap.insert( StatusBarHashMap::value_type( temp, (StatusBar_XML_Entry)i ) );
194*cdf0e10cSrcweir 		}
195*cdf0e10cSrcweir 		else
196*cdf0e10cSrcweir 		{
197*cdf0e10cSrcweir 			::rtl::OUString temp( aNamespaceXLink );
198*cdf0e10cSrcweir 			temp += aSeparator;
199*cdf0e10cSrcweir 			temp += ::rtl::OUString::createFromAscii( StatusBarEntries[i].aEntryName );
200*cdf0e10cSrcweir 			m_aStatusBarMap.insert( StatusBarHashMap::value_type( temp, (StatusBar_XML_Entry)i ) );
201*cdf0e10cSrcweir 		}
202*cdf0e10cSrcweir 	}
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	m_bStatusBarStartFound			= sal_False;
205*cdf0e10cSrcweir 	m_bStatusBarEndFound			= sal_False;
206*cdf0e10cSrcweir 	m_bStatusBarItemStartFound		= sal_False;
207*cdf0e10cSrcweir }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir OReadStatusBarDocumentHandler::~OReadStatusBarDocumentHandler()
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir }
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir // XDocumentHandler
214*cdf0e10cSrcweir void SAL_CALL OReadStatusBarDocumentHandler::startDocument(void)
215*cdf0e10cSrcweir throw (	SAXException, RuntimeException )
216*cdf0e10cSrcweir {
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir void SAL_CALL OReadStatusBarDocumentHandler::endDocument(void)
220*cdf0e10cSrcweir throw(	SAXException, RuntimeException )
221*cdf0e10cSrcweir {
222*cdf0e10cSrcweir 	ResetableGuard aGuard( m_aLock );
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir 	if (( m_bStatusBarStartFound && !m_bStatusBarEndFound ) ||
225*cdf0e10cSrcweir 		( !m_bStatusBarStartFound && m_bStatusBarEndFound )		)
226*cdf0e10cSrcweir 	{
227*cdf0e10cSrcweir 		::rtl::OUString aErrorMessage = getErrorLineString();
228*cdf0e10cSrcweir 		aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No matching start or end element 'statusbar' found!" ));
229*cdf0e10cSrcweir 		throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
230*cdf0e10cSrcweir 	}
231*cdf0e10cSrcweir }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir void SAL_CALL OReadStatusBarDocumentHandler::startElement(
234*cdf0e10cSrcweir 	const ::rtl::OUString& aName, const Reference< XAttributeList > &xAttribs )
235*cdf0e10cSrcweir throw(	SAXException, RuntimeException )
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir 	ResetableGuard aGuard( m_aLock );
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir 	StatusBarHashMap::const_iterator pStatusBarEntry = m_aStatusBarMap.find( aName ) ;
240*cdf0e10cSrcweir 	if ( pStatusBarEntry != m_aStatusBarMap.end() )
241*cdf0e10cSrcweir 	{
242*cdf0e10cSrcweir 		switch ( pStatusBarEntry->second )
243*cdf0e10cSrcweir 		{
244*cdf0e10cSrcweir 			case SB_ELEMENT_STATUSBAR:
245*cdf0e10cSrcweir 			{
246*cdf0e10cSrcweir 				if ( m_bStatusBarStartFound )
247*cdf0e10cSrcweir 				{
248*cdf0e10cSrcweir 					::rtl::OUString aErrorMessage = getErrorLineString();
249*cdf0e10cSrcweir 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'statusbar:statusbar' cannot be embeded into 'statusbar:statusbar'!" ));
250*cdf0e10cSrcweir 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
251*cdf0e10cSrcweir 				}
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir 				m_bStatusBarStartFound = sal_True;
254*cdf0e10cSrcweir 			}
255*cdf0e10cSrcweir 			break;
256*cdf0e10cSrcweir 
257*cdf0e10cSrcweir 			case SB_ELEMENT_STATUSBARITEM:
258*cdf0e10cSrcweir 			{
259*cdf0e10cSrcweir 				if ( !m_bStatusBarStartFound )
260*cdf0e10cSrcweir 				{
261*cdf0e10cSrcweir 					::rtl::OUString aErrorMessage = getErrorLineString();
262*cdf0e10cSrcweir 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'statusbar:statusbaritem' must be embeded into element 'statusbar:statusbar'!" ));
263*cdf0e10cSrcweir 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
264*cdf0e10cSrcweir 				}
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir 				if ( m_bStatusBarItemStartFound )
267*cdf0e10cSrcweir 				{
268*cdf0e10cSrcweir 					::rtl::OUString aErrorMessage = getErrorLineString();
269*cdf0e10cSrcweir 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element statusbar:statusbaritem is not a container!" ));
270*cdf0e10cSrcweir 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
271*cdf0e10cSrcweir 				}
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir 				::rtl::OUString    aCommandURL;
274*cdf0e10cSrcweir                 ::rtl::OUString    aHelpURL;
275*cdf0e10cSrcweir                 sal_Int16   nItemBits( ItemStyle::ALIGN_CENTER|ItemStyle::DRAW_IN3D );
276*cdf0e10cSrcweir                 sal_Int16   nWidth( 0 );
277*cdf0e10cSrcweir                 sal_Int16   nOffset( STATUSBAR_OFFSET );
278*cdf0e10cSrcweir 				sal_Bool    bCommandURL( sal_False );
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir 				m_bStatusBarItemStartFound = sal_True;
281*cdf0e10cSrcweir 				for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ )
282*cdf0e10cSrcweir 				{
283*cdf0e10cSrcweir 					pStatusBarEntry = m_aStatusBarMap.find( xAttribs->getNameByIndex( n ) );
284*cdf0e10cSrcweir 					if ( pStatusBarEntry != m_aStatusBarMap.end() )
285*cdf0e10cSrcweir 					{
286*cdf0e10cSrcweir 						switch ( pStatusBarEntry->second )
287*cdf0e10cSrcweir 						{
288*cdf0e10cSrcweir 							case SB_ATTRIBUTE_URL:
289*cdf0e10cSrcweir 							{
290*cdf0e10cSrcweir 								bCommandURL	= sal_True;
291*cdf0e10cSrcweir 								aCommandURL = xAttribs->getValueByIndex( n );
292*cdf0e10cSrcweir 							}
293*cdf0e10cSrcweir 							break;
294*cdf0e10cSrcweir 
295*cdf0e10cSrcweir 							case SB_ATTRIBUTE_ALIGN:
296*cdf0e10cSrcweir 							{
297*cdf0e10cSrcweir 								if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ALIGN_LEFT )) )
298*cdf0e10cSrcweir 								{
299*cdf0e10cSrcweir                                     nItemBits |= ItemStyle::ALIGN_LEFT;
300*cdf0e10cSrcweir 									nItemBits &= ~ItemStyle::ALIGN_CENTER;
301*cdf0e10cSrcweir 								}
302*cdf0e10cSrcweir 								else if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ALIGN_CENTER )) )
303*cdf0e10cSrcweir 								{
304*cdf0e10cSrcweir 									nItemBits |= ItemStyle::ALIGN_CENTER;
305*cdf0e10cSrcweir 									nItemBits &= ~ItemStyle::ALIGN_LEFT;
306*cdf0e10cSrcweir 								}
307*cdf0e10cSrcweir 								else if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_ALIGN_RIGHT )) )
308*cdf0e10cSrcweir 								{
309*cdf0e10cSrcweir 									nItemBits |= ItemStyle::ALIGN_RIGHT;
310*cdf0e10cSrcweir 								}
311*cdf0e10cSrcweir 								else
312*cdf0e10cSrcweir 								{
313*cdf0e10cSrcweir 									::rtl::OUString aErrorMessage = getErrorLineString();
314*cdf0e10cSrcweir 									aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Attribute statusbar:align must have one value of 'left','right' or 'center'!" ));
315*cdf0e10cSrcweir 									throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
316*cdf0e10cSrcweir 								}
317*cdf0e10cSrcweir 							}
318*cdf0e10cSrcweir 							break;
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 							case SB_ATTRIBUTE_STYLE:
321*cdf0e10cSrcweir 							{
322*cdf0e10cSrcweir 								if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_STYLE_IN )) )
323*cdf0e10cSrcweir 								{
324*cdf0e10cSrcweir 									nItemBits |= ItemStyle::DRAW_IN3D;
325*cdf0e10cSrcweir 									nItemBits &= ~ItemStyle::DRAW_OUT3D;
326*cdf0e10cSrcweir 								}
327*cdf0e10cSrcweir 								else if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_STYLE_OUT )) )
328*cdf0e10cSrcweir 								{
329*cdf0e10cSrcweir 									nItemBits |= ItemStyle::DRAW_OUT3D;
330*cdf0e10cSrcweir 									nItemBits &= ~ItemStyle::DRAW_IN3D;
331*cdf0e10cSrcweir 								}
332*cdf0e10cSrcweir 								else if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_STYLE_FLAT )) )
333*cdf0e10cSrcweir 								{
334*cdf0e10cSrcweir 									nItemBits |= ItemStyle::DRAW_FLAT;
335*cdf0e10cSrcweir 								}
336*cdf0e10cSrcweir 								else
337*cdf0e10cSrcweir 								{
338*cdf0e10cSrcweir 									::rtl::OUString aErrorMessage = getErrorLineString();
339*cdf0e10cSrcweir 									aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Attribute statusbar:autosize must have value 'true' or 'false'!" ));
340*cdf0e10cSrcweir 									throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
341*cdf0e10cSrcweir 								}
342*cdf0e10cSrcweir 							}
343*cdf0e10cSrcweir 							break;
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir 							case SB_ATTRIBUTE_AUTOSIZE:
346*cdf0e10cSrcweir 							{
347*cdf0e10cSrcweir 								if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_BOOLEAN_TRUE )) )
348*cdf0e10cSrcweir 									nItemBits |= ItemStyle::AUTO_SIZE;
349*cdf0e10cSrcweir 								else if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_BOOLEAN_FALSE )) )
350*cdf0e10cSrcweir 									nItemBits &= ~ItemStyle::AUTO_SIZE;
351*cdf0e10cSrcweir 								else
352*cdf0e10cSrcweir 								{
353*cdf0e10cSrcweir 									::rtl::OUString aErrorMessage = getErrorLineString();
354*cdf0e10cSrcweir 									aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Attribute statusbar:autosize must have value 'true' or 'false'!" ));
355*cdf0e10cSrcweir 									throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
356*cdf0e10cSrcweir 								}
357*cdf0e10cSrcweir 							}
358*cdf0e10cSrcweir 							break;
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir 							case SB_ATTRIBUTE_OWNERDRAW:
361*cdf0e10cSrcweir 							{
362*cdf0e10cSrcweir 								if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_BOOLEAN_TRUE )) )
363*cdf0e10cSrcweir 									nItemBits |= ItemStyle::OWNER_DRAW;
364*cdf0e10cSrcweir 								else if ( xAttribs->getValueByIndex( n ).equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( ATTRIBUTE_BOOLEAN_FALSE )) )
365*cdf0e10cSrcweir 									nItemBits &= ~ItemStyle::OWNER_DRAW;
366*cdf0e10cSrcweir 								else
367*cdf0e10cSrcweir 								{
368*cdf0e10cSrcweir 									::rtl::OUString aErrorMessage = getErrorLineString();
369*cdf0e10cSrcweir 									aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Attribute statusbar:ownerdraw must have value 'true' or 'false'!" ));
370*cdf0e10cSrcweir 									throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
371*cdf0e10cSrcweir 								}
372*cdf0e10cSrcweir 							}
373*cdf0e10cSrcweir 							break;
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir 							case SB_ATTRIBUTE_WIDTH:
376*cdf0e10cSrcweir 							{
377*cdf0e10cSrcweir 								nWidth = (sal_Int16)(xAttribs->getValueByIndex( n ).toInt32());
378*cdf0e10cSrcweir 							}
379*cdf0e10cSrcweir 							break;
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 							case SB_ATTRIBUTE_OFFSET:
382*cdf0e10cSrcweir 							{
383*cdf0e10cSrcweir 								nOffset = (sal_Int16)(xAttribs->getValueByIndex( n ).toInt32());
384*cdf0e10cSrcweir 							}
385*cdf0e10cSrcweir 							break;
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir                                           case SB_ATTRIBUTE_HELPURL:
388*cdf0e10cSrcweir                                           {
389*cdf0e10cSrcweir                                                 aHelpURL = xAttribs->getValueByIndex( n );
390*cdf0e10cSrcweir                                           }
391*cdf0e10cSrcweir                                           break;
392*cdf0e10cSrcweir 
393*cdf0e10cSrcweir                                           default:
394*cdf0e10cSrcweir                                               break;
395*cdf0e10cSrcweir 						}
396*cdf0e10cSrcweir 					}
397*cdf0e10cSrcweir 				} // for
398*cdf0e10cSrcweir 
399*cdf0e10cSrcweir 				if ( !bCommandURL )
400*cdf0e10cSrcweir 				{
401*cdf0e10cSrcweir 					::rtl::OUString aErrorMessage = getErrorLineString();
402*cdf0e10cSrcweir 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute statusbar:url must have a value!" ));
403*cdf0e10cSrcweir 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
404*cdf0e10cSrcweir 				}
405*cdf0e10cSrcweir                         else
406*cdf0e10cSrcweir                         {
407*cdf0e10cSrcweir                             Sequence< PropertyValue > aStatusbarItemProp( 6 );
408*cdf0e10cSrcweir                             aStatusbarItemProp[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_COMMANDURL ));
409*cdf0e10cSrcweir                             aStatusbarItemProp[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_HELPURL ));
410*cdf0e10cSrcweir                             aStatusbarItemProp[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_OFFSET ));
411*cdf0e10cSrcweir                             aStatusbarItemProp[3].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_STYLE ));
412*cdf0e10cSrcweir                             aStatusbarItemProp[4].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_WIDTH ));
413*cdf0e10cSrcweir                             aStatusbarItemProp[5].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ITEM_DESCRIPTOR_TYPE ));
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir                             aStatusbarItemProp[0].Value <<= aCommandURL;
416*cdf0e10cSrcweir                             aStatusbarItemProp[1].Value <<= aHelpURL;
417*cdf0e10cSrcweir                             aStatusbarItemProp[2].Value <<= nOffset;
418*cdf0e10cSrcweir                             aStatusbarItemProp[3].Value <<= nItemBits;
419*cdf0e10cSrcweir                             aStatusbarItemProp[4].Value <<= nWidth;
420*cdf0e10cSrcweir                             aStatusbarItemProp[5].Value = makeAny( ::com::sun::star::ui::ItemType::DEFAULT );
421*cdf0e10cSrcweir 
422*cdf0e10cSrcweir                             m_aStatusBarItems->insertByIndex( m_aStatusBarItems->getCount(), makeAny( aStatusbarItemProp ) );
423*cdf0e10cSrcweir                        }
424*cdf0e10cSrcweir 			}
425*cdf0e10cSrcweir 			break;
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir                   default:
428*cdf0e10cSrcweir                       break;
429*cdf0e10cSrcweir 		}
430*cdf0e10cSrcweir 	}
431*cdf0e10cSrcweir }
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir void SAL_CALL OReadStatusBarDocumentHandler::endElement(const ::rtl::OUString& aName)
434*cdf0e10cSrcweir throw(	SAXException, RuntimeException )
435*cdf0e10cSrcweir {
436*cdf0e10cSrcweir 	ResetableGuard aGuard( m_aLock );
437*cdf0e10cSrcweir 
438*cdf0e10cSrcweir 	StatusBarHashMap::const_iterator pStatusBarEntry = m_aStatusBarMap.find( aName ) ;
439*cdf0e10cSrcweir 	if ( pStatusBarEntry != m_aStatusBarMap.end() )
440*cdf0e10cSrcweir 	{
441*cdf0e10cSrcweir 		switch ( pStatusBarEntry->second )
442*cdf0e10cSrcweir 		{
443*cdf0e10cSrcweir 			case SB_ELEMENT_STATUSBAR:
444*cdf0e10cSrcweir 			{
445*cdf0e10cSrcweir 				if ( !m_bStatusBarStartFound )
446*cdf0e10cSrcweir 				{
447*cdf0e10cSrcweir 					::rtl::OUString aErrorMessage = getErrorLineString();
448*cdf0e10cSrcweir 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "End element 'statusbar' found, but no start element 'statusbar'" ));
449*cdf0e10cSrcweir 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
450*cdf0e10cSrcweir 				}
451*cdf0e10cSrcweir 
452*cdf0e10cSrcweir 				m_bStatusBarStartFound = sal_False;
453*cdf0e10cSrcweir 			}
454*cdf0e10cSrcweir 			break;
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 			case SB_ELEMENT_STATUSBARITEM:
457*cdf0e10cSrcweir 			{
458*cdf0e10cSrcweir 				if ( !m_bStatusBarItemStartFound )
459*cdf0e10cSrcweir 				{
460*cdf0e10cSrcweir 					::rtl::OUString aErrorMessage = getErrorLineString();
461*cdf0e10cSrcweir 					aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "End element 'statusbar:statusbaritem' found, but no start element 'statusbar:statusbaritem'" ));
462*cdf0e10cSrcweir 					throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
463*cdf0e10cSrcweir 				}
464*cdf0e10cSrcweir 
465*cdf0e10cSrcweir 				m_bStatusBarItemStartFound = sal_False;
466*cdf0e10cSrcweir 			}
467*cdf0e10cSrcweir 			break;
468*cdf0e10cSrcweir 
469*cdf0e10cSrcweir                   default:
470*cdf0e10cSrcweir                       break;
471*cdf0e10cSrcweir 		}
472*cdf0e10cSrcweir 	}
473*cdf0e10cSrcweir }
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir void SAL_CALL OReadStatusBarDocumentHandler::characters(const ::rtl::OUString&)
476*cdf0e10cSrcweir throw(	SAXException, RuntimeException )
477*cdf0e10cSrcweir {
478*cdf0e10cSrcweir }
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir void SAL_CALL OReadStatusBarDocumentHandler::ignorableWhitespace(const ::rtl::OUString&)
481*cdf0e10cSrcweir throw(	SAXException, RuntimeException )
482*cdf0e10cSrcweir {
483*cdf0e10cSrcweir }
484*cdf0e10cSrcweir 
485*cdf0e10cSrcweir void SAL_CALL OReadStatusBarDocumentHandler::processingInstruction(
486*cdf0e10cSrcweir 	const ::rtl::OUString& /*aTarget*/, const ::rtl::OUString& /*aData*/ )
487*cdf0e10cSrcweir throw(	SAXException, RuntimeException )
488*cdf0e10cSrcweir {
489*cdf0e10cSrcweir }
490*cdf0e10cSrcweir 
491*cdf0e10cSrcweir void SAL_CALL OReadStatusBarDocumentHandler::setDocumentLocator(
492*cdf0e10cSrcweir 	const Reference< XLocator > &xLocator)
493*cdf0e10cSrcweir throw(	SAXException, RuntimeException )
494*cdf0e10cSrcweir {
495*cdf0e10cSrcweir 	ResetableGuard aGuard( m_aLock );
496*cdf0e10cSrcweir 
497*cdf0e10cSrcweir 	m_xLocator = xLocator;
498*cdf0e10cSrcweir }
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir ::rtl::OUString OReadStatusBarDocumentHandler::getErrorLineString()
501*cdf0e10cSrcweir {
502*cdf0e10cSrcweir 	ResetableGuard aGuard( m_aLock );
503*cdf0e10cSrcweir 
504*cdf0e10cSrcweir 	char buffer[32];
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir 	if ( m_xLocator.is() )
507*cdf0e10cSrcweir 	{
508*cdf0e10cSrcweir 		snprintf( buffer, sizeof(buffer), "Line: %ld - ", static_cast<long>( m_xLocator->getLineNumber() ));
509*cdf0e10cSrcweir 		return ::rtl::OUString::createFromAscii( buffer );
510*cdf0e10cSrcweir 	}
511*cdf0e10cSrcweir 	else
512*cdf0e10cSrcweir 		return ::rtl::OUString();
513*cdf0e10cSrcweir }
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir 
516*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
517*cdf0e10cSrcweir //	OWriteStatusBarDocumentHandler
518*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir OWriteStatusBarDocumentHandler::OWriteStatusBarDocumentHandler(
521*cdf0e10cSrcweir     const Reference< XIndexAccess >& aStatusBarItems,
522*cdf0e10cSrcweir     const Reference< XDocumentHandler >& rWriteDocumentHandler ) :
523*cdf0e10cSrcweir     ThreadHelpBase( &Application::GetSolarMutex() ),
524*cdf0e10cSrcweir 	m_aStatusBarItems( aStatusBarItems ),
525*cdf0e10cSrcweir 	m_xWriteDocumentHandler( rWriteDocumentHandler )
526*cdf0e10cSrcweir {
527*cdf0e10cSrcweir 	::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
528*cdf0e10cSrcweir 	m_xEmptyList		= Reference< XAttributeList >( (XAttributeList *) pList, UNO_QUERY );
529*cdf0e10cSrcweir 	m_aAttributeType	= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TYPE_CDATA ));
530*cdf0e10cSrcweir 	m_aXMLXlinkNS		= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_PREFIX ));
531*cdf0e10cSrcweir 	m_aXMLStatusBarNS	= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_STATUSBAR_PREFIX ));
532*cdf0e10cSrcweir }
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir OWriteStatusBarDocumentHandler::~OWriteStatusBarDocumentHandler()
535*cdf0e10cSrcweir {
536*cdf0e10cSrcweir }
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir void OWriteStatusBarDocumentHandler::WriteStatusBarDocument() throw
539*cdf0e10cSrcweir ( SAXException, RuntimeException )
540*cdf0e10cSrcweir {
541*cdf0e10cSrcweir 	ResetableGuard aGuard( m_aLock );
542*cdf0e10cSrcweir 
543*cdf0e10cSrcweir 	m_xWriteDocumentHandler->startDocument();
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir 	// write DOCTYPE line!
546*cdf0e10cSrcweir 	Reference< XExtendedDocumentHandler > xExtendedDocHandler( m_xWriteDocumentHandler, UNO_QUERY );
547*cdf0e10cSrcweir 	if ( xExtendedDocHandler.is() )
548*cdf0e10cSrcweir 	{
549*cdf0e10cSrcweir 		xExtendedDocHandler->unknown( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STATUSBAR_DOCTYPE )) );
550*cdf0e10cSrcweir 		m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
551*cdf0e10cSrcweir 	}
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir 	::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
554*cdf0e10cSrcweir 	Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY );
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir 	pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_STATUSBAR )),
557*cdf0e10cSrcweir 						 m_aAttributeType,
558*cdf0e10cSrcweir 						 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_STATUSBAR )) );
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir 	pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_XLINK )),
561*cdf0e10cSrcweir 						 m_aAttributeType,
562*cdf0e10cSrcweir 						 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK )) );
563*cdf0e10cSrcweir 
564*cdf0e10cSrcweir 	m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_STATUSBAR )), pList );
565*cdf0e10cSrcweir 	m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
566*cdf0e10cSrcweir 
567*cdf0e10cSrcweir 	sal_Int32  nItemCount = m_aStatusBarItems->getCount();
568*cdf0e10cSrcweir     Any        aAny;
569*cdf0e10cSrcweir 
570*cdf0e10cSrcweir 	for ( sal_Int32 nItemPos = 0; nItemPos < nItemCount; nItemPos++ )
571*cdf0e10cSrcweir 	{
572*cdf0e10cSrcweir         Sequence< PropertyValue > aProps;
573*cdf0e10cSrcweir         aAny = m_aStatusBarItems->getByIndex( nItemPos );
574*cdf0e10cSrcweir         if ( aAny >>= aProps )
575*cdf0e10cSrcweir         {
576*cdf0e10cSrcweir             ::rtl::OUString    aCommandURL;
577*cdf0e10cSrcweir             ::rtl::OUString    aHelpURL;
578*cdf0e10cSrcweir             sal_Int16   nStyle( ItemStyle::ALIGN_CENTER|ItemStyle::DRAW_IN3D );
579*cdf0e10cSrcweir             sal_Int16   nWidth( 0 );
580*cdf0e10cSrcweir             sal_Int16   nOffset( STATUSBAR_OFFSET );
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir             ExtractStatusbarItemParameters(
583*cdf0e10cSrcweir                 aProps,
584*cdf0e10cSrcweir                 aCommandURL,
585*cdf0e10cSrcweir                 aHelpURL,
586*cdf0e10cSrcweir                 nOffset,
587*cdf0e10cSrcweir                 nStyle,
588*cdf0e10cSrcweir                 nWidth );
589*cdf0e10cSrcweir 
590*cdf0e10cSrcweir             if ( aCommandURL.getLength() > 0 )
591*cdf0e10cSrcweir                 WriteStatusBarItem( aCommandURL, aHelpURL, nOffset, nStyle, nWidth );
592*cdf0e10cSrcweir         }
593*cdf0e10cSrcweir     }
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir 	m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
596*cdf0e10cSrcweir 	m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_STATUSBAR )) );
597*cdf0e10cSrcweir 	m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
598*cdf0e10cSrcweir 	m_xWriteDocumentHandler->endDocument();
599*cdf0e10cSrcweir }
600*cdf0e10cSrcweir 
601*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
602*cdf0e10cSrcweir //	protected member functions
603*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir void OWriteStatusBarDocumentHandler::WriteStatusBarItem(
606*cdf0e10cSrcweir     const rtl::OUString& rCommandURL,
607*cdf0e10cSrcweir     const rtl::OUString& /*rHelpURL*/,
608*cdf0e10cSrcweir     sal_Int16            nOffset,
609*cdf0e10cSrcweir     sal_Int16            nStyle,
610*cdf0e10cSrcweir     sal_Int16            nWidth )
611*cdf0e10cSrcweir throw ( SAXException, RuntimeException )
612*cdf0e10cSrcweir {
613*cdf0e10cSrcweir 	::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
614*cdf0e10cSrcweir 	Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY );
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir 	if ( m_aAttributeURL.getLength() == 0 )
617*cdf0e10cSrcweir 	{
618*cdf0e10cSrcweir 		m_aAttributeURL = m_aXMLXlinkNS;
619*cdf0e10cSrcweir 		m_aAttributeURL += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_URL ));
620*cdf0e10cSrcweir 	}
621*cdf0e10cSrcweir 
622*cdf0e10cSrcweir     // save required attribute (URL)
623*cdf0e10cSrcweir 	pList->AddAttribute( m_aAttributeURL, m_aAttributeType, rCommandURL );
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir 	// alignment
626*cdf0e10cSrcweir 	if ( nStyle & ItemStyle::ALIGN_RIGHT )
627*cdf0e10cSrcweir 	{
628*cdf0e10cSrcweir 		pList->AddAttribute( m_aXMLStatusBarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ALIGN )),
629*cdf0e10cSrcweir 							 m_aAttributeType,
630*cdf0e10cSrcweir 							 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ALIGN_RIGHT )) );
631*cdf0e10cSrcweir 	}
632*cdf0e10cSrcweir 	else if ( nStyle & ItemStyle::ALIGN_CENTER )
633*cdf0e10cSrcweir 	{
634*cdf0e10cSrcweir 		pList->AddAttribute( m_aXMLStatusBarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ALIGN )),
635*cdf0e10cSrcweir 							 m_aAttributeType,
636*cdf0e10cSrcweir 							 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ALIGN_CENTER )) );
637*cdf0e10cSrcweir 	}
638*cdf0e10cSrcweir 	else
639*cdf0e10cSrcweir 	{
640*cdf0e10cSrcweir 		pList->AddAttribute( m_aXMLStatusBarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ALIGN )),
641*cdf0e10cSrcweir 							 m_aAttributeType,
642*cdf0e10cSrcweir 							 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_ALIGN_LEFT )) );
643*cdf0e10cSrcweir 	}
644*cdf0e10cSrcweir 
645*cdf0e10cSrcweir 	// style ( SIB_IN is default )
646*cdf0e10cSrcweir 	if ( nStyle & ItemStyle::DRAW_FLAT )
647*cdf0e10cSrcweir 	{
648*cdf0e10cSrcweir 		pList->AddAttribute( m_aXMLStatusBarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_STYLE )),
649*cdf0e10cSrcweir 							 m_aAttributeType,
650*cdf0e10cSrcweir 							 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_STYLE_FLAT )) );
651*cdf0e10cSrcweir 	}
652*cdf0e10cSrcweir 	else if ( nStyle & ItemStyle::DRAW_OUT3D )
653*cdf0e10cSrcweir 	{
654*cdf0e10cSrcweir 		pList->AddAttribute( m_aXMLStatusBarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_STYLE )),
655*cdf0e10cSrcweir 							 m_aAttributeType,
656*cdf0e10cSrcweir 							 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_STYLE_OUT )) );
657*cdf0e10cSrcweir 	}
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir 	// autosize (default sal_False)
660*cdf0e10cSrcweir 	if ( nStyle & ItemStyle::AUTO_SIZE )
661*cdf0e10cSrcweir 	{
662*cdf0e10cSrcweir 		pList->AddAttribute( m_aXMLStatusBarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_AUTOSIZE )),
663*cdf0e10cSrcweir 							 m_aAttributeType,
664*cdf0e10cSrcweir 							 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_BOOLEAN_TRUE )) );
665*cdf0e10cSrcweir 	}
666*cdf0e10cSrcweir 
667*cdf0e10cSrcweir 	// ownerdraw (default sal_False)
668*cdf0e10cSrcweir 	if ( nStyle & ItemStyle::OWNER_DRAW )
669*cdf0e10cSrcweir 	{
670*cdf0e10cSrcweir 		pList->AddAttribute( m_aXMLStatusBarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_OWNERDRAW )),
671*cdf0e10cSrcweir 							 m_aAttributeType,
672*cdf0e10cSrcweir 							 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_BOOLEAN_TRUE )) );
673*cdf0e10cSrcweir 	}
674*cdf0e10cSrcweir 
675*cdf0e10cSrcweir 	// width (default 0)
676*cdf0e10cSrcweir 	if ( nWidth > 0 )
677*cdf0e10cSrcweir 	{
678*cdf0e10cSrcweir 		pList->AddAttribute( m_aXMLStatusBarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_WIDTH )),
679*cdf0e10cSrcweir 							 m_aAttributeType,
680*cdf0e10cSrcweir 							 ::rtl::OUString::valueOf( (sal_Int32)nWidth ) );
681*cdf0e10cSrcweir 	}
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir 	// offset (default STATUSBAR_OFFSET)
684*cdf0e10cSrcweir 	if ( nOffset != STATUSBAR_OFFSET )
685*cdf0e10cSrcweir 	{
686*cdf0e10cSrcweir 		pList->AddAttribute( m_aXMLStatusBarNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_OFFSET )),
687*cdf0e10cSrcweir 							 m_aAttributeType,
688*cdf0e10cSrcweir 							 ::rtl::OUString::valueOf( (sal_Int32)nOffset ) );
689*cdf0e10cSrcweir 	}
690*cdf0e10cSrcweir 
691*cdf0e10cSrcweir 	m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
692*cdf0e10cSrcweir 	m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_STATUSBARITEM )), xList );
693*cdf0e10cSrcweir 	m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() );
694*cdf0e10cSrcweir 	m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_STATUSBARITEM )) );
695*cdf0e10cSrcweir }
696*cdf0e10cSrcweir 
697*cdf0e10cSrcweir } // namespace framework
698*cdf0e10cSrcweir 
699