1c718a697SOliver-Rainer Wittmann /**************************************************************
2c718a697SOliver-Rainer Wittmann *
3c718a697SOliver-Rainer Wittmann * Licensed to the Apache Software Foundation (ASF) under one
4c718a697SOliver-Rainer Wittmann * or more contributor license agreements. See the NOTICE file
5c718a697SOliver-Rainer Wittmann * distributed with this work for additional information
6c718a697SOliver-Rainer Wittmann * regarding copyright ownership. The ASF licenses this file
7c718a697SOliver-Rainer Wittmann * to you under the Apache License, Version 2.0 (the
8c718a697SOliver-Rainer Wittmann * "License"); you may not use this file except in compliance
9c718a697SOliver-Rainer Wittmann * with the License. You may obtain a copy of the License at
10c718a697SOliver-Rainer Wittmann *
11c718a697SOliver-Rainer Wittmann * http://www.apache.org/licenses/LICENSE-2.0
12c718a697SOliver-Rainer Wittmann *
13c718a697SOliver-Rainer Wittmann * Unless required by applicable law or agreed to in writing,
14c718a697SOliver-Rainer Wittmann * software distributed under the License is distributed on an
15c718a697SOliver-Rainer Wittmann * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16c718a697SOliver-Rainer Wittmann * KIND, either express or implied. See the License for the
17c718a697SOliver-Rainer Wittmann * specific language governing permissions and limitations
18c718a697SOliver-Rainer Wittmann * under the License.
19c718a697SOliver-Rainer Wittmann *
20c718a697SOliver-Rainer Wittmann *************************************************************/
21c718a697SOliver-Rainer Wittmann
22c718a697SOliver-Rainer Wittmann #include "svx/sidebar/ValueSetWithTextControl.hxx"
23766ce4d0SZheng Fan #include <svx/dialogs.hrc>
24766ce4d0SZheng Fan #include <svx/dialmgr.hxx>
252055df08SOliver-Rainer Wittmann #include <sfx2/sidebar/Theme.hxx>
26c718a697SOliver-Rainer Wittmann
27766ce4d0SZheng Fan #include <limits.h>
28766ce4d0SZheng Fan #include <com/sun/star/uno/Reference.h>
29766ce4d0SZheng Fan #include <com/sun/star/uno/Sequence.h>
30766ce4d0SZheng Fan #include <com/sun/star/lang/Locale.hpp>
31766ce4d0SZheng Fan #include <com/sun/star/style/NumberingType.hpp>
32766ce4d0SZheng Fan #include <com/sun/star/lang/XMultiServiceFactory.hpp>
33766ce4d0SZheng Fan #include <com/sun/star/container/XIndexAccess.hpp>
34766ce4d0SZheng Fan #include <com/sun/star/text/XDefaultNumberingProvider.hpp>
35766ce4d0SZheng Fan #include <com/sun/star/text/XNumberingFormatter.hpp>
36766ce4d0SZheng Fan #include <com/sun/star/beans/PropertyValue.hpp>
37766ce4d0SZheng Fan #include <comphelper/processfactory.hxx>
38766ce4d0SZheng Fan #include <com/sun/star/text/XNumberingTypeInfo.hpp>
392055df08SOliver-Rainer Wittmann #include <i18npool/mslangid.hxx>
40766ce4d0SZheng Fan #include <svtools/valueset.hxx>
41766ce4d0SZheng Fan #include <editeng/brshitem.hxx>
42766ce4d0SZheng Fan #include <vcl/graph.hxx>
43766ce4d0SZheng Fan #include <svx/nbdtmg.hxx>
44766ce4d0SZheng Fan #include <svx/nbdtmgfact.hxx>
45766ce4d0SZheng Fan
46766ce4d0SZheng Fan using namespace com::sun::star::uno;
47766ce4d0SZheng Fan using namespace com::sun::star::beans;
48766ce4d0SZheng Fan using namespace com::sun::star::lang;
49766ce4d0SZheng Fan using namespace com::sun::star::i18n;
50766ce4d0SZheng Fan using namespace com::sun::star::text;
51766ce4d0SZheng Fan using namespace com::sun::star::container;
52766ce4d0SZheng Fan using namespace com::sun::star::style;
53766ce4d0SZheng Fan using rtl::OUString;
54766ce4d0SZheng Fan
55766ce4d0SZheng Fan #define C2U(cChar) OUString::createFromAscii(cChar)
56c718a697SOliver-Rainer Wittmann
57c718a697SOliver-Rainer Wittmann namespace svx { namespace sidebar {
58766ce4d0SZheng Fan static const sal_Char cValue[] = "Value";
59766ce4d0SZheng Fan
lcl_GetDefaultBulletFont()60766ce4d0SZheng Fan static Font& lcl_GetDefaultBulletFont()
61766ce4d0SZheng Fan {
62766ce4d0SZheng Fan static sal_Bool bInit = 0;
63766ce4d0SZheng Fan static Font aDefBulletFont( UniString::CreateFromAscii(
64766ce4d0SZheng Fan RTL_CONSTASCII_STRINGPARAM( "StarSymbol" ) ),
65766ce4d0SZheng Fan String(), Size( 0, 14 ) );
66766ce4d0SZheng Fan if(!bInit)
67766ce4d0SZheng Fan {
68766ce4d0SZheng Fan aDefBulletFont.SetCharSet( RTL_TEXTENCODING_SYMBOL );
69766ce4d0SZheng Fan aDefBulletFont.SetFamily( FAMILY_DONTKNOW );
70766ce4d0SZheng Fan aDefBulletFont.SetPitch( PITCH_DONTKNOW );
71766ce4d0SZheng Fan aDefBulletFont.SetWeight( WEIGHT_DONTKNOW );
72766ce4d0SZheng Fan aDefBulletFont.SetTransparent( sal_True );
73766ce4d0SZheng Fan bInit = sal_True;
74766ce4d0SZheng Fan }
75766ce4d0SZheng Fan return aDefBulletFont;
76766ce4d0SZheng Fan }
77c718a697SOliver-Rainer Wittmann
ValueSetWithTextControl(const tControlType eControlType,Window * pParent,const ResId & rResId)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
~ValueSetWithTextControl(void)902055df08SOliver-Rainer Wittmann ValueSetWithTextControl::~ValueSetWithTextControl(void)
912055df08SOliver-Rainer Wittmann {
922055df08SOliver-Rainer Wittmann }
932055df08SOliver-Rainer Wittmann
94ccdbcfa9SOliver-Rainer Wittmann
AddItem(const Image & rItemImage,const Image * pSelectedItemImage,const XubString & rItemText,const XubString * pItemHelpText)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
AddItem(const XubString & rItemText,const XubString & rItemText2,const XubString * pItemHelpText)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
ReplaceItemImages(const sal_uInt16 nItemId,const Image & rItemImage,const Image * pSelectedItemImage)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
UserDraw(const UserDrawEvent & rUDEvt)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 }
182da72173fSAndre Fischer
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 }
248c718a697SOliver-Rainer Wittmann
SvxNumValueSet2(Window * pParent,const ResId & rResId)249766ce4d0SZheng Fan SvxNumValueSet2::SvxNumValueSet2( Window* pParent, const ResId& rResId) :
250766ce4d0SZheng Fan ValueSet( pParent, rResId ),
251766ce4d0SZheng Fan aLineColor ( COL_LIGHTGRAY ),
252766ce4d0SZheng Fan pVDev ( NULL )
253766ce4d0SZheng Fan {
254766ce4d0SZheng Fan SetColCount( 3 );
255766ce4d0SZheng Fan SetLineCount( 3 );
256766ce4d0SZheng Fan SetStyle( GetStyle() | WB_ITEMBORDER );
257766ce4d0SZheng Fan }
258766ce4d0SZheng Fan
~SvxNumValueSet2()259766ce4d0SZheng Fan SvxNumValueSet2::~SvxNumValueSet2()
260766ce4d0SZheng Fan {
261766ce4d0SZheng Fan delete pVDev;
262766ce4d0SZheng Fan }
263766ce4d0SZheng Fan
SetNumberingSettings(const Sequence<Sequence<PropertyValue>> & aNum,Reference<XNumberingFormatter> & xFormat,const Locale & rLocale)264766ce4d0SZheng Fan void SvxNumValueSet2::SetNumberingSettings(
265766ce4d0SZheng Fan const Sequence<Sequence<PropertyValue> >& aNum,
266766ce4d0SZheng Fan Reference<XNumberingFormatter>& xFormat,
267766ce4d0SZheng Fan const Locale& rLocale )
268766ce4d0SZheng Fan {
269766ce4d0SZheng Fan aNumSettings = aNum;
270766ce4d0SZheng Fan xFormatter = xFormat;
271766ce4d0SZheng Fan aLocale = rLocale;
272766ce4d0SZheng Fan if(aNum.getLength() > 9)
273766ce4d0SZheng Fan SetStyle( GetStyle()|WB_VSCROLL);
274766ce4d0SZheng Fan InsertItem( DEFAULT_NONE, DEFAULT_NONE - 1 );
275766ce4d0SZheng Fan SetItemText( DEFAULT_NONE, SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE ));
276766ce4d0SZheng Fan
277*2684b347SPavel Janík for ( sal_Int32 i = 0; i < aNum.getLength(); i++ )
278766ce4d0SZheng Fan {
279766ce4d0SZheng Fan InsertItem( i + 1);
280766ce4d0SZheng Fan if( i < 8 )
281766ce4d0SZheng Fan {
282766ce4d0SZheng Fan NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
283766ce4d0SZheng Fan if ( pNumbering )
284766ce4d0SZheng Fan {
285766ce4d0SZheng Fan SetItemText( i + 1, pNumbering->GetDescription(i));
286766ce4d0SZheng Fan }
287766ce4d0SZheng Fan }
288766ce4d0SZheng Fan }
289766ce4d0SZheng Fan }
290766ce4d0SZheng Fan
UserDraw(const UserDrawEvent & rUDEvt)291766ce4d0SZheng Fan void SvxNumValueSet2::UserDraw( const UserDrawEvent& rUDEvt )
292766ce4d0SZheng Fan {
293766ce4d0SZheng Fan const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
294766ce4d0SZheng Fan const Color aBackColor = rStyleSettings.GetFieldColor();
295766ce4d0SZheng Fan const Color aTextColor = rStyleSettings.GetFieldTextColor();
296766ce4d0SZheng Fan
297766ce4d0SZheng Fan OutputDevice* pDev = rUDEvt.GetDevice();
298766ce4d0SZheng Fan Rectangle aRect = rUDEvt.GetRect();
299766ce4d0SZheng Fan sal_uInt32 nItemId = rUDEvt.GetItemId();
300766ce4d0SZheng Fan long nRectWidth = aRect.GetWidth();
301766ce4d0SZheng Fan long nRectHeight = aRect.GetHeight();
302766ce4d0SZheng Fan Size aRectSize(nRectWidth, aRect.GetHeight());
303766ce4d0SZheng Fan Point aBLPos = aRect.TopLeft();
304766ce4d0SZheng Fan Font aOldFont = pDev->GetFont();
305766ce4d0SZheng Fan Color aOldColor = pDev->GetLineColor();
306766ce4d0SZheng Fan pDev->SetLineColor(aBackColor);
307766ce4d0SZheng Fan Font aFont(OutputDevice::GetDefaultFont(
308766ce4d0SZheng Fan DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
309766ce4d0SZheng Fan
310766ce4d0SZheng Fan Size aSize = aFont.GetSize();
311766ce4d0SZheng Fan aSize.Height() = nRectHeight/5;
312766ce4d0SZheng Fan aFont.SetColor(aTextColor);
313766ce4d0SZheng Fan aFont.SetFillColor(aBackColor);
314766ce4d0SZheng Fan aFont.SetSize( aSize );
315766ce4d0SZheng Fan pDev->SetFont(aFont);
316766ce4d0SZheng Fan pDev->SetLineColor(aTextColor);
317766ce4d0SZheng Fan if(!pVDev)
318766ce4d0SZheng Fan {
319766ce4d0SZheng Fan // Die Linien werden nur einmalig in das VirtualDevice gepainted
320766ce4d0SZheng Fan // nur die Gliederungspage bekommt es aktuell
321766ce4d0SZheng Fan pVDev = new VirtualDevice(*pDev);
322766ce4d0SZheng Fan pVDev->SetMapMode(pDev->GetMapMode());
323766ce4d0SZheng Fan pVDev->EnableRTL( IsRTLEnabled() );
324766ce4d0SZheng Fan pVDev->SetOutputSize( aRectSize );
325766ce4d0SZheng Fan aOrgRect = aRect;
326766ce4d0SZheng Fan
327766ce4d0SZheng Fan pVDev->SetLineColor( aBackColor );
328766ce4d0SZheng Fan pVDev->SetFillColor( aBackColor );
329766ce4d0SZheng Fan pVDev->DrawRect(aOrgRect);
330766ce4d0SZheng Fan
331766ce4d0SZheng Fan if(aBackColor == aLineColor)
332766ce4d0SZheng Fan aLineColor.Invert();
333766ce4d0SZheng Fan if(GetSettings().GetStyleSettings().GetHighContrastMode())
334766ce4d0SZheng Fan pVDev->SetLineColor(aTextColor);
335766ce4d0SZheng Fan else
336766ce4d0SZheng Fan pVDev->SetLineColor(aLineColor);
337766ce4d0SZheng Fan // Linien nur einmalig Zeichnen
338766ce4d0SZheng Fan Point aStart(aBLPos.X() + nRectWidth *30 / 100,0);
339766ce4d0SZheng Fan Point aEnd(aBLPos.X() + nRectWidth * 9 / 10,0);
340766ce4d0SZheng Fan for( sal_uInt32 i = 11; i < 100; i += 33)
341766ce4d0SZheng Fan {
342766ce4d0SZheng Fan aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * i / 100;
343766ce4d0SZheng Fan pVDev->DrawLine(aStart, aEnd);
344766ce4d0SZheng Fan aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * (i + 11) / 100;
345766ce4d0SZheng Fan pVDev->DrawLine(aStart, aEnd);
346766ce4d0SZheng Fan }
347766ce4d0SZheng Fan }
348766ce4d0SZheng Fan if ( nItemId != DEFAULT_NONE)
349766ce4d0SZheng Fan pDev->DrawOutDev( aRect.TopLeft(), aRectSize,
350766ce4d0SZheng Fan aOrgRect.TopLeft(), aRectSize,
351766ce4d0SZheng Fan *pVDev );
352766ce4d0SZheng Fan const OUString sValue(C2U(cValue));
353766ce4d0SZheng Fan
354766ce4d0SZheng Fan Point aStart(aBLPos.X() + nRectWidth / 9,0);
355766ce4d0SZheng Fan if ( nItemId == DEFAULT_NONE)
356766ce4d0SZheng Fan {
357766ce4d0SZheng Fan String sText(SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE));
358766ce4d0SZheng Fan Font aFont = pDev->GetFont();
359766ce4d0SZheng Fan Size aSize = aFont.GetSize();
360766ce4d0SZheng Fan aSize.Height() = nRectHeight/4;
361766ce4d0SZheng Fan aFont.SetSize( aSize );
362766ce4d0SZheng Fan pDev->SetFont(aFont);
363766ce4d0SZheng Fan long nTextWidth = pDev->GetTextWidth(sText);
364766ce4d0SZheng Fan long nTextHeight = pDev->GetTextHeight();
365766ce4d0SZheng Fan //GVT refine
366766ce4d0SZheng Fan while (nTextWidth>nRectWidth && aSize.Height()>4) {
367766ce4d0SZheng Fan aSize.Height() = aSize.Height()*0.9;
368766ce4d0SZheng Fan aFont.SetSize( aSize );
369766ce4d0SZheng Fan pDev->SetFont(aFont);
370766ce4d0SZheng Fan nTextWidth = pDev->GetTextWidth(sText);
371766ce4d0SZheng Fan }
372766ce4d0SZheng Fan Point aSStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2);
373766ce4d0SZheng Fan pDev->DrawText(aSStart, sText);
374766ce4d0SZheng Fan pDev->SetFont(aOldFont);
375766ce4d0SZheng Fan }
376766ce4d0SZheng Fan else
377766ce4d0SZheng Fan {
378766ce4d0SZheng Fan NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
379766ce4d0SZheng Fan if ( pNumbering && nItemId <= DEFAULT_BULLET_TYPES )
380766ce4d0SZheng Fan {
381766ce4d0SZheng Fan for( sal_uInt32 i = 0; i < 3; i++ )
382766ce4d0SZheng Fan {
383766ce4d0SZheng Fan sal_uInt32 nY = 11 + i * 33;
384766ce4d0SZheng Fan aStart.Y() = aBLPos.Y() + nRectHeight * nY / 100;
385766ce4d0SZheng Fan String sText;
386766ce4d0SZheng Fan sal_uInt16 nLvl = 0;
387766ce4d0SZheng Fan SvxNumRule aTempRule( 0, 10, false );
388766ce4d0SZheng Fan pNumbering->ApplyNumRule(aTempRule,nItemId -1,1<<nLvl);
389766ce4d0SZheng Fan SvxNumberFormat aNumFmt(aTempRule.GetLevel(nLvl));
390766ce4d0SZheng Fan sText=aNumFmt.GetNumStr(i+1);
391766ce4d0SZheng Fan sText.Insert( aNumFmt.GetPrefix(), 0 );
392766ce4d0SZheng Fan sText += aNumFmt.GetSuffix();
393766ce4d0SZheng Fan aStart.X() = aBLPos.X() + 2;
394766ce4d0SZheng Fan aStart.Y() -= pDev->GetTextHeight()/2;
395766ce4d0SZheng Fan pDev->DrawText(aStart, sText);
396766ce4d0SZheng Fan }
397766ce4d0SZheng Fan }
398766ce4d0SZheng Fan pDev->SetFont(aOldFont);
399766ce4d0SZheng Fan pDev->SetLineColor(aOldColor);
400766ce4d0SZheng Fan }
401766ce4d0SZheng Fan //End
402766ce4d0SZheng Fan }
403766ce4d0SZheng Fan
404766ce4d0SZheng Fan //===============================================================================================
405766ce4d0SZheng Fan
SvxNumValueSet3(Window * pParent,const ResId & rResId)406766ce4d0SZheng Fan SvxNumValueSet3::SvxNumValueSet3( Window* pParent, const ResId& rResId) :
407766ce4d0SZheng Fan ValueSet( pParent, rResId )
408766ce4d0SZheng Fan {
409766ce4d0SZheng Fan SetColCount( 3 );
410766ce4d0SZheng Fan SetLineCount( 4 );
411766ce4d0SZheng Fan SetStyle( GetStyle() | WB_ITEMBORDER );
412766ce4d0SZheng Fan }
413766ce4d0SZheng Fan
~SvxNumValueSet3()414766ce4d0SZheng Fan SvxNumValueSet3::~SvxNumValueSet3()
415766ce4d0SZheng Fan {
416766ce4d0SZheng Fan }
417766ce4d0SZheng Fan
UserDraw(const UserDrawEvent & rUDEvt)418766ce4d0SZheng Fan void SvxNumValueSet3::UserDraw( const UserDrawEvent& rUDEvt )
419766ce4d0SZheng Fan {
420766ce4d0SZheng Fan Rectangle aRect = rUDEvt.GetRect();
421766ce4d0SZheng Fan OutputDevice* pDev = rUDEvt.GetDevice();
422766ce4d0SZheng Fan sal_uInt32 nItemId = rUDEvt.GetItemId();
423766ce4d0SZheng Fan
424766ce4d0SZheng Fan long nRectHeight = aRect.GetHeight();
425766ce4d0SZheng Fan long nRectWidth = aRect.GetWidth();
426766ce4d0SZheng Fan Point aBLPos = aRect.TopLeft();
427766ce4d0SZheng Fan NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
428766ce4d0SZheng Fan if ( pBullets )
429766ce4d0SZheng Fan {
430766ce4d0SZheng Fan if ( nItemId <= DEFAULT_BULLET_TYPES ) {
431766ce4d0SZheng Fan sal_uInt16 nLvl = 0;
432766ce4d0SZheng Fan SvxNumRule aTempRule( 0, 10, false );
433766ce4d0SZheng Fan pBullets->ApplyNumRule(aTempRule,nItemId -1,1<<nLvl);
434766ce4d0SZheng Fan SvxNumberFormat aFmt(aTempRule.GetLevel(nLvl));
435766ce4d0SZheng Fan sal_Int16 eNumType = aFmt.GetNumberingType();
436766ce4d0SZheng Fan if( eNumType == SVX_NUM_CHAR_SPECIAL)
437766ce4d0SZheng Fan {
438766ce4d0SZheng Fan sal_Unicode cChar = aFmt.GetBulletChar();
439766ce4d0SZheng Fan //End
440766ce4d0SZheng Fan const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
441766ce4d0SZheng Fan const Color aBackColor = rStyleSettings.GetFieldColor();
442766ce4d0SZheng Fan const Color aTextColor = rStyleSettings.GetFieldTextColor();
443766ce4d0SZheng Fan
444766ce4d0SZheng Fan Font aOldFont = pDev->GetFont();
445766ce4d0SZheng Fan Font aFont( lcl_GetDefaultBulletFont() );
446766ce4d0SZheng Fan
447766ce4d0SZheng Fan Size aSize = aFont.GetSize();
448766ce4d0SZheng Fan aSize.Height() = nRectHeight*3/6;
449766ce4d0SZheng Fan aFont.SetColor(aTextColor);
450766ce4d0SZheng Fan aFont.SetFillColor(aBackColor);
451766ce4d0SZheng Fan aFont.SetSize( aSize );
452766ce4d0SZheng Fan pDev->SetFont(aFont);
453766ce4d0SZheng Fan pDev->SetFillColor( aBackColor ); //wj
454766ce4d0SZheng Fan
455766ce4d0SZheng Fan String sText;
456766ce4d0SZheng Fan sText = cChar;
457766ce4d0SZheng Fan Font aOldBulletFont = pDev->GetFont();
458766ce4d0SZheng Fan Font aBulletFnt(aFmt.GetBulletFont() ? *aFmt.GetBulletFont() : aOldBulletFont);
459766ce4d0SZheng Fan Size aBulSize = aOldBulletFont.GetSize();
460766ce4d0SZheng Fan aBulletFnt.SetSize(aBulSize);
461766ce4d0SZheng Fan pDev->SetFont(aBulletFnt);
462766ce4d0SZheng Fan long nTextWidth = pDev->GetTextWidth(sText);
463766ce4d0SZheng Fan long nTextHeight = pDev->GetTextHeight();
464766ce4d0SZheng Fan Point aStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2);
465766ce4d0SZheng Fan pDev->DrawText(aStart, sText);
466766ce4d0SZheng Fan pDev->SetFont(aOldFont);
467766ce4d0SZheng Fan }else if ( eNumType == SVX_NUM_BITMAP )
468766ce4d0SZheng Fan {
469766ce4d0SZheng Fan const SvxBrushItem* pBrushItem = aFmt.GetBrush();
470766ce4d0SZheng Fan if(pBrushItem)
471766ce4d0SZheng Fan {
472766ce4d0SZheng Fan const Graphic* pGrf = pBrushItem->GetGraphic();
473766ce4d0SZheng Fan if(pGrf)
474766ce4d0SZheng Fan {
475766ce4d0SZheng Fan Size aSize(nRectHeight*6/20, nRectHeight*6/20);
476766ce4d0SZheng Fan Point aStart(aBLPos.X() + nRectWidth*7/20, aBLPos.Y() + nRectHeight*7/20);
477766ce4d0SZheng Fan
478766ce4d0SZheng Fan pGrf->Draw( pDev, aStart, aSize );
479766ce4d0SZheng Fan }
480766ce4d0SZheng Fan }
481766ce4d0SZheng Fan }
482766ce4d0SZheng Fan }else if ( nItemId == DEFAULT_NONE)
483766ce4d0SZheng Fan {
484766ce4d0SZheng Fan const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
485766ce4d0SZheng Fan const Color aBackColor = rStyleSettings.GetFieldColor();
486766ce4d0SZheng Fan const Color aTextColor = rStyleSettings.GetFieldTextColor();
487766ce4d0SZheng Fan
488766ce4d0SZheng Fan Font aOldFont = pDev->GetFont();
489766ce4d0SZheng Fan Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
490766ce4d0SZheng Fan Size aSize = aFont.GetSize();
491766ce4d0SZheng Fan //aSize.Height() = nRectHeight/5;
492766ce4d0SZheng Fan aSize.Height() = nRectHeight/4;
493766ce4d0SZheng Fan aFont.SetColor(aTextColor);
494766ce4d0SZheng Fan aFont.SetFillColor(aBackColor);
495766ce4d0SZheng Fan aFont.SetSize( aSize );
496766ce4d0SZheng Fan pDev->SetFont(aFont);
497766ce4d0SZheng Fan pDev->SetFillColor( aBackColor );
498766ce4d0SZheng Fan
499766ce4d0SZheng Fan String sText(SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE));
500766ce4d0SZheng Fan
501766ce4d0SZheng Fan long nTextWidth = pDev->GetTextWidth(sText);
502766ce4d0SZheng Fan long nTextHeight = pDev->GetTextHeight();
503766ce4d0SZheng Fan //GVT refine
504766ce4d0SZheng Fan while (nTextWidth>nRectWidth && aSize.Height()>4) {
505766ce4d0SZheng Fan aSize.Height() = aSize.Height()*0.9;
506766ce4d0SZheng Fan aFont.SetSize( aSize );
507766ce4d0SZheng Fan pDev->SetFont(aFont);
508766ce4d0SZheng Fan nTextWidth = pDev->GetTextWidth(sText);
509766ce4d0SZheng Fan }
510766ce4d0SZheng Fan Point aStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2);
511766ce4d0SZheng Fan pDev->DrawText(aStart, sText);
512766ce4d0SZheng Fan
513766ce4d0SZheng Fan pDev->SetFont(aOldFont);
514766ce4d0SZheng Fan }
515766ce4d0SZheng Fan }
516766ce4d0SZheng Fan
517766ce4d0SZheng Fan }
518766ce4d0SZheng Fan
519c718a697SOliver-Rainer Wittmann } } // end of namespace svx::sidebar
520