12055df08SOliver-Rainer Wittmann /************************************************************** 22055df08SOliver-Rainer Wittmann * 32055df08SOliver-Rainer Wittmann * Licensed to the Apache Software Foundation (ASF) under one 42055df08SOliver-Rainer Wittmann * or more contributor license agreements. See the NOTICE file 52055df08SOliver-Rainer Wittmann * distributed with this work for additional information 62055df08SOliver-Rainer Wittmann * regarding copyright ownership. The ASF licenses this file 72055df08SOliver-Rainer Wittmann * to you under the Apache License, Version 2.0 (the 82055df08SOliver-Rainer Wittmann * "License"); you may not use this file except in compliance 92055df08SOliver-Rainer Wittmann * with the License. You may obtain a copy of the License at 102055df08SOliver-Rainer Wittmann * 112055df08SOliver-Rainer Wittmann * http://www.apache.org/licenses/LICENSE-2.0 122055df08SOliver-Rainer Wittmann * 132055df08SOliver-Rainer Wittmann * Unless required by applicable law or agreed to in writing, 142055df08SOliver-Rainer Wittmann * software distributed under the License is distributed on an 152055df08SOliver-Rainer Wittmann * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 162055df08SOliver-Rainer Wittmann * KIND, either express or implied. See the License for the 172055df08SOliver-Rainer Wittmann * specific language governing permissions and limitations 182055df08SOliver-Rainer Wittmann * under the License. 192055df08SOliver-Rainer Wittmann * 202055df08SOliver-Rainer Wittmann *************************************************************/ 212055df08SOliver-Rainer Wittmann 222055df08SOliver-Rainer Wittmann #include "svx/sidebar/ValueSetWithTextControl.hxx" 23*766ce4d0SZheng Fan #include <svx/dialogs.hrc> 24*766ce4d0SZheng Fan #include <svx/dialmgr.hxx> 252055df08SOliver-Rainer Wittmann #include <sfx2/sidebar/Theme.hxx> 262055df08SOliver-Rainer Wittmann 27*766ce4d0SZheng Fan #include <limits.h> 28*766ce4d0SZheng Fan #include <com/sun/star/uno/Reference.h> 29*766ce4d0SZheng Fan #include <com/sun/star/uno/Sequence.h> 30*766ce4d0SZheng Fan #include <com/sun/star/lang/Locale.hpp> 31*766ce4d0SZheng Fan #include <com/sun/star/style/NumberingType.hpp> 32*766ce4d0SZheng Fan #include <com/sun/star/lang/XMultiServiceFactory.hpp> 33*766ce4d0SZheng Fan #include <com/sun/star/container/XIndexAccess.hpp> 34*766ce4d0SZheng Fan #include <com/sun/star/text/XDefaultNumberingProvider.hpp> 35*766ce4d0SZheng Fan #include <com/sun/star/text/XNumberingFormatter.hpp> 36*766ce4d0SZheng Fan #include <com/sun/star/beans/PropertyValue.hpp> 37*766ce4d0SZheng Fan #include <comphelper/processfactory.hxx> 38*766ce4d0SZheng Fan #include <com/sun/star/text/XNumberingTypeInfo.hpp> 392055df08SOliver-Rainer Wittmann #include <i18npool/mslangid.hxx> 40*766ce4d0SZheng Fan #include <svtools/valueset.hxx> 41*766ce4d0SZheng Fan #include <editeng/brshitem.hxx> 42*766ce4d0SZheng Fan #include <vcl/graph.hxx> 43*766ce4d0SZheng Fan #include <svx/nbdtmg.hxx> 44*766ce4d0SZheng Fan #include <svx/nbdtmgfact.hxx> 45*766ce4d0SZheng Fan 46*766ce4d0SZheng Fan using namespace com::sun::star::uno; 47*766ce4d0SZheng Fan using namespace com::sun::star::beans; 48*766ce4d0SZheng Fan using namespace com::sun::star::lang; 49*766ce4d0SZheng Fan using namespace com::sun::star::i18n; 50*766ce4d0SZheng Fan using namespace com::sun::star::text; 51*766ce4d0SZheng Fan using namespace com::sun::star::container; 52*766ce4d0SZheng Fan using namespace com::sun::star::style; 53*766ce4d0SZheng Fan using rtl::OUString; 54*766ce4d0SZheng Fan 55*766ce4d0SZheng Fan #define C2U(cChar) OUString::createFromAscii(cChar) 562055df08SOliver-Rainer Wittmann 572055df08SOliver-Rainer Wittmann namespace svx { namespace sidebar { 58*766ce4d0SZheng Fan static const sal_Char cValue[] = "Value"; 59*766ce4d0SZheng Fan 60*766ce4d0SZheng Fan static Font& lcl_GetDefaultBulletFont() 61*766ce4d0SZheng Fan { 62*766ce4d0SZheng Fan static sal_Bool bInit = 0; 63*766ce4d0SZheng Fan static Font aDefBulletFont( UniString::CreateFromAscii( 64*766ce4d0SZheng Fan RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ), 65*766ce4d0SZheng Fan String(), Size( 0, 14 ) ); 66*766ce4d0SZheng Fan if(!bInit) 67*766ce4d0SZheng Fan { 68*766ce4d0SZheng Fan aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL ); 69*766ce4d0SZheng Fan aDefBulletFont.SetFamily( FAMILY_DONTKNOW ); 70*766ce4d0SZheng Fan aDefBulletFont.SetPitch( PITCH_DONTKNOW ); 71*766ce4d0SZheng Fan aDefBulletFont.SetWeight( WEIGHT_DONTKNOW ); 72*766ce4d0SZheng Fan aDefBulletFont.SetTransparent( sal_True ); 73*766ce4d0SZheng Fan bInit = sal_True; 74*766ce4d0SZheng Fan } 75*766ce4d0SZheng Fan return aDefBulletFont; 76*766ce4d0SZheng Fan } 772055df08SOliver-Rainer Wittmann 782055df08SOliver-Rainer Wittmann ValueSetWithTextControl::ValueSetWithTextControl( 792055df08SOliver-Rainer Wittmann const tControlType eControlType, 802055df08SOliver-Rainer Wittmann Window* pParent, 812055df08SOliver-Rainer Wittmann const ResId& rResId) 822055df08SOliver-Rainer Wittmann : ValueSet( pParent, rResId ) 832055df08SOliver-Rainer Wittmann , meControlType( eControlType ) 842055df08SOliver-Rainer Wittmann , maItems() 852055df08SOliver-Rainer Wittmann { 862055df08SOliver-Rainer Wittmann SetColCount( 1 ); 872055df08SOliver-Rainer Wittmann } 882055df08SOliver-Rainer Wittmann 89ccdbcfa9SOliver-Rainer Wittmann 902055df08SOliver-Rainer Wittmann ValueSetWithTextControl::~ValueSetWithTextControl(void) 912055df08SOliver-Rainer Wittmann { 922055df08SOliver-Rainer Wittmann } 932055df08SOliver-Rainer Wittmann 94ccdbcfa9SOliver-Rainer Wittmann 952055df08SOliver-Rainer Wittmann void ValueSetWithTextControl::AddItem( 962055df08SOliver-Rainer Wittmann const Image& rItemImage, 972055df08SOliver-Rainer Wittmann const Image* pSelectedItemImage, 982055df08SOliver-Rainer Wittmann const XubString& rItemText, 992055df08SOliver-Rainer Wittmann const XubString* pItemHelpText ) 1002055df08SOliver-Rainer Wittmann { 1012055df08SOliver-Rainer Wittmann if ( meControlType != IMAGE_TEXT ) 1022055df08SOliver-Rainer Wittmann { 1032055df08SOliver-Rainer Wittmann return; 1042055df08SOliver-Rainer Wittmann } 1052055df08SOliver-Rainer Wittmann 1062055df08SOliver-Rainer Wittmann ValueSetWithTextItem aItem; 1072055df08SOliver-Rainer Wittmann aItem.maItemImage = rItemImage; 1082055df08SOliver-Rainer Wittmann aItem.maSelectedItemImage = (pSelectedItemImage != 0) 1092055df08SOliver-Rainer Wittmann ? *pSelectedItemImage 1102055df08SOliver-Rainer Wittmann : rItemImage; 1112055df08SOliver-Rainer Wittmann aItem.maItemText = rItemText; 1122055df08SOliver-Rainer Wittmann 1132055df08SOliver-Rainer Wittmann maItems.push_back( aItem ); 1142055df08SOliver-Rainer Wittmann 1152055df08SOliver-Rainer Wittmann InsertItem( maItems.size() ); 1162055df08SOliver-Rainer Wittmann SetItemText( maItems.size(), 1172055df08SOliver-Rainer Wittmann (pItemHelpText != 0) ? *pItemHelpText : rItemText ); 1182055df08SOliver-Rainer Wittmann } 1192055df08SOliver-Rainer Wittmann 120ccdbcfa9SOliver-Rainer Wittmann 1212055df08SOliver-Rainer Wittmann void ValueSetWithTextControl::AddItem( 1222055df08SOliver-Rainer Wittmann const XubString& rItemText, 1232055df08SOliver-Rainer Wittmann const XubString& rItemText2, 1242055df08SOliver-Rainer Wittmann const XubString* pItemHelpText ) 1252055df08SOliver-Rainer Wittmann { 1262055df08SOliver-Rainer Wittmann if ( meControlType != TEXT_TEXT ) 1272055df08SOliver-Rainer Wittmann { 1282055df08SOliver-Rainer Wittmann return; 1292055df08SOliver-Rainer Wittmann } 1302055df08SOliver-Rainer Wittmann 1312055df08SOliver-Rainer Wittmann ValueSetWithTextItem aItem; 1322055df08SOliver-Rainer Wittmann aItem.maItemText = rItemText; 1332055df08SOliver-Rainer Wittmann aItem.maItemText2 = rItemText2; 1342055df08SOliver-Rainer Wittmann 1352055df08SOliver-Rainer Wittmann maItems.push_back( aItem ); 1362055df08SOliver-Rainer Wittmann 1372055df08SOliver-Rainer Wittmann InsertItem( maItems.size() ); 1382055df08SOliver-Rainer Wittmann SetItemText( maItems.size(), 1392055df08SOliver-Rainer Wittmann (pItemHelpText != 0) ? *pItemHelpText : rItemText ); 1402055df08SOliver-Rainer Wittmann } 1412055df08SOliver-Rainer Wittmann 142ccdbcfa9SOliver-Rainer Wittmann 143ccdbcfa9SOliver-Rainer Wittmann void ValueSetWithTextControl::ReplaceItemImages( 144ccdbcfa9SOliver-Rainer Wittmann const sal_uInt16 nItemId, 145ccdbcfa9SOliver-Rainer Wittmann const Image& rItemImage, 146ccdbcfa9SOliver-Rainer Wittmann const Image* pSelectedItemImage ) 147ccdbcfa9SOliver-Rainer Wittmann { 148ccdbcfa9SOliver-Rainer Wittmann if ( meControlType != IMAGE_TEXT ) 149ccdbcfa9SOliver-Rainer Wittmann { 150ccdbcfa9SOliver-Rainer Wittmann return; 151ccdbcfa9SOliver-Rainer Wittmann } 152ccdbcfa9SOliver-Rainer Wittmann 153ccdbcfa9SOliver-Rainer Wittmann if ( nItemId == 0 || 154ccdbcfa9SOliver-Rainer Wittmann nItemId > maItems.size() ) 155ccdbcfa9SOliver-Rainer Wittmann { 156ccdbcfa9SOliver-Rainer Wittmann return; 157ccdbcfa9SOliver-Rainer Wittmann } 158ccdbcfa9SOliver-Rainer Wittmann 159ccdbcfa9SOliver-Rainer Wittmann maItems[nItemId-1].maItemImage = rItemImage; 160ccdbcfa9SOliver-Rainer Wittmann maItems[nItemId-1].maSelectedItemImage = (pSelectedItemImage != 0) 161ccdbcfa9SOliver-Rainer Wittmann ? *pSelectedItemImage 162ccdbcfa9SOliver-Rainer Wittmann : rItemImage; 163ccdbcfa9SOliver-Rainer Wittmann } 164ccdbcfa9SOliver-Rainer Wittmann 165ccdbcfa9SOliver-Rainer Wittmann 1662055df08SOliver-Rainer Wittmann void ValueSetWithTextControl::UserDraw( const UserDrawEvent& rUDEvt ) 1672055df08SOliver-Rainer Wittmann { 1682055df08SOliver-Rainer Wittmann const Rectangle aRect = rUDEvt.GetRect(); 1692055df08SOliver-Rainer Wittmann OutputDevice* pDev = rUDEvt.GetDevice(); 1702055df08SOliver-Rainer Wittmann pDev->Push( PUSH_ALL ); 1712055df08SOliver-Rainer Wittmann const sal_uInt16 nItemId = rUDEvt.GetItemId(); 1722055df08SOliver-Rainer Wittmann 1732055df08SOliver-Rainer Wittmann const long nRectHeight = aRect.GetHeight(); 1742055df08SOliver-Rainer Wittmann const Point aBLPos = aRect.TopLeft(); 1752055df08SOliver-Rainer Wittmann 1762055df08SOliver-Rainer Wittmann Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE)); 1772055df08SOliver-Rainer Wittmann { 1782055df08SOliver-Rainer Wittmann Size aSize = aFont.GetSize(); 1792055df08SOliver-Rainer Wittmann aSize.Height() = (nRectHeight*4)/9; 1802055df08SOliver-Rainer Wittmann aFont.SetSize( aSize ); 1812055df08SOliver-Rainer Wittmann } 1822055df08SOliver-Rainer Wittmann 1832055df08SOliver-Rainer Wittmann { 1842055df08SOliver-Rainer Wittmann //draw backgroud 1852055df08SOliver-Rainer Wittmann if ( GetSelectItemId() == nItemId ) 1862055df08SOliver-Rainer Wittmann { 1872055df08SOliver-Rainer Wittmann Rectangle aBackRect = aRect; 1882055df08SOliver-Rainer Wittmann aBackRect.Top() += 3; 1892055df08SOliver-Rainer Wittmann aBackRect.Bottom() -= 2; 1902055df08SOliver-Rainer Wittmann pDev->SetFillColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_Highlight ) ); 1912055df08SOliver-Rainer Wittmann pDev->DrawRect(aBackRect); 1922055df08SOliver-Rainer Wittmann } 1932055df08SOliver-Rainer Wittmann else 1942055df08SOliver-Rainer Wittmann { 1952055df08SOliver-Rainer Wittmann pDev->SetFillColor( COL_TRANSPARENT ); 1962055df08SOliver-Rainer Wittmann pDev->DrawRect(aRect); 1972055df08SOliver-Rainer Wittmann } 1982055df08SOliver-Rainer Wittmann 1992055df08SOliver-Rainer Wittmann //draw image + text resp. text + text 2002055df08SOliver-Rainer Wittmann Image* pImage = 0; 2012055df08SOliver-Rainer Wittmann if ( GetSelectItemId() == nItemId ) 2022055df08SOliver-Rainer Wittmann { 2032055df08SOliver-Rainer Wittmann aFont.SetColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_HighlightText ) ); 2042055df08SOliver-Rainer Wittmann pImage = &maItems[nItemId-1].maSelectedItemImage; 2052055df08SOliver-Rainer Wittmann } 2062055df08SOliver-Rainer Wittmann else 2072055df08SOliver-Rainer Wittmann { 2082055df08SOliver-Rainer Wittmann aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() ); 2092055df08SOliver-Rainer Wittmann pImage = &maItems[nItemId-1].maItemImage; 2102055df08SOliver-Rainer Wittmann } 2112055df08SOliver-Rainer Wittmann 2122055df08SOliver-Rainer Wittmann Rectangle aStrRect = aRect; 2132055df08SOliver-Rainer Wittmann aStrRect.Top() += nRectHeight/4; 2142055df08SOliver-Rainer Wittmann aStrRect.Bottom() -= nRectHeight/4; 2152055df08SOliver-Rainer Wittmann 2162055df08SOliver-Rainer Wittmann switch ( meControlType ) 2172055df08SOliver-Rainer Wittmann { 2182055df08SOliver-Rainer Wittmann case IMAGE_TEXT: 2192055df08SOliver-Rainer Wittmann { 2202055df08SOliver-Rainer Wittmann Point aImgStart( 2212055df08SOliver-Rainer Wittmann aBLPos.X() + 4, 2222055df08SOliver-Rainer Wittmann aBLPos.Y() + ( ( nRectHeight - pImage->GetSizePixel().Height() ) / 2 ) ); 2232055df08SOliver-Rainer Wittmann pDev->DrawImage( aImgStart, *pImage ); 2242055df08SOliver-Rainer Wittmann 2252055df08SOliver-Rainer Wittmann aStrRect.Left() += pImage->GetSizePixel().Width() + 12; 2262055df08SOliver-Rainer Wittmann pDev->SetFont(aFont); 2272055df08SOliver-Rainer Wittmann pDev->DrawText(aStrRect, maItems[nItemId-1].maItemText, TEXT_DRAW_ENDELLIPSIS); 2282055df08SOliver-Rainer Wittmann } 2292055df08SOliver-Rainer Wittmann break; 2302055df08SOliver-Rainer Wittmann case TEXT_TEXT: 2312055df08SOliver-Rainer Wittmann { 2322055df08SOliver-Rainer Wittmann const long nRectWidth = aRect.GetWidth(); 2332055df08SOliver-Rainer Wittmann aStrRect.Left() += 8; 2342055df08SOliver-Rainer Wittmann aStrRect.Right() -= (nRectWidth*2)/3; 2352055df08SOliver-Rainer Wittmann pDev->SetFont(aFont); 2362055df08SOliver-Rainer Wittmann pDev->DrawText(aStrRect, maItems[nItemId-1].maItemText, TEXT_DRAW_ENDELLIPSIS); 2372055df08SOliver-Rainer Wittmann aStrRect.Left() += nRectWidth/3; 2382055df08SOliver-Rainer Wittmann aStrRect.Right() += (nRectWidth*2)/3; 2392055df08SOliver-Rainer Wittmann pDev->DrawText(aStrRect, maItems[nItemId-1].maItemText2, TEXT_DRAW_ENDELLIPSIS); 2402055df08SOliver-Rainer Wittmann } 2412055df08SOliver-Rainer Wittmann break; 2422055df08SOliver-Rainer Wittmann } 2432055df08SOliver-Rainer Wittmann } 2442055df08SOliver-Rainer Wittmann 2452055df08SOliver-Rainer Wittmann Invalidate( aRect ); 2462055df08SOliver-Rainer Wittmann pDev->Pop(); 2472055df08SOliver-Rainer Wittmann } 2482055df08SOliver-Rainer Wittmann 249*766ce4d0SZheng Fan SvxNumValueSet2::SvxNumValueSet2( Window* pParent, const ResId& rResId) : 250*766ce4d0SZheng Fan ValueSet( pParent, rResId ), 251*766ce4d0SZheng Fan aLineColor ( COL_LIGHTGRAY ), 252*766ce4d0SZheng Fan pVDev ( NULL ) 253*766ce4d0SZheng Fan { 254*766ce4d0SZheng Fan SetColCount( 3 ); 255*766ce4d0SZheng Fan SetLineCount( 3 ); 256*766ce4d0SZheng Fan SetStyle( GetStyle() | WB_ITEMBORDER ); 257*766ce4d0SZheng Fan } 258*766ce4d0SZheng Fan 259*766ce4d0SZheng Fan SvxNumValueSet2::~SvxNumValueSet2() 260*766ce4d0SZheng Fan { 261*766ce4d0SZheng Fan delete pVDev; 262*766ce4d0SZheng Fan } 263*766ce4d0SZheng Fan 264*766ce4d0SZheng Fan void SvxNumValueSet2::SetNumberingSettings( 265*766ce4d0SZheng Fan const Sequence<Sequence<PropertyValue> >& aNum, 266*766ce4d0SZheng Fan Reference<XNumberingFormatter>& xFormat, 267*766ce4d0SZheng Fan const Locale& rLocale ) 268*766ce4d0SZheng Fan { 269*766ce4d0SZheng Fan aNumSettings = aNum; 270*766ce4d0SZheng Fan xFormatter = xFormat; 271*766ce4d0SZheng Fan aLocale = rLocale; 272*766ce4d0SZheng Fan if(aNum.getLength() > 9) 273*766ce4d0SZheng Fan SetStyle( GetStyle()|WB_VSCROLL); 274*766ce4d0SZheng Fan InsertItem( DEFAULT_NONE, DEFAULT_NONE - 1 ); 275*766ce4d0SZheng Fan SetItemText( DEFAULT_NONE, SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE )); 276*766ce4d0SZheng Fan 277*766ce4d0SZheng Fan for ( sal_uInt32 i = 0; i < aNum.getLength(); i++ ) 278*766ce4d0SZheng Fan { 279*766ce4d0SZheng Fan InsertItem( i + 1); 280*766ce4d0SZheng Fan if( i < 8 ) 281*766ce4d0SZheng Fan { 282*766ce4d0SZheng Fan NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING); 283*766ce4d0SZheng Fan if ( pNumbering ) 284*766ce4d0SZheng Fan { 285*766ce4d0SZheng Fan SetItemText( i + 1, pNumbering->GetDescription(i)); 286*766ce4d0SZheng Fan } 287*766ce4d0SZheng Fan } 288*766ce4d0SZheng Fan } 289*766ce4d0SZheng Fan } 290*766ce4d0SZheng Fan 291*766ce4d0SZheng Fan void SvxNumValueSet2::UserDraw( const UserDrawEvent& rUDEvt ) 292*766ce4d0SZheng Fan { 293*766ce4d0SZheng Fan const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 294*766ce4d0SZheng Fan const Color aBackColor = rStyleSettings.GetFieldColor(); 295*766ce4d0SZheng Fan const Color aTextColor = rStyleSettings.GetFieldTextColor(); 296*766ce4d0SZheng Fan 297*766ce4d0SZheng Fan OutputDevice* pDev = rUDEvt.GetDevice(); 298*766ce4d0SZheng Fan Rectangle aRect = rUDEvt.GetRect(); 299*766ce4d0SZheng Fan sal_uInt32 nItemId = rUDEvt.GetItemId(); 300*766ce4d0SZheng Fan long nRectWidth = aRect.GetWidth(); 301*766ce4d0SZheng Fan long nRectHeight = aRect.GetHeight(); 302*766ce4d0SZheng Fan Size aRectSize(nRectWidth, aRect.GetHeight()); 303*766ce4d0SZheng Fan Point aBLPos = aRect.TopLeft(); 304*766ce4d0SZheng Fan Font aOldFont = pDev->GetFont(); 305*766ce4d0SZheng Fan Color aOldColor = pDev->GetLineColor(); 306*766ce4d0SZheng Fan pDev->SetLineColor(aBackColor); 307*766ce4d0SZheng Fan Font aFont(OutputDevice::GetDefaultFont( 308*766ce4d0SZheng Fan DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE)); 309*766ce4d0SZheng Fan 310*766ce4d0SZheng Fan Size aSize = aFont.GetSize(); 311*766ce4d0SZheng Fan aSize.Height() = nRectHeight/5; 312*766ce4d0SZheng Fan aFont.SetColor(aTextColor); 313*766ce4d0SZheng Fan aFont.SetFillColor(aBackColor); 314*766ce4d0SZheng Fan aFont.SetSize( aSize ); 315*766ce4d0SZheng Fan pDev->SetFont(aFont); 316*766ce4d0SZheng Fan pDev->SetLineColor(aTextColor); 317*766ce4d0SZheng Fan if(!pVDev) 318*766ce4d0SZheng Fan { 319*766ce4d0SZheng Fan // Die Linien werden nur einmalig in das VirtualDevice gepainted 320*766ce4d0SZheng Fan // nur die Gliederungspage bekommt es aktuell 321*766ce4d0SZheng Fan pVDev = new VirtualDevice(*pDev); 322*766ce4d0SZheng Fan pVDev->SetMapMode(pDev->GetMapMode()); 323*766ce4d0SZheng Fan pVDev->EnableRTL( IsRTLEnabled() ); 324*766ce4d0SZheng Fan pVDev->SetOutputSize( aRectSize ); 325*766ce4d0SZheng Fan aOrgRect = aRect; 326*766ce4d0SZheng Fan 327*766ce4d0SZheng Fan pVDev->SetLineColor( aBackColor ); 328*766ce4d0SZheng Fan pVDev->SetFillColor( aBackColor ); 329*766ce4d0SZheng Fan pVDev->DrawRect(aOrgRect); 330*766ce4d0SZheng Fan 331*766ce4d0SZheng Fan if(aBackColor == aLineColor) 332*766ce4d0SZheng Fan aLineColor.Invert(); 333*766ce4d0SZheng Fan if(GetSettings().GetStyleSettings().GetHighContrastMode()) 334*766ce4d0SZheng Fan pVDev->SetLineColor(aTextColor); 335*766ce4d0SZheng Fan else 336*766ce4d0SZheng Fan pVDev->SetLineColor(aLineColor); 337*766ce4d0SZheng Fan // Linien nur einmalig Zeichnen 338*766ce4d0SZheng Fan Point aStart(aBLPos.X() + nRectWidth *30 / 100,0); 339*766ce4d0SZheng Fan Point aEnd(aBLPos.X() + nRectWidth * 9 / 10,0); 340*766ce4d0SZheng Fan for( sal_uInt32 i = 11; i < 100; i += 33) 341*766ce4d0SZheng Fan { 342*766ce4d0SZheng Fan aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * i / 100; 343*766ce4d0SZheng Fan pVDev->DrawLine(aStart, aEnd); 344*766ce4d0SZheng Fan aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * (i + 11) / 100; 345*766ce4d0SZheng Fan pVDev->DrawLine(aStart, aEnd); 346*766ce4d0SZheng Fan } 347*766ce4d0SZheng Fan } 348*766ce4d0SZheng Fan if ( nItemId != DEFAULT_NONE) 349*766ce4d0SZheng Fan pDev->DrawOutDev( aRect.TopLeft(), aRectSize, 350*766ce4d0SZheng Fan aOrgRect.TopLeft(), aRectSize, 351*766ce4d0SZheng Fan *pVDev ); 352*766ce4d0SZheng Fan const OUString sValue(C2U(cValue)); 353*766ce4d0SZheng Fan 354*766ce4d0SZheng Fan Point aStart(aBLPos.X() + nRectWidth / 9,0); 355*766ce4d0SZheng Fan if ( nItemId == DEFAULT_NONE) 356*766ce4d0SZheng Fan { 357*766ce4d0SZheng Fan String sText(SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE)); 358*766ce4d0SZheng Fan Font aFont = pDev->GetFont(); 359*766ce4d0SZheng Fan Size aSize = aFont.GetSize(); 360*766ce4d0SZheng Fan aSize.Height() = nRectHeight/4; 361*766ce4d0SZheng Fan aFont.SetSize( aSize ); 362*766ce4d0SZheng Fan pDev->SetFont(aFont); 363*766ce4d0SZheng Fan long nTextWidth = pDev->GetTextWidth(sText); 364*766ce4d0SZheng Fan long nTextHeight = pDev->GetTextHeight(); 365*766ce4d0SZheng Fan //GVT refine 366*766ce4d0SZheng Fan while (nTextWidth>nRectWidth && aSize.Height()>4) { 367*766ce4d0SZheng Fan aSize.Height() = aSize.Height()*0.9; 368*766ce4d0SZheng Fan aFont.SetSize( aSize ); 369*766ce4d0SZheng Fan pDev->SetFont(aFont); 370*766ce4d0SZheng Fan nTextWidth = pDev->GetTextWidth(sText); 371*766ce4d0SZheng Fan } 372*766ce4d0SZheng Fan Point aSStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2); 373*766ce4d0SZheng Fan pDev->DrawText(aSStart, sText); 374*766ce4d0SZheng Fan pDev->SetFont(aOldFont); 375*766ce4d0SZheng Fan } 376*766ce4d0SZheng Fan else 377*766ce4d0SZheng Fan { 378*766ce4d0SZheng Fan NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING); 379*766ce4d0SZheng Fan if ( pNumbering && nItemId <= DEFAULT_BULLET_TYPES ) 380*766ce4d0SZheng Fan { 381*766ce4d0SZheng Fan for( sal_uInt32 i = 0; i < 3; i++ ) 382*766ce4d0SZheng Fan { 383*766ce4d0SZheng Fan sal_uInt32 nY = 11 + i * 33; 384*766ce4d0SZheng Fan aStart.Y() = aBLPos.Y() + nRectHeight * nY / 100; 385*766ce4d0SZheng Fan String sText; 386*766ce4d0SZheng Fan sal_uInt16 nLvl = 0; 387*766ce4d0SZheng Fan SvxNumRule aTempRule( 0, 10, false ); 388*766ce4d0SZheng Fan pNumbering->ApplyNumRule(aTempRule,nItemId -1,1<<nLvl); 389*766ce4d0SZheng Fan SvxNumberFormat aNumFmt(aTempRule.GetLevel(nLvl)); 390*766ce4d0SZheng Fan sText=aNumFmt.GetNumStr(i+1); 391*766ce4d0SZheng Fan sText.Insert( aNumFmt.GetPrefix(), 0 ); 392*766ce4d0SZheng Fan sText += aNumFmt.GetSuffix(); 393*766ce4d0SZheng Fan aStart.X() = aBLPos.X() + 2; 394*766ce4d0SZheng Fan aStart.Y() -= pDev->GetTextHeight()/2; 395*766ce4d0SZheng Fan pDev->DrawText(aStart, sText); 396*766ce4d0SZheng Fan } 397*766ce4d0SZheng Fan } 398*766ce4d0SZheng Fan pDev->SetFont(aOldFont); 399*766ce4d0SZheng Fan pDev->SetLineColor(aOldColor); 400*766ce4d0SZheng Fan } 401*766ce4d0SZheng Fan //End 402*766ce4d0SZheng Fan } 403*766ce4d0SZheng Fan 404*766ce4d0SZheng Fan //=============================================================================================== 405*766ce4d0SZheng Fan 406*766ce4d0SZheng Fan static const long aOffsetX[] = 407*766ce4d0SZheng Fan { 408*766ce4d0SZheng Fan -1,//1, 409*766ce4d0SZheng Fan 3,//4, 410*766ce4d0SZheng Fan 4,//5, 411*766ce4d0SZheng Fan -3,//0, 412*766ce4d0SZheng Fan -1,//0, 413*766ce4d0SZheng Fan 3 414*766ce4d0SZheng Fan }; 415*766ce4d0SZheng Fan 416*766ce4d0SZheng Fan SvxNumValueSet3::SvxNumValueSet3( Window* pParent, const ResId& rResId) : 417*766ce4d0SZheng Fan ValueSet( pParent, rResId ) 418*766ce4d0SZheng Fan { 419*766ce4d0SZheng Fan SetColCount( 3 ); 420*766ce4d0SZheng Fan SetLineCount( 4 ); 421*766ce4d0SZheng Fan SetStyle( GetStyle() | WB_ITEMBORDER ); 422*766ce4d0SZheng Fan } 423*766ce4d0SZheng Fan 424*766ce4d0SZheng Fan SvxNumValueSet3::~SvxNumValueSet3() 425*766ce4d0SZheng Fan { 426*766ce4d0SZheng Fan } 427*766ce4d0SZheng Fan 428*766ce4d0SZheng Fan void SvxNumValueSet3::UserDraw( const UserDrawEvent& rUDEvt ) 429*766ce4d0SZheng Fan { 430*766ce4d0SZheng Fan Rectangle aRect = rUDEvt.GetRect(); 431*766ce4d0SZheng Fan OutputDevice* pDev = rUDEvt.GetDevice(); 432*766ce4d0SZheng Fan sal_uInt32 nItemId = rUDEvt.GetItemId(); 433*766ce4d0SZheng Fan 434*766ce4d0SZheng Fan long nRectHeight = aRect.GetHeight(); 435*766ce4d0SZheng Fan long nRectWidth = aRect.GetWidth(); 436*766ce4d0SZheng Fan Point aBLPos = aRect.TopLeft(); 437*766ce4d0SZheng Fan NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS); 438*766ce4d0SZheng Fan if ( pBullets ) 439*766ce4d0SZheng Fan { 440*766ce4d0SZheng Fan if ( nItemId <= DEFAULT_BULLET_TYPES ) { 441*766ce4d0SZheng Fan sal_uInt16 nLvl = 0; 442*766ce4d0SZheng Fan SvxNumRule aTempRule( 0, 10, false ); 443*766ce4d0SZheng Fan pBullets->ApplyNumRule(aTempRule,nItemId -1,1<<nLvl); 444*766ce4d0SZheng Fan SvxNumberFormat aFmt(aTempRule.GetLevel(nLvl)); 445*766ce4d0SZheng Fan sal_Int16 eNumType = aFmt.GetNumberingType(); 446*766ce4d0SZheng Fan if( eNumType == SVX_NUM_CHAR_SPECIAL) 447*766ce4d0SZheng Fan { 448*766ce4d0SZheng Fan sal_Unicode cChar = aFmt.GetBulletChar(); 449*766ce4d0SZheng Fan //End 450*766ce4d0SZheng Fan const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 451*766ce4d0SZheng Fan const Color aBackColor = rStyleSettings.GetFieldColor(); 452*766ce4d0SZheng Fan const Color aTextColor = rStyleSettings.GetFieldTextColor(); 453*766ce4d0SZheng Fan 454*766ce4d0SZheng Fan Font aOldFont = pDev->GetFont(); 455*766ce4d0SZheng Fan Font aFont( lcl_GetDefaultBulletFont() ); 456*766ce4d0SZheng Fan 457*766ce4d0SZheng Fan Size aSize = aFont.GetSize(); 458*766ce4d0SZheng Fan aSize.Height() = nRectHeight*3/6; 459*766ce4d0SZheng Fan aFont.SetColor(aTextColor); 460*766ce4d0SZheng Fan aFont.SetFillColor(aBackColor); 461*766ce4d0SZheng Fan aFont.SetSize( aSize ); 462*766ce4d0SZheng Fan pDev->SetFont(aFont); 463*766ce4d0SZheng Fan pDev->SetFillColor( aBackColor ); //wj 464*766ce4d0SZheng Fan 465*766ce4d0SZheng Fan String sText; 466*766ce4d0SZheng Fan sText = cChar; 467*766ce4d0SZheng Fan Font aOldBulletFont = pDev->GetFont(); 468*766ce4d0SZheng Fan Font aBulletFnt(aFmt.GetBulletFont() ? *aFmt.GetBulletFont() : aOldBulletFont); 469*766ce4d0SZheng Fan Size aBulSize = aOldBulletFont.GetSize(); 470*766ce4d0SZheng Fan aBulletFnt.SetSize(aBulSize); 471*766ce4d0SZheng Fan pDev->SetFont(aBulletFnt); 472*766ce4d0SZheng Fan long nTextWidth = pDev->GetTextWidth(sText); 473*766ce4d0SZheng Fan long nTextHeight = pDev->GetTextHeight(); 474*766ce4d0SZheng Fan Point aStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2); 475*766ce4d0SZheng Fan pDev->DrawText(aStart, sText); 476*766ce4d0SZheng Fan pDev->SetFont(aOldFont); 477*766ce4d0SZheng Fan }else if ( eNumType == SVX_NUM_BITMAP ) 478*766ce4d0SZheng Fan { 479*766ce4d0SZheng Fan const SvxBrushItem* pBrushItem = aFmt.GetBrush(); 480*766ce4d0SZheng Fan if(pBrushItem) 481*766ce4d0SZheng Fan { 482*766ce4d0SZheng Fan const Graphic* pGrf = pBrushItem->GetGraphic(); 483*766ce4d0SZheng Fan if(pGrf) 484*766ce4d0SZheng Fan { 485*766ce4d0SZheng Fan Size aSize(nRectHeight*6/20, nRectHeight*6/20); 486*766ce4d0SZheng Fan Point aStart(aBLPos.X() + nRectWidth*7/20, aBLPos.Y() + nRectHeight*7/20); 487*766ce4d0SZheng Fan 488*766ce4d0SZheng Fan pGrf->Draw( pDev, aStart, aSize ); 489*766ce4d0SZheng Fan } 490*766ce4d0SZheng Fan } 491*766ce4d0SZheng Fan } 492*766ce4d0SZheng Fan }else if ( nItemId == DEFAULT_NONE) 493*766ce4d0SZheng Fan { 494*766ce4d0SZheng Fan const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); 495*766ce4d0SZheng Fan const Color aBackColor = rStyleSettings.GetFieldColor(); 496*766ce4d0SZheng Fan const Color aTextColor = rStyleSettings.GetFieldTextColor(); 497*766ce4d0SZheng Fan 498*766ce4d0SZheng Fan Font aOldFont = pDev->GetFont(); 499*766ce4d0SZheng Fan Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE)); 500*766ce4d0SZheng Fan Size aSize = aFont.GetSize(); 501*766ce4d0SZheng Fan //aSize.Height() = nRectHeight/5; 502*766ce4d0SZheng Fan aSize.Height() = nRectHeight/4; 503*766ce4d0SZheng Fan aFont.SetColor(aTextColor); 504*766ce4d0SZheng Fan aFont.SetFillColor(aBackColor); 505*766ce4d0SZheng Fan aFont.SetSize( aSize ); 506*766ce4d0SZheng Fan pDev->SetFont(aFont); 507*766ce4d0SZheng Fan pDev->SetFillColor( aBackColor ); 508*766ce4d0SZheng Fan 509*766ce4d0SZheng Fan String sText(SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE)); 510*766ce4d0SZheng Fan 511*766ce4d0SZheng Fan long nTextWidth = pDev->GetTextWidth(sText); 512*766ce4d0SZheng Fan long nTextHeight = pDev->GetTextHeight(); 513*766ce4d0SZheng Fan //GVT refine 514*766ce4d0SZheng Fan while (nTextWidth>nRectWidth && aSize.Height()>4) { 515*766ce4d0SZheng Fan aSize.Height() = aSize.Height()*0.9; 516*766ce4d0SZheng Fan aFont.SetSize( aSize ); 517*766ce4d0SZheng Fan pDev->SetFont(aFont); 518*766ce4d0SZheng Fan nTextWidth = pDev->GetTextWidth(sText); 519*766ce4d0SZheng Fan } 520*766ce4d0SZheng Fan Point aStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2); 521*766ce4d0SZheng Fan pDev->DrawText(aStart, sText); 522*766ce4d0SZheng Fan 523*766ce4d0SZheng Fan pDev->SetFont(aOldFont); 524*766ce4d0SZheng Fan } 525*766ce4d0SZheng Fan } 526*766ce4d0SZheng Fan 527*766ce4d0SZheng Fan } 528*766ce4d0SZheng Fan 5292055df08SOliver-Rainer Wittmann } } // end of namespace svx::sidebar 530