xref: /aoo41x/main/svx/source/stbctrls/pszctrl.cxx (revision cffdb0bf)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <limits.h>
30cdf0e10cSrcweir #include <tools/shl.hxx>
31cdf0e10cSrcweir #include <vcl/status.hxx>
32cdf0e10cSrcweir #include <vcl/menu.hxx>
33cdf0e10cSrcweir #include <vcl/image.hxx>
34cdf0e10cSrcweir #include <svl/stritem.hxx>
35cdf0e10cSrcweir #include <svl/ptitem.hxx>
36cdf0e10cSrcweir #include <svl/itempool.hxx>
37cdf0e10cSrcweir #include <sfx2/app.hxx>
38cdf0e10cSrcweir #include <sfx2/module.hxx>
39cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
40cdf0e10cSrcweir #include <sfx2/objsh.hxx>
41cdf0e10cSrcweir #include <svl/intitem.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "svx/pszctrl.hxx"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #define PAINT_OFFSET	5
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
48cdf0e10cSrcweir #include <svx/dialmgr.hxx>
49cdf0e10cSrcweir #include "svx/dlgutil.hxx"
50cdf0e10cSrcweir #include "stbctrls.h"
51cdf0e10cSrcweir #include "sfx2/module.hxx"
52cdf0e10cSrcweir 
53cdf0e10cSrcweir #include <svx/dialogs.hrc>
54cdf0e10cSrcweir #include <unotools/localedatawrapper.hxx>
55cdf0e10cSrcweir #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
56cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
57cdf0e10cSrcweir #endif
58cdf0e10cSrcweir 
59cdf0e10cSrcweir // -----------------------------------------------------------------------
60cdf0e10cSrcweir 
61cdf0e10cSrcweir /*	[Beschreibung]
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	Funktion, mit der ein metrischer Wert in textueller Darstellung
64cdf0e10cSrcweir 	umgewandelt wird.
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 	nVal ist hier der metrische Wert in der Einheit eUnit.
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 	[Querverweise]
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	<SvxPosSizeStatusBarControl::Paint(const UserDrawEvent&)>
71cdf0e10cSrcweir */
72cdf0e10cSrcweir 
GetMetricStr_Impl(long nVal)73cdf0e10cSrcweir String SvxPosSizeStatusBarControl::GetMetricStr_Impl( long nVal )
74cdf0e10cSrcweir {
75cdf0e10cSrcweir 	// Applikations-Metrik besorgen und setzen
76cdf0e10cSrcweir 	FieldUnit eOutUnit = SfxModule::GetModuleFieldUnit( getFrameInterface() );
77cdf0e10cSrcweir     FieldUnit eInUnit = FUNIT_100TH_MM;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	String sMetric;
80cdf0e10cSrcweir 	const sal_Unicode cSep = Application::GetSettings().GetLocaleDataWrapper().getNumDecimalSep().GetChar(0);
81cdf0e10cSrcweir 	sal_Int64 nConvVal = MetricField::ConvertValue( nVal * 100, 0L, 0, eInUnit, eOutUnit );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	if ( nConvVal < 0 && ( nConvVal / 100 == 0 ) )
84cdf0e10cSrcweir 		sMetric += '-';
85cdf0e10cSrcweir 	sMetric += String::CreateFromInt64( nConvVal / 100 );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	if( FUNIT_NONE != eOutUnit )
88cdf0e10cSrcweir 	{
89cdf0e10cSrcweir 		sMetric += cSep;
90cdf0e10cSrcweir 		sal_Int64 nFract = nConvVal % 100;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 		if ( nFract < 0 )
93cdf0e10cSrcweir 			nFract *= -1;
94cdf0e10cSrcweir 		if ( nFract < 10 )
95cdf0e10cSrcweir 			sMetric += '0';
96cdf0e10cSrcweir 		sMetric += String::CreateFromInt64( nFract );
97cdf0e10cSrcweir 	}
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	return sMetric;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir // -----------------------------------------------------------------------
103cdf0e10cSrcweir 
104cdf0e10cSrcweir SFX_IMPL_STATUSBAR_CONTROL(SvxPosSizeStatusBarControl, SvxSizeItem);
105cdf0e10cSrcweir 
106cdf0e10cSrcweir // class FunctionPopup_Impl ----------------------------------------------
107cdf0e10cSrcweir 
108cdf0e10cSrcweir class FunctionPopup_Impl : public PopupMenu
109cdf0e10cSrcweir {
110cdf0e10cSrcweir public:
111cdf0e10cSrcweir 	FunctionPopup_Impl( sal_uInt16 nCheck );
112cdf0e10cSrcweir 
GetSelected() const113cdf0e10cSrcweir 	sal_uInt16			GetSelected() const { return nSelected; }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir private:
116cdf0e10cSrcweir 	sal_uInt16			nSelected;
117cdf0e10cSrcweir 
118cdf0e10cSrcweir 	virtual void    Select();
119cdf0e10cSrcweir };
120cdf0e10cSrcweir 
121cdf0e10cSrcweir // -----------------------------------------------------------------------
122cdf0e10cSrcweir 
FunctionPopup_Impl(sal_uInt16 nCheck)123cdf0e10cSrcweir FunctionPopup_Impl::FunctionPopup_Impl( sal_uInt16 nCheck ) :
124cdf0e10cSrcweir 	PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ),
125cdf0e10cSrcweir 	nSelected( 0 )
126cdf0e10cSrcweir {
127cdf0e10cSrcweir 	if (nCheck)
128cdf0e10cSrcweir 		CheckItem( nCheck );
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir // -----------------------------------------------------------------------
132cdf0e10cSrcweir 
Select()133cdf0e10cSrcweir void FunctionPopup_Impl::Select()
134cdf0e10cSrcweir {
135cdf0e10cSrcweir 	nSelected = GetCurItemId();
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir // struct SvxPosSizeStatusBarControl_Impl --------------------------------
139cdf0e10cSrcweir 
140cdf0e10cSrcweir struct SvxPosSizeStatusBarControl_Impl
141cdf0e10cSrcweir 
142cdf0e10cSrcweir /*	[Beschreibung]
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	Diese Implementations-Struktur der Klasse SvxPosSizeStatusBarControl
145cdf0e10cSrcweir 	dient der Entkopplung von "Anderungen vom exportierten Interface sowie
146cdf0e10cSrcweir 	der Verringerung von extern sichtbaren Symbolen.
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	Eine Instanz exisitiert pro SvxPosSizeStatusBarControl-Instanz
149cdf0e10cSrcweir 	f"ur deren Laufzeit.
150cdf0e10cSrcweir */
151cdf0e10cSrcweir 
152cdf0e10cSrcweir {
153cdf0e10cSrcweir 	Point   aPos;		// g"ultig, wenn eine Position angezeigt wird
154cdf0e10cSrcweir 	Size    aSize;		// g"ultig, wenn eine Gr"o/se angezeigt wird
155cdf0e10cSrcweir 	String	aStr;		// g"ultig, wenn ein Text angezeigt wird
156cdf0e10cSrcweir     sal_Bool    bPos;       // show position
157cdf0e10cSrcweir 	sal_Bool	bSize;		// Gr"o/se anzeigen?
158cdf0e10cSrcweir 	sal_Bool	bTable;		// Tabellenindex anzeigen?
159cdf0e10cSrcweir 	sal_Bool	bHasMenu;	// StarCalc Popup-Menue anzeigen?
160cdf0e10cSrcweir 	sal_uInt16	nFunction;	// selektierte StarCalc Funktion
161cdf0e10cSrcweir 	Image	aPosImage; 	// Image f"ur die Positionsanzeige
162cdf0e10cSrcweir 	Image	aSizeImage;	// Image f"ur die Gr"o/senanzeige
163cdf0e10cSrcweir };
164cdf0e10cSrcweir 
165cdf0e10cSrcweir // class SvxPosSizeStatusBarControl ------------------------------------------
166cdf0e10cSrcweir 
167cdf0e10cSrcweir /*	[Beschreibung]
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 	Ctor():
170cdf0e10cSrcweir 	Anlegen einer Impl-Klassen-Instanz, Default die Zeitanzeige enablen,
171cdf0e10cSrcweir 	Images fu"r die Position und Gro"sse laden.
172cdf0e10cSrcweir */
173cdf0e10cSrcweir 
174cdf0e10cSrcweir #define STR_POSITION ".uno:Position"
175cdf0e10cSrcweir #define STR_TABLECELL ".uno:StateTableCell"
176cdf0e10cSrcweir #define STR_FUNC ".uno:StatusBarFunc"
177cdf0e10cSrcweir 
SvxPosSizeStatusBarControl(sal_uInt16 _nSlotId,sal_uInt16 _nId,StatusBar & rStb)178cdf0e10cSrcweir SvxPosSizeStatusBarControl::SvxPosSizeStatusBarControl( sal_uInt16 _nSlotId,
179cdf0e10cSrcweir                                                         sal_uInt16 _nId,
180cdf0e10cSrcweir 														StatusBar& rStb ) :
181cdf0e10cSrcweir 	SfxStatusBarControl( _nSlotId, _nId, rStb ),
182cdf0e10cSrcweir 	pImp( new SvxPosSizeStatusBarControl_Impl )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir     pImp->bPos = sal_False;
185cdf0e10cSrcweir 	pImp->bSize = sal_False;
186cdf0e10cSrcweir 	pImp->bTable = sal_False;
187cdf0e10cSrcweir 	pImp->bHasMenu = sal_False;
188cdf0e10cSrcweir 	pImp->nFunction = 0;
189*cffdb0bfSmseidel 	sal_Bool bHC = GetStatusBar().GetSettings().GetStyleSettings().GetHighContrastMode();
190*cffdb0bfSmseidel 		pImp->aPosImage = Image( SVX_RES( bHC ? RID_SVXBMP_POSITION_H : RID_SVXBMP_POSITION ) );
191*cffdb0bfSmseidel 		pImp->aSizeImage = Image( SVX_RES( bHC ? RID_SVXBMP_SIZE_H : RID_SVXBMP_SIZE ) );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STR_POSITION )));         // SID_ATTR_POSITION
194cdf0e10cSrcweir     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STR_TABLECELL )));   // SID_TABLE_CELL
195cdf0e10cSrcweir     addStatusListener( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( STR_FUNC )));    // SID_PSZ_FUNCTION
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir // -----------------------------------------------------------------------
199cdf0e10cSrcweir 
200cdf0e10cSrcweir /*	[Beschreibung]
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	Dtor():
203cdf0e10cSrcweir 	Pointer auf die Impl-Klasse lo"schen, damit der Timer gestoppt wird.
204cdf0e10cSrcweir */
205cdf0e10cSrcweir 
~SvxPosSizeStatusBarControl()206cdf0e10cSrcweir SvxPosSizeStatusBarControl::~SvxPosSizeStatusBarControl()
207cdf0e10cSrcweir {
208cdf0e10cSrcweir 	delete pImp;
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir // -----------------------------------------------------------------------
212cdf0e10cSrcweir 
213cdf0e10cSrcweir /*	[Beschreibung]
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 	SID_PSZ_FUNCTION aktiviert das Popup-Menue fuer Calc, ansonsten:
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 	Statusbenachrichtigung;
218cdf0e10cSrcweir 	Je nach Item-Typ wird eine bestimmte Anzeige enabled, die anderen disabled.
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 				NULL/Void	SfxPointItem	SvxSizeItem		SfxStringItem
221cdf0e10cSrcweir 	------------------------------------------------------------------------
222cdf0e10cSrcweir 	Zeit		sal_True		sal_False			sal_False			FALSE
223cdf0e10cSrcweir 	Position	sal_False										FALSE
224cdf0e10cSrcweir 	Gro"sse		FALSE						TRUE			FALSE
225cdf0e10cSrcweir 	Text		sal_False						sal_False			TRUE
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 	Ein anderes Item bewirkt einen Assert, die Zeitanzeige wird enabled.
228cdf0e10cSrcweir */
229cdf0e10cSrcweir 
StateChanged(sal_uInt16 nSID,SfxItemState eState,const SfxPoolItem * pState)230cdf0e10cSrcweir void SvxPosSizeStatusBarControl::StateChanged( sal_uInt16 nSID, SfxItemState eState,
231cdf0e10cSrcweir 											   const SfxPoolItem* pState )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir 	// da Kombi-Controller, immer die aktuelle Id als HelpId setzen
234cdf0e10cSrcweir 	// gecachten HelpText vorher l"oschen
235cdf0e10cSrcweir 	GetStatusBar().SetHelpText( GetId(), String() );
236cdf0e10cSrcweir 
237cdf0e10cSrcweir     switch ( nSID )
238cdf0e10cSrcweir     {
239cdf0e10cSrcweir         case SID_ATTR_POSITION : GetStatusBar().SetHelpId( GetId(), STR_POSITION ); break;
240cdf0e10cSrcweir         case SID_TABLE_CELL: GetStatusBar().SetHelpId( GetId(), STR_TABLECELL ); break;
241cdf0e10cSrcweir         case SID_PSZ_FUNCTION: GetStatusBar().SetHelpId( GetId(), STR_FUNC ); break;
242cdf0e10cSrcweir         default: break;
243cdf0e10cSrcweir     }
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	if ( nSID == SID_PSZ_FUNCTION )
246cdf0e10cSrcweir 	{
247cdf0e10cSrcweir 		if ( eState == SFX_ITEM_AVAILABLE )
248cdf0e10cSrcweir 		{
249cdf0e10cSrcweir 			pImp->bHasMenu = sal_True;
250cdf0e10cSrcweir 			if ( pState && pState->ISA(SfxUInt16Item) )
251cdf0e10cSrcweir 				pImp->nFunction = ((const SfxUInt16Item*)pState)->GetValue();
252cdf0e10cSrcweir 		}
253cdf0e10cSrcweir 		else
254cdf0e10cSrcweir 			pImp->bHasMenu = sal_False;
255cdf0e10cSrcweir 	}
256cdf0e10cSrcweir 	else if ( SFX_ITEM_AVAILABLE != eState )
257cdf0e10cSrcweir 	{
258cdf0e10cSrcweir         // #i34458# don't switch to empty display before an empty state was
259cdf0e10cSrcweir         // notified for all display types
260cdf0e10cSrcweir 
261cdf0e10cSrcweir         if ( nSID == SID_TABLE_CELL )
262cdf0e10cSrcweir             pImp->bTable = sal_False;
263cdf0e10cSrcweir         else if ( nSID == SID_ATTR_POSITION )
264cdf0e10cSrcweir             pImp->bPos = sal_False;
265cdf0e10cSrcweir         else if ( nSID == GetSlotId() )     // controller is registered for SID_ATTR_SIZE
266cdf0e10cSrcweir             pImp->bSize = sal_False;
267cdf0e10cSrcweir         else
268cdf0e10cSrcweir         {
269cdf0e10cSrcweir             DBG_ERRORFILE("unknown slot id");
270cdf0e10cSrcweir         }
271cdf0e10cSrcweir 	}
272cdf0e10cSrcweir 	else if ( pState->ISA( SfxPointItem ) )
273cdf0e10cSrcweir 	{
274cdf0e10cSrcweir 		// Position anzeigen
275cdf0e10cSrcweir 		pImp->aPos = ( (SfxPointItem*)pState )->GetValue();
276cdf0e10cSrcweir         pImp->bPos = sal_True;
277cdf0e10cSrcweir 		pImp->bTable = sal_False;
278cdf0e10cSrcweir 	}
279cdf0e10cSrcweir 	else if ( pState->ISA( SvxSizeItem ) )
280cdf0e10cSrcweir 	{
281cdf0e10cSrcweir 		// Groesse anzeigen
282cdf0e10cSrcweir 		pImp->aSize = ( (SvxSizeItem*)pState )->GetSize();
283cdf0e10cSrcweir 		pImp->bSize = sal_True;
284cdf0e10cSrcweir 		pImp->bTable = sal_False;
285cdf0e10cSrcweir 	}
286cdf0e10cSrcweir 	else if ( pState->ISA( SfxStringItem ) )
287cdf0e10cSrcweir 	{
288cdf0e10cSrcweir 		// String anzeigen (Tabellen-Zelle oder anderes)
289cdf0e10cSrcweir 		pImp->aStr = ( (SfxStringItem*)pState )->GetValue();
290cdf0e10cSrcweir 		pImp->bTable = sal_True;
291cdf0e10cSrcweir         pImp->bPos = sal_False;
292cdf0e10cSrcweir 		pImp->bSize = sal_False;
293cdf0e10cSrcweir 	}
294cdf0e10cSrcweir 	else
295cdf0e10cSrcweir 	{
296cdf0e10cSrcweir 		DBG_ERRORFILE( "invalid item type" );
297cdf0e10cSrcweir 		// trotzdem Datum und Zeit anzeigen
298cdf0e10cSrcweir         pImp->bPos = sal_False;
299cdf0e10cSrcweir 		pImp->bSize = sal_False;
300cdf0e10cSrcweir 		pImp->bTable = sal_False;
301cdf0e10cSrcweir 	}
302cdf0e10cSrcweir 
303cdf0e10cSrcweir 	if ( GetStatusBar().AreItemsVisible() )
304cdf0e10cSrcweir 		GetStatusBar().SetItemData( GetId(), 0 );
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	//	nur Strings auch als Text an der StatusBar setzen, damit Tip-Hilfe
307cdf0e10cSrcweir 	//	funktioniert, wenn der Text zu lang ist.
308cdf0e10cSrcweir 	String aText;
309cdf0e10cSrcweir 	if ( pImp->bTable )
310cdf0e10cSrcweir 		aText = pImp->aStr;
311cdf0e10cSrcweir 	GetStatusBar().SetItemText( GetId(), aText );
312cdf0e10cSrcweir }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir // -----------------------------------------------------------------------
315cdf0e10cSrcweir 
316cdf0e10cSrcweir /*	[Beschreibung]
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 	Popup-Menue ausfuehren, wenn per Status enabled
319cdf0e10cSrcweir */
320cdf0e10cSrcweir 
Command(const CommandEvent & rCEvt)321cdf0e10cSrcweir void SvxPosSizeStatusBarControl::Command( const CommandEvent& rCEvt )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir 	if ( rCEvt.GetCommand() == COMMAND_CONTEXTMENU && pImp->bHasMenu )
324cdf0e10cSrcweir 	{
325cdf0e10cSrcweir 		sal_uInt16 nSelect = pImp->nFunction;
326cdf0e10cSrcweir 		if (!nSelect)
327cdf0e10cSrcweir 			nSelect = PSZ_FUNC_NONE;
328cdf0e10cSrcweir 		FunctionPopup_Impl aMenu( nSelect );
329cdf0e10cSrcweir 		if ( aMenu.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel() ) )
330cdf0e10cSrcweir 		{
331cdf0e10cSrcweir 			nSelect = aMenu.GetSelected();
332cdf0e10cSrcweir 			if (nSelect)
333cdf0e10cSrcweir 			{
334cdf0e10cSrcweir 				if (nSelect == PSZ_FUNC_NONE)
335cdf0e10cSrcweir 					nSelect = 0;
336cdf0e10cSrcweir 
337cdf0e10cSrcweir                 ::com::sun::star::uno::Any a;
338cdf0e10cSrcweir 				SfxUInt16Item aItem( SID_PSZ_FUNCTION, nSelect );
339cdf0e10cSrcweir 
340cdf0e10cSrcweir                 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgs( 1 );
341cdf0e10cSrcweir                 aArgs[0].Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusBarFunc" ));
342cdf0e10cSrcweir                 aItem.QueryValue( a );
343cdf0e10cSrcweir                 aArgs[0].Value = a;
344cdf0e10cSrcweir 
345cdf0e10cSrcweir                 execute( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:StatusBarFunc" )), aArgs );
346cdf0e10cSrcweir //				GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SFX_CALLMODE_RECORD, &aItem, 0L );
347cdf0e10cSrcweir 			}
348cdf0e10cSrcweir 		}
349cdf0e10cSrcweir 	}
350cdf0e10cSrcweir 	else
351cdf0e10cSrcweir 		SfxStatusBarControl::Command( rCEvt );
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir // -----------------------------------------------------------------------
355cdf0e10cSrcweir 
356cdf0e10cSrcweir /*	[Beschreibung]
357cdf0e10cSrcweir 
358cdf0e10cSrcweir 	Je nach enableden Anzeigentyp, wird der Wert angezeigt. Vorher wird
359cdf0e10cSrcweir 	das Rectangle u"bermalt (gelo"scht).
360cdf0e10cSrcweir */
361cdf0e10cSrcweir 
Paint(const UserDrawEvent & rUsrEvt)362cdf0e10cSrcweir void SvxPosSizeStatusBarControl::Paint( const UserDrawEvent& rUsrEvt )
363cdf0e10cSrcweir {
364cdf0e10cSrcweir 	OutputDevice* pDev = rUsrEvt.GetDevice();
365cdf0e10cSrcweir 	DBG_ASSERT( pDev, "no OutputDevice on UserDrawEvent" );
366cdf0e10cSrcweir 	const Rectangle& rRect = rUsrEvt.GetRect();
367cdf0e10cSrcweir 	StatusBar& rBar = GetStatusBar();
368cdf0e10cSrcweir 	Point aItemPos = rBar.GetItemTextPos( GetId() );
369cdf0e10cSrcweir 	Color aOldLineColor = pDev->GetLineColor();
370cdf0e10cSrcweir 	Color aOldFillColor = pDev->GetFillColor();
371cdf0e10cSrcweir 	pDev->SetLineColor();
372cdf0e10cSrcweir 	pDev->SetFillColor( pDev->GetBackground().GetColor() );
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 	if ( pImp->bPos || pImp->bSize )
375cdf0e10cSrcweir 	{
376cdf0e10cSrcweir 		// Position fuer Size-Anzeige berechnen
377cdf0e10cSrcweir 		long nSizePosX =
378cdf0e10cSrcweir 			rRect.Left() + rRect.GetWidth() / 2 + PAINT_OFFSET;
379cdf0e10cSrcweir 		// Position zeichnen
380cdf0e10cSrcweir 		Point aPnt = rRect.TopLeft();
381cdf0e10cSrcweir 		aPnt.Y() = aItemPos.Y();
382cdf0e10cSrcweir 		aPnt.X() += PAINT_OFFSET;
383cdf0e10cSrcweir 		pDev->DrawImage( aPnt, pImp->aPosImage );
384cdf0e10cSrcweir 		aPnt.X() += pImp->aPosImage.GetSizePixel().Width();
385cdf0e10cSrcweir 		aPnt.X() += PAINT_OFFSET;
386cdf0e10cSrcweir         String aStr = GetMetricStr_Impl( pImp->aPos.X());
387cdf0e10cSrcweir 		aStr.AppendAscii(" / ");
388cdf0e10cSrcweir         aStr += GetMetricStr_Impl( pImp->aPos.Y());
389cdf0e10cSrcweir 		pDev->DrawRect(
390cdf0e10cSrcweir 			Rectangle( aPnt, Point( nSizePosX, rRect.Bottom() ) ) );
391cdf0e10cSrcweir 		pDev->DrawText( aPnt, aStr );
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 		// falls verf"ugbar, Gr"osse zeichnen
394cdf0e10cSrcweir 		aPnt.X() = nSizePosX;
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 		if ( pImp->bSize )
397cdf0e10cSrcweir 		{
398cdf0e10cSrcweir 			pDev->DrawImage( aPnt, pImp->aSizeImage );
399cdf0e10cSrcweir 			aPnt.X() += pImp->aSizeImage.GetSizePixel().Width();
400cdf0e10cSrcweir 			Point aDrwPnt = aPnt;
401cdf0e10cSrcweir 			aPnt.X() += PAINT_OFFSET;
402cdf0e10cSrcweir             aStr = GetMetricStr_Impl( pImp->aSize.Width() );
403cdf0e10cSrcweir 			aStr.AppendAscii(" x ");
404cdf0e10cSrcweir             aStr += GetMetricStr_Impl( pImp->aSize.Height() );
405cdf0e10cSrcweir 			pDev->DrawRect( Rectangle( aDrwPnt, rRect.BottomRight() ) );
406cdf0e10cSrcweir 			pDev->DrawText( aPnt, aStr );
407cdf0e10cSrcweir 		}
408cdf0e10cSrcweir 		else
409cdf0e10cSrcweir 			pDev->DrawRect( Rectangle( aPnt, rRect.BottomRight() ) );
410cdf0e10cSrcweir 	}
411cdf0e10cSrcweir 	else if ( pImp->bTable )
412cdf0e10cSrcweir 	{
413cdf0e10cSrcweir 		pDev->DrawRect( rRect );
414cdf0e10cSrcweir 		pDev->DrawText( Point(
415cdf0e10cSrcweir 			rRect.Left() + rRect.GetWidth() / 2 - pDev->GetTextWidth( pImp->aStr ) / 2,
416cdf0e10cSrcweir 			aItemPos.Y() ),	pImp->aStr );
417cdf0e10cSrcweir 	}
418cdf0e10cSrcweir     else
419cdf0e10cSrcweir     {
420cdf0e10cSrcweir         // Empty display if neither size nor table position are available.
421cdf0e10cSrcweir         // Date/Time are no longer used (#65302#).
422cdf0e10cSrcweir         pDev->DrawRect( rRect );
423cdf0e10cSrcweir     }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir 	pDev->SetLineColor( aOldLineColor );
426cdf0e10cSrcweir 	pDev->SetFillColor( aOldFillColor );
427cdf0e10cSrcweir }
428cdf0e10cSrcweir 
429cdf0e10cSrcweir // -----------------------------------------------------------------------
430cdf0e10cSrcweir 
GetDefItemWidth(const StatusBar & rStb)431cdf0e10cSrcweir sal_uIntPtr SvxPosSizeStatusBarControl::GetDefItemWidth(const StatusBar& rStb)
432cdf0e10cSrcweir {
433cdf0e10cSrcweir 	Image aTmpPosImage( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) );
434cdf0e10cSrcweir 	Image aTmpSizeImage( ResId( RID_SVXBMP_SIZE, DIALOG_MGR() ) );
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 	sal_uIntPtr nWidth=PAINT_OFFSET+aTmpPosImage.GetSizePixel().Width();
437cdf0e10cSrcweir 	nWidth+=PAINT_OFFSET+aTmpSizeImage.GetSizePixel().Width();
438cdf0e10cSrcweir 	nWidth+=2*(PAINT_OFFSET+rStb.GetTextWidth(String::CreateFromAscii("XXXX,XX / XXXX,XX")));
439cdf0e10cSrcweir 
440cdf0e10cSrcweir 	return nWidth;
441cdf0e10cSrcweir }
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 
444