From 71ac08253fa7af25d5f4d62bf053ddc4fbe2c44f Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Fri, 11 Mar 2011 15:50:36 +0100 Subject: fwk167: #i109640# Don't call SetWindowState if window state is the same as the current one --- framework/source/helper/persistentwindowstate.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'framework') diff --git a/framework/source/helper/persistentwindowstate.cxx b/framework/source/helper/persistentwindowstate.cxx index 877c2dd3d711..c25036c5c346 100644 --- a/framework/source/helper/persistentwindowstate.cxx +++ b/framework/source/helper/persistentwindowstate.cxx @@ -61,6 +61,7 @@ #endif #include #include +#include //_________________________________________________________________________________________________________________ // namespace @@ -343,7 +344,9 @@ void PersistentWindowState::implst_setWindowStateOnWindow(const css::uno::Refere if (pWorkWindow->IsMinimized()) return; - pSystemWindow->SetWindowState(U2B_ENC(sWindowState,RTL_TEXTENCODING_UTF8)); + ::rtl::OUString sOldWindowState = ::rtl::OStringToOUString( pSystemWindow->GetWindowState(), RTL_TEXTENCODING_ASCII_US ); + if ( sOldWindowState != sWindowState ) + pSystemWindow->SetWindowState(U2B_ENC(sWindowState,RTL_TEXTENCODING_UTF8)); aSolarLock.clear(); // <- SOLAR SAFE ------------------------ -- cgit From 104874537cf87e29f24861db53dd690673fb57c4 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Wed, 16 Mar 2011 14:38:22 +0100 Subject: fwk167: #i116139# Check for preview frame in requestToolbar method. --- framework/source/layoutmanager/toolbarlayoutmanager.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'framework') diff --git a/framework/source/layoutmanager/toolbarlayoutmanager.cxx b/framework/source/layoutmanager/toolbarlayoutmanager.cxx index 5992e7b42dc5..2f66699de459 100644 --- a/framework/source/layoutmanager/toolbarlayoutmanager.cxx +++ b/framework/source/layoutmanager/toolbarlayoutmanager.cxx @@ -420,6 +420,14 @@ bool ToolbarLayoutManager::requestToolbar( const ::rtl::OUString& rResourceURL ) bool bMustCallCreate( false ); uno::Reference< ui::XUIElement > xUIElement; + ReadGuard aReadLock( m_aLock ); + uno::Reference< frame::XFrame > xFrame( m_xFrame ); + aReadLock.unlock(); + + uno::Reference< frame::XModel > xModel( impl_getModelFromFrame( xFrame )); + if ( implts_isPreviewModel( xModel )) + return false; // no toolbars for preview frame! + UIElement aRequestedToolbar = impl_findToolbar( rResourceURL ); if ( aRequestedToolbar.m_aName != rResourceURL ) { -- cgit From b46dab973c91c3a94bcda188a9888fef3fd16426 Mon Sep 17 00:00:00 2001 From: "Daniel Rentz [dr]" Date: Fri, 25 Mar 2011 10:40:25 +0100 Subject: calcvba: #164410# improve VBA compatibility implementation in various areas: Excel symbols, MSForms symbols, document and forms event handling --- framework/source/uielement/menubarmanager.cxx | 64 ++++++++++++++++----------- 1 file changed, 39 insertions(+), 25 deletions(-) (limited to 'framework') diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index fd8e0d3fbcd7..a74fbabb271e 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -134,16 +134,20 @@ static const char ITEM_DESCRIPTOR_LABEL[] = "Label"; static const char ITEM_DESCRIPTOR_TYPE[] = "Type"; static const char ITEM_DESCRIPTOR_MODULEIDENTIFIER[] = "ModuleIdentifier"; static const char ITEM_DESCRIPTOR_DISPATCHPROVIDER[] = "DispatchProvider"; -static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; - -const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10; -const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7; -const sal_Int32 LEN_DESCRIPTOR_CONTAINER = 23; -const sal_Int32 LEN_DESCRIPTOR_LABEL = 5; -const sal_Int32 LEN_DESCRIPTOR_TYPE = 4; -const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16; -const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16; -static const sal_Int32 ITEM_DESCRIPTOR_STYLE_LEN = 5; +static const char ITEM_DESCRIPTOR_STYLE[] = "Style"; +static const char ITEM_DESCRIPTOR_ISVISIBLE[] = "IsVisible"; +static const char ITEM_DESCRIPTOR_ENABLED[] = "Enabled"; + +static const sal_Int32 LEN_DESCRIPTOR_COMMANDURL = 10; +static const sal_Int32 LEN_DESCRIPTOR_HELPURL = 7; +static const sal_Int32 LEN_DESCRIPTOR_CONTAINER = 23; +static const sal_Int32 LEN_DESCRIPTOR_LABEL = 5; +static const sal_Int32 LEN_DESCRIPTOR_TYPE = 4; +static const sal_Int32 LEN_DESCRIPTOR_MODULEIDENTIFIER = 16; +static const sal_Int32 LEN_DESCRIPTOR_DISPATCHPROVIDER = 16; +static const sal_Int32 LEN_DESCRIPTOR_STYLE = 5; +static const sal_Int32 LEN_DESCRIPTOR_ISVISIBLE = 9; +static const sal_Int32 LEN_DESCRIPTOR_ENABLED = 7; const sal_uInt16 ADDONMENU_MERGE_ITEMID_START = 1500; @@ -1757,6 +1761,8 @@ void MenuBarManager::FillMenu( rtl::OUString aLabel; rtl::OUString aHelpURL; rtl::OUString aModuleIdentifier( rModuleIdentifier ); + sal_Bool bShow(sal_True); + sal_Bool bEnabled(sal_True); sal_uInt16 nType = 0; Reference< XIndexAccess > xIndexContainer; Reference< XDispatchProvider > xDispatchProvider( rDispatchProvider ); @@ -1768,29 +1774,26 @@ void MenuBarManager::FillMenu( for ( int i = 0; i < aProp.getLength(); i++ ) { rtl::OUString aPropName = aProp[i].Name; - if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL, - LEN_DESCRIPTOR_COMMANDURL )) + if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_COMMANDURL, LEN_DESCRIPTOR_COMMANDURL )) aProp[i].Value >>= aCommandURL; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, - LEN_DESCRIPTOR_HELPURL )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_HELPURL, LEN_DESCRIPTOR_HELPURL )) aProp[i].Value >>= aHelpURL; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, - LEN_DESCRIPTOR_CONTAINER )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_CONTAINER, LEN_DESCRIPTOR_CONTAINER )) aProp[i].Value >>= xIndexContainer; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, - LEN_DESCRIPTOR_LABEL )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_LABEL, LEN_DESCRIPTOR_LABEL )) aProp[i].Value >>= aLabel; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, - LEN_DESCRIPTOR_TYPE )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_TYPE, LEN_DESCRIPTOR_TYPE )) aProp[i].Value >>= nType; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_MODULEIDENTIFIER, - LEN_DESCRIPTOR_MODULEIDENTIFIER )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_MODULEIDENTIFIER, LEN_DESCRIPTOR_MODULEIDENTIFIER )) aProp[i].Value >>= aModuleIdentifier; - else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER, - LEN_DESCRIPTOR_DISPATCHPROVIDER )) + else if ( aPropName.equalsAsciiL( ITEM_DESCRIPTOR_DISPATCHPROVIDER, LEN_DESCRIPTOR_DISPATCHPROVIDER )) aProp[i].Value >>= xDispatchProvider; - else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, ITEM_DESCRIPTOR_STYLE_LEN )) + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_STYLE, LEN_DESCRIPTOR_STYLE )) aProp[i].Value >>= nStyle; + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_ISVISIBLE, LEN_DESCRIPTOR_ISVISIBLE )) + aProp[i].Value >>= bShow; + else if ( aProp[i].Name.equalsAsciiL( ITEM_DESCRIPTOR_ENABLED, LEN_DESCRIPTOR_ENABLED )) + aProp[i].Value >>= bEnabled; } if ( nType == ::com::sun::star::ui::ItemType::DEFAULT ) @@ -1809,6 +1812,17 @@ void MenuBarManager::FillMenu( nBits |= MIB_RADIOCHECK; pMenu->SetItemBits( nId, nBits ); } + + if ( bShow ) + pMenu->ShowItem( nId ); + else + pMenu->HideItem( nId ); + + if ( bEnabled) + pMenu->EnableItem( nId, sal_True ); + else + pMenu->EnableItem( nId, sal_False ); + if ( xIndexContainer.is() ) { PopupMenu* pNewPopupMenu = new PopupMenu; -- cgit From a11f433a956f0176643391e7c945b008ca91d9bf Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 30 Mar 2011 08:27:21 +0000 Subject: solaris11: #i117606#: framework: move imagesconfiguration.{c,h}xx to libfwk --- framework/Library_fwe.mk | 2 - framework/Library_fwk.mk | 2 + framework/Package_inc.mk | 1 - framework/inc/framework/imagesconfiguration.hxx | 128 ---- framework/inc/xml/imagesconfiguration.hxx | 128 ++++ framework/inc/xml/imagesdocumenthandler.hxx | 8 +- framework/source/fwe/xml/imagesconfiguration.cxx | 238 ------ framework/source/fwe/xml/imagesdocumenthandler.cxx | 851 --------------------- framework/source/uiconfiguration/imagemanager.cxx | 3 +- .../source/uiconfiguration/imagemanagerimpl.cxx | 3 +- .../source/uiconfiguration/moduleimagemanager.cxx | 3 +- framework/source/xml/imagesconfiguration.cxx | 237 ++++++ framework/source/xml/imagesdocumenthandler.cxx | 851 +++++++++++++++++++++ 13 files changed, 1227 insertions(+), 1228 deletions(-) delete mode 100644 framework/inc/framework/imagesconfiguration.hxx create mode 100644 framework/inc/xml/imagesconfiguration.hxx delete mode 100644 framework/source/fwe/xml/imagesconfiguration.cxx delete mode 100644 framework/source/fwe/xml/imagesdocumenthandler.cxx create mode 100644 framework/source/xml/imagesconfiguration.cxx create mode 100644 framework/source/xml/imagesdocumenthandler.cxx (limited to 'framework') diff --git a/framework/Library_fwe.mk b/framework/Library_fwe.mk index 5d30d108cde6..408a514c2f06 100644 --- a/framework/Library_fwe.mk +++ b/framework/Library_fwe.mk @@ -83,8 +83,6 @@ $(eval $(call gb_Library_add_exception_objects,fwe,\ framework/source/fwe/interaction/preventduplicateinteraction \ framework/source/fwe/xml/eventsconfiguration \ framework/source/fwe/xml/eventsdocumenthandler \ - framework/source/fwe/xml/imagesconfiguration \ - framework/source/fwe/xml/imagesdocumenthandler \ framework/source/fwe/xml/menuconfiguration \ framework/source/fwe/xml/menudocumenthandler \ framework/source/fwe/xml/saxnamespacefilter \ diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk index a34a1bc59720..3953d129afc2 100644 --- a/framework/Library_fwk.mk +++ b/framework/Library_fwk.mk @@ -183,6 +183,8 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\ framework/source/uifactory/windowcontentfactorymanager \ framework/source/xml/acceleratorconfigurationreader \ framework/source/xml/acceleratorconfigurationwriter \ + framework/source/xml/imagesconfiguration \ + framework/source/xml/imagesdocumenthandler \ )) # vim: set noet sw=4 ts=4: diff --git a/framework/Package_inc.mk b/framework/Package_inc.mk index 6d1c03a5975b..d72dd52128b8 100644 --- a/framework/Package_inc.mk +++ b/framework/Package_inc.mk @@ -39,7 +39,6 @@ $(eval $(call gb_Package_add_file,framework_inc,inc/framework/undomanagerhelper. $(eval $(call gb_Package_add_file,framework_inc,inc/framework/imutex.hxx,framework/imutex.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/iguard.hxx,framework/iguard.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/imageproducer.hxx,framework/imageproducer.hxx)) -$(eval $(call gb_Package_add_file,framework_inc,inc/framework/imagesconfiguration.hxx,framework/imagesconfiguration.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/interaction.hxx,framework/interaction.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/menuconfiguration.hxx,framework/menuconfiguration.hxx)) $(eval $(call gb_Package_add_file,framework_inc,inc/framework/menuextensionsupplier.hxx,framework/menuextensionsupplier.hxx)) diff --git a/framework/inc/framework/imagesconfiguration.hxx b/framework/inc/framework/imagesconfiguration.hxx deleted file mode 100644 index 0771e2d8f7f1..000000000000 --- a/framework/inc/framework/imagesconfiguration.hxx +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * 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. - * - * 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). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ -#define __FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ - -#include -#include -#include -#include -#include - -// #110897# -#include -#include -#include - -#include - -namespace framework -{ - -enum ImageMaskMode -{ - ImageMaskMode_Color, - ImageMaskMode_Bitmap -}; - -struct FWE_DLLPUBLIC ImageItemDescriptor -{ - ImageItemDescriptor() : nIndex( -1 ) {} - - String aCommandURL; // URL command to dispatch - long nIndex; // index of the bitmap inside the bitmaplist -}; - -struct FWE_DLLPUBLIC ExternalImageItemDescriptor -{ - String aCommandURL; // URL command to dispatch - String aURL; // a URL to an external bitmap -}; - -typedef ImageItemDescriptor* ImageItemDescriptorPtr; -SV_DECL_PTRARR_DEL( ImageItemListDescriptor, ImageItemDescriptorPtr, 10, 2) - -typedef ExternalImageItemDescriptor* ExternalImageItemDescriptorPtr; -SV_DECL_PTRARR_DEL( ExternalImageItemListDescriptor, ExternalImageItemDescriptorPtr, 10, 2) - -struct FWE_DLLPUBLIC ImageListItemDescriptor -{ - ImageListItemDescriptor() : nMaskMode( ImageMaskMode_Color ), - pImageItemList( 0 ) {} - - ~ImageListItemDescriptor() { delete pImageItemList; } - - String aURL; // an URL to a bitmap with several images inside - Color aMaskColor; // a color used as transparent - String aMaskURL; // an URL to an optional bitmap used as a mask - ImageMaskMode nMaskMode; // an enum to describe the current mask mode - ImageItemListDescriptor* pImageItemList; // an array of ImageItemDescriptors that describes every image - String aHighContrastURL; // an URL to an optional high contrast bitmap with serveral images inside - String aHighContrastMaskURL; // an URL to an optional high contrast bitmap as a mask -}; - -typedef ImageListItemDescriptor* ImageListItemDescriptorPtr; -SV_DECL_PTRARR_DEL( ImageListDescriptor, ImageListItemDescriptorPtr, 10, 2) - -struct FWE_DLLPUBLIC ImageListsDescriptor -{ - ImageListsDescriptor() : pImageList( 0 ), - pExternalImageList( 0 ) {} - ~ImageListsDescriptor() { delete pImageList; delete pExternalImageList; } - - ImageListDescriptor* pImageList; - ExternalImageItemListDescriptor* pExternalImageList; -}; - -class FWE_DLLPUBLIC ImagesConfiguration -{ - public: - // #110897# - static sal_Bool LoadImages( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, - SvStream& rInStream, ImageListsDescriptor& aItems ); - - // #110897# - static sal_Bool StoreImages( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, - SvStream& rOutStream, const ImageListsDescriptor& aItems ); - - static sal_Bool LoadImages( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream, - ImageListsDescriptor& rItems ); - - static sal_Bool StoreImages( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream, - const ImageListsDescriptor& rItems ); -}; - -} // namespace framework - -#endif // __FRAMEWORK_CLASSES_IMAGES diff --git a/framework/inc/xml/imagesconfiguration.hxx b/framework/inc/xml/imagesconfiguration.hxx new file mode 100644 index 000000000000..3174e6d51b22 --- /dev/null +++ b/framework/inc/xml/imagesconfiguration.hxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ +#define FRAMEWORK_XML_IMAGESCONFIGURATION_HXX_ + +#include +#include +#include +#include +#include + +// #110897# +#include +#include +#include + +#include + +namespace framework +{ + +enum ImageMaskMode +{ + ImageMaskMode_Color, + ImageMaskMode_Bitmap +}; + +struct ImageItemDescriptor +{ + ImageItemDescriptor() : nIndex( -1 ) {} + + String aCommandURL; // URL command to dispatch + long nIndex; // index of the bitmap inside the bitmaplist +}; + +struct ExternalImageItemDescriptor +{ + String aCommandURL; // URL command to dispatch + String aURL; // a URL to an external bitmap +}; + +typedef ImageItemDescriptor* ImageItemDescriptorPtr; +SV_DECL_PTRARR_DEL( ImageItemListDescriptor, ImageItemDescriptorPtr, 10, 2) + +typedef ExternalImageItemDescriptor* ExternalImageItemDescriptorPtr; +SV_DECL_PTRARR_DEL( ExternalImageItemListDescriptor, ExternalImageItemDescriptorPtr, 10, 2) + +struct ImageListItemDescriptor +{ + ImageListItemDescriptor() : nMaskMode( ImageMaskMode_Color ), + pImageItemList( 0 ) {} + + ~ImageListItemDescriptor() { delete pImageItemList; } + + String aURL; // an URL to a bitmap with several images inside + Color aMaskColor; // a color used as transparent + String aMaskURL; // an URL to an optional bitmap used as a mask + ImageMaskMode nMaskMode; // an enum to describe the current mask mode + ImageItemListDescriptor* pImageItemList; // an array of ImageItemDescriptors that describes every image + String aHighContrastURL; // an URL to an optional high contrast bitmap with serveral images inside + String aHighContrastMaskURL; // an URL to an optional high contrast bitmap as a mask +}; + +typedef ImageListItemDescriptor* ImageListItemDescriptorPtr; +SV_DECL_PTRARR_DEL( ImageListDescriptor, ImageListItemDescriptorPtr, 10, 2) + +struct ImageListsDescriptor +{ + ImageListsDescriptor() : pImageList( 0 ), + pExternalImageList( 0 ) {} + ~ImageListsDescriptor() { delete pImageList; delete pExternalImageList; } + + ImageListDescriptor* pImageList; + ExternalImageItemListDescriptor* pExternalImageList; +}; + +class ImagesConfiguration +{ + public: + // #110897# + static sal_Bool LoadImages( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + SvStream& rInStream, ImageListsDescriptor& aItems ); + + // #110897# + static sal_Bool StoreImages( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + SvStream& rOutStream, const ImageListsDescriptor& aItems ); + + static sal_Bool LoadImages( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream, + ImageListsDescriptor& rItems ); + + static sal_Bool StoreImages( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream, + const ImageListsDescriptor& rItems ); +}; + +} // namespace framework + +#endif // __FRAMEWORK_CLASSES_IMAGES diff --git a/framework/inc/xml/imagesdocumenthandler.hxx b/framework/inc/xml/imagesdocumenthandler.hxx index 59d1e4abdb3a..4aa370c013d7 100644 --- a/framework/inc/xml/imagesdocumenthandler.hxx +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -25,8 +25,8 @@ * ************************************************************************/ -#ifndef __FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ -#define __FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ +#ifndef FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ +#define FRAMEWORK_XML_IMAGEDOCUMENTHANDLER_HXX_ #include @@ -34,14 +34,12 @@ // interface includes //_________________________________________________________________________________________________________________ -#ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_ #include -#endif //_________________________________________________________________________________________________________________ // other includes //_________________________________________________________________________________________________________________ -#include +#include #include #include #include diff --git a/framework/source/fwe/xml/imagesconfiguration.cxx b/framework/source/fwe/xml/imagesconfiguration.cxx deleted file mode 100644 index d561a76d5995..000000000000 --- a/framework/source/fwe/xml/imagesconfiguration.cxx +++ /dev/null @@ -1,238 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * 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. - * - * 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). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" -#include -#include - -#ifndef __FRAMEWORK_CLASSES_IMAGESDOCUMENTHANDLER_HXX_ -#include -#endif -#include - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ -#include -#include -#include -#include - -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ - -#ifndef _UNOTOOLS_PROCESSFACTORY_HXX -#include -#endif -#include -#include - -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::xml::sax; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::io; - - -namespace framework -{ - -SV_IMPL_PTRARR( ImageItemListDescriptor, ImageItemDescriptorPtr ); -SV_IMPL_PTRARR( ExternalImageItemListDescriptor, ExternalImageItemDescriptorPtr ); -SV_IMPL_PTRARR( ImageListDescriptor, ImageListItemDescriptorPtr ); - -static Reference< XParser > GetSaxParser( - // #110897# - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory - ) -{ - //Reference< XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); - //return Reference< XParser >( xServiceManager->createInstance( SERVICENAME_SAXPARSER), UNO_QUERY); - return Reference< XParser >( xServiceFactory->createInstance( SERVICENAME_SAXPARSER), UNO_QUERY); -} - -static Reference< XDocumentHandler > GetSaxWriter( - // #110897# - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory - ) -{ - //Reference< XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); - //return Reference< XDocumentHandler >( xServiceManager->createInstance( SERVICENAME_SAXWRITER), UNO_QUERY) ; - return Reference< XDocumentHandler >( xServiceFactory->createInstance( SERVICENAME_SAXWRITER), UNO_QUERY) ; -} - -// #110897# -sal_Bool ImagesConfiguration::LoadImages( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, - SvStream& rInStream, ImageListsDescriptor& aItems ) -{ - Reference< XParser > xParser( GetSaxParser( xServiceFactory ) ); - Reference< XInputStream > xInputStream( - (::cppu::OWeakObject *)new utl::OInputStreamWrapper( rInStream ), - UNO_QUERY ); - - // connect stream to input stream to the parser - InputSource aInputSource; - - aInputSource.aInputStream = xInputStream; - - // create namespace filter and set document handler inside to support xml namespaces - Reference< XDocumentHandler > xDocHandler( new OReadImagesDocumentHandler( aItems )); - Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler )); - - // connect parser and filter - xParser->setDocumentHandler( xFilter ); - - try - { - xParser->parseStream( aInputSource ); - return sal_True; - } - catch ( RuntimeException& ) - { - return sal_False; - } - catch( SAXException& ) - { - return sal_False; - } - catch( ::com::sun::star::io::IOException& ) - { - return sal_False; - } -} - - -// #110897# -sal_Bool ImagesConfiguration::StoreImages( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, - SvStream& rOutStream, const ImageListsDescriptor& aItems ) -{ - Reference< XDocumentHandler > xWriter( GetSaxWriter( xServiceFactory ) ); - - Reference< XOutputStream > xOutputStream( - (::cppu::OWeakObject *)new utl::OOutputStreamWrapper( rOutStream ), - UNO_QUERY ); - - Reference< ::com::sun::star::io::XActiveDataSource> xDataSource( xWriter , UNO_QUERY ); - xDataSource->setOutputStream( xOutputStream ); - - try - { - OWriteImagesDocumentHandler aWriteImagesDocumentHandler( aItems, xWriter ); - aWriteImagesDocumentHandler.WriteImagesDocument(); - return sal_True; - } - catch ( RuntimeException& ) - { - return sal_False; - } - catch ( SAXException& ) - { - return sal_False; - } - catch ( ::com::sun::star::io::IOException& ) - { - return sal_False; - } -} - -sal_Bool ImagesConfiguration::LoadImages( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream, - ImageListsDescriptor& rItems ) -{ - Reference< XParser > xParser( GetSaxParser( xServiceFactory ) ); - - // connect stream to input stream to the parser - InputSource aInputSource; - - aInputSource.aInputStream = rInputStream; - - // create namespace filter and set document handler inside to support xml namespaces - Reference< XDocumentHandler > xDocHandler( new OReadImagesDocumentHandler( rItems )); - Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler )); - - // connect parser and filter - xParser->setDocumentHandler( xFilter ); - - try - { - xParser->parseStream( aInputSource ); - return sal_True; - } - catch ( RuntimeException& ) - { - return sal_False; - } - catch( SAXException& ) - { - return sal_False; - } - catch( ::com::sun::star::io::IOException& ) - { - return sal_False; - } -} - -sal_Bool ImagesConfiguration::StoreImages( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream, - const ImageListsDescriptor& rItems ) -{ - Reference< XDocumentHandler > xWriter( GetSaxWriter( xServiceFactory ) ); - - Reference< ::com::sun::star::io::XActiveDataSource> xDataSource( xWriter , UNO_QUERY ); - xDataSource->setOutputStream( rOutputStream ); - - try - { - OWriteImagesDocumentHandler aWriteImagesDocumentHandler( rItems, xWriter ); - aWriteImagesDocumentHandler.WriteImagesDocument(); - return sal_True; - } - catch ( RuntimeException& ) - { - return sal_False; - } - catch ( SAXException& ) - { - return sal_False; - } - catch ( ::com::sun::star::io::IOException& ) - { - return sal_False; - } -} - -} - diff --git a/framework/source/fwe/xml/imagesdocumenthandler.cxx b/framework/source/fwe/xml/imagesdocumenthandler.cxx deleted file mode 100644 index cdf20958332a..000000000000 --- a/framework/source/fwe/xml/imagesdocumenthandler.cxx +++ /dev/null @@ -1,851 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * 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. - * - * 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). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" - -#include - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ - -#include -#include -#include - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ - -#ifndef __COM_SUN_STAR_XML_SAX_XEXTENDEDDOCUMENTHANDLER_HPP_ -#include -#endif - -//_________________________________________________________________________________________________________________ -// other includes -//_________________________________________________________________________________________________________________ -#include -#include -#include - -#include - -//_________________________________________________________________________________________________________________ -// namespace -//_________________________________________________________________________________________________________________ - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::xml::sax; - -#define ELEMENT_IMAGECONTAINER "imagescontainer" -#define ELEMENT_IMAGES "images" -#define ELEMENT_ENTRY "entry" -#define ELEMENT_EXTERNALIMAGES "externalimages" -#define ELEMENT_EXTERNALENTRY "externalentry" - -#define ELEMENT_NS_IMAGESCONTAINER "image:imagescontainer" -#define ELEMENT_NS_IMAGES "image:images" -#define ELEMENT_NS_ENTRY "image:entry" -#define ELEMENT_NS_EXTERNALIMAGES "image:externalimages" -#define ELEMENT_NS_EXTERNALENTRY "image:externalentry" - -#define ATTRIBUTE_HREF "href" -#define ATTRIBUTE_MASKCOLOR "maskcolor" -#define ATTRIBUTE_COMMAND "command" -#define ATTRIBUTE_BITMAPINDEX "bitmap-index" -#define ATTRIBUTE_MASKURL "maskurl" -#define ATTRIBUTE_MASKMODE "maskmode" -#define ATTRIBUTE_HIGHCONTRASTURL "highcontrasturl" -#define ATTRIBUTE_HIGHCONTRASTMASKURL "highcontrastmaskurl" -#define ATTRIBUTE_TYPE_CDATA "CDATA" - -#define ATTRIBUTE_MASKMODE_BITMAP "maskbitmap" -#define ATTRIBUTE_MASKMODE_COLOR "maskcolor" - -#define ATTRIBUTE_XMLNS_IMAGE "xmlns:image" -#define ATTRIBUTE_XMLNS_XLINK "xmlns:xlink" - -#define ATTRIBUTE_XLINK_TYPE "xlink:type" -#define ATTRIBUTE_XLINK_TYPE_VALUE "simple" - -#define XMLNS_IMAGE "http://openoffice.org/2001/image" -#define XMLNS_XLINK "http://www.w3.org/1999/xlink" -#define XMLNS_IMAGE_PREFIX "image:" -#define XMLNS_XLINK_PREFIX "xlink:" - -#define XMLNS_FILTER_SEPARATOR "^" - -#define IMAGES_DOCTYPE "" - -namespace framework -{ - -struct ImageXMLEntryProperty -{ - OReadImagesDocumentHandler::Image_XML_Namespace nNamespace; - char aEntryName[20]; -}; - -ImageXMLEntryProperty ImagesEntries[OReadImagesDocumentHandler::IMG_XML_ENTRY_COUNT] = -{ - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_IMAGECONTAINER }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_IMAGES }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_ENTRY }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_EXTERNALIMAGES }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_EXTERNALENTRY }, - { OReadImagesDocumentHandler::IMG_NS_XLINK, ATTRIBUTE_HREF }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_MASKCOLOR }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_COMMAND }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_BITMAPINDEX }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_MASKURL }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_MASKMODE }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_HIGHCONTRASTURL }, - { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_HIGHCONTRASTMASKURL } -}; - - -OReadImagesDocumentHandler::OReadImagesDocumentHandler( ImageListsDescriptor& aItems ) : - ThreadHelpBase( &Application::GetSolarMutex() ), - m_aImageList( aItems ), - m_pImages( 0 ), - m_pExternalImages( 0 ) -{ - m_aImageList.pImageList = NULL; - m_aImageList.pExternalImageList = NULL; - - m_nHashMaskModeBitmap = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE_BITMAP )).hashCode(); - m_nHashMaskModeColor = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE_COLOR )).hashCode(); - - // create hash map to speed up lookup - for ( int i = 0; i < (int)IMG_XML_ENTRY_COUNT; i++ ) - { - ::rtl::OUStringBuffer temp( 20 ); - - if ( ImagesEntries[i].nNamespace == IMG_NS_IMAGE ) - temp.appendAscii( XMLNS_IMAGE ); - else - temp.appendAscii( XMLNS_XLINK ); - - temp.appendAscii( XMLNS_FILTER_SEPARATOR ); - temp.appendAscii( ImagesEntries[i].aEntryName ); - m_aImageMap.insert( ImageHashMap::value_type( temp.makeStringAndClear(), (Image_XML_Entry)i ) ); - } - - // reset states - m_bImageContainerStartFound = sal_False; - m_bImageContainerEndFound = sal_False; - m_bImagesStartFound = sal_False; - m_bImagesEndFound = sal_False; - m_bImageStartFound = sal_False; - m_bExternalImagesStartFound = sal_False; - m_bExternalImagesEndFound = sal_False; - m_bExternalImageStartFound = sal_False; -} - -OReadImagesDocumentHandler::~OReadImagesDocumentHandler() -{ -} - -// XDocumentHandler -void SAL_CALL OReadImagesDocumentHandler::startDocument(void) -throw ( SAXException, RuntimeException ) -{ -} - -void SAL_CALL OReadImagesDocumentHandler::endDocument(void) -throw( SAXException, RuntimeException ) -{ - ResetableGuard aGuard( m_aLock ); - - if (( m_bImageContainerStartFound && !m_bImageContainerEndFound ) || - ( !m_bImageContainerStartFound && m_bImageContainerEndFound ) ) - { - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No matching start or end element 'image:imagecontainer' found!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } -} - -void SAL_CALL OReadImagesDocumentHandler::startElement( - const ::rtl::OUString& aName, const Reference< XAttributeList > &xAttribs ) -throw( SAXException, RuntimeException ) -{ - ResetableGuard aGuard( m_aLock ); - - ImageHashMap::const_iterator pImageEntry = m_aImageMap.find( aName ) ; - if ( pImageEntry != m_aImageMap.end() ) - { - switch ( pImageEntry->second ) - { - case IMG_ELEMENT_IMAGECONTAINER: - { - // image:imagecontainer element (container element for all further image elements) - if ( m_bImageContainerStartFound ) - { - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:imagecontainer' cannot be embeded into 'image:imagecontainer'!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - m_bImageContainerStartFound = sal_True; - } - break; - - case IMG_ELEMENT_IMAGES: - { - if ( !m_bImageContainerStartFound ) - { - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:images' must be embeded into element 'image:imagecontainer'!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - if ( m_bImagesStartFound ) - { - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:images' cannot be embeded into 'image:images'!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - if ( !m_aImageList.pImageList ) - m_aImageList.pImageList = new ImageListDescriptor; - - m_bImagesStartFound = sal_True; - m_pImages = new ImageListItemDescriptor; - - for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) - { - pImageEntry = m_aImageMap.find( xAttribs->getNameByIndex( n ) ); - if ( pImageEntry != m_aImageMap.end() ) - { - switch ( pImageEntry->second ) - { - case IMG_ATTRIBUTE_HREF: - { - m_pImages->aURL = xAttribs->getValueByIndex( n ); - } - break; - - case IMG_ATTRIBUTE_MASKCOLOR: - { - ::rtl::OUString aColor = xAttribs->getValueByIndex( n ); - - if ( aColor.getLength() > 0 ) - { - if ( aColor.getStr()[0] == '#' ) - { - // the color value is given as #rrggbb and used the hexadecimal system!! - sal_uInt32 nColor = aColor.copy( 1 ).toInt32( 16 ); - - m_pImages->aMaskColor = Color( COLORDATA_RGB( nColor ) ); - } - } - } - break; - - case IMG_ATTRIBUTE_MASKURL: - { - m_pImages->aMaskURL = xAttribs->getValueByIndex( n ); - } - break; - - case IMG_ATTRIBUTE_MASKMODE: - { - sal_Int32 nHashCode = xAttribs->getValueByIndex( n ).hashCode(); - if ( nHashCode == m_nHashMaskModeBitmap ) - m_pImages->nMaskMode = ImageMaskMode_Bitmap; - else if ( nHashCode == m_nHashMaskModeColor ) - m_pImages->nMaskMode = ImageMaskMode_Color; - else - { - delete m_pImages; - m_pImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Attribute image:maskmode must be 'maskcolor' or 'maskbitmap'!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - } - break; - - case IMG_ATTRIBUTE_HIGHCONTRASTURL: - { - m_pImages->aHighContrastURL = xAttribs->getValueByIndex( n ); - } - break; - - case IMG_ATTRIBUTE_HIGHCONTRASTMASKURL: - { - m_pImages->aHighContrastMaskURL = xAttribs->getValueByIndex( n ); - } - break; - - default: - break; - } - } - } // for - - if ( m_pImages->aURL.Len() == 0 ) - { - delete m_pImages; - m_pImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute xlink:href must have a value!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - } - break; - - case IMG_ELEMENT_ENTRY: - { - // Check that image:entry is embeded into image:images! - if ( !m_bImagesStartFound ) - { - delete m_pImages; - m_pImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:entry' must be embeded into element 'image:images'!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - if ( !m_pImages->pImageItemList ) - m_pImages->pImageItemList = new ImageItemListDescriptor; - - m_bImageStartFound = sal_True; - - // Create new image item descriptor - ImageItemDescriptor* pItem = new ImageItemDescriptor; - pItem->nIndex = -1; - - // Read attributes for this image definition - for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) - { - pImageEntry = m_aImageMap.find( xAttribs->getNameByIndex( n ) ); - if ( pImageEntry != m_aImageMap.end() ) - { - switch ( pImageEntry->second ) - { - case IMG_ATTRIBUTE_COMMAND: - { - pItem->aCommandURL = xAttribs->getValueByIndex( n ); - } - break; - - case IMG_ATTRIBUTE_BITMAPINDEX: - { - pItem->nIndex = xAttribs->getValueByIndex( n ).toInt32(); - } - break; - - default: - break; - } - } - } - - // Check required attribute "bitmap-index" - if ( pItem->nIndex < 0 ) - { - delete pItem; - delete m_pImages; - m_pImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute 'image:bitmap-index' must have a value >= 0!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - // Check required attribute "command" - if ( pItem->aCommandURL.Len() == 0 ) - { - delete pItem; - delete m_pImages; - m_pImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute 'image:command' must have a value!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - if ( m_pImages ) - m_pImages->pImageItemList->Insert( pItem, m_pImages->pImageItemList->Count() ); - } - break; - - case IMG_ELEMENT_EXTERNALIMAGES: - { - // Check that image:externalimages is embeded into image:imagecontainer - if ( !m_bImageContainerStartFound ) - { - delete m_pImages; - m_pImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:externalimages' must be embeded into element 'image:imagecontainer'!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - // Check that image:externalentry is NOT embeded into image:externalentry - if ( m_bExternalImagesStartFound ) - { - delete m_pImages; - m_pImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:externalimages' cannot be embeded into 'image:externalimages'!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - // Create unique external image container - m_bExternalImagesStartFound = sal_True; - m_pExternalImages = new ExternalImageItemListDescriptor; - } - break; - - case IMG_ELEMENT_EXTERNALENTRY: - { - if ( !m_bExternalImagesStartFound ) - { - delete m_pImages; - delete m_pExternalImages; - m_pImages = NULL; - m_pExternalImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:externalentry' must be embeded into 'image:externalimages'!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - if ( m_bExternalImageStartFound ) - { - delete m_pImages; - delete m_pExternalImages; - m_pImages = NULL; - m_pExternalImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:externalentry' cannot be embeded into 'image:externalentry'!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - m_bExternalImageStartFound = sal_True; - - ExternalImageItemDescriptor* pItem = new ExternalImageItemDescriptor; - - // Read attributes for this external image definition - for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) - { - pImageEntry = m_aImageMap.find( xAttribs->getNameByIndex( n ) ); - if ( pImageEntry != m_aImageMap.end() ) - { - switch ( pImageEntry->second ) - { - case IMG_ATTRIBUTE_COMMAND: - { - pItem->aCommandURL = xAttribs->getValueByIndex( n ); - } - break; - - case IMG_ATTRIBUTE_HREF: - { - pItem->aURL = xAttribs->getValueByIndex( n ); - } - break; - - default: - break; - } - } - } - - // Check required attribute "command" - if ( pItem->aCommandURL.Len() == 0 ) - { - delete pItem; - delete m_pImages; - delete m_pExternalImages; - m_pImages = NULL; - m_pExternalImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute 'image:command' must have a value!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - // Check required attribute "href" - if ( pItem->aURL.Len() == 0 ) - { - delete pItem; - delete m_pImages; - delete m_pExternalImages; - m_pImages = NULL; - m_pExternalImages = NULL; - - ::rtl::OUString aErrorMessage = getErrorLineString(); - aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute 'xlink:href' must have a value!" )); - throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); - } - - if ( m_pExternalImages ) - m_pExternalImages->Insert( pItem, m_pExternalImages->Count() ); - } - break; - - default: - break; - } - } -} - -void SAL_CALL OReadImagesDocumentHandler::endElement(const ::rtl::OUString& aName) -throw( SAXException, RuntimeException ) -{ - ResetableGuard aGuard( m_aLock ); - - ImageHashMap::const_iterator pImageEntry = m_aImageMap.find( aName ) ; - if ( pImageEntry != m_aImageMap.end() ) - { - switch ( pImageEntry->second ) - { - case IMG_ELEMENT_IMAGECONTAINER: - { - m_bImageContainerEndFound = sal_True; - } - break; - - case IMG_ELEMENT_IMAGES: - { - if ( m_pImages ) - { - if ( m_aImageList.pImageList ) - m_aImageList.pImageList->Insert( m_pImages, m_aImageList.pImageList->Count() ); - m_pImages = NULL; - } - m_bImagesStartFound = sal_False; - } - break; - - case IMG_ELEMENT_ENTRY: - { - m_bImageStartFound = sal_False; - } - break; - - case IMG_ELEMENT_EXTERNALIMAGES: - { - if ( m_pExternalImages && !m_aImageList.pExternalImageList ) - { - if ( !m_aImageList.pExternalImageList ) - m_aImageList.pExternalImageList = m_pExternalImages; - } - - m_bExternalImagesStartFound = sal_False; - m_pExternalImages = NULL; - } - break; - - case IMG_ELEMENT_EXTERNALENTRY: - { - m_bExternalImageStartFound = sal_False; - } - break; - - default: - break; - } - } -} - -void SAL_CALL OReadImagesDocumentHandler::characters(const ::rtl::OUString&) -throw( SAXException, RuntimeException ) -{ -} - -void SAL_CALL OReadImagesDocumentHandler::ignorableWhitespace(const ::rtl::OUString&) -throw( SAXException, RuntimeException ) -{ -} - -void SAL_CALL OReadImagesDocumentHandler::processingInstruction( - const ::rtl::OUString& /*aTarget*/, const ::rtl::OUString& /*aData*/ ) -throw( SAXException, RuntimeException ) -{ -} - -void SAL_CALL OReadImagesDocumentHandler::setDocumentLocator( - const Reference< XLocator > &xLocator) -throw( SAXException, RuntimeException ) -{ - ResetableGuard aGuard( m_aLock ); - - m_xLocator = xLocator; -} - -::rtl::OUString OReadImagesDocumentHandler::getErrorLineString() -{ - ResetableGuard aGuard( m_aLock ); - - char buffer[32]; - - if ( m_xLocator.is() ) - { - snprintf( buffer, sizeof(buffer), "Line: %ld - ", static_cast( m_xLocator->getLineNumber() )); - return ::rtl::OUString::createFromAscii( buffer ); - } - else - return ::rtl::OUString(); -} - - -//_________________________________________________________________________________________________________________ -// OWriteImagesDocumentHandler -//_________________________________________________________________________________________________________________ - -OWriteImagesDocumentHandler::OWriteImagesDocumentHandler( - const ImageListsDescriptor& aItems, - Reference< XDocumentHandler > rWriteDocumentHandler ) : - ThreadHelpBase( &Application::GetSolarMutex() ), - m_aImageListsItems( aItems ), - m_xWriteDocumentHandler( rWriteDocumentHandler ) -{ - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - m_xEmptyList = Reference< XAttributeList >( (XAttributeList *) pList, UNO_QUERY ); - m_aAttributeType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TYPE_CDATA )); - m_aXMLImageNS = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_IMAGE_PREFIX )); - m_aXMLXlinkNS = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_PREFIX )); - m_aAttributeXlinkType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XLINK_TYPE )); - m_aAttributeValueSimple = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XLINK_TYPE_VALUE )); -} - -OWriteImagesDocumentHandler::~OWriteImagesDocumentHandler() -{ -} - -void OWriteImagesDocumentHandler::WriteImagesDocument() throw -( SAXException, RuntimeException ) -{ - ResetableGuard aGuard( m_aLock ); - - m_xWriteDocumentHandler->startDocument(); - - // write DOCTYPE line! - Reference< XExtendedDocumentHandler > xExtendedDocHandler( m_xWriteDocumentHandler, UNO_QUERY ); - if ( xExtendedDocHandler.is() ) - { - xExtendedDocHandler->unknown( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMAGES_DOCTYPE )) ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); - } - - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY ); - - pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_IMAGE )), - m_aAttributeType, - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_IMAGE )) ); - - pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_XLINK )), - m_aAttributeType, - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK )) ); - - m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_IMAGESCONTAINER )), pList ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); - - if ( m_aImageListsItems.pImageList ) - { - ImageListDescriptor* pImageList = m_aImageListsItems.pImageList; - - for ( sal_uInt16 i = 0; i < m_aImageListsItems.pImageList->Count(); i++ ) - { - const ImageListItemDescriptor* pImageItems = (*pImageList)[i]; - WriteImageList( pImageItems ); - } - } - - if ( m_aImageListsItems.pExternalImageList ) - { - WriteExternalImageList( m_aImageListsItems.pExternalImageList ); - } - - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); - m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_IMAGESCONTAINER )) ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); - m_xWriteDocumentHandler->endDocument(); -} - -//_________________________________________________________________________________________________________________ -// protected member functions -//_________________________________________________________________________________________________________________ - -void OWriteImagesDocumentHandler::WriteImageList( const ImageListItemDescriptor* pImageList ) throw -( SAXException, RuntimeException ) -{ - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY ); - - // save required attributes - pList->AddAttribute( m_aAttributeXlinkType, - m_aAttributeType, - m_aAttributeValueSimple ); - - pList->AddAttribute( m_aXMLXlinkNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HREF )), - m_aAttributeType, - pImageList->aURL ); - - if ( pImageList->nMaskMode == ImageMaskMode_Bitmap ) - { - pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE )), - m_aAttributeType, - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE_BITMAP )) ); - - pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKURL )), - m_aAttributeType, - pImageList->aMaskURL ); - - if ( pImageList->aHighContrastMaskURL.Len() > 0 ) - { - pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HIGHCONTRASTMASKURL )), - m_aAttributeType, - pImageList->aHighContrastMaskURL ); - } - } - else - { - ::rtl::OUStringBuffer aColorStrBuffer( 8 ); - sal_Int64 nValue = pImageList->aMaskColor.GetRGBColor(); - - aColorStrBuffer.appendAscii( "#" ); - aColorStrBuffer.append( ::rtl::OUString::valueOf( nValue, 16 )); - - pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKCOLOR )), - m_aAttributeType, - aColorStrBuffer.makeStringAndClear() ); - - pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE )), - m_aAttributeType, - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE_COLOR )) ); - } - - if ( pImageList->aHighContrastURL.Len() > 0 ) - { - pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HIGHCONTRASTURL )), - m_aAttributeType, - pImageList->aHighContrastURL ); - } - - m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_IMAGES )), xList ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); - - ImageItemListDescriptor* pImageItemList = pImageList->pImageItemList; - if ( pImageItemList ) - { - for ( sal_uInt16 i = 0; i < pImageItemList->Count(); i++ ) - WriteImage( (*pImageItemList)[i] ); - } - - m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_IMAGES )) ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); -} - -void OWriteImagesDocumentHandler::WriteImage( const ImageItemDescriptor* pImage ) throw -( SAXException, RuntimeException ) -{ - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY ); - - pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_BITMAPINDEX )), - m_aAttributeType, - ::rtl::OUString::valueOf( (sal_Int32)pImage->nIndex ) ); - - pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_COMMAND )), - m_aAttributeType, - pImage->aCommandURL ); - - m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_ENTRY )), xList ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); - - m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_ENTRY )) ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); -} - -void OWriteImagesDocumentHandler::WriteExternalImageList( const ExternalImageItemListDescriptor* pExternalImageList ) throw -( SAXException, RuntimeException ) -{ - m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EXTERNALIMAGES )), m_xEmptyList ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); - - for ( sal_uInt16 i = 0; i < pExternalImageList->Count(); i++ ) - { - ExternalImageItemDescriptor* pItem = (*pExternalImageList)[i]; - WriteExternalImage( pItem ); - } - - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); - m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EXTERNALIMAGES )) ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); -} - -void OWriteImagesDocumentHandler::WriteExternalImage( const ExternalImageItemDescriptor* pExternalImage ) throw -( SAXException, RuntimeException ) -{ - ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; - Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY ); - - // save required attributes - pList->AddAttribute( m_aAttributeXlinkType, - m_aAttributeType, - m_aAttributeValueSimple ); - - if ( pExternalImage->aURL.Len() > 0 ) - { - pList->AddAttribute( m_aXMLXlinkNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HREF )), - m_aAttributeType, - pExternalImage->aURL ); - } - - if ( pExternalImage->aCommandURL.Len() > 0 ) - { - pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_COMMAND )), - m_aAttributeType, - pExternalImage->aCommandURL ); - } - - m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EXTERNALENTRY )), xList ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); - - m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EXTERNALENTRY )) ); - m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); -} - -} // namespace framework - - - - diff --git a/framework/source/uiconfiguration/imagemanager.cxx b/framework/source/uiconfiguration/imagemanager.cxx index 2a57e72e1ce4..776af9982de4 100644 --- a/framework/source/uiconfiguration/imagemanager.cxx +++ b/framework/source/uiconfiguration/imagemanager.cxx @@ -27,9 +27,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include #include -#include +#include #include #include #include "imagemanagerimpl.hxx" diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx index 537fe623d633..d0caee82297e 100755 --- a/framework/source/uiconfiguration/imagemanagerimpl.cxx +++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx @@ -27,9 +27,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include #include -#include +#include #include #include diff --git a/framework/source/uiconfiguration/moduleimagemanager.cxx b/framework/source/uiconfiguration/moduleimagemanager.cxx index fc90dd102912..0e0f828a253f 100644 --- a/framework/source/uiconfiguration/moduleimagemanager.cxx +++ b/framework/source/uiconfiguration/moduleimagemanager.cxx @@ -27,10 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include #include #include -#include +#include #include #include #include "imagemanagerimpl.hxx" diff --git a/framework/source/xml/imagesconfiguration.cxx b/framework/source/xml/imagesconfiguration.cxx new file mode 100644 index 000000000000..946b5b9d0f11 --- /dev/null +++ b/framework/source/xml/imagesconfiguration.cxx @@ -0,0 +1,237 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_framework.hxx" + +#include +#include + +#include +#include + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include +#include +#include +#include + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ + +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX +#include +#endif +#include +#include + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::io; + + +namespace framework +{ + +SV_IMPL_PTRARR( ImageItemListDescriptor, ImageItemDescriptorPtr ); +SV_IMPL_PTRARR( ExternalImageItemListDescriptor, ExternalImageItemDescriptorPtr ); +SV_IMPL_PTRARR( ImageListDescriptor, ImageListItemDescriptorPtr ); + +static Reference< XParser > GetSaxParser( + // #110897# + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory + ) +{ + //Reference< XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); + //return Reference< XParser >( xServiceManager->createInstance( SERVICENAME_SAXPARSER), UNO_QUERY); + return Reference< XParser >( xServiceFactory->createInstance( SERVICENAME_SAXPARSER), UNO_QUERY); +} + +static Reference< XDocumentHandler > GetSaxWriter( + // #110897# + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory + ) +{ + //Reference< XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); + //return Reference< XDocumentHandler >( xServiceManager->createInstance( SERVICENAME_SAXWRITER), UNO_QUERY) ; + return Reference< XDocumentHandler >( xServiceFactory->createInstance( SERVICENAME_SAXWRITER), UNO_QUERY) ; +} + +// #110897# +sal_Bool ImagesConfiguration::LoadImages( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + SvStream& rInStream, ImageListsDescriptor& aItems ) +{ + Reference< XParser > xParser( GetSaxParser( xServiceFactory ) ); + Reference< XInputStream > xInputStream( + (::cppu::OWeakObject *)new utl::OInputStreamWrapper( rInStream ), + UNO_QUERY ); + + // connect stream to input stream to the parser + InputSource aInputSource; + + aInputSource.aInputStream = xInputStream; + + // create namespace filter and set document handler inside to support xml namespaces + Reference< XDocumentHandler > xDocHandler( new OReadImagesDocumentHandler( aItems )); + Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler )); + + // connect parser and filter + xParser->setDocumentHandler( xFilter ); + + try + { + xParser->parseStream( aInputSource ); + return sal_True; + } + catch ( RuntimeException& ) + { + return sal_False; + } + catch( SAXException& ) + { + return sal_False; + } + catch( ::com::sun::star::io::IOException& ) + { + return sal_False; + } +} + + +// #110897# +sal_Bool ImagesConfiguration::StoreImages( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + SvStream& rOutStream, const ImageListsDescriptor& aItems ) +{ + Reference< XDocumentHandler > xWriter( GetSaxWriter( xServiceFactory ) ); + + Reference< XOutputStream > xOutputStream( + (::cppu::OWeakObject *)new utl::OOutputStreamWrapper( rOutStream ), + UNO_QUERY ); + + Reference< ::com::sun::star::io::XActiveDataSource> xDataSource( xWriter , UNO_QUERY ); + xDataSource->setOutputStream( xOutputStream ); + + try + { + OWriteImagesDocumentHandler aWriteImagesDocumentHandler( aItems, xWriter ); + aWriteImagesDocumentHandler.WriteImagesDocument(); + return sal_True; + } + catch ( RuntimeException& ) + { + return sal_False; + } + catch ( SAXException& ) + { + return sal_False; + } + catch ( ::com::sun::star::io::IOException& ) + { + return sal_False; + } +} + +sal_Bool ImagesConfiguration::LoadImages( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& rInputStream, + ImageListsDescriptor& rItems ) +{ + Reference< XParser > xParser( GetSaxParser( xServiceFactory ) ); + + // connect stream to input stream to the parser + InputSource aInputSource; + + aInputSource.aInputStream = rInputStream; + + // create namespace filter and set document handler inside to support xml namespaces + Reference< XDocumentHandler > xDocHandler( new OReadImagesDocumentHandler( rItems )); + Reference< XDocumentHandler > xFilter( new SaxNamespaceFilter( xDocHandler )); + + // connect parser and filter + xParser->setDocumentHandler( xFilter ); + + try + { + xParser->parseStream( aInputSource ); + return sal_True; + } + catch ( RuntimeException& ) + { + return sal_False; + } + catch( SAXException& ) + { + return sal_False; + } + catch( ::com::sun::star::io::IOException& ) + { + return sal_False; + } +} + +sal_Bool ImagesConfiguration::StoreImages( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, + const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& rOutputStream, + const ImageListsDescriptor& rItems ) +{ + Reference< XDocumentHandler > xWriter( GetSaxWriter( xServiceFactory ) ); + + Reference< ::com::sun::star::io::XActiveDataSource> xDataSource( xWriter , UNO_QUERY ); + xDataSource->setOutputStream( rOutputStream ); + + try + { + OWriteImagesDocumentHandler aWriteImagesDocumentHandler( rItems, xWriter ); + aWriteImagesDocumentHandler.WriteImagesDocument(); + return sal_True; + } + catch ( RuntimeException& ) + { + return sal_False; + } + catch ( SAXException& ) + { + return sal_False; + } + catch ( ::com::sun::star::io::IOException& ) + { + return sal_False; + } +} + +} + diff --git a/framework/source/xml/imagesdocumenthandler.cxx b/framework/source/xml/imagesdocumenthandler.cxx new file mode 100644 index 000000000000..cdf20958332a --- /dev/null +++ b/framework/source/xml/imagesdocumenthandler.cxx @@ -0,0 +1,851 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * 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. + * + * 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). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_framework.hxx" + +#include + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include +#include +#include + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ + +#ifndef __COM_SUN_STAR_XML_SAX_XEXTENDEDDOCUMENTHANDLER_HPP_ +#include +#endif + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ +#include +#include +#include + +#include + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::xml::sax; + +#define ELEMENT_IMAGECONTAINER "imagescontainer" +#define ELEMENT_IMAGES "images" +#define ELEMENT_ENTRY "entry" +#define ELEMENT_EXTERNALIMAGES "externalimages" +#define ELEMENT_EXTERNALENTRY "externalentry" + +#define ELEMENT_NS_IMAGESCONTAINER "image:imagescontainer" +#define ELEMENT_NS_IMAGES "image:images" +#define ELEMENT_NS_ENTRY "image:entry" +#define ELEMENT_NS_EXTERNALIMAGES "image:externalimages" +#define ELEMENT_NS_EXTERNALENTRY "image:externalentry" + +#define ATTRIBUTE_HREF "href" +#define ATTRIBUTE_MASKCOLOR "maskcolor" +#define ATTRIBUTE_COMMAND "command" +#define ATTRIBUTE_BITMAPINDEX "bitmap-index" +#define ATTRIBUTE_MASKURL "maskurl" +#define ATTRIBUTE_MASKMODE "maskmode" +#define ATTRIBUTE_HIGHCONTRASTURL "highcontrasturl" +#define ATTRIBUTE_HIGHCONTRASTMASKURL "highcontrastmaskurl" +#define ATTRIBUTE_TYPE_CDATA "CDATA" + +#define ATTRIBUTE_MASKMODE_BITMAP "maskbitmap" +#define ATTRIBUTE_MASKMODE_COLOR "maskcolor" + +#define ATTRIBUTE_XMLNS_IMAGE "xmlns:image" +#define ATTRIBUTE_XMLNS_XLINK "xmlns:xlink" + +#define ATTRIBUTE_XLINK_TYPE "xlink:type" +#define ATTRIBUTE_XLINK_TYPE_VALUE "simple" + +#define XMLNS_IMAGE "http://openoffice.org/2001/image" +#define XMLNS_XLINK "http://www.w3.org/1999/xlink" +#define XMLNS_IMAGE_PREFIX "image:" +#define XMLNS_XLINK_PREFIX "xlink:" + +#define XMLNS_FILTER_SEPARATOR "^" + +#define IMAGES_DOCTYPE "" + +namespace framework +{ + +struct ImageXMLEntryProperty +{ + OReadImagesDocumentHandler::Image_XML_Namespace nNamespace; + char aEntryName[20]; +}; + +ImageXMLEntryProperty ImagesEntries[OReadImagesDocumentHandler::IMG_XML_ENTRY_COUNT] = +{ + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_IMAGECONTAINER }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_IMAGES }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_ENTRY }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_EXTERNALIMAGES }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ELEMENT_EXTERNALENTRY }, + { OReadImagesDocumentHandler::IMG_NS_XLINK, ATTRIBUTE_HREF }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_MASKCOLOR }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_COMMAND }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_BITMAPINDEX }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_MASKURL }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_MASKMODE }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_HIGHCONTRASTURL }, + { OReadImagesDocumentHandler::IMG_NS_IMAGE, ATTRIBUTE_HIGHCONTRASTMASKURL } +}; + + +OReadImagesDocumentHandler::OReadImagesDocumentHandler( ImageListsDescriptor& aItems ) : + ThreadHelpBase( &Application::GetSolarMutex() ), + m_aImageList( aItems ), + m_pImages( 0 ), + m_pExternalImages( 0 ) +{ + m_aImageList.pImageList = NULL; + m_aImageList.pExternalImageList = NULL; + + m_nHashMaskModeBitmap = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE_BITMAP )).hashCode(); + m_nHashMaskModeColor = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE_COLOR )).hashCode(); + + // create hash map to speed up lookup + for ( int i = 0; i < (int)IMG_XML_ENTRY_COUNT; i++ ) + { + ::rtl::OUStringBuffer temp( 20 ); + + if ( ImagesEntries[i].nNamespace == IMG_NS_IMAGE ) + temp.appendAscii( XMLNS_IMAGE ); + else + temp.appendAscii( XMLNS_XLINK ); + + temp.appendAscii( XMLNS_FILTER_SEPARATOR ); + temp.appendAscii( ImagesEntries[i].aEntryName ); + m_aImageMap.insert( ImageHashMap::value_type( temp.makeStringAndClear(), (Image_XML_Entry)i ) ); + } + + // reset states + m_bImageContainerStartFound = sal_False; + m_bImageContainerEndFound = sal_False; + m_bImagesStartFound = sal_False; + m_bImagesEndFound = sal_False; + m_bImageStartFound = sal_False; + m_bExternalImagesStartFound = sal_False; + m_bExternalImagesEndFound = sal_False; + m_bExternalImageStartFound = sal_False; +} + +OReadImagesDocumentHandler::~OReadImagesDocumentHandler() +{ +} + +// XDocumentHandler +void SAL_CALL OReadImagesDocumentHandler::startDocument(void) +throw ( SAXException, RuntimeException ) +{ +} + +void SAL_CALL OReadImagesDocumentHandler::endDocument(void) +throw( SAXException, RuntimeException ) +{ + ResetableGuard aGuard( m_aLock ); + + if (( m_bImageContainerStartFound && !m_bImageContainerEndFound ) || + ( !m_bImageContainerStartFound && m_bImageContainerEndFound ) ) + { + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No matching start or end element 'image:imagecontainer' found!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } +} + +void SAL_CALL OReadImagesDocumentHandler::startElement( + const ::rtl::OUString& aName, const Reference< XAttributeList > &xAttribs ) +throw( SAXException, RuntimeException ) +{ + ResetableGuard aGuard( m_aLock ); + + ImageHashMap::const_iterator pImageEntry = m_aImageMap.find( aName ) ; + if ( pImageEntry != m_aImageMap.end() ) + { + switch ( pImageEntry->second ) + { + case IMG_ELEMENT_IMAGECONTAINER: + { + // image:imagecontainer element (container element for all further image elements) + if ( m_bImageContainerStartFound ) + { + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:imagecontainer' cannot be embeded into 'image:imagecontainer'!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + m_bImageContainerStartFound = sal_True; + } + break; + + case IMG_ELEMENT_IMAGES: + { + if ( !m_bImageContainerStartFound ) + { + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:images' must be embeded into element 'image:imagecontainer'!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + if ( m_bImagesStartFound ) + { + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:images' cannot be embeded into 'image:images'!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + if ( !m_aImageList.pImageList ) + m_aImageList.pImageList = new ImageListDescriptor; + + m_bImagesStartFound = sal_True; + m_pImages = new ImageListItemDescriptor; + + for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) + { + pImageEntry = m_aImageMap.find( xAttribs->getNameByIndex( n ) ); + if ( pImageEntry != m_aImageMap.end() ) + { + switch ( pImageEntry->second ) + { + case IMG_ATTRIBUTE_HREF: + { + m_pImages->aURL = xAttribs->getValueByIndex( n ); + } + break; + + case IMG_ATTRIBUTE_MASKCOLOR: + { + ::rtl::OUString aColor = xAttribs->getValueByIndex( n ); + + if ( aColor.getLength() > 0 ) + { + if ( aColor.getStr()[0] == '#' ) + { + // the color value is given as #rrggbb and used the hexadecimal system!! + sal_uInt32 nColor = aColor.copy( 1 ).toInt32( 16 ); + + m_pImages->aMaskColor = Color( COLORDATA_RGB( nColor ) ); + } + } + } + break; + + case IMG_ATTRIBUTE_MASKURL: + { + m_pImages->aMaskURL = xAttribs->getValueByIndex( n ); + } + break; + + case IMG_ATTRIBUTE_MASKMODE: + { + sal_Int32 nHashCode = xAttribs->getValueByIndex( n ).hashCode(); + if ( nHashCode == m_nHashMaskModeBitmap ) + m_pImages->nMaskMode = ImageMaskMode_Bitmap; + else if ( nHashCode == m_nHashMaskModeColor ) + m_pImages->nMaskMode = ImageMaskMode_Color; + else + { + delete m_pImages; + m_pImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Attribute image:maskmode must be 'maskcolor' or 'maskbitmap'!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + } + break; + + case IMG_ATTRIBUTE_HIGHCONTRASTURL: + { + m_pImages->aHighContrastURL = xAttribs->getValueByIndex( n ); + } + break; + + case IMG_ATTRIBUTE_HIGHCONTRASTMASKURL: + { + m_pImages->aHighContrastMaskURL = xAttribs->getValueByIndex( n ); + } + break; + + default: + break; + } + } + } // for + + if ( m_pImages->aURL.Len() == 0 ) + { + delete m_pImages; + m_pImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute xlink:href must have a value!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + } + break; + + case IMG_ELEMENT_ENTRY: + { + // Check that image:entry is embeded into image:images! + if ( !m_bImagesStartFound ) + { + delete m_pImages; + m_pImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:entry' must be embeded into element 'image:images'!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + if ( !m_pImages->pImageItemList ) + m_pImages->pImageItemList = new ImageItemListDescriptor; + + m_bImageStartFound = sal_True; + + // Create new image item descriptor + ImageItemDescriptor* pItem = new ImageItemDescriptor; + pItem->nIndex = -1; + + // Read attributes for this image definition + for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) + { + pImageEntry = m_aImageMap.find( xAttribs->getNameByIndex( n ) ); + if ( pImageEntry != m_aImageMap.end() ) + { + switch ( pImageEntry->second ) + { + case IMG_ATTRIBUTE_COMMAND: + { + pItem->aCommandURL = xAttribs->getValueByIndex( n ); + } + break; + + case IMG_ATTRIBUTE_BITMAPINDEX: + { + pItem->nIndex = xAttribs->getValueByIndex( n ).toInt32(); + } + break; + + default: + break; + } + } + } + + // Check required attribute "bitmap-index" + if ( pItem->nIndex < 0 ) + { + delete pItem; + delete m_pImages; + m_pImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute 'image:bitmap-index' must have a value >= 0!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + // Check required attribute "command" + if ( pItem->aCommandURL.Len() == 0 ) + { + delete pItem; + delete m_pImages; + m_pImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute 'image:command' must have a value!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + if ( m_pImages ) + m_pImages->pImageItemList->Insert( pItem, m_pImages->pImageItemList->Count() ); + } + break; + + case IMG_ELEMENT_EXTERNALIMAGES: + { + // Check that image:externalimages is embeded into image:imagecontainer + if ( !m_bImageContainerStartFound ) + { + delete m_pImages; + m_pImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:externalimages' must be embeded into element 'image:imagecontainer'!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + // Check that image:externalentry is NOT embeded into image:externalentry + if ( m_bExternalImagesStartFound ) + { + delete m_pImages; + m_pImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:externalimages' cannot be embeded into 'image:externalimages'!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + // Create unique external image container + m_bExternalImagesStartFound = sal_True; + m_pExternalImages = new ExternalImageItemListDescriptor; + } + break; + + case IMG_ELEMENT_EXTERNALENTRY: + { + if ( !m_bExternalImagesStartFound ) + { + delete m_pImages; + delete m_pExternalImages; + m_pImages = NULL; + m_pExternalImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:externalentry' must be embeded into 'image:externalimages'!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + if ( m_bExternalImageStartFound ) + { + delete m_pImages; + delete m_pExternalImages; + m_pImages = NULL; + m_pExternalImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Element 'image:externalentry' cannot be embeded into 'image:externalentry'!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + m_bExternalImageStartFound = sal_True; + + ExternalImageItemDescriptor* pItem = new ExternalImageItemDescriptor; + + // Read attributes for this external image definition + for ( sal_Int16 n = 0; n < xAttribs->getLength(); n++ ) + { + pImageEntry = m_aImageMap.find( xAttribs->getNameByIndex( n ) ); + if ( pImageEntry != m_aImageMap.end() ) + { + switch ( pImageEntry->second ) + { + case IMG_ATTRIBUTE_COMMAND: + { + pItem->aCommandURL = xAttribs->getValueByIndex( n ); + } + break; + + case IMG_ATTRIBUTE_HREF: + { + pItem->aURL = xAttribs->getValueByIndex( n ); + } + break; + + default: + break; + } + } + } + + // Check required attribute "command" + if ( pItem->aCommandURL.Len() == 0 ) + { + delete pItem; + delete m_pImages; + delete m_pExternalImages; + m_pImages = NULL; + m_pExternalImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute 'image:command' must have a value!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + // Check required attribute "href" + if ( pItem->aURL.Len() == 0 ) + { + delete pItem; + delete m_pImages; + delete m_pExternalImages; + m_pImages = NULL; + m_pExternalImages = NULL; + + ::rtl::OUString aErrorMessage = getErrorLineString(); + aErrorMessage += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Required attribute 'xlink:href' must have a value!" )); + throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); + } + + if ( m_pExternalImages ) + m_pExternalImages->Insert( pItem, m_pExternalImages->Count() ); + } + break; + + default: + break; + } + } +} + +void SAL_CALL OReadImagesDocumentHandler::endElement(const ::rtl::OUString& aName) +throw( SAXException, RuntimeException ) +{ + ResetableGuard aGuard( m_aLock ); + + ImageHashMap::const_iterator pImageEntry = m_aImageMap.find( aName ) ; + if ( pImageEntry != m_aImageMap.end() ) + { + switch ( pImageEntry->second ) + { + case IMG_ELEMENT_IMAGECONTAINER: + { + m_bImageContainerEndFound = sal_True; + } + break; + + case IMG_ELEMENT_IMAGES: + { + if ( m_pImages ) + { + if ( m_aImageList.pImageList ) + m_aImageList.pImageList->Insert( m_pImages, m_aImageList.pImageList->Count() ); + m_pImages = NULL; + } + m_bImagesStartFound = sal_False; + } + break; + + case IMG_ELEMENT_ENTRY: + { + m_bImageStartFound = sal_False; + } + break; + + case IMG_ELEMENT_EXTERNALIMAGES: + { + if ( m_pExternalImages && !m_aImageList.pExternalImageList ) + { + if ( !m_aImageList.pExternalImageList ) + m_aImageList.pExternalImageList = m_pExternalImages; + } + + m_bExternalImagesStartFound = sal_False; + m_pExternalImages = NULL; + } + break; + + case IMG_ELEMENT_EXTERNALENTRY: + { + m_bExternalImageStartFound = sal_False; + } + break; + + default: + break; + } + } +} + +void SAL_CALL OReadImagesDocumentHandler::characters(const ::rtl::OUString&) +throw( SAXException, RuntimeException ) +{ +} + +void SAL_CALL OReadImagesDocumentHandler::ignorableWhitespace(const ::rtl::OUString&) +throw( SAXException, RuntimeException ) +{ +} + +void SAL_CALL OReadImagesDocumentHandler::processingInstruction( + const ::rtl::OUString& /*aTarget*/, const ::rtl::OUString& /*aData*/ ) +throw( SAXException, RuntimeException ) +{ +} + +void SAL_CALL OReadImagesDocumentHandler::setDocumentLocator( + const Reference< XLocator > &xLocator) +throw( SAXException, RuntimeException ) +{ + ResetableGuard aGuard( m_aLock ); + + m_xLocator = xLocator; +} + +::rtl::OUString OReadImagesDocumentHandler::getErrorLineString() +{ + ResetableGuard aGuard( m_aLock ); + + char buffer[32]; + + if ( m_xLocator.is() ) + { + snprintf( buffer, sizeof(buffer), "Line: %ld - ", static_cast( m_xLocator->getLineNumber() )); + return ::rtl::OUString::createFromAscii( buffer ); + } + else + return ::rtl::OUString(); +} + + +//_________________________________________________________________________________________________________________ +// OWriteImagesDocumentHandler +//_________________________________________________________________________________________________________________ + +OWriteImagesDocumentHandler::OWriteImagesDocumentHandler( + const ImageListsDescriptor& aItems, + Reference< XDocumentHandler > rWriteDocumentHandler ) : + ThreadHelpBase( &Application::GetSolarMutex() ), + m_aImageListsItems( aItems ), + m_xWriteDocumentHandler( rWriteDocumentHandler ) +{ + ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; + m_xEmptyList = Reference< XAttributeList >( (XAttributeList *) pList, UNO_QUERY ); + m_aAttributeType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TYPE_CDATA )); + m_aXMLImageNS = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_IMAGE_PREFIX )); + m_aXMLXlinkNS = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK_PREFIX )); + m_aAttributeXlinkType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XLINK_TYPE )); + m_aAttributeValueSimple = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XLINK_TYPE_VALUE )); +} + +OWriteImagesDocumentHandler::~OWriteImagesDocumentHandler() +{ +} + +void OWriteImagesDocumentHandler::WriteImagesDocument() throw +( SAXException, RuntimeException ) +{ + ResetableGuard aGuard( m_aLock ); + + m_xWriteDocumentHandler->startDocument(); + + // write DOCTYPE line! + Reference< XExtendedDocumentHandler > xExtendedDocHandler( m_xWriteDocumentHandler, UNO_QUERY ); + if ( xExtendedDocHandler.is() ) + { + xExtendedDocHandler->unknown( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( IMAGES_DOCTYPE )) ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); + } + + ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; + Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY ); + + pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_IMAGE )), + m_aAttributeType, + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_IMAGE )) ); + + pList->AddAttribute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_XMLNS_XLINK )), + m_aAttributeType, + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( XMLNS_XLINK )) ); + + m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_IMAGESCONTAINER )), pList ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); + + if ( m_aImageListsItems.pImageList ) + { + ImageListDescriptor* pImageList = m_aImageListsItems.pImageList; + + for ( sal_uInt16 i = 0; i < m_aImageListsItems.pImageList->Count(); i++ ) + { + const ImageListItemDescriptor* pImageItems = (*pImageList)[i]; + WriteImageList( pImageItems ); + } + } + + if ( m_aImageListsItems.pExternalImageList ) + { + WriteExternalImageList( m_aImageListsItems.pExternalImageList ); + } + + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); + m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_IMAGESCONTAINER )) ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); + m_xWriteDocumentHandler->endDocument(); +} + +//_________________________________________________________________________________________________________________ +// protected member functions +//_________________________________________________________________________________________________________________ + +void OWriteImagesDocumentHandler::WriteImageList( const ImageListItemDescriptor* pImageList ) throw +( SAXException, RuntimeException ) +{ + ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; + Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY ); + + // save required attributes + pList->AddAttribute( m_aAttributeXlinkType, + m_aAttributeType, + m_aAttributeValueSimple ); + + pList->AddAttribute( m_aXMLXlinkNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HREF )), + m_aAttributeType, + pImageList->aURL ); + + if ( pImageList->nMaskMode == ImageMaskMode_Bitmap ) + { + pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE )), + m_aAttributeType, + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE_BITMAP )) ); + + pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKURL )), + m_aAttributeType, + pImageList->aMaskURL ); + + if ( pImageList->aHighContrastMaskURL.Len() > 0 ) + { + pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HIGHCONTRASTMASKURL )), + m_aAttributeType, + pImageList->aHighContrastMaskURL ); + } + } + else + { + ::rtl::OUStringBuffer aColorStrBuffer( 8 ); + sal_Int64 nValue = pImageList->aMaskColor.GetRGBColor(); + + aColorStrBuffer.appendAscii( "#" ); + aColorStrBuffer.append( ::rtl::OUString::valueOf( nValue, 16 )); + + pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKCOLOR )), + m_aAttributeType, + aColorStrBuffer.makeStringAndClear() ); + + pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE )), + m_aAttributeType, + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MASKMODE_COLOR )) ); + } + + if ( pImageList->aHighContrastURL.Len() > 0 ) + { + pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HIGHCONTRASTURL )), + m_aAttributeType, + pImageList->aHighContrastURL ); + } + + m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_IMAGES )), xList ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); + + ImageItemListDescriptor* pImageItemList = pImageList->pImageItemList; + if ( pImageItemList ) + { + for ( sal_uInt16 i = 0; i < pImageItemList->Count(); i++ ) + WriteImage( (*pImageItemList)[i] ); + } + + m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_IMAGES )) ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); +} + +void OWriteImagesDocumentHandler::WriteImage( const ImageItemDescriptor* pImage ) throw +( SAXException, RuntimeException ) +{ + ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; + Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY ); + + pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_BITMAPINDEX )), + m_aAttributeType, + ::rtl::OUString::valueOf( (sal_Int32)pImage->nIndex ) ); + + pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_COMMAND )), + m_aAttributeType, + pImage->aCommandURL ); + + m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_ENTRY )), xList ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); + + m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_ENTRY )) ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); +} + +void OWriteImagesDocumentHandler::WriteExternalImageList( const ExternalImageItemListDescriptor* pExternalImageList ) throw +( SAXException, RuntimeException ) +{ + m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EXTERNALIMAGES )), m_xEmptyList ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); + + for ( sal_uInt16 i = 0; i < pExternalImageList->Count(); i++ ) + { + ExternalImageItemDescriptor* pItem = (*pExternalImageList)[i]; + WriteExternalImage( pItem ); + } + + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); + m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EXTERNALIMAGES )) ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); +} + +void OWriteImagesDocumentHandler::WriteExternalImage( const ExternalImageItemDescriptor* pExternalImage ) throw +( SAXException, RuntimeException ) +{ + ::comphelper::AttributeList* pList = new ::comphelper::AttributeList; + Reference< XAttributeList > xList( (XAttributeList *) pList , UNO_QUERY ); + + // save required attributes + pList->AddAttribute( m_aAttributeXlinkType, + m_aAttributeType, + m_aAttributeValueSimple ); + + if ( pExternalImage->aURL.Len() > 0 ) + { + pList->AddAttribute( m_aXMLXlinkNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_HREF )), + m_aAttributeType, + pExternalImage->aURL ); + } + + if ( pExternalImage->aCommandURL.Len() > 0 ) + { + pList->AddAttribute( m_aXMLImageNS + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_COMMAND )), + m_aAttributeType, + pExternalImage->aCommandURL ); + } + + m_xWriteDocumentHandler->startElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EXTERNALENTRY )), xList ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); + + m_xWriteDocumentHandler->endElement( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_NS_EXTERNALENTRY )) ); + m_xWriteDocumentHandler->ignorableWhitespace( ::rtl::OUString() ); +} + +} // namespace framework + + + + -- cgit From 776de14da77af214201eba74e53ec5b1896a114b Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Mon, 4 Apr 2011 15:07:20 +0200 Subject: masterfix DEV300: #i10000# header cleanup --- framework/inc/xml/imagesdocumenthandler.hxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'framework') diff --git a/framework/inc/xml/imagesdocumenthandler.hxx b/framework/inc/xml/imagesdocumenthandler.hxx index 4aa370c013d7..dd6201b5b9e3 100644 --- a/framework/inc/xml/imagesdocumenthandler.hxx +++ b/framework/inc/xml/imagesdocumenthandler.hxx @@ -57,7 +57,7 @@ namespace framework{ //***************************************************************************************************************** // Hash code function for using in all hash maps of follow implementation. -class FWE_DLLPUBLIC OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses. +class OReadImagesDocumentHandler : private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses. public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XDocumentHandler > { public: @@ -158,7 +158,7 @@ class FWE_DLLPUBLIC OReadImagesDocumentHandler : private ThreadHelpBase, // S ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator; }; -class FWE_DLLPUBLIC OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses. +class OWriteImagesDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses. { public: OWriteImagesDocumentHandler( -- cgit From 86e7ed8c72184b7a04b836848743979aa3f5fd3d Mon Sep 17 00:00:00 2001 From: Ivo Hinkelmann Date: Mon, 4 Apr 2011 17:05:53 +0200 Subject: masterfix DEV300: #i10000# smoketest assertion fix --- framework/source/uielement/menubarmanager.cxx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'framework') diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index a74fbabb271e..9df04fa17ab4 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -1813,14 +1813,10 @@ void MenuBarManager::FillMenu( pMenu->SetItemBits( nId, nBits ); } - if ( bShow ) - pMenu->ShowItem( nId ); - else + if ( !bShow ) pMenu->HideItem( nId ); - if ( bEnabled) - pMenu->EnableItem( nId, sal_True ); - else + if ( !bEnabled) pMenu->EnableItem( nId, sal_False ); if ( xIndexContainer.is() ) -- cgit