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