summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2015-11-03 18:33:43 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2015-11-03 22:11:35 +0200
commit0c6305a01f13f5c09dc4c000d5b250319fffe0e4 (patch)
tree69cece883de7691231a49301625bf4ccde41addb /framework
parent281be263619a8e513a26e6a9165d1d77cf6524ea (diff)
Support of popupmenu resource type
Reusing the same xml format as the menubar, except that a popup menu use menu:menupopup as the root element. Change-Id: I2987af0dc698b09aeeb757cff828617515bc3009
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/xml/menudocumenthandler.hxx7
-rw-r--r--framework/source/fwe/xml/menuconfiguration.cxx4
-rw-r--r--framework/source/fwe/xml/menudocumenthandler.cxx55
-rw-r--r--framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx13
-rw-r--r--framework/source/uiconfiguration/uiconfigurationmanager.cxx10
5 files changed, 56 insertions, 33 deletions
diff --git a/framework/inc/xml/menudocumenthandler.hxx b/framework/inc/xml/menudocumenthandler.hxx
index 087836f556af..58df5bb07c2b 100644
--- a/framework/inc/xml/menudocumenthandler.hxx
+++ b/framework/inc/xml/menudocumenthandler.hxx
@@ -127,7 +127,8 @@ class FWE_DLLPUBLIC OReadMenuDocumentHandler : public ReadMenuDocumentHandlerBas
private:
int m_nElementDepth;
- bool m_bMenuBarMode;
+ enum class ReaderMode { None, MenuBar, MenuPopup };
+ ReaderMode m_eReaderMode;
css::uno::Reference< css::container::XIndexContainer > m_xMenuBarContainer;
css::uno::Reference< css::lang::XSingleComponentFactory > m_xContainerFactory;
}; // OReadMenuDocumentHandler
@@ -254,7 +255,8 @@ class FWE_DLLPUBLIC OWriteMenuDocumentHandler
public:
OWriteMenuDocumentHandler(
const css::uno::Reference< css::container::XIndexAccess >& rMenuBarContainer,
- const css::uno::Reference< css::xml::sax::XDocumentHandler >& rDocumentHandler );
+ const css::uno::Reference< css::xml::sax::XDocumentHandler >& rDocumentHandler,
+ bool bIsMenuBar );
virtual ~OWriteMenuDocumentHandler();
void WriteMenuDocument() throw
@@ -270,6 +272,7 @@ class FWE_DLLPUBLIC OWriteMenuDocumentHandler
css::uno::Reference< css::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
css::uno::Reference< css::xml::sax::XAttributeList > m_xEmptyList;
OUString m_aAttributeType;
+ bool m_bIsMenuBar;
};
} // namespace framework
diff --git a/framework/source/fwe/xml/menuconfiguration.cxx b/framework/source/fwe/xml/menuconfiguration.cxx
index b2b378eaf787..417bb05d077f 100644
--- a/framework/source/fwe/xml/menuconfiguration.cxx
+++ b/framework/source/fwe/xml/menuconfiguration.cxx
@@ -114,7 +114,7 @@ PopupMenu* MenuConfiguration::CreateBookmarkMenu(css::uno::Reference<css::frame:
void MenuConfiguration::StoreMenuBarConfigurationToXML(
Reference< XIndexAccess >& rMenuBarConfiguration,
- Reference< XOutputStream >& rOutputStream )
+ Reference< XOutputStream >& rOutputStream, bool bIsMenuBar )
throw (WrappedTargetException, RuntimeException)
{
Reference< XWriter > xWriter = Writer::create(m_xContext);
@@ -122,7 +122,7 @@ void MenuConfiguration::StoreMenuBarConfigurationToXML(
try
{
- OWriteMenuDocumentHandler aWriteMenuDocumentHandler( rMenuBarConfiguration, xWriter );
+ OWriteMenuDocumentHandler aWriteMenuDocumentHandler( rMenuBarConfiguration, xWriter, bIsMenuBar );
aWriteMenuDocumentHandler.WriteMenuDocument();
}
catch ( const RuntimeException& e )
diff --git a/framework/source/fwe/xml/menudocumenthandler.cxx b/framework/source/fwe/xml/menudocumenthandler.cxx
index 24ca38b4b25f..23131021a62c 100644
--- a/framework/source/fwe/xml/menudocumenthandler.cxx
+++ b/framework/source/fwe/xml/menudocumenthandler.cxx
@@ -217,7 +217,7 @@ void ReadMenuDocumentHandlerBase::initPropertyCommon(
OReadMenuDocumentHandler::OReadMenuDocumentHandler(
const Reference< XIndexContainer >& rMenuBarContainer )
: m_nElementDepth( 0 ),
- m_bMenuBarMode( false ),
+ m_eReaderMode( ReaderMode::None ),
m_xMenuBarContainer( rMenuBarContainer ),
m_xContainerFactory( rMenuBarContainer, UNO_QUERY )
{
@@ -247,17 +247,24 @@ void SAL_CALL OReadMenuDocumentHandler::startElement(
const OUString& aName, const Reference< XAttributeList > &xAttrList )
throw( SAXException, RuntimeException, std::exception )
{
- if ( m_bMenuBarMode )
+ if ( m_eReaderMode != ReaderMode::None )
{
++m_nElementDepth;
m_xReader->startElement( aName, xAttrList );
}
- else if ( aName == ELEMENT_MENUBAR )
+ else
{
+ if ( aName == ELEMENT_MENUBAR )
+ {
+ m_eReaderMode = ReaderMode::MenuBar;
+ m_xReader.set( new OReadMenuBarHandler( m_xMenuBarContainer, m_xContainerFactory ));
+ }
+ else if ( aName == ELEMENT_MENUPOPUP )
+ {
+ m_eReaderMode = ReaderMode::MenuPopup;
+ m_xReader.set( new OReadMenuPopupHandler( m_xMenuBarContainer, m_xContainerFactory ));
+ }
++m_nElementDepth;
- m_bMenuBarMode = true;
- m_xReader.set( new OReadMenuBarHandler( m_xMenuBarContainer, m_xContainerFactory ));
-
m_xReader->startDocument();
}
}
@@ -270,7 +277,7 @@ throw( SAXException, RuntimeException, std::exception )
void SAL_CALL OReadMenuDocumentHandler::endElement( const OUString& aName )
throw( SAXException, RuntimeException, std::exception )
{
- if ( m_bMenuBarMode )
+ if ( m_eReaderMode != ReaderMode::None )
{
--m_nElementDepth;
m_xReader->endElement( aName );
@@ -278,13 +285,19 @@ void SAL_CALL OReadMenuDocumentHandler::endElement( const OUString& aName )
{
m_xReader->endDocument();
m_xReader.clear();
- m_bMenuBarMode = false;
- if ( aName != ELEMENT_MENUBAR )
+ if ( m_eReaderMode == ReaderMode::MenuBar && aName != ELEMENT_MENUBAR )
{
OUString aErrorMessage = getErrorLineString();
aErrorMessage += "closing element menubar expected!";
throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
}
+ else if ( m_eReaderMode == ReaderMode::MenuPopup && aName != ELEMENT_MENUPOPUP )
+ {
+ OUString aErrorMessage = getErrorLineString();
+ aErrorMessage += "closing element menupopup expected!";
+ throw SAXException( aErrorMessage, Reference< XInterface >(), Any() );
+ }
+ m_eReaderMode = ReaderMode::None;
}
}
}
@@ -728,9 +741,11 @@ void SAL_CALL OReadMenuPopupHandler::endElement( const OUString& aName )
OWriteMenuDocumentHandler::OWriteMenuDocumentHandler(
const Reference< XIndexAccess >& rMenuBarContainer,
- const Reference< XDocumentHandler >& rDocumentHandler ) :
+ const Reference< XDocumentHandler >& rDocumentHandler,
+ bool bIsMenuBar ) :
m_xMenuBarContainer( rMenuBarContainer ),
- m_xWriteDocumentHandler( rDocumentHandler )
+ m_xWriteDocumentHandler( rDocumentHandler ),
+ m_bIsMenuBar( bIsMenuBar )
{
::comphelper::AttributeList* pList = new ::comphelper::AttributeList;
m_xEmptyList.set( static_cast<XAttributeList *>(pList), UNO_QUERY );
@@ -751,7 +766,7 @@ throw ( SAXException, RuntimeException )
// write DOCTYPE line!
Reference< XExtendedDocumentHandler > xExtendedDocHandler( m_xWriteDocumentHandler, UNO_QUERY );
- if ( xExtendedDocHandler.is() )
+ if ( m_bIsMenuBar /*FIXME*/ && xExtendedDocHandler.is() )
{
xExtendedDocHandler->unknown( MENUBAR_DOCTYPE );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
@@ -761,17 +776,23 @@ throw ( SAXException, RuntimeException )
m_aAttributeType,
OUString( XMLNS_MENU ) );
- pList->AddAttribute( OUString( ATTRIBUTE_NS_ID ),
- m_aAttributeType,
- OUString( "menubar" ) );
+ if ( m_bIsMenuBar ) //FIXME
+ pList->AddAttribute( OUString( ATTRIBUTE_NS_ID ),
+ m_aAttributeType,
+ OUString( "menubar" ) );
- m_xWriteDocumentHandler->startElement( ELEMENT_NS_MENUBAR, pList );
+ OUString aRootElement;
+ if ( m_bIsMenuBar )
+ aRootElement = ELEMENT_NS_MENUBAR;
+ else
+ aRootElement = ELEMENT_NS_MENUPOPUP;
+ m_xWriteDocumentHandler->startElement( aRootElement, pList );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
WriteMenu( m_xMenuBarContainer );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
- m_xWriteDocumentHandler->endElement( ELEMENT_NS_MENUBAR );
+ m_xWriteDocumentHandler->endElement( aRootElement );
m_xWriteDocumentHandler->ignorableWhitespace( OUString() );
m_xWriteDocumentHandler->endDocument();
}
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 9f9999e414ee..fc1134452fd7 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -64,6 +64,7 @@ using namespace framework;
#define RESOURCETYPE_MENUBAR "menubar"
#define RESOURCETYPE_TOOLBAR "toolbar"
#define RESOURCETYPE_STATUSBAR "statusbar"
+#define RESOURCETYPE_POPUPMENU "popupmenu"
namespace {
@@ -429,6 +430,7 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement
break;
case css::ui::UIElementType::MENUBAR:
+ case css::ui::UIElementType::POPUPMENU:
{
try
{
@@ -447,11 +449,6 @@ void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElement
}
break;
- case css::ui::UIElementType::POPUPMENU:
- {
- break;
- }
-
case css::ui::UIElementType::TOOLBAR:
{
try
@@ -570,11 +567,13 @@ void ModuleUIConfigurationManager::impl_storeElementTypeData( Reference< XStorag
switch( rElementType.nElementType )
{
case css::ui::UIElementType::MENUBAR:
+ case css::ui::UIElementType::POPUPMENU:
{
try
{
MenuConfiguration aMenuCfg( m_xContext );
- aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream );
+ aMenuCfg.StoreMenuBarConfigurationToXML(
+ rElement.xSettings, xOutputStream, rElementType.nElementType == css::ui::UIElementType::MENUBAR );
}
catch ( const css::lang::WrappedTargetException& )
{
@@ -891,6 +890,8 @@ ModuleUIConfigurationManager::ModuleUIConfigurationManager(
aResourceType = RESOURCETYPE_TOOLBAR;
else if ( i == css::ui::UIElementType::STATUSBAR )
aResourceType = RESOURCETYPE_STATUSBAR;
+ else if ( i == css::ui::UIElementType::POPUPMENU )
+ aResourceType = RESOURCETYPE_POPUPMENU;
if ( !aResourceType.isEmpty() )
{
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index 0451b6732a0a..cb958b26f900 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -347,6 +347,7 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
break;
case css::ui::UIElementType::MENUBAR:
+ case css::ui::UIElementType::POPUPMENU:
{
try
{
@@ -365,11 +366,6 @@ void UIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType,
}
break;
- case css::ui::UIElementType::POPUPMENU:
- {
- break;
- }
-
case css::ui::UIElementType::TOOLBAR:
{
try
@@ -479,11 +475,13 @@ void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage >& x
switch( rElementType.nElementType )
{
case css::ui::UIElementType::MENUBAR:
+ case css::ui::UIElementType::POPUPMENU:
{
try
{
MenuConfiguration aMenuCfg( m_xContext );
- aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream );
+ aMenuCfg.StoreMenuBarConfigurationToXML(
+ rElement.xSettings, xOutputStream, rElementType.nElementType == css::ui::UIElementType::MENUBAR );
}
catch ( const css::lang::WrappedTargetException& )
{