On Wed, 2012-05-02 at 14:16 +0200, Tim Hardeck wrote: > Does anybody have an idea how to change the Zoom from appserv.cxx? Maybe > it is possible to use the functions of the original zoom dialog ( > cui/source/dialogs/zoom.cxx )?
Meh, the right combination of uno dispatch apis and frames and so forth would probably do it. But I got depressed quickly in the maze so how about the attached, just move the damn zoomitem down into sfx2 altogether. (rough and ready patch) C.
>From 809ec6f6ee664adbb73f1273d4c53827a23503f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caol...@redhat.com> Date: Fri, 8 Jun 2012 14:47:54 +0100 Subject: [PATCH] move zoomitem to sfx2 Change-Id: I6244960a9926eaebf1ff00a06a36e1afc3b255d3 --- sfx2/Library_sfx.mk | 1 + sfx2/Package_inc.mk | 1 + sfx2/inc/sfx2/sfx.hrc | 11 +- sfx2/inc/sfx2/sfxsids.hrc | 1 + sfx2/inc/sfx2/zoomitem.hxx | 92 +++++++++++++++++ sfx2/sdi/sfx.sdi | 26 +++++ sfx2/sdi/sfxitems.sdi | 7 ++ sfx2/source/appl/appserv.cxx | 25 +++++ sfx2/source/doc/zoomitem.cxx | 180 ++++++++++++++++++++++++++++++++ starmath/sdi/smitems.sdi | 10 -- svx/Library_svx.mk | 1 - svx/Package_inc.mk | 1 - svx/inc/svx/svxids.hrc | 8 +- svx/inc/svx/unomid.hxx | 3 - svx/inc/svx/zoomitem.hxx | 92 ----------------- svx/sdi/svx.sdi | 27 ----- svx/sdi/svxitems.sdi | 8 -- svx/source/items/zoomitem.cxx | 228 ----------------------------------------- 18 files changed, 342 insertions(+), 380 deletions(-) create mode 100644 sfx2/inc/sfx2/zoomitem.hxx create mode 100644 sfx2/source/doc/zoomitem.cxx delete mode 100644 svx/inc/svx/zoomitem.hxx delete mode 100644 svx/source/items/zoomitem.cxx diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index f9d848b..6da9165 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -214,6 +214,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/doc/sfxbasemodel \ sfx2/source/doc/sfxmodelfactory \ sfx2/source/doc/syspath \ + sfx2/source/doc/zoomitem \ sfx2/source/explorer/nochaos \ sfx2/source/inet/inettbc \ sfx2/source/menu/mnuitem \ diff --git a/sfx2/Package_inc.mk b/sfx2/Package_inc.mk index 4c2594c..d0a8b22 100644 --- a/sfx2/Package_inc.mk +++ b/sfx2/Package_inc.mk @@ -134,5 +134,6 @@ $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/userinputinterception.hxx,sf $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/viewfac.hxx,sfx2/viewfac.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/viewfrm.hxx,sfx2/viewfrm.hxx)) $(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/viewsh.hxx,sfx2/viewsh.hxx)) +$(eval $(call gb_Package_add_file,sfx2_inc,inc/sfx2/zoomitem.hxx,sfx2/zoomitem.hxx)) # vim: set noet sw=4 ts=4: diff --git a/sfx2/inc/sfx2/sfx.hrc b/sfx2/inc/sfx2/sfx.hrc index e09af81..fd734fc 100644 --- a/sfx2/inc/sfx2/sfx.hrc +++ b/sfx2/inc/sfx2/sfx.hrc @@ -352,10 +352,13 @@ #define MID_DOCINFO_ENCRYPTED 0x2c #define MID_DOCINFO_STATISTIC 0x33 #define MID_DOCINFO_CHARLOCALE 0x34 -#define MID_CATEGORY 0x35 -#define MID_COMPANY 0x36 -#define MID_MANAGER 0x37 -#define MID_LAST_USED_PROPID MID_MANAGER +#define MID_CATEGORY 0x35 +#define MID_COMPANY 0x36 +#define MID_MANAGER 0x37 +#define MID_TYPE 0x38 +#define MID_VALUE 0x39 +#define MID_VALUESET 0x40 +#define MID_LAST_USED_PROPID MID_VALUESET // Config-Ids ----------------------------------------------------------- diff --git a/sfx2/inc/sfx2/sfxsids.hrc b/sfx2/inc/sfx2/sfxsids.hrc index 175e8df..472a7ff 100644 --- a/sfx2/inc/sfx2/sfxsids.hrc +++ b/sfx2/inc/sfx2/sfxsids.hrc @@ -981,6 +981,7 @@ //----------------------------------------------------------------------- +#define SID_ATTR_ZOOM (SID_SVX_START + 1419) #define SID_ZOOM_OPTIMAL (SID_SIZE_OPTIMAL) #define SID_ZOOM_ENTIRE_PAGE (SID_SIZE_PAGE) #define SID_ZOOM_PAGE_WIDTH (SID_SVX_START + 1420) diff --git a/sfx2/inc/sfx2/zoomitem.hxx b/sfx2/inc/sfx2/zoomitem.hxx new file mode 100644 index 0000000..592e81f --- /dev/null +++ b/sfx2/inc/sfx2/zoomitem.hxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SVX_ZOOMITEM_HXX +#define _SVX_ZOOMITEM_HXX + +#include <svl/intitem.hxx> +#include <sfx2/sfxsids.hrc> +#include "sfx2/dllapi.h" + +//------------------------------------------------------------------------- + +enum SvxZoomType +{ + SVX_ZOOM_PERCENT, // GetValue() ist kein besonderer prozentualer Wert + SVX_ZOOM_OPTIMAL, // GetValue() entspricht der optimalen Gr"o\se + SVX_ZOOM_WHOLEPAGE, // GetValue() entspricht der ganzen Seite + SVX_ZOOM_PAGEWIDTH, // GetValue() entspricht der Seitenbreite + SVX_ZOOM_PAGEWIDTH_NOBORDER // GetValue() pagewidth without border +}; + +//------------------------------------------------------------------------- + +class SFX2_DLLPUBLIC SvxZoomItem: public SfxUInt16Item +{ + sal_uInt16 nValueSet; // erlaubte Werte (siehe #defines unten) + SvxZoomType eType; + +public: + TYPEINFO(); + + SvxZoomItem( SvxZoomType eZoomType = SVX_ZOOM_PERCENT, + sal_uInt16 nVal = 0, sal_uInt16 nWhich = SID_ATTR_ZOOM ); + SvxZoomItem( const SvxZoomItem& ); + ~SvxZoomItem(); + + void SetValueSet( sal_uInt16 nValues ) { nValueSet = nValues; } + sal_uInt16 GetValueSet() const { return nValueSet; } + bool IsValueAllowed( sal_uInt16 nValue ) const + { return nValue == ( nValue & nValueSet ); } + + SvxZoomType GetType() const { return eType; } + void SetType( SvxZoomType eNewType ) + { eType = eNewType; } + + virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; + virtual SfxPoolItem* Create( SvStream& rStrm, sal_uInt16 nVersion ) const; + virtual SvStream& Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const; + virtual int operator==( const SfxPoolItem& ) const; + virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const; + virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ); +}; + +//------------------------------------------------------------------------ + +#define SVX_ZOOM_ENABLE_50 0x0001 +#define SVX_ZOOM_ENABLE_75 0x0002 +#define SVX_ZOOM_ENABLE_100 0x0004 +#define SVX_ZOOM_ENABLE_150 0x0008 +#define SVX_ZOOM_ENABLE_200 0x0010 +#define SVX_ZOOM_ENABLE_OPTIMAL 0x1000 +#define SVX_ZOOM_ENABLE_WHOLEPAGE 0x2000 +#define SVX_ZOOM_ENABLE_PAGEWIDTH 0x4000 +#define SVX_ZOOM_ENABLE_ALL 0x701F + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 4e555b0..cb93595 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -8539,3 +8539,29 @@ SfxInt16Item ThesaurusFromContext SID_THES GroupId = GID_TEXT; ] +//-------------------------------------------------------------------------- +SvxZoomItem Zoom SID_ATTR_ZOOM + +[ + /* flags: */ + AutoUpdate = FALSE, + Cachable = Cachable, + FastCall = FALSE, + HasCoreId = FALSE, + HasDialog = TRUE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + Asynchron; + + Readonly = FALSE, + + /* config: */ + AccelConfig = TRUE, + MenuConfig = TRUE, + StatusBarConfig = TRUE, + ToolBoxConfig = TRUE, + GroupId = GID_VIEW; +] diff --git a/sfx2/sdi/sfxitems.sdi b/sfx2/sdi/sfxitems.sdi index 421c1cb..ab335a9 100644 --- a/sfx2/sdi/sfxitems.sdi +++ b/sfx2/sdi/sfxitems.sdi @@ -88,3 +88,10 @@ item SfxScriptOrganizer SfxScriptOrganizerItem; item String SvxClipboardFmtItem; //! Dummy + struct SvxZoom + { + UINT16 Value MID_VALUE; + INT16 ValueSet MID_VALUESET; + INT16 Type MID_TYPE; + }; + item SvxZoom SvxZoomItem; diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 52764c0..24f7c6d 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -124,6 +124,7 @@ #include <sfx2/dialogs.hrc> #include "sorgitm.hxx" #include "sfx2/sfxhelp.hxx" +#include <sfx2/zoomitem.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::beans; @@ -611,6 +612,30 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) case SID_ZOOM_PAGE_WIDTH: { printf("Zoom functions\n"); + + SvxZoomItem aZoom; + + switch (rReq.GetSlot()) + { + case SID_ZOOM_50_PERCENT: + aZoom.SetValue(50); + break; + case SID_ZOOM_75_PERCENT: + aZoom.SetValue(75); + break; + case SID_ZOOM_100_PERCENT: + aZoom.SetValue(100); + break; + case SID_ZOOM_150_PERCENT: + aZoom.SetValue(150); + break; + case SID_ZOOM_200_PERCENT: + aZoom.SetValue(200); + break; + } + + SfxViewFrame::Current()->GetDispatcher()->Execute(SID_ATTR_ZOOM, SFX_CALLMODE_ASYNCHRON, &aZoom, 0L); + break; } case SID_AVAILABLE_TOOLBARS: diff --git a/sfx2/source/doc/zoomitem.cxx b/sfx2/source/doc/zoomitem.cxx new file mode 100644 index 0000000..d590608 --- /dev/null +++ b/sfx2/source/doc/zoomitem.cxx @@ -0,0 +1,180 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <tools/stream.hxx> +#include <basic/sbxvar.hxx> + +#include <sfx2/zoomitem.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> + +// ----------------------------------------------------------------------- + +TYPEINIT1_FACTORY(SvxZoomItem,SfxUInt16Item, new SvxZoomItem); + +#define ZOOM_PARAM_VALUE "Value" +#define ZOOM_PARAM_VALUESET "ValueSet" +#define ZOOM_PARAM_TYPE "Type" +#define ZOOM_PARAMS 3 + +// ----------------------------------------------------------------------- + +SvxZoomItem::SvxZoomItem +( + SvxZoomType eZoomType, + sal_uInt16 nVal, + sal_uInt16 _nWhich +) +: SfxUInt16Item( _nWhich, nVal ), + nValueSet( SVX_ZOOM_ENABLE_ALL ), + eType( eZoomType ) +{ +} + +// ----------------------------------------------------------------------- + +SvxZoomItem::SvxZoomItem( const SvxZoomItem& rOrig ) +: SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ), + nValueSet( rOrig.GetValueSet() ), + eType( rOrig.GetType() ) +{ +} + +// ----------------------------------------------------------------------- + +SvxZoomItem::~SvxZoomItem() +{ +} + +// ----------------------------------------------------------------------- + +SfxPoolItem* SvxZoomItem::Clone( SfxItemPool * /*pPool*/ ) const +{ + return new SvxZoomItem( *this ); +} + +// ----------------------------------------------------------------------- + +SfxPoolItem* SvxZoomItem::Create( SvStream& rStrm, sal_uInt16 /*nVersion*/ ) const +{ + sal_uInt16 nValue; + sal_uInt16 nValSet; + sal_Int8 nType; + rStrm >> nValue >> nValSet >> nType; + SvxZoomItem* pNew = new SvxZoomItem( (SvxZoomType)nType, nValue, Which() ); + pNew->SetValueSet( nValSet ); + return pNew; +} + +// ----------------------------------------------------------------------- + +SvStream& SvxZoomItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const +{ + rStrm << (sal_uInt16)GetValue() + << nValueSet + << (sal_Int8)eType; + return rStrm; +} + +// ----------------------------------------------------------------------- + +int SvxZoomItem::operator==( const SfxPoolItem& rAttr ) const +{ + DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); + + SvxZoomItem& rItem = (SvxZoomItem&)rAttr; + + return ( GetValue() == rItem.GetValue() && + nValueSet == rItem.GetValueSet() && + eType == rItem.GetType() ); +} + +bool SvxZoomItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const +{ +// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); + nMemberId &= ~CONVERT_TWIPS; + + assert(nMemberId == 0); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( ZOOM_PARAMS ); + aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_VALUE )); + aSeq[0].Value <<= sal_Int32( GetValue() ); + aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_VALUESET )); + aSeq[1].Value <<= sal_Int16( nValueSet ); + aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_TYPE )); + aSeq[2].Value <<= sal_Int16( eType ); + rVal <<= aSeq; + + return true; +} + +bool SvxZoomItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) +{ + nMemberId &= ~CONVERT_TWIPS; + assert(nMemberId == 0); + + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq; + if (( rVal >>= aSeq ) && ( aSeq.getLength() == ZOOM_PARAMS )) + { + sal_Int32 nValueTmp( 0 ); + sal_Int16 nValueSetTmp( 0 ); + sal_Int16 nTypeTmp( 0 ); + sal_Bool bAllConverted( sal_True ); + sal_Int16 nConvertedCount( 0 ); + for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ ) + { + if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUE )) + { + bAllConverted &= ( aSeq[i].Value >>= nValueTmp ); + ++nConvertedCount; + } + else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUESET )) + { + bAllConverted &= ( aSeq[i].Value >>= nValueSetTmp ); + ++nConvertedCount; + } + else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_TYPE )) + { + bAllConverted &= ( aSeq[i].Value >>= nTypeTmp ); + ++nConvertedCount; + } + } + + if ( bAllConverted && nConvertedCount == ZOOM_PARAMS ) + { + SetValue( (sal_uInt16)nValueTmp ); + nValueSet = nValueSetTmp; + eType = SvxZoomType( nTypeTmp ); + return true; + } + } + + return false; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/sdi/smitems.sdi b/starmath/sdi/smitems.sdi index 019d2c5..0cf73d0 100644 --- a/starmath/sdi/smitems.sdi +++ b/starmath/sdi/smitems.sdi @@ -580,16 +580,6 @@ item SvxLongULSpace SvxLongULSpaceItem; //------------------------------------------------------------------------- -struct SvxZoom -{ - INT32 Type MID_TYPE; - UINT16 ValueSet MID_VALUESET; - INT32 Percent MID_PERCENT; -}; -item SvxZoom SvxZoomItem; - -//------------------------------------------------------------------------- - item SbxObject SvxTabStopItem; diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index ba8ffa1..c294c73 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -158,7 +158,6 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/items/SmartTagItem \ svx/source/items/svxerr \ svx/source/items/viewlayoutitem \ - svx/source/items/zoomitem \ svx/source/items/zoomslideritem \ svx/source/mnuctrls/clipboardctl \ svx/source/mnuctrls/fntctl \ diff --git a/svx/Package_inc.mk b/svx/Package_inc.mk index bd07e7b..0b8014a 100644 --- a/svx/Package_inc.mk +++ b/svx/Package_inc.mk @@ -120,7 +120,6 @@ $(eval $(call gb_Package_add_file,svx_inc,inc/svx/unofill.hxx,svx/unofill.hxx)) $(eval $(call gb_Package_add_file,svx_inc,inc/svx/drawitem.hxx,svx/drawitem.hxx)) $(eval $(call gb_Package_add_file,svx_inc,inc/svx/xmlgrhlp.hxx,svx/xmlgrhlp.hxx)) $(eval $(call gb_Package_add_file,svx_inc,inc/svx/fmresids.hrc,svx/fmresids.hrc)) -$(eval $(call gb_Package_add_file,svx_inc,inc/svx/zoomitem.hxx,svx/zoomitem.hxx)) $(eval $(call gb_Package_add_file,svx_inc,inc/svx/sdtcfitm.hxx,svx/sdtcfitm.hxx)) $(eval $(call gb_Package_add_file,svx_inc,inc/svx/sdmetitm.hxx,svx/sdmetitm.hxx)) $(eval $(call gb_Package_add_file,svx_inc,inc/svx/fmtools.hxx,svx/fmtools.hxx)) diff --git a/svx/inc/svx/svxids.hrc b/svx/inc/svx/svxids.hrc index f66af83..07b8dd7 100644 --- a/svx/inc/svx/svxids.hrc +++ b/svx/inc/svx/svxids.hrc @@ -82,10 +82,8 @@ #define MID_RIGHT_MARGIN 0x47 #define MID_ROW_DIRECTION 0x48 #define MID_SIZE 0x4a -#define MID_TYPE 0x4c -#define MID_UPPER 0x4d -#define MID_USExxx 0x4e -#define MID_VALUESET 0x4f +#define MID_UPPER 0x4b +#define MID_USExxx 0x4c #define MID_ADR_CITY 0x50 #define MID_ADR_COMPANY 0x51 @@ -412,8 +410,6 @@ // Svx-Id's // -------------------------------------------------------------------------- -#define SID_ATTR_ZOOM ( SID_SVX_START + 0 ) - #define SID_ATTR_BORDER_INNER ( SID_SVX_START + 23 ) diff --git a/svx/inc/svx/unomid.hxx b/svx/inc/svx/unomid.hxx index 828bbd5..356efb6 100644 --- a/svx/inc/svx/unomid.hxx +++ b/svx/inc/svx/unomid.hxx @@ -65,9 +65,6 @@ #define MID_HORJUST_HORJUST 0 #define MID_HORJUST_ADJUST 1 -// SvxZoomItem -#define MID_VALUE 2 - // SvxObjectItem #define MID_START_X 1 #define MID_START_Y 2 diff --git a/svx/inc/svx/zoomitem.hxx b/svx/inc/svx/zoomitem.hxx deleted file mode 100644 index 77cf645..0000000 --- a/svx/inc/svx/zoomitem.hxx +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _SVX_ZOOMITEM_HXX -#define _SVX_ZOOMITEM_HXX - -#include <svl/intitem.hxx> -#include <svx/svxids.hrc> -#include "svx/svxdllapi.h" - -//------------------------------------------------------------------------- - -enum SvxZoomType -{ - SVX_ZOOM_PERCENT, // GetValue() ist kein besonderer prozentualer Wert - SVX_ZOOM_OPTIMAL, // GetValue() entspricht der optimalen Gr"o\se - SVX_ZOOM_WHOLEPAGE, // GetValue() entspricht der ganzen Seite - SVX_ZOOM_PAGEWIDTH, // GetValue() entspricht der Seitenbreite - SVX_ZOOM_PAGEWIDTH_NOBORDER // GetValue() pagewidth without border -}; - -//------------------------------------------------------------------------- - -class SVX_DLLPUBLIC SvxZoomItem: public SfxUInt16Item -{ - sal_uInt16 nValueSet; // erlaubte Werte (siehe #defines unten) - SvxZoomType eType; - -public: - TYPEINFO(); - - SvxZoomItem( SvxZoomType eZoomType = SVX_ZOOM_PERCENT, - sal_uInt16 nVal = 0, sal_uInt16 nWhich = SID_ATTR_ZOOM ); - SvxZoomItem( const SvxZoomItem& ); - ~SvxZoomItem(); - - void SetValueSet( sal_uInt16 nValues ) { nValueSet = nValues; } - sal_uInt16 GetValueSet() const { return nValueSet; } - bool IsValueAllowed( sal_uInt16 nValue ) const - { return nValue == ( nValue & nValueSet ); } - - SvxZoomType GetType() const { return eType; } - void SetType( SvxZoomType eNewType ) - { eType = eNewType; } - - virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const; - virtual SfxPoolItem* Create( SvStream& rStrm, sal_uInt16 nVersion ) const; - virtual SvStream& Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const; - virtual int operator==( const SfxPoolItem& ) const; - virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const; - virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ); -}; - -//------------------------------------------------------------------------ - -#define SVX_ZOOM_ENABLE_50 0x0001 -#define SVX_ZOOM_ENABLE_75 0x0002 -#define SVX_ZOOM_ENABLE_100 0x0004 -#define SVX_ZOOM_ENABLE_150 0x0008 -#define SVX_ZOOM_ENABLE_200 0x0010 -#define SVX_ZOOM_ENABLE_OPTIMAL 0x1000 -#define SVX_ZOOM_ENABLE_WHOLEPAGE 0x2000 -#define SVX_ZOOM_ENABLE_PAGEWIDTH 0x4000 -#define SVX_ZOOM_ENABLE_ALL 0x701F - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 8afec8b..5e19175 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -11786,33 +11786,6 @@ XLineStyleItem XLineStyle SID_ATTR_LINE_STYLE ] //-------------------------------------------------------------------------- -SvxZoomItem Zoom SID_ATTR_ZOOM - -[ - /* flags: */ - AutoUpdate = FALSE, - Cachable = Cachable, - FastCall = FALSE, - HasCoreId = FALSE, - HasDialog = TRUE, - ReadOnlyDoc = TRUE, - Toggle = FALSE, - Container = FALSE, - RecordAbsolute = FALSE, - RecordPerSet; - Asynchron; - - Readonly = FALSE, - - /* config: */ - AccelConfig = TRUE, - MenuConfig = TRUE, - StatusBarConfig = TRUE, - ToolBoxConfig = TRUE, - GroupId = GID_VIEW; -] - -//-------------------------------------------------------------------------- SfxVoidItem Zoom100Percent SID_SIZE_REAL () [ diff --git a/svx/sdi/svxitems.sdi b/svx/sdi/svxitems.sdi index ef1a954..6824a6d 100644 --- a/svx/sdi/svxitems.sdi +++ b/svx/sdi/svxitems.sdi @@ -599,14 +599,6 @@ struct SvxProtect }; item SvxProtect SvxProtectItem; -struct SvxZoom -{ - UINT16 Value MID_VALUE; - INT16 ValueSet MID_VALUESET; - INT16 Type MID_TYPE; -}; -item SvxZoom SvxZoomItem; - struct SvxRulerObject { INT32 StartX MID_START_X; diff --git a/svx/source/items/zoomitem.cxx b/svx/source/items/zoomitem.cxx deleted file mode 100644 index 226d18d..0000000 --- a/svx/source/items/zoomitem.cxx +++ /dev/null @@ -1,228 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * 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 - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <tools/stream.hxx> -#include <basic/sbxvar.hxx> - -#include <svx/zoomitem.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/beans/PropertyValue.hpp> - -// ----------------------------------------------------------------------- - -TYPEINIT1_FACTORY(SvxZoomItem,SfxUInt16Item, new SvxZoomItem); - -#define ZOOM_PARAM_VALUE "Value" -#define ZOOM_PARAM_VALUESET "ValueSet" -#define ZOOM_PARAM_TYPE "Type" -#define ZOOM_PARAMS 3 - -// ----------------------------------------------------------------------- - -SvxZoomItem::SvxZoomItem -( - SvxZoomType eZoomType, - sal_uInt16 nVal, - sal_uInt16 _nWhich -) -: SfxUInt16Item( _nWhich, nVal ), - nValueSet( SVX_ZOOM_ENABLE_ALL ), - eType( eZoomType ) -{ -} - -// ----------------------------------------------------------------------- - -SvxZoomItem::SvxZoomItem( const SvxZoomItem& rOrig ) -: SfxUInt16Item( rOrig.Which(), rOrig.GetValue() ), - nValueSet( rOrig.GetValueSet() ), - eType( rOrig.GetType() ) -{ -} - -// ----------------------------------------------------------------------- - -SvxZoomItem::~SvxZoomItem() -{ -} - -// ----------------------------------------------------------------------- - -SfxPoolItem* SvxZoomItem::Clone( SfxItemPool * /*pPool*/ ) const -{ - return new SvxZoomItem( *this ); -} - -// ----------------------------------------------------------------------- - -SfxPoolItem* SvxZoomItem::Create( SvStream& rStrm, sal_uInt16 /*nVersion*/ ) const -{ - sal_uInt16 nValue; - sal_uInt16 nValSet; - sal_Int8 nType; - rStrm >> nValue >> nValSet >> nType; - SvxZoomItem* pNew = new SvxZoomItem( (SvxZoomType)nType, nValue, Which() ); - pNew->SetValueSet( nValSet ); - return pNew; -} - -// ----------------------------------------------------------------------- - -SvStream& SvxZoomItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) const -{ - rStrm << (sal_uInt16)GetValue() - << nValueSet - << (sal_Int8)eType; - return rStrm; -} - -// ----------------------------------------------------------------------- - -int SvxZoomItem::operator==( const SfxPoolItem& rAttr ) const -{ - DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); - - SvxZoomItem& rItem = (SvxZoomItem&)rAttr; - - return ( GetValue() == rItem.GetValue() && - nValueSet == rItem.GetValueSet() && - eType == rItem.GetType() ); -} - -bool SvxZoomItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) const -{ -// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); - nMemberId &= ~CONVERT_TWIPS; - switch ( nMemberId ) - { - case 0 : - { - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq( ZOOM_PARAMS ); - aSeq[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_VALUE )); - aSeq[0].Value <<= sal_Int32( GetValue() ); - aSeq[1].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_VALUESET )); - aSeq[1].Value <<= sal_Int16( nValueSet ); - aSeq[2].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ZOOM_PARAM_TYPE )); - aSeq[2].Value <<= sal_Int16( eType ); - rVal <<= aSeq; - } - break; - - case MID_VALUE: rVal <<= (sal_Int32) GetValue(); break; - case MID_VALUESET: rVal <<= (sal_Int16) nValueSet; break; - case MID_TYPE: rVal <<= (sal_Int16) eType; break; - default: - OSL_FAIL("svx::SvxZoomItem::QueryValue(), Wrong MemberId!"); - return false; - } - - return true; -} - -bool SvxZoomItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId ) -{ -// sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); - nMemberId &= ~CONVERT_TWIPS; - switch ( nMemberId ) - { - case 0 : - { - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aSeq; - if (( rVal >>= aSeq ) && ( aSeq.getLength() == ZOOM_PARAMS )) - { - sal_Int32 nValueTmp( 0 ); - sal_Int16 nValueSetTmp( 0 ); - sal_Int16 nTypeTmp( 0 ); - sal_Bool bAllConverted( sal_True ); - sal_Int16 nConvertedCount( 0 ); - for ( sal_Int32 i = 0; i < aSeq.getLength(); i++ ) - { - if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUE )) - { - bAllConverted &= ( aSeq[i].Value >>= nValueTmp ); - ++nConvertedCount; - } - else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_VALUESET )) - { - bAllConverted &= ( aSeq[i].Value >>= nValueSetTmp ); - ++nConvertedCount; - } - else if ( aSeq[i].Name.equalsAscii( ZOOM_PARAM_TYPE )) - { - bAllConverted &= ( aSeq[i].Value >>= nTypeTmp ); - ++nConvertedCount; - } - } - - if ( bAllConverted && nConvertedCount == ZOOM_PARAMS ) - { - SetValue( (sal_uInt16)nValueTmp ); - nValueSet = nValueSetTmp; - eType = SvxZoomType( nTypeTmp ); - return true; - } - } - - return false; - } - - case MID_VALUE: - { - sal_Int32 nVal = 0; - if ( rVal >>= nVal ) - { - SetValue( (sal_uInt16)nVal ); - return true; - } - else - return false; - } - - case MID_VALUESET: - case MID_TYPE: - { - sal_Int16 nVal = sal_Int16(); - if ( rVal >>= nVal ) - { - if ( nMemberId == MID_VALUESET ) - nValueSet = (sal_Int16) nVal; - else if ( nMemberId == MID_TYPE ) - eType = SvxZoomType( (sal_Int16) nVal ); - return true; - } - else - return false; - } - - default: - OSL_FAIL("svx::SvxZoomItem::PutValue(), Wrong MemberId!"); - return false; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- 1.7.10.2
_______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice