xml based toolbar layout configuration

This commit is contained in:
Carsten Driesner 2001-06-18 08:51:07 +00:00
parent 5da304fe7f
commit a74b08ed57
5 changed files with 375 additions and 28 deletions

View file

@ -4,19 +4,18 @@
#ifndef _SVARRAY_HXX
#include <svtools/svarray.hxx>
#endif
#ifndef _SV_BITMAP_HXX
#include <vcl/bitmap.hxx>
#endif
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif
#ifndef _STREAM_HXX
#include <tools/stream.hxx>
#endif
#ifndef _SV_TOOLBOX_HXX
#include <vcl/toolbox.hxx>
#endif
#ifndef _SV_TOOLBOX_HXX
#include <vcl/toolbox.hxx>
#endif
@ -27,16 +26,16 @@ namespace framework
struct ToolBoxItemDescriptor
{
Bitmap* pBmp;
String aBitmapName;
String aItemText;
String aURL;
USHORT nId;
USHORT nItemBits;
USHORT nItemType;
USHORT nVisible;
USHORT nWidth;
USHORT nUserDef;
Bitmap* pBmp; // Bitmap ptr not used by xml configuration
String aBitmapName; // bitmap name => use to find correct bmp file
String aItemText; // label for this toolbox item
String aURL; // URL command to dispatch
USHORT nId; // internal id not used by xml configuration
USHORT nItemBits; // properties for this toolbox item (WinBits)
USHORT nItemType; // toolbox item type (BUTTON, SPACE, BREAK, SEPARATOR)
USHORT nVisible; // toolbox item visible?
USHORT nWidth; // width of a toolbox window (edit field, etc.)
USHORT nUserDef; // user defined toolbox item (1=yes/0=no)
public:
@ -52,11 +51,49 @@ struct ToolBoxItemDescriptor
typedef ToolBoxItemDescriptor* ToolBoxItemDescriptorPtr;
SV_DECL_PTRARR_DEL( ToolBoxDescriptor, ToolBoxItemDescriptorPtr, 10, 2)
struct ToolBoxConfigItemDescriptor
{
String aContext; // Name des Contexts ( "Text", "Table", "Graphic" etc. )
String aName; // Name der Toolbar ( "writertableobjectbar", "calctextobjectbar" etc. )
BOOL bVisible; // ein - oder ausgeschaltet
ButtonType eType; // Text, Symbol oder Text+Symbol
ToolBoxConfigItemDescriptor() : bVisible( sal_False )
,eType( BUTTON_SYMBOL ) {}
};
typedef ToolBoxConfigItemDescriptor* ToolBoxConfigItemDescriptorPtr;
SV_DECL_PTRARR_DEL( ToolBoxConfigDescriptor, ToolBoxConfigItemDescriptorPtr, 10, 2)
struct ToolBoxLayoutItemDescriptor
{
String aName; // Name der Toolbox ( Objectbar, Toolbar etc. )
Point aFloatingPos; // Position im nicht angedockten Zustand
USHORT nFloatingLines; // Anzahl der Zeilen im nicht angedockten Zustand
USHORT nLines; // Anzahl der Zeilen im angedockten Zustand
ToolBoxAlign eAlign; // Alignment im angedockten Zustand
BOOL bVisible; // ein - oder ausgeschaltet
BOOL bFloating; // angedockt oder nicht
ToolBoxConfigDescriptor* pContexts; // Context information
ToolBoxLayoutItemDescriptor() : nFloatingLines( 0 )
,nLines( 0 )
,eAlign( BOXALIGN_LEFT )
,bVisible( sal_False )
,bFloating( sal_False )
,pContexts( NULL ) {}
};
typedef ToolBoxLayoutItemDescriptor* ToolBoxLayoutItemDescriptorPtr;
SV_DECL_PTRARR_DEL( ToolBoxLayoutDescriptor, ToolBoxLayoutItemDescriptorPtr, 10, 2)
class ToolBoxConfiguration
{
public:
static sal_Bool LoadToolBox( SvStream& rInStream, ToolBoxDescriptor& aItems );
static sal_Bool StoreToolBox( SvStream& rOutStream, const ToolBoxDescriptor& aItems );
static sal_Bool LoadToolBoxLayout( SvStream& rInStream, ToolBoxLayoutDescriptor& aItems );
static sal_Bool StoreToolBoxLayout( SvStream& rOutStream, ToolBoxLayoutDescriptor& aItems );
};
} // namespace framework

View file

@ -0,0 +1,69 @@
#ifndef __FRAMEWORK_TOOLBOXCONFIGURATIONDEFINES_HXX_
#define __FRAMEWORK_TOOLBOXCONFIGURATIONDEFINES_HXX_
#define XMLNS_TOOLBAR "http://openoffice.org/2001/toolbar"
#define XMLNS_XLINK "http://www.w3.org/1999/xlink"
#define XMLNS_TOOLBAR_PREFIX "toolbar:"
#define XMLNS_XLINK_PREFIX "xlink:"
#define XMLNS_FILTER_SEPARATOR "^"
#define ELEMENT_TOOLBAR "toolbar"
#define ELEMENT_TOOLBARITEM "toolbaritem"
#define ELEMENT_TOOLBARSPACE "toolbarspace"
#define ELEMENT_TOOLBARBREAK "toolbarbreak"
#define ELEMENT_TOOLBARSEPARATOR "toolbarseparator"
#define ELEMENT_TOOLBARLAYOUTS "toolbarlayouts"
#define ELEMENT_TOOLBARLAYOUT "toolbarlayout"
#define ELEMENT_TOOLBARCONFIGITEMS "toolbarconfigitems"
#define ELEMENT_TOOLBARCONFIGITEM "toolbarconfigitem"
#define ATTRIBUTE_BITMAP "bitmap"
#define ATTRIBUTE_TEXT "text"
#define ATTRIBUTE_URL "href"
#define ATTRIBUTE_ITEMBITS "property"
#define ATTRIBUTE_VISIBLE "visible"
#define ATTRIBUTE_WIDTH "width"
#define ATTRIBUTE_USER "userdefined"
#define ATTRIBUTE_ID "id"
#define ATTRIBUTE_FLOATINGPOSLEFT "floatingposleft"
#define ATTRIBUTE_FLOATINGPOSTOP "floatingpostop"
#define ATTRIBUTE_TOOLBARNAME "toolbarname"
#define ATTRIBUTE_CONTEXT "context"
#define ATTRIBUTE_FLOATINGLINES "floatinglines"
#define ATTRIBUTE_DOCKINGLINES "dockinglines"
#define ATTRIBUTE_ALIGN "align"
#define ATTRIBUTE_FLOATING "floating"
#define ATTRIBUTE_BUTTONTYPE "style"
#define ELEMENT_NS_TOOLBAR "toolbar:toolbar"
#define ELEMENT_NS_TOOLBARITEM "toolbar:toolbaritem"
#define ELEMENT_NS_TOOLBARSPACE "toolbar:toolbarspace"
#define ELEMENT_NS_TOOLBARBREAK "toolbar:toolbarbreak"
#define ELEMENT_NS_TOOLBARSEPARATOR "toolbar:toolbarseparator"
#define ELEMENT_NS_TOOLBARLAYOUTS "toolbar:toolbarlayouts"
#define ELEMENT_NS_TOOLBARLAYOUT "toolbar:toolbarlayout"
#define ELEMENT_NS_TOOLBARCONFIGITEMS "toolbar:toolbarconfigitems"
#define ELEMENT_NS_TOOLBARCONFIGITEM "toolbar:toolbarconfigitem"
#define ATTRIBUTE_XMLNS_TOOLBAR "xmlns:toolbar"
#define ATTRIBUTE_XMLNS_XLINK "xmlns:xlink"
#define ATTRIBUTE_TYPE_CDATA "CDATA"
#define ATTRIBUTE_BOOLEAN_TRUE "true"
#define ATTRIBUTE_BOOLEAN_FALSE "false"
#define ATTRIBUTE_ALIGN_LEFT "left"
#define ATTRIBUTE_ALIGN_RIGHT "right"
#define ATTRIBUTE_ALIGN_TOP "top"
#define ATTRIBUTE_ALIGN_BOTTOM "bottom"
#define ATTRIBUTE_STYLE_TEXT "text"
#define ATTRIBUTE_STYLE_SYMBOL "symbol"
#define ATTRIBUTE_STYLE_SYMBOLTEXT "symboltext"
#endif

View file

@ -2,9 +2,9 @@
*
* $RCSfile: toolboxdocumenthandler.hxx,v $
*
* $Revision: 1.1 $
* $Revision: 1.2 $
*
* last change: $Author: cd $ $Date: 2001-06-11 11:31:32 $
* last change: $Author: cd $ $Date: 2001-06-18 09:49:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -94,6 +94,10 @@
#include <hash_map>
#endif
#ifndef __FRAMEWORK_STDTYPES_H_
#include <stdtypes.h>
#endif
//_________________________________________________________________________________________________________________
// namespace
//_________________________________________________________________________________________________________________
@ -103,15 +107,6 @@ namespace framework{
//*****************************************************************************************************************
// Hash code function for using in all hash maps of follow implementation.
struct StringHashFunction
{
size_t operator()(const ::rtl::OUString& sString) const
{
return sString.hashCode();
}
};
class OReadToolBoxDocumentHandler : public ::com::sun::star::xml::sax::XDocumentHandler,
private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
public ::cppu::OWeakObject
@ -194,7 +189,7 @@ class OReadToolBoxDocumentHandler : public ::com::sun::star::xml::sax::XDocument
class ToolBoxHashMap : public ::std::hash_map< ::rtl::OUString ,
ToolBox_XML_Entry ,
StringHashFunction ,
OUStringHashCode ,
::std::equal_to< ::rtl::OUString > >
{
public:

View file

@ -0,0 +1,245 @@
/*************************************************************************
*
* $RCSfile: toolboxlayoutdocumenthandler.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: cd $ $Date: 2001-06-18 09:47:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef __FRAMEWORK_CLASSES_TOOLBOXLAYOUTDOCUMENTHANDLER_HXX_
#define __FRAMEWORK_CLASSES_TOOLBOXLAYOUTDOCUMENTHANDLER_HXX_
#ifndef __FRAMEWORK_CLASSES_TOOLBOXCONFIGURATION_HXX_
#include <classes/toolboxconfiguration.hxx>
#endif
//_________________________________________________________________________________________________________________
// interface includes
//_________________________________________________________________________________________________________________
#ifndef __COM_SUN_STAR_XML_SAX_XDOCUMENTHANDLER_HPP_
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#endif
//_________________________________________________________________________________________________________________
// other includes
//_________________________________________________________________________________________________________________
#ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_
#include <threadhelp/threadhelpbase.hxx>
#endif
#ifndef _RTL_USTRING_
#include <rtl/ustring.hxx>
#endif
#ifndef _CPPUHELPER_WEAK_HXX_
#include <cppuhelper/weak.hxx>
#endif
#ifndef __SGI_STL_HASH_MAP
#include <hash_map>
#endif
#ifndef __FRAMEWORK_STDTYPES_H_
#include <stdtypes.h>
#endif
//_________________________________________________________________________________________________________________
// namespace
//_________________________________________________________________________________________________________________
namespace framework{
//*****************************************************************************************************************
// Hash code function for using in all hash maps of follow implementation.
class OReadToolBoxLayoutDocumentHandler : public ::com::sun::star::xml::sax::XDocumentHandler,
private ThreadHelpBase, // Struct for right initalization of lock member! Must be first of baseclasses.
public ::cppu::OWeakObject
{
public:
enum ToolBoxLayout_XML_Entry
{
TBL_ELEMENT_TOOLBARLAYOUTS,
TBL_ELEMENT_TOOLBARLAYOUT,
TBL_ELEMENT_TOOLBARCONFIGITEMS,
TBL_ELEMENT_TOOLBARCONFIGITEM,
TBL_ATTRIBUTE_ID,
TBL_ATTRIBUTE_TOOLBARNAME,
TBL_ATTRIBUTE_CONTEXT,
TBL_ATTRIBUTE_FLOATINGLINES,
TBL_ATTRIBUTE_DOCKINGLINES,
TBL_ATTRIBUTE_ALIGN,
TBL_ATTRIBUTE_FLOATING,
TBL_ATTRIBUTE_FLOATINGPOSLEFT,
TBL_ATTRIBUTE_FLOATINGPOSTOP,
TBL_ATTRIBUTE_VISIBLE,
TBL_ATTRIBUTE_STYLE,
TBL_XML_ENTRY_COUNT
};
enum ToolBox_XML_Namespace
{
TBL_NS_TOOLBAR,
TBL_XML_NAMESPACES_COUNT
};
OReadToolBoxLayoutDocumentHandler( ToolBoxLayoutDescriptor& aToolBoxLayoutItems );
virtual ~OReadToolBoxLayoutDocumentHandler();
// XInterface
virtual void SAL_CALL acquire() throw( ::com::sun::star::uno::RuntimeException )
{ OWeakObject::acquire(); }
virtual void SAL_CALL release() throw( ::com::sun::star::uno::RuntimeException )
{ OWeakObject::release(); }
virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
const ::com::sun::star::uno::Type & rType ) throw( ::com::sun::star::uno::RuntimeException );
// XDocumentHandler
virtual void SAL_CALL startDocument(void)
throw ( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL endDocument(void)
throw( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL startElement(
const rtl::OUString& aName,
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > &xAttribs)
throw( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL endElement(const rtl::OUString& aName)
throw( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL characters(const rtl::OUString& aChars)
throw( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL ignorableWhitespace(const rtl::OUString& aWhitespaces)
throw( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL processingInstruction(const rtl::OUString& aTarget,
const rtl::OUString& aData)
throw( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
virtual void SAL_CALL setDocumentLocator(
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > &xLocator)
throw( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
private:
::rtl::OUString getErrorLineString();
class ToolBoxLayoutHashMap : public ::std::hash_map< ::rtl::OUString ,
ToolBoxLayout_XML_Entry ,
OUStringHashCode ,
::std::equal_to< ::rtl::OUString > >
{
public:
inline void free()
{
ToolBoxLayoutHashMap().swap( *this );
}
};
sal_Bool m_bToolBarLayoutsStartFound;
sal_Bool m_bToolBarLayoutsEndFound;
sal_Bool m_bToolBarLayoutStartFound;
sal_Bool m_bToolBarConfigListStartFound;
sal_Bool m_bToolBarConfigItemStartFound;
ToolBoxLayoutHashMap m_aToolBoxMap;
ToolBoxLayoutDescriptor& m_aToolBoxItems;
ToolBoxConfigDescriptor* m_pCurrentToolBoxConfigs;
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator > m_xLocator;
};
class OWriteToolBoxLayoutDocumentHandler : private ThreadHelpBase // Struct for right initalization of lock member! Must be first of baseclasses.
{
public:
OWriteToolBoxLayoutDocumentHandler(
const ToolBoxLayoutDescriptor& aToolBoxLayoutItems,
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > );
virtual ~OWriteToolBoxLayoutDocumentHandler();
void WriteToolBoxLayoutDocument() throw
( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
protected:
virtual void WriteToolBoxLayoutItem( const ToolBoxLayoutItemDescriptor* ) throw
( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
virtual void WriteToolBoxConfigItem( const ToolBoxConfigItemDescriptor* ) throw
( ::com::sun::star::xml::sax::SAXException,
::com::sun::star::uno::RuntimeException );
const ToolBoxLayoutDescriptor& m_aToolBoxLayoutItems;
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > m_xWriteDocumentHandler;
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > m_xEmptyList;
::rtl::OUString m_aXMLToolbarNS;
::rtl::OUString m_aAttributeType;
};
} // namespace framework
#endif

View file

@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.13 $
# $Revision: 1.14 $
#
# last change: $Author: pb $ $Date: 2001-06-15 09:30:14 $
# last change: $Author: cd $ $Date: 2001-06-18 09:51:07 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@ -92,6 +92,7 @@ SLOFILES= $(SLO)$/servicemanager.obj \
$(SLO)$/fltdlg.obj \
$(SLO)$/toolboxconfiguration.obj \
$(SLO)$/toolboxdocumenthandler.obj \
$(SLO)$/toolboxlayoutdocumenthandler.obj
$(SLO)$/droptargetlistener.obj
SRCFILES= fltdlg.src