summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorTim Hardeck <thardeck@suse.de>2012-06-12 19:04:05 +0200
committerTim Hardeck <thardeck@suse.de>2012-06-15 13:38:56 +0200
commit6484ccb4edad34d03d1300929fe20788f41b255e (patch)
tree81889977e5eebedc929206a82baaa00c30512090 /sfx2
parent4ad231a6abea556ce7815fc6dafc9aebb87a4e26 (diff)
move zoomitem from svx to sfx2
To allow using SvxZoomItem in sfx2 zoomitem is moved from svx to sfx2. This patch does base on Caolán McNamara's patch he sent to the mailing list. Change-Id: I4d245f938d92ad3a20b692f5f76d8e0d00b1a648
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/Library_sfx.mk1
-rw-r--r--sfx2/Package_inc.mk1
-rw-r--r--sfx2/inc/sfx2/sfx.hrc11
-rw-r--r--sfx2/inc/sfx2/sfxsids.hrc3
-rw-r--r--sfx2/inc/sfx2/zoomitem.hxx92
-rw-r--r--sfx2/sdi/sfx.sdi26
-rw-r--r--sfx2/sdi/sfxitems.sdi7
-rw-r--r--sfx2/source/doc/zoomitem.cxx180
8 files changed, 316 insertions, 5 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index f9d848b54058..6da9165dbcc3 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 4c2594c258fb..d0a8b22c8f27 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 462b00fb5e79..48e44b216792 100644
--- a/sfx2/inc/sfx2/sfx.hrc
+++ b/sfx2/inc/sfx2/sfx.hrc
@@ -323,10 +323,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 c6a86f1322fc..f29902ecce2b 100644
--- a/sfx2/inc/sfx2/sfxsids.hrc
+++ b/sfx2/inc/sfx2/sfxsids.hrc
@@ -200,6 +200,8 @@
#define ID_FILETP_READONLY (ID_FILETP_START + 0)
#define ID_FILETP_TITLE (ID_FILETP_START + 1)
+#define SID_ATTR_ZOOM (SID_SVX_START + 1419)
+
#define SID_EXPLORER_PROPS_START (SID_SFX_START + 1410)
#define SID_EXPLORER_PROPS_END (SID_SFX_START + 1499)
@@ -1024,4 +1026,3 @@
#define SID_CHG_PROTECT (SC_VIEW_START + 84)
// eof ------------------------------------------------------------------------
-
diff --git a/sfx2/inc/sfx2/zoomitem.hxx b/sfx2/inc/sfx2/zoomitem.hxx
new file mode 100644
index 000000000000..592e81ff4fe5
--- /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 e1dd418a1331..b209baa7ba87 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -8290,3 +8290,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 421c1cb29529..ab335a96e047 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/doc/zoomitem.cxx b/sfx2/source/doc/zoomitem.cxx
new file mode 100644
index 000000000000..d5906089ea1b
--- /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: */