ValueSetWithTextControl.cxx (da72173f) ValueSetWithTextControl.cxx (766ce4d0)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 6 unchanged lines hidden (view full) ---

15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22#include "svx/sidebar/ValueSetWithTextControl.hxx"
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 6 unchanged lines hidden (view full) ---

15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22#include "svx/sidebar/ValueSetWithTextControl.hxx"
23
23#include <svx/dialogs.hrc>
24#include <svx/dialmgr.hxx>
24#include <sfx2/sidebar/Theme.hxx>
25
25#include <sfx2/sidebar/Theme.hxx>
26
27#include <limits.h>
28#include <com/sun/star/uno/Reference.h>
29#include <com/sun/star/uno/Sequence.h>
30#include <com/sun/star/lang/Locale.hpp>
31#include <com/sun/star/style/NumberingType.hpp>
32#include <com/sun/star/lang/XMultiServiceFactory.hpp>
33#include <com/sun/star/container/XIndexAccess.hpp>
34#include <com/sun/star/text/XDefaultNumberingProvider.hpp>
35#include <com/sun/star/text/XNumberingFormatter.hpp>
36#include <com/sun/star/beans/PropertyValue.hpp>
37#include <comphelper/processfactory.hxx>
38#include <com/sun/star/text/XNumberingTypeInfo.hpp>
26#include <i18npool/mslangid.hxx>
39#include <i18npool/mslangid.hxx>
40#include <svtools/valueset.hxx>
41#include <editeng/brshitem.hxx>
42#include <vcl/graph.hxx>
43#include <svx/nbdtmg.hxx>
44#include <svx/nbdtmgfact.hxx>
27
45
46using namespace com::sun::star::uno;
47using namespace com::sun::star::beans;
48using namespace com::sun::star::lang;
49using namespace com::sun::star::i18n;
50using namespace com::sun::star::text;
51using namespace com::sun::star::container;
52using namespace com::sun::star::style;
53using rtl::OUString;
54
55#define C2U(cChar) OUString::createFromAscii(cChar)
56
28namespace svx { namespace sidebar {
57namespace svx { namespace sidebar {
58static const sal_Char cValue[] = "Value";
29
59
60static Font& lcl_GetDefaultBulletFont()
61{
62 static sal_Bool bInit = 0;
63 static Font aDefBulletFont( UniString::CreateFromAscii(
64 RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ),
65 String(), Size( 0, 14 ) );
66 if(!bInit)
67 {
68 aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
69 aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
70 aDefBulletFont.SetPitch( PITCH_DONTKNOW );
71 aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
72 aDefBulletFont.SetTransparent( sal_True );
73 bInit = sal_True;
74 }
75 return aDefBulletFont;
76}
77
30ValueSetWithTextControl::ValueSetWithTextControl(
31 const tControlType eControlType,
32 Window* pParent,
33 const ResId& rResId)
34 : ValueSet( pParent, rResId )
35 , meControlType( eControlType )
36 , maItems()
37{

--- 155 unchanged lines hidden (view full) ---

193 break;
194 }
195 }
196
197 Invalidate( aRect );
198 pDev->Pop();
199}
200
78ValueSetWithTextControl::ValueSetWithTextControl(
79 const tControlType eControlType,
80 Window* pParent,
81 const ResId& rResId)
82 : ValueSet( pParent, rResId )
83 , meControlType( eControlType )
84 , maItems()
85{

--- 155 unchanged lines hidden (view full) ---

241 break;
242 }
243 }
244
245 Invalidate( aRect );
246 pDev->Pop();
247}
248
249SvxNumValueSet2::SvxNumValueSet2( Window* pParent, const ResId& rResId) :
250 ValueSet( pParent, rResId ),
251 aLineColor ( COL_LIGHTGRAY ),
252 pVDev ( NULL )
253{
254 SetColCount( 3 );
255 SetLineCount( 3 );
256 SetStyle( GetStyle() | WB_ITEMBORDER );
257}
258
259 SvxNumValueSet2::~SvxNumValueSet2()
260{
261 delete pVDev;
262}
263
264void SvxNumValueSet2::SetNumberingSettings(
265 const Sequence<Sequence<PropertyValue> >& aNum,
266 Reference<XNumberingFormatter>& xFormat,
267 const Locale& rLocale )
268{
269 aNumSettings = aNum;
270 xFormatter = xFormat;
271 aLocale = rLocale;
272 if(aNum.getLength() > 9)
273 SetStyle( GetStyle()|WB_VSCROLL);
274 InsertItem( DEFAULT_NONE, DEFAULT_NONE - 1 );
275 SetItemText( DEFAULT_NONE, SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE ));
276
277 for ( sal_uInt32 i = 0; i < aNum.getLength(); i++ )
278 {
279 InsertItem( i + 1);
280 if( i < 8 )
281 {
282 NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
283 if ( pNumbering )
284 {
285 SetItemText( i + 1, pNumbering->GetDescription(i));
286 }
287 }
288 }
289}
290
291void SvxNumValueSet2::UserDraw( const UserDrawEvent& rUDEvt )
292{
293 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
294 const Color aBackColor = rStyleSettings.GetFieldColor();
295 const Color aTextColor = rStyleSettings.GetFieldTextColor();
296
297 OutputDevice* pDev = rUDEvt.GetDevice();
298 Rectangle aRect = rUDEvt.GetRect();
299 sal_uInt32 nItemId = rUDEvt.GetItemId();
300 long nRectWidth = aRect.GetWidth();
301 long nRectHeight = aRect.GetHeight();
302 Size aRectSize(nRectWidth, aRect.GetHeight());
303 Point aBLPos = aRect.TopLeft();
304 Font aOldFont = pDev->GetFont();
305 Color aOldColor = pDev->GetLineColor();
306 pDev->SetLineColor(aBackColor);
307 Font aFont(OutputDevice::GetDefaultFont(
308 DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
309
310 Size aSize = aFont.GetSize();
311 aSize.Height() = nRectHeight/5;
312 aFont.SetColor(aTextColor);
313 aFont.SetFillColor(aBackColor);
314 aFont.SetSize( aSize );
315 pDev->SetFont(aFont);
316 pDev->SetLineColor(aTextColor);
317 if(!pVDev)
318 {
319 // Die Linien werden nur einmalig in das VirtualDevice gepainted
320 // nur die Gliederungspage bekommt es aktuell
321 pVDev = new VirtualDevice(*pDev);
322 pVDev->SetMapMode(pDev->GetMapMode());
323 pVDev->EnableRTL( IsRTLEnabled() );
324 pVDev->SetOutputSize( aRectSize );
325 aOrgRect = aRect;
326
327 pVDev->SetLineColor( aBackColor );
328 pVDev->SetFillColor( aBackColor );
329 pVDev->DrawRect(aOrgRect);
330
331 if(aBackColor == aLineColor)
332 aLineColor.Invert();
333 if(GetSettings().GetStyleSettings().GetHighContrastMode())
334 pVDev->SetLineColor(aTextColor);
335 else
336 pVDev->SetLineColor(aLineColor);
337 // Linien nur einmalig Zeichnen
338 Point aStart(aBLPos.X() + nRectWidth *30 / 100,0);
339 Point aEnd(aBLPos.X() + nRectWidth * 9 / 10,0);
340 for( sal_uInt32 i = 11; i < 100; i += 33)
341 {
342 aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * i / 100;
343 pVDev->DrawLine(aStart, aEnd);
344 aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * (i + 11) / 100;
345 pVDev->DrawLine(aStart, aEnd);
346 }
347 }
348 if ( nItemId != DEFAULT_NONE)
349 pDev->DrawOutDev( aRect.TopLeft(), aRectSize,
350 aOrgRect.TopLeft(), aRectSize,
351 *pVDev );
352 const OUString sValue(C2U(cValue));
353
354 Point aStart(aBLPos.X() + nRectWidth / 9,0);
355 if ( nItemId == DEFAULT_NONE)
356 {
357 String sText(SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE));
358 Font aFont = pDev->GetFont();
359 Size aSize = aFont.GetSize();
360 aSize.Height() = nRectHeight/4;
361 aFont.SetSize( aSize );
362 pDev->SetFont(aFont);
363 long nTextWidth = pDev->GetTextWidth(sText);
364 long nTextHeight = pDev->GetTextHeight();
365 //GVT refine
366 while (nTextWidth>nRectWidth && aSize.Height()>4) {
367 aSize.Height() = aSize.Height()*0.9;
368 aFont.SetSize( aSize );
369 pDev->SetFont(aFont);
370 nTextWidth = pDev->GetTextWidth(sText);
371 }
372 Point aSStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2);
373 pDev->DrawText(aSStart, sText);
374 pDev->SetFont(aOldFont);
375 }
376 else
377 {
378 NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
379 if ( pNumbering && nItemId <= DEFAULT_BULLET_TYPES )
380 {
381 for( sal_uInt32 i = 0; i < 3; i++ )
382 {
383 sal_uInt32 nY = 11 + i * 33;
384 aStart.Y() = aBLPos.Y() + nRectHeight * nY / 100;
385 String sText;
386 sal_uInt16 nLvl = 0;
387 SvxNumRule aTempRule( 0, 10, false );
388 pNumbering->ApplyNumRule(aTempRule,nItemId -1,1<<nLvl);
389 SvxNumberFormat aNumFmt(aTempRule.GetLevel(nLvl));
390 sText=aNumFmt.GetNumStr(i+1);
391 sText.Insert( aNumFmt.GetPrefix(), 0 );
392 sText += aNumFmt.GetSuffix();
393 aStart.X() = aBLPos.X() + 2;
394 aStart.Y() -= pDev->GetTextHeight()/2;
395 pDev->DrawText(aStart, sText);
396 }
397 }
398 pDev->SetFont(aOldFont);
399 pDev->SetLineColor(aOldColor);
400 }
401 //End
402}
403
404//===============================================================================================
405
406static const long aOffsetX[] =
407{
408 -1,//1,
409 3,//4,
410 4,//5,
411 -3,//0,
412 -1,//0,
413 3
414};
415
416SvxNumValueSet3::SvxNumValueSet3( Window* pParent, const ResId& rResId) :
417 ValueSet( pParent, rResId )
418{
419 SetColCount( 3 );
420 SetLineCount( 4 );
421 SetStyle( GetStyle() | WB_ITEMBORDER );
422}
423
424 SvxNumValueSet3::~SvxNumValueSet3()
425{
426}
427
428void SvxNumValueSet3::UserDraw( const UserDrawEvent& rUDEvt )
429{
430 Rectangle aRect = rUDEvt.GetRect();
431 OutputDevice* pDev = rUDEvt.GetDevice();
432 sal_uInt32 nItemId = rUDEvt.GetItemId();
433
434 long nRectHeight = aRect.GetHeight();
435 long nRectWidth = aRect.GetWidth();
436 Point aBLPos = aRect.TopLeft();
437 NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
438 if ( pBullets )
439 {
440 if ( nItemId <= DEFAULT_BULLET_TYPES ) {
441 sal_uInt16 nLvl = 0;
442 SvxNumRule aTempRule( 0, 10, false );
443 pBullets->ApplyNumRule(aTempRule,nItemId -1,1<<nLvl);
444 SvxNumberFormat aFmt(aTempRule.GetLevel(nLvl));
445 sal_Int16 eNumType = aFmt.GetNumberingType();
446 if( eNumType == SVX_NUM_CHAR_SPECIAL)
447 {
448 sal_Unicode cChar = aFmt.GetBulletChar();
449 //End
450 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
451 const Color aBackColor = rStyleSettings.GetFieldColor();
452 const Color aTextColor = rStyleSettings.GetFieldTextColor();
453
454 Font aOldFont = pDev->GetFont();
455 Font aFont( lcl_GetDefaultBulletFont() );
456
457 Size aSize = aFont.GetSize();
458 aSize.Height() = nRectHeight*3/6;
459 aFont.SetColor(aTextColor);
460 aFont.SetFillColor(aBackColor);
461 aFont.SetSize( aSize );
462 pDev->SetFont(aFont);
463 pDev->SetFillColor( aBackColor ); //wj
464
465 String sText;
466 sText = cChar;
467 Font aOldBulletFont = pDev->GetFont();
468 Font aBulletFnt(aFmt.GetBulletFont() ? *aFmt.GetBulletFont() : aOldBulletFont);
469 Size aBulSize = aOldBulletFont.GetSize();
470 aBulletFnt.SetSize(aBulSize);
471 pDev->SetFont(aBulletFnt);
472 long nTextWidth = pDev->GetTextWidth(sText);
473 long nTextHeight = pDev->GetTextHeight();
474 Point aStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2);
475 pDev->DrawText(aStart, sText);
476 pDev->SetFont(aOldFont);
477 }else if ( eNumType == SVX_NUM_BITMAP )
478 {
479 const SvxBrushItem* pBrushItem = aFmt.GetBrush();
480 if(pBrushItem)
481 {
482 const Graphic* pGrf = pBrushItem->GetGraphic();
483 if(pGrf)
484 {
485 Size aSize(nRectHeight*6/20, nRectHeight*6/20);
486 Point aStart(aBLPos.X() + nRectWidth*7/20, aBLPos.Y() + nRectHeight*7/20);
487
488 pGrf->Draw( pDev, aStart, aSize );
489 }
490 }
491 }
492 }else if ( nItemId == DEFAULT_NONE)
493 {
494 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
495 const Color aBackColor = rStyleSettings.GetFieldColor();
496 const Color aTextColor = rStyleSettings.GetFieldTextColor();
497
498 Font aOldFont = pDev->GetFont();
499 Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
500 Size aSize = aFont.GetSize();
501 //aSize.Height() = nRectHeight/5;
502 aSize.Height() = nRectHeight/4;
503 aFont.SetColor(aTextColor);
504 aFont.SetFillColor(aBackColor);
505 aFont.SetSize( aSize );
506 pDev->SetFont(aFont);
507 pDev->SetFillColor( aBackColor );
508
509 String sText(SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE));
510
511 long nTextWidth = pDev->GetTextWidth(sText);
512 long nTextHeight = pDev->GetTextHeight();
513 //GVT refine
514 while (nTextWidth>nRectWidth && aSize.Height()>4) {
515 aSize.Height() = aSize.Height()*0.9;
516 aFont.SetSize( aSize );
517 pDev->SetFont(aFont);
518 nTextWidth = pDev->GetTextWidth(sText);
519 }
520 Point aStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2);
521 pDev->DrawText(aStart, sText);
522
523 pDev->SetFont(aOldFont);
524 }
525 }
526
527}
528
201} } // end of namespace svx::sidebar
529} } // end of namespace svx::sidebar