1f8e07b45SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f8e07b45SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f8e07b45SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f8e07b45SAndrew Rist * distributed with this work for additional information 6f8e07b45SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f8e07b45SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f8e07b45SAndrew Rist * "License"); you may not use this file except in compliance 9f8e07b45SAndrew Rist * with the License. You may obtain a copy of the License at 10f8e07b45SAndrew Rist * 11f8e07b45SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f8e07b45SAndrew Rist * 13f8e07b45SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f8e07b45SAndrew Rist * software distributed under the License is distributed on an 15f8e07b45SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f8e07b45SAndrew Rist * KIND, either express or implied. See the License for the 17f8e07b45SAndrew Rist * specific language governing permissions and limitations 18f8e07b45SAndrew Rist * under the License. 19f8e07b45SAndrew Rist * 20f8e07b45SAndrew Rist *************************************************************/ 21f8e07b45SAndrew Rist 22f8e07b45SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef __FRAMEWORK_XML_MENUDOCUMENTHANDLER_HXX_ 25cdf0e10cSrcweir #define __FRAMEWORK_XML_MENUDOCUMENTHANDLER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 28cdf0e10cSrcweir // interface includes 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir 31cdf0e10cSrcweir #ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_ 32cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp> 33cdf0e10cSrcweir #endif 34cdf0e10cSrcweir #include <com/sun/star/container/XIndexContainer.hpp> 35cdf0e10cSrcweir #include <com/sun/star/lang/XSingleComponentFactory.hpp> 36cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 37cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.h> 38cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 41cdf0e10cSrcweir // other includes 42cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 43cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 44cdf0e10cSrcweir #include <rtl/ustring.hxx> 45cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 46cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 47cdf0e10cSrcweir #include <framework/fwedllapi.h> 48cdf0e10cSrcweir 49cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 50cdf0e10cSrcweir // namespace 51cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 52cdf0e10cSrcweir 53cdf0e10cSrcweir namespace framework{ 54cdf0e10cSrcweir 55*30acf5e8Spfg class FWE_DLLPUBLIC ReadMenuDocumentHandlerBase : public ThreadHelpBase, // Struct for right initialization of mutex member! Must be first of baseclasses. 56cdf0e10cSrcweir public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler > 57cdf0e10cSrcweir { 58cdf0e10cSrcweir public: 59cdf0e10cSrcweir ReadMenuDocumentHandlerBase(); 60cdf0e10cSrcweir virtual ~ReadMenuDocumentHandlerBase(); 61cdf0e10cSrcweir 62cdf0e10cSrcweir // XDocumentHandler 63cdf0e10cSrcweir virtual void SAL_CALL startDocument(void) 64cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 65cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ) = 0; 66cdf0e10cSrcweir 67cdf0e10cSrcweir virtual void SAL_CALL endDocument(void) 68cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 69cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ) = 0; 70cdf0e10cSrcweir 71cdf0e10cSrcweir virtual void SAL_CALL startElement( 72cdf0e10cSrcweir const rtl::OUString& aName, 73cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs) 74cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 75cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ) = 0; 76cdf0e10cSrcweir 77cdf0e10cSrcweir virtual void SAL_CALL endElement(const rtl::OUString& aName) 78cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 79cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ) = 0; 80cdf0e10cSrcweir 81cdf0e10cSrcweir virtual void SAL_CALL characters(const rtl::OUString& aChars) 82cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 83cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ) = 0; 84cdf0e10cSrcweir 85cdf0e10cSrcweir virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces) 86cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 87cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 88cdf0e10cSrcweir 89cdf0e10cSrcweir virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget, 90cdf0e10cSrcweir const rtl::OUString& aData) 91cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 92cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir virtual void SAL_CALL setDocumentLocator( 95cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator) 96cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 97cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 98cdf0e10cSrcweir 99cdf0e10cSrcweir protected: 100cdf0e10cSrcweir ::rtl::OUString getErrorLineString(); 101cdf0e10cSrcweir 102cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator; 103cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler> m_xReader; 104cdf0e10cSrcweir void initPropertyCommon( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > &rProps, 105cdf0e10cSrcweir const rtl::OUString &rCommandURL, const rtl::OUString &rHelpId, 106cdf0e10cSrcweir const rtl::OUString &rLabel, sal_Int16 nItemStyleBits ); 107cdf0e10cSrcweir private: 108cdf0e10cSrcweir rtl::OUString m_aType; 109cdf0e10cSrcweir rtl::OUString m_aLabel; 110cdf0e10cSrcweir rtl::OUString m_aContainer; 111cdf0e10cSrcweir rtl::OUString m_aHelpURL; 112cdf0e10cSrcweir rtl::OUString m_aCommandURL; 113cdf0e10cSrcweir rtl::OUString m_aStyle; 114cdf0e10cSrcweir ::com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > m_aItemProp; 115cdf0e10cSrcweir }; 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweir class FWE_DLLPUBLIC OReadMenuDocumentHandler : public ReadMenuDocumentHandlerBase 119cdf0e10cSrcweir { 120cdf0e10cSrcweir public: 121cdf0e10cSrcweir // #110897# 122cdf0e10cSrcweir OReadMenuDocumentHandler( 123cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 124cdf0e10cSrcweir const com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >& rItemContainer ); 125cdf0e10cSrcweir virtual ~OReadMenuDocumentHandler(); 126cdf0e10cSrcweir 127cdf0e10cSrcweir // #110897# 128cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory(); 129cdf0e10cSrcweir 130cdf0e10cSrcweir // XDocumentHandler 131cdf0e10cSrcweir virtual void SAL_CALL startDocument(void) 132cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 133cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 134cdf0e10cSrcweir 135cdf0e10cSrcweir virtual void SAL_CALL endDocument(void) 136cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 137cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir virtual void SAL_CALL startElement( 140cdf0e10cSrcweir const rtl::OUString& aName, 141cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs) 142cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 143cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 144cdf0e10cSrcweir 145cdf0e10cSrcweir virtual void SAL_CALL endElement(const rtl::OUString& aName) 146cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 147cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 148cdf0e10cSrcweir 149cdf0e10cSrcweir virtual void SAL_CALL characters(const rtl::OUString& aChars) 150cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 151cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 152cdf0e10cSrcweir 153cdf0e10cSrcweir private: 154cdf0e10cSrcweir int m_nElementDepth; 155cdf0e10cSrcweir sal_Bool m_bMenuBarMode; 156cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_xMenuBarContainer; 157cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > m_xContainerFactory; 158cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory; 159cdf0e10cSrcweir }; // OReadMenuDocumentHandler 160cdf0e10cSrcweir 161cdf0e10cSrcweir 162cdf0e10cSrcweir class FWE_DLLPUBLIC OReadMenuBarHandler : public ReadMenuDocumentHandlerBase 163cdf0e10cSrcweir { 164cdf0e10cSrcweir public: 165cdf0e10cSrcweir // #110897# 166cdf0e10cSrcweir OReadMenuBarHandler( 167cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 168cdf0e10cSrcweir const com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rMenuBarContainer, 169cdf0e10cSrcweir const com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory >& rContainerFactory ); 170cdf0e10cSrcweir virtual ~OReadMenuBarHandler(); 171cdf0e10cSrcweir 172cdf0e10cSrcweir // #110897# 173cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory(); 174cdf0e10cSrcweir 175cdf0e10cSrcweir // XDocumentHandler 176cdf0e10cSrcweir virtual void SAL_CALL startDocument(void) 177cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 178cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir virtual void SAL_CALL endDocument(void) 181cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 182cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 183cdf0e10cSrcweir 184cdf0e10cSrcweir virtual void SAL_CALL startElement( 185cdf0e10cSrcweir const rtl::OUString& aName, 186cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs) 187cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 188cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 189cdf0e10cSrcweir 190cdf0e10cSrcweir virtual void SAL_CALL endElement(const rtl::OUString& aName) 191cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 192cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 193cdf0e10cSrcweir 194cdf0e10cSrcweir virtual void SAL_CALL characters(const rtl::OUString& aChars) 195cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 196cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 197cdf0e10cSrcweir 198cdf0e10cSrcweir private: 199cdf0e10cSrcweir int m_nElementDepth; 200cdf0e10cSrcweir sal_Bool m_bMenuMode; 201cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_xMenuBarContainer; 202cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > m_xContainerFactory; 203cdf0e10cSrcweir 204cdf0e10cSrcweir // #110897# 205cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory; 206cdf0e10cSrcweir }; // OReadMenuBarHandler 207cdf0e10cSrcweir 208cdf0e10cSrcweir 209cdf0e10cSrcweir class FWE_DLLPUBLIC OReadMenuHandler : public ReadMenuDocumentHandlerBase 210cdf0e10cSrcweir { 211cdf0e10cSrcweir public: 212cdf0e10cSrcweir OReadMenuHandler( const com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rMenuContainer, 213cdf0e10cSrcweir const com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory >& rContainerFactory ); 214cdf0e10cSrcweir virtual ~OReadMenuHandler(); 215cdf0e10cSrcweir 216cdf0e10cSrcweir // XDocumentHandler 217cdf0e10cSrcweir virtual void SAL_CALL startDocument(void) 218cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 219cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 220cdf0e10cSrcweir 221cdf0e10cSrcweir virtual void SAL_CALL endDocument(void) 222cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 223cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 224cdf0e10cSrcweir 225cdf0e10cSrcweir virtual void SAL_CALL startElement( 226cdf0e10cSrcweir const rtl::OUString& aName, 227cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs) 228cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 229cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 230cdf0e10cSrcweir 231cdf0e10cSrcweir virtual void SAL_CALL endElement(const rtl::OUString& aName) 232cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 233cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 234cdf0e10cSrcweir 235cdf0e10cSrcweir virtual void SAL_CALL characters(const rtl::OUString& aChars) 236cdf0e10cSrcweir throw( ::com::sun::star::xml::sax::SAXException, 237cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 238cdf0e10cSrcweir 239cdf0e10cSrcweir private: 240cdf0e10cSrcweir int m_nElementDepth; 241cdf0e10cSrcweir sal_Bool m_bMenuPopupMode; 242cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_xMenuContainer; 243cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > m_xContainerFactory; 244cdf0e10cSrcweir }; // OReadMenuHandler 245cdf0e10cSrcweir 246cdf0e10cSrcweir 247cdf0e10cSrcweir class FWE_DLLPUBLIC OReadMenuPopupHandler : public ReadMenuDocumentHandlerBase 248cdf0e10cSrcweir { 249cdf0e10cSrcweir public: 250cdf0e10cSrcweir OReadMenuPopupHandler( const com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer >& rMenuContainer, 251cdf0e10cSrcweir const com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory >& rContainerFactory ); 252cdf0e10cSrcweir virtual ~OReadMenuPopupHandler(); 253cdf0e10cSrcweir 254cdf0e10cSrcweir // XDocumentHandler 255cdf0e10cSrcweir virtual void SAL_CALL startDocument(void) 256cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 257cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 258cdf0e10cSrcweir 259cdf0e10cSrcweir virtual void SAL_CALL endDocument(void) 260cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 261cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 262cdf0e10cSrcweir 263cdf0e10cSrcweir virtual void SAL_CALL startElement( 264cdf0e10cSrcweir const rtl::OUString& aName, 265cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 266cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > &xAttribs) 267cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 268cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 269cdf0e10cSrcweir 270cdf0e10cSrcweir virtual void SAL_CALL endElement(const rtl::OUString& aName) 271cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 272cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 273cdf0e10cSrcweir 274cdf0e10cSrcweir virtual void SAL_CALL characters(const rtl::OUString& aChars) 275cdf0e10cSrcweir throw ( ::com::sun::star::xml::sax::SAXException, 276cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException ); 277cdf0e10cSrcweir 278cdf0e10cSrcweir private: 279cdf0e10cSrcweir enum NextElementClose { ELEM_CLOSE_NONE, ELEM_CLOSE_MENUITEM, ELEM_CLOSE_MENUSEPARATOR }; 280cdf0e10cSrcweir 281cdf0e10cSrcweir int m_nElementDepth; 282cdf0e10cSrcweir sal_Bool m_bMenuMode; 283cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > m_xMenuContainer; 284cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > m_xContainerFactory; 285cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xComponentContext; 286cdf0e10cSrcweir NextElementClose m_nNextElementExpected; 287cdf0e10cSrcweir }; // OReadMenuPopupHandler 288cdf0e10cSrcweir 289cdf0e10cSrcweir 290cdf0e10cSrcweir class FWE_DLLPUBLIC OWriteMenuDocumentHandler 291cdf0e10cSrcweir { 292cdf0e10cSrcweir public: 293cdf0e10cSrcweir OWriteMenuDocumentHandler( 294cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rMenuBarContainer, 295cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler >& rDocumentHandler ); 296cdf0e10cSrcweir virtual ~OWriteMenuDocumentHandler(); 297cdf0e10cSrcweir 298cdf0e10cSrcweir void WriteMenuDocument() throw 299cdf0e10cSrcweir ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 300cdf0e10cSrcweir protected: 301cdf0e10cSrcweir virtual void WriteMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& rSubMenuContainer ) throw 302cdf0e10cSrcweir ( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 303cdf0e10cSrcweir 304cdf0e10cSrcweir virtual void WriteMenuItem( const rtl::OUString& aCommandURL, const rtl::OUString& aLabel, const rtl::OUString& aHelpURL, sal_Int16 nStyle = 0 ); 305cdf0e10cSrcweir virtual void WriteMenuSeparator(); 306cdf0e10cSrcweir 307cdf0e10cSrcweir com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > m_xMenuBarContainer; 308cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler; 309cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList; 310cdf0e10cSrcweir ::rtl::OUString m_aAttributeType; 311cdf0e10cSrcweir }; 312cdf0e10cSrcweir 313cdf0e10cSrcweir } // namespace framework 314cdf0e10cSrcweir 315cdf0e10cSrcweir #endif // #ifndef __FRAMEWORK_XML_MENUDOCUMENTHANDLER_HXX_ 316