22#include <com/sun/star/xml/sax/SAXException.hpp>
23#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
24#include <com/sun/star/ui/ItemStyle.hpp>
25#include <com/sun/star/ui/ItemType.hpp>
26#include <com/sun/star/beans/PropertyValue.hpp>
27#include <com/sun/star/container/XIndexAccess.hpp>
28#include <com/sun/star/container/XIndexContainer.hpp>
42constexpr OUStringLiteral
XMLNS_XLINK =
u"http://www.w3.org/1999/xlink";
48#define ELEMENT_STATUSBAR "statusbar"
49#define ELEMENT_STATUSBARITEM "statusbaritem"
51#define ATTRIBUTE_ALIGN "align"
52#define ATTRIBUTE_STYLE "style"
53#define ATTRIBUTE_URL "href"
54#define ATTRIBUTE_WIDTH "width"
55#define ATTRIBUTE_OFFSET "offset"
56#define ATTRIBUTE_AUTOSIZE "autosize"
57#define ATTRIBUTE_OWNERDRAW "ownerdraw"
58#define ATTRIBUTE_HELPURL "helpid"
59#define ATTRIBUTE_MANDATORY "mandatory"
78constexpr OUStringLiteral
STATUSBAR_DOCTYPE =
u"<!DOCTYPE statusbar:statusbar PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\" \"statusbar.dtd\">";
92 const Sequence< PropertyValue >& rProp,
93 OUString& rCommandURL,
99 for (
const PropertyValue& rEntry : rProp )
103 rEntry.Value >>= rCommandURL;
107 rEntry.Value >>= rHelpURL;
111 rEntry.Value >>= rOffset;
115 rEntry.Value >>= rStyle;
119 rEntry.Value >>= rWidth;
126struct StatusBarEntryProperty
150 const Reference< XIndexContainer >& rStatusBarItems ) :
151 m_aStatusBarItems( rStatusBarItems )
187 OUString aErrorMessage =
getErrorLineString() +
"No matching start or end element 'statusbar' found!";
188 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
193 const OUString& aName,
const Reference< XAttributeList > &xAttribs )
199 switch ( pStatusBarEntry->second )
205 OUString aErrorMessage =
getErrorLineString() +
"Element 'statusbar:statusbar' cannot be embedded into 'statusbar:statusbar'!";
206 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
217 OUString aErrorMessage =
getErrorLineString() +
"Element 'statusbar:statusbaritem' must be embedded into element 'statusbar:statusbar'!";
218 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
223 OUString aErrorMessage =
getErrorLineString() +
"Element statusbar:statusbaritem is not a container!";
224 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
227 OUString aCommandURL;
229 sal_Int16 nItemBits( ItemStyle::ALIGN_CENTER|ItemStyle::DRAW_IN3D|ItemStyle::MANDATORY );
230 sal_Int16 nWidth( 0 );
232 bool bCommandURL(
false );
235 for ( sal_Int16
n = 0;
n < xAttribs->getLength();
n++ )
240 switch ( pStatusBarEntry->second )
245 aCommandURL = xAttribs->getValueByIndex(
n );
253 nItemBits |= ItemStyle::ALIGN_LEFT;
254 nItemBits &= ~ItemStyle::ALIGN_CENTER;
258 nItemBits |= ItemStyle::ALIGN_CENTER;
259 nItemBits &= ~ItemStyle::ALIGN_LEFT;
263 nItemBits |= ItemStyle::ALIGN_RIGHT;
267 OUString aErrorMessage =
getErrorLineString() +
"Attribute statusbar:align must have one value of 'left','right' or 'center'!";
268 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
277 nItemBits |= ItemStyle::DRAW_IN3D;
278 nItemBits &= ~ItemStyle::DRAW_OUT3D;
282 nItemBits |= ItemStyle::DRAW_OUT3D;
283 nItemBits &= ~ItemStyle::DRAW_IN3D;
287 nItemBits |= ItemStyle::DRAW_FLAT;
291 OUString aErrorMessage =
getErrorLineString() +
"Attribute statusbar:autosize must have value 'true' or 'false'!";
292 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
300 nItemBits |= ItemStyle::AUTO_SIZE;
302 nItemBits &= ~ItemStyle::AUTO_SIZE;
305 OUString aErrorMessage =
getErrorLineString() +
"Attribute statusbar:autosize must have value 'true' or 'false'!";
306 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
314 nItemBits |= ItemStyle::OWNER_DRAW;
316 nItemBits &= ~ItemStyle::OWNER_DRAW;
319 OUString aErrorMessage =
getErrorLineString() +
"Attribute statusbar:ownerdraw must have value 'true' or 'false'!";
320 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
327 nWidth =
static_cast<sal_Int16
>(xAttribs->getValueByIndex(
n ).toInt32());
333 nOffset =
static_cast<sal_Int16
>(xAttribs->getValueByIndex(
n ).toInt32());
339 aHelpURL = xAttribs->getValueByIndex(
n );
346 nItemBits |= ItemStyle::MANDATORY;
348 nItemBits &= ~ItemStyle::MANDATORY;
351 OUString aErrorMessage =
getErrorLineString() +
"Attribute statusbar:mandatory must have value 'true' or 'false'!";
352 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
365 OUString aErrorMessage =
getErrorLineString() +
"Required attribute statusbar:url must have a value!";
366 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
370 Sequence< PropertyValue > aStatusbarItemProp{
395 switch ( pStatusBarEntry->second )
401 OUString aErrorMessage =
getErrorLineString() +
"End element 'statusbar' found, but no start element 'statusbar'";
402 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
413 OUString aErrorMessage =
getErrorLineString() +
"End element 'statusbar:statusbaritem' found, but no start element 'statusbar:statusbaritem'";
414 throw SAXException( aErrorMessage, Reference< XInterface >(),
Any() );
434 const OUString& ,
const OUString& )
439 const Reference< XLocator > &xLocator)
447 return "Line: " + OUString::number(
m_xLocator->getLineNumber() ) +
" - ";
455 const Reference< XIndexAccess >& aStatusBarItems,
456 const Reference< XDocumentHandler >& rWriteDocumentHandler ) :
457 m_aStatusBarItems( aStatusBarItems ),
458 m_xWriteDocumentHandler( rWriteDocumentHandler )
475 if ( xExtendedDocHandler.is() )
495 for ( sal_Int32 nItemPos = 0; nItemPos < nItemCount; nItemPos++ )
497 Sequence< PropertyValue > aProps;
499 if ( aAny >>= aProps )
501 OUString aCommandURL;
503 sal_Int16 nStyle( ItemStyle::ALIGN_CENTER|ItemStyle::DRAW_IN3D );
504 sal_Int16 nWidth( 0 );
515 if ( !aCommandURL.isEmpty() )
529 const OUString& rCommandURL,
545 if ( nStyle & ItemStyle::ALIGN_RIGHT )
550 else if ( nStyle & ItemStyle::ALIGN_CENTER )
562 if ( nStyle & ItemStyle::DRAW_FLAT )
567 else if ( nStyle & ItemStyle::DRAW_OUT3D )
574 if ( nStyle & ItemStyle::AUTO_SIZE )
581 if ( nStyle & ItemStyle::OWNER_DRAW )
591 OUString::number( nWidth ) );
598 OUString::number( nOffset ) );
602 if ( !( nStyle & ItemStyle::MANDATORY ) )
bool m_bStatusBarItemStartFound
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
OUString getErrorLineString()
virtual void SAL_CALL characters(const OUString &aChars) override
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
@ SB_ELEMENT_STATUSBARITEM
bool m_bStatusBarStartFound
virtual void SAL_CALL startDocument() override
css::uno::Reference< css::xml::sax::XLocator > m_xLocator
virtual void SAL_CALL endDocument() override
virtual void SAL_CALL endElement(const OUString &aName) override
StatusBarHashMap m_aStatusBarMap
virtual void SAL_CALL ignorableWhitespace(const OUString &aWhitespaces) override
OReadStatusBarDocumentHandler(const css::uno::Reference< css::container::XIndexContainer > &aStatusBarItems)
virtual ~OReadStatusBarDocumentHandler() override
css::uno::Reference< css::container::XIndexContainer > m_aStatusBarItems
css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler
OWriteStatusBarDocumentHandler(const css::uno::Reference< css::container::XIndexAccess > &rStatusBarItems, const css::uno::Reference< css::xml::sax::XDocumentHandler > &rWriteDocHandler)
css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList
void WriteStatusBarDocument()
void WriteStatusBarItem(const OUString &rCommandURL, sal_Int16 nOffset, sal_Int16 nStyle, sal_Int16 nWidth)
css::uno::Reference< css::container::XIndexAccess > m_aStatusBarItems
~OWriteStatusBarDocumentHandler()
OUString m_aXMLStatusBarNS
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr OUStringLiteral ITEM_DESCRIPTOR_STYLE
constexpr OUStringLiteral ITEM_DESCRIPTOR_COMMANDURL
constexpr OUStringLiteral ITEM_DESCRIPTOR_WIDTH
constexpr OUStringLiteral ITEM_DESCRIPTOR_TYPE
constexpr OUStringLiteral ITEM_DESCRIPTOR_OFFSET
static void ExtractStatusbarItemParameters(const Sequence< PropertyValue > &rProp, OUString &rCommandURL, OUString &rHelpURL, sal_Int16 &rOffset, sal_Int16 &rStyle, sal_Int16 &rWidth)
constexpr OUStringLiteral ITEM_DESCRIPTOR_HELPURL
StatusBarEntryProperty const StatusBarEntries[OReadStatusBarDocumentHandler::SB_XML_ENTRY_COUNT]
constexpr OUStringLiteral STATUSBAR_DOCTYPE
constexpr OUStringLiteral XMLNS_STATUSBAR
constexpr OUStringLiteral ATTRIBUTE_STYLE_IN
#define ELEMENT_STATUSBAR
constexpr OUStringLiteral XMLNS_FILTER_SEPARATOR
#define ATTRIBUTE_MANDATORY
constexpr OUStringLiteral ATTRIBUTE_STYLE_OUT
constexpr OUStringLiteral ATTRIBUTE_BOOLEAN_TRUE
OReadStatusBarDocumentHandler::StatusBar_XML_Namespace nNamespace
#define ATTRIBUTE_HELPURL
constexpr OUStringLiteral ATTRIBUTE_STYLE_FLAT
constexpr OUStringLiteral ATTRIBUTE_ALIGN_RIGHT
#define ATTRIBUTE_AUTOSIZE
constexpr OUStringLiteral ATTRIBUTE_BOOLEAN_FALSE
constexpr OUStringLiteral XMLNS_STATUSBAR_PREFIX
#define ATTRIBUTE_OWNERDRAW
constexpr OUStringLiteral ATTRIBUTE_ALIGN_CENTER
constexpr OUStringLiteral ELEMENT_NS_STATUSBARITEM
constexpr OUStringLiteral ELEMENT_NS_STATUSBAR
constexpr OUStringLiteral ATTRIBUTE_ALIGN_LEFT
constexpr OUStringLiteral ATTRIBUTE_XMLNS_XLINK
#define ELEMENT_STATUSBARITEM
constexpr OUStringLiteral XMLNS_XLINK_PREFIX
constexpr OUStringLiteral XMLNS_XLINK
constexpr OUStringLiteral ATTRIBUTE_XMLNS_STATUSBAR