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"
23766ce4d0SZheng Fan #include <svx/dialogs.hrc>
24766ce4d0SZheng Fan #include <svx/dialmgr.hxx>
252055df08SOliver-Rainer Wittmann #include <sfx2/sidebar/Theme.hxx>
262055df08SOliver-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)
562055df08SOliver-Rainer Wittmann
572055df08SOliver-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 }
772055df08SOliver-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
~ValueSetWithTextControl(void)892055df08SOliver-Rainer Wittmann ValueSetWithTextControl::~ValueSetWithTextControl(void)
902055df08SOliver-Rainer Wittmann {
912055df08SOliver-Rainer Wittmann }
922055df08SOliver-Rainer Wittmann
AddItem(const Image & rItemImage,const Image * pSelectedItemImage,const XubString & rItemText,const XubString * pItemHelpText)932055df08SOliver-Rainer Wittmann void ValueSetWithTextControl::AddItem(
942055df08SOliver-Rainer Wittmann const Image& rItemImage,
952055df08SOliver-Rainer Wittmann const Image* pSelectedItemImage,
962055df08SOliver-Rainer Wittmann const XubString& rItemText,
972055df08SOliver-Rainer Wittmann const XubString* pItemHelpText )
982055df08SOliver-Rainer Wittmann {
992055df08SOliver-Rainer Wittmann if ( meControlType != IMAGE_TEXT )
1002055df08SOliver-Rainer Wittmann {
1012055df08SOliver-Rainer Wittmann return;
1022055df08SOliver-Rainer Wittmann }
1032055df08SOliver-Rainer Wittmann
1042055df08SOliver-Rainer Wittmann ValueSetWithTextItem aItem;
1052055df08SOliver-Rainer Wittmann aItem.maItemImage = rItemImage;
1062055df08SOliver-Rainer Wittmann aItem.maSelectedItemImage = (pSelectedItemImage != 0)
1072055df08SOliver-Rainer Wittmann ? *pSelectedItemImage
1082055df08SOliver-Rainer Wittmann : rItemImage;
1092055df08SOliver-Rainer Wittmann aItem.maItemText = rItemText;
1102055df08SOliver-Rainer Wittmann
1112055df08SOliver-Rainer Wittmann maItems.push_back( aItem );
1122055df08SOliver-Rainer Wittmann
1132055df08SOliver-Rainer Wittmann InsertItem( maItems.size() );
1142055df08SOliver-Rainer Wittmann SetItemText( maItems.size(),
1152055df08SOliver-Rainer Wittmann (pItemHelpText != 0) ? *pItemHelpText : rItemText );
1162055df08SOliver-Rainer Wittmann }
1172055df08SOliver-Rainer Wittmann
118ccdbcfa9SOliver-Rainer Wittmann
AddItem(const XubString & rItemText,const XubString & rItemText2,const XubString * pItemHelpText)1192055df08SOliver-Rainer Wittmann void ValueSetWithTextControl::AddItem(
1202055df08SOliver-Rainer Wittmann const XubString& rItemText,
1212055df08SOliver-Rainer Wittmann const XubString& rItemText2,
1222055df08SOliver-Rainer Wittmann const XubString* pItemHelpText )
1232055df08SOliver-Rainer Wittmann {
1242055df08SOliver-Rainer Wittmann if ( meControlType != TEXT_TEXT )
1252055df08SOliver-Rainer Wittmann {
1262055df08SOliver-Rainer Wittmann return;
1272055df08SOliver-Rainer Wittmann }
1282055df08SOliver-Rainer Wittmann
1292055df08SOliver-Rainer Wittmann ValueSetWithTextItem aItem;
1302055df08SOliver-Rainer Wittmann aItem.maItemText = rItemText;
1312055df08SOliver-Rainer Wittmann aItem.maItemText2 = rItemText2;
1322055df08SOliver-Rainer Wittmann
1332055df08SOliver-Rainer Wittmann maItems.push_back( aItem );
1342055df08SOliver-Rainer Wittmann
1352055df08SOliver-Rainer Wittmann InsertItem( maItems.size() );
1362055df08SOliver-Rainer Wittmann SetItemText( maItems.size(),
1372055df08SOliver-Rainer Wittmann (pItemHelpText != 0) ? *pItemHelpText : rItemText );
1382055df08SOliver-Rainer Wittmann }
1392055df08SOliver-Rainer Wittmann
140ccdbcfa9SOliver-Rainer Wittmann
ReplaceItemImages(const sal_uInt16 nItemId,const Image & rItemImage,const Image * pSelectedItemImage)141ccdbcfa9SOliver-Rainer Wittmann void ValueSetWithTextControl::ReplaceItemImages(
142ccdbcfa9SOliver-Rainer Wittmann const sal_uInt16 nItemId,
143ccdbcfa9SOliver-Rainer Wittmann const Image& rItemImage,
144ccdbcfa9SOliver-Rainer Wittmann const Image* pSelectedItemImage )
145ccdbcfa9SOliver-Rainer Wittmann {
146ccdbcfa9SOliver-Rainer Wittmann if ( meControlType != IMAGE_TEXT )
147ccdbcfa9SOliver-Rainer Wittmann {
148ccdbcfa9SOliver-Rainer Wittmann return;
149ccdbcfa9SOliver-Rainer Wittmann }
150ccdbcfa9SOliver-Rainer Wittmann
151ccdbcfa9SOliver-Rainer Wittmann if ( nItemId == 0 ||
152ccdbcfa9SOliver-Rainer Wittmann nItemId > maItems.size() )
153ccdbcfa9SOliver-Rainer Wittmann {
154ccdbcfa9SOliver-Rainer Wittmann return;
155ccdbcfa9SOliver-Rainer Wittmann }
156ccdbcfa9SOliver-Rainer Wittmann
157ccdbcfa9SOliver-Rainer Wittmann maItems[nItemId-1].maItemImage = rItemImage;
158ccdbcfa9SOliver-Rainer Wittmann maItems[nItemId-1].maSelectedItemImage = (pSelectedItemImage != 0)
159ccdbcfa9SOliver-Rainer Wittmann ? *pSelectedItemImage
160ccdbcfa9SOliver-Rainer Wittmann : rItemImage;
161ccdbcfa9SOliver-Rainer Wittmann }
162ccdbcfa9SOliver-Rainer Wittmann
163ccdbcfa9SOliver-Rainer Wittmann
UserDraw(const UserDrawEvent & rUDEvt)1642055df08SOliver-Rainer Wittmann void ValueSetWithTextControl::UserDraw( const UserDrawEvent& rUDEvt )
1652055df08SOliver-Rainer Wittmann {
1662055df08SOliver-Rainer Wittmann const Rectangle aRect = rUDEvt.GetRect();
1672055df08SOliver-Rainer Wittmann OutputDevice* pDev = rUDEvt.GetDevice();
1682055df08SOliver-Rainer Wittmann pDev->Push( PUSH_ALL );
1692055df08SOliver-Rainer Wittmann const sal_uInt16 nItemId = rUDEvt.GetItemId();
1702055df08SOliver-Rainer Wittmann
1712055df08SOliver-Rainer Wittmann const long nRectHeight = aRect.GetHeight();
1722055df08SOliver-Rainer Wittmann const Point aBLPos = aRect.TopLeft();
1732055df08SOliver-Rainer Wittmann
1742055df08SOliver-Rainer Wittmann Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
1752055df08SOliver-Rainer Wittmann {
1762055df08SOliver-Rainer Wittmann Size aSize = aFont.GetSize();
1772055df08SOliver-Rainer Wittmann aSize.Height() = (nRectHeight*4)/9;
1782055df08SOliver-Rainer Wittmann aFont.SetSize( aSize );
1792055df08SOliver-Rainer Wittmann }
1802055df08SOliver-Rainer Wittmann
1812055df08SOliver-Rainer Wittmann {
182*7658c399Smseidel // draw background
1832055df08SOliver-Rainer Wittmann if ( GetSelectItemId() == nItemId )
1842055df08SOliver-Rainer Wittmann {
1852055df08SOliver-Rainer Wittmann Rectangle aBackRect = aRect;
1862055df08SOliver-Rainer Wittmann aBackRect.Top() += 3;
1872055df08SOliver-Rainer Wittmann aBackRect.Bottom() -= 2;
1882055df08SOliver-Rainer Wittmann pDev->SetFillColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_Highlight ) );
1892055df08SOliver-Rainer Wittmann pDev->DrawRect(aBackRect);
1902055df08SOliver-Rainer Wittmann }
1912055df08SOliver-Rainer Wittmann else
1922055df08SOliver-Rainer Wittmann {
1932055df08SOliver-Rainer Wittmann pDev->SetFillColor( COL_TRANSPARENT );
1942055df08SOliver-Rainer Wittmann pDev->DrawRect(aRect);
1952055df08SOliver-Rainer Wittmann }
1962055df08SOliver-Rainer Wittmann
1972055df08SOliver-Rainer Wittmann // draw image + text resp. text + text
1982055df08SOliver-Rainer Wittmann Image* pImage = 0;
1992055df08SOliver-Rainer Wittmann if ( GetSelectItemId() == nItemId )
2002055df08SOliver-Rainer Wittmann {
2012055df08SOliver-Rainer Wittmann aFont.SetColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_HighlightText ) );
2022055df08SOliver-Rainer Wittmann pImage = &maItems[nItemId-1].maSelectedItemImage;
2032055df08SOliver-Rainer Wittmann }
2042055df08SOliver-Rainer Wittmann else
2052055df08SOliver-Rainer Wittmann {
2062055df08SOliver-Rainer Wittmann aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() );
2072055df08SOliver-Rainer Wittmann pImage = &maItems[nItemId-1].maItemImage;
2082055df08SOliver-Rainer Wittmann }
2092055df08SOliver-Rainer Wittmann
2102055df08SOliver-Rainer Wittmann Rectangle aStrRect = aRect;
2112055df08SOliver-Rainer Wittmann aStrRect.Top() += nRectHeight/4;
2122055df08SOliver-Rainer Wittmann aStrRect.Bottom() -= nRectHeight/4;
2132055df08SOliver-Rainer Wittmann
2142055df08SOliver-Rainer Wittmann switch ( meControlType )
2152055df08SOliver-Rainer Wittmann {
2162055df08SOliver-Rainer Wittmann case IMAGE_TEXT:
2172055df08SOliver-Rainer Wittmann {
2182055df08SOliver-Rainer Wittmann Point aImgStart(
2192055df08SOliver-Rainer Wittmann aBLPos.X() + 4,
2202055df08SOliver-Rainer Wittmann aBLPos.Y() + ( ( nRectHeight - pImage->GetSizePixel().Height() ) / 2 ) );
2212055df08SOliver-Rainer Wittmann pDev->DrawImage( aImgStart, *pImage );
2222055df08SOliver-Rainer Wittmann
2232055df08SOliver-Rainer Wittmann aStrRect.Left() += pImage->GetSizePixel().Width() + 12;
2242055df08SOliver-Rainer Wittmann pDev->SetFont(aFont);
2252055df08SOliver-Rainer Wittmann pDev->DrawText(aStrRect, maItems[nItemId-1].maItemText, TEXT_DRAW_ENDELLIPSIS);
2262055df08SOliver-Rainer Wittmann }
2272055df08SOliver-Rainer Wittmann break;
2282055df08SOliver-Rainer Wittmann case TEXT_TEXT:
2292055df08SOliver-Rainer Wittmann {
2302055df08SOliver-Rainer Wittmann const long nRectWidth = aRect.GetWidth();
2312055df08SOliver-Rainer Wittmann aStrRect.Left() += 8;
2322055df08SOliver-Rainer Wittmann aStrRect.Right() -= (nRectWidth*2)/3;
2332055df08SOliver-Rainer Wittmann pDev->SetFont(aFont);
2342055df08SOliver-Rainer Wittmann pDev->DrawText(aStrRect, maItems[nItemId-1].maItemText, TEXT_DRAW_ENDELLIPSIS);
2352055df08SOliver-Rainer Wittmann aStrRect.Left() += nRectWidth/3;
2362055df08SOliver-Rainer Wittmann aStrRect.Right() += (nRectWidth*2)/3;
2372055df08SOliver-Rainer Wittmann pDev->DrawText(aStrRect, maItems[nItemId-1].maItemText2, TEXT_DRAW_ENDELLIPSIS);
2382055df08SOliver-Rainer Wittmann }
2392055df08SOliver-Rainer Wittmann break;
2402055df08SOliver-Rainer Wittmann }
2412055df08SOliver-Rainer Wittmann }
2422055df08SOliver-Rainer Wittmann
2432055df08SOliver-Rainer Wittmann Invalidate( aRect );
2442055df08SOliver-Rainer Wittmann pDev->Pop();
2452055df08SOliver-Rainer Wittmann }
2462055df08SOliver-Rainer Wittmann
SvxNumValueSet2(Window * pParent,const ResId & rResId)247766ce4d0SZheng Fan SvxNumValueSet2::SvxNumValueSet2( Window* pParent, const ResId& rResId) :
248766ce4d0SZheng Fan ValueSet( pParent, rResId ),
249766ce4d0SZheng Fan aLineColor ( COL_LIGHTGRAY ),
250766ce4d0SZheng Fan pVDev ( NULL )
251766ce4d0SZheng Fan {
252766ce4d0SZheng Fan SetColCount( 3 );
253766ce4d0SZheng Fan SetLineCount( 3 );
254766ce4d0SZheng Fan SetStyle( GetStyle() | WB_ITEMBORDER );
255766ce4d0SZheng Fan }
256766ce4d0SZheng Fan
~SvxNumValueSet2()257766ce4d0SZheng Fan SvxNumValueSet2::~SvxNumValueSet2()
258766ce4d0SZheng Fan {
259766ce4d0SZheng Fan delete pVDev;
260766ce4d0SZheng Fan }
261766ce4d0SZheng Fan
SetNumberingSettings(const Sequence<Sequence<PropertyValue>> & aNum,Reference<XNumberingFormatter> & xFormat,const Locale & rLocale)262766ce4d0SZheng Fan void SvxNumValueSet2::SetNumberingSettings(
263766ce4d0SZheng Fan const Sequence<Sequence<PropertyValue> >& aNum,
264766ce4d0SZheng Fan Reference<XNumberingFormatter>& xFormat,
265766ce4d0SZheng Fan const Locale& rLocale )
266766ce4d0SZheng Fan {
267766ce4d0SZheng Fan aNumSettings = aNum;
268766ce4d0SZheng Fan xFormatter = xFormat;
269766ce4d0SZheng Fan aLocale = rLocale;
270766ce4d0SZheng Fan if(aNum.getLength() > 9)
271766ce4d0SZheng Fan SetStyle( GetStyle()|WB_VSCROLL);
272766ce4d0SZheng Fan InsertItem( DEFAULT_NONE, DEFAULT_NONE - 1 );
273766ce4d0SZheng Fan SetItemText( DEFAULT_NONE, SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE ));
274766ce4d0SZheng Fan
2752684b347SPavel Janík for ( sal_Int32 i = 0; i < aNum.getLength(); i++ )
276766ce4d0SZheng Fan {
277766ce4d0SZheng Fan InsertItem( i + 1);
278766ce4d0SZheng Fan if( i < 8 )
279766ce4d0SZheng Fan {
280766ce4d0SZheng Fan NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
281766ce4d0SZheng Fan if ( pNumbering )
282766ce4d0SZheng Fan {
283766ce4d0SZheng Fan SetItemText( i + 1, pNumbering->GetDescription(i));
284766ce4d0SZheng Fan }
285766ce4d0SZheng Fan }
286766ce4d0SZheng Fan }
287766ce4d0SZheng Fan }
288766ce4d0SZheng Fan
UserDraw(const UserDrawEvent & rUDEvt)289766ce4d0SZheng Fan void SvxNumValueSet2::UserDraw( const UserDrawEvent& rUDEvt )
290766ce4d0SZheng Fan {
291766ce4d0SZheng Fan const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
292766ce4d0SZheng Fan const Color aBackColor = rStyleSettings.GetFieldColor();
293766ce4d0SZheng Fan const Color aTextColor = rStyleSettings.GetFieldTextColor();
294766ce4d0SZheng Fan
295766ce4d0SZheng Fan OutputDevice* pDev = rUDEvt.GetDevice();
296766ce4d0SZheng Fan Rectangle aRect = rUDEvt.GetRect();
297766ce4d0SZheng Fan sal_uInt32 nItemId = rUDEvt.GetItemId();
298766ce4d0SZheng Fan long nRectWidth = aRect.GetWidth();
299766ce4d0SZheng Fan long nRectHeight = aRect.GetHeight();
300766ce4d0SZheng Fan Size aRectSize(nRectWidth, aRect.GetHeight());
301766ce4d0SZheng Fan Point aBLPos = aRect.TopLeft();
302766ce4d0SZheng Fan Font aOldFont = pDev->GetFont();
303766ce4d0SZheng Fan Color aOldColor = pDev->GetLineColor();
304766ce4d0SZheng Fan pDev->SetLineColor(aBackColor);
305766ce4d0SZheng Fan Font aFont(OutputDevice::GetDefaultFont(
306766ce4d0SZheng Fan DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
307766ce4d0SZheng Fan
308766ce4d0SZheng Fan Size aSize = aFont.GetSize();
309766ce4d0SZheng Fan aSize.Height() = nRectHeight/5;
310766ce4d0SZheng Fan aFont.SetColor(aTextColor);
311766ce4d0SZheng Fan aFont.SetFillColor(aBackColor);
312766ce4d0SZheng Fan aFont.SetSize( aSize );
313766ce4d0SZheng Fan pDev->SetFont(aFont);
314766ce4d0SZheng Fan pDev->SetLineColor(aTextColor);
315766ce4d0SZheng Fan if(!pVDev)
316766ce4d0SZheng Fan {
317766ce4d0SZheng Fan // Die Linien werden nur einmalig in das VirtualDevice gepainted
318766ce4d0SZheng Fan // nur die Gliederungspage bekommt es aktuell
319766ce4d0SZheng Fan pVDev = new VirtualDevice(*pDev);
320766ce4d0SZheng Fan pVDev->SetMapMode(pDev->GetMapMode());
321766ce4d0SZheng Fan pVDev->EnableRTL( IsRTLEnabled() );
322766ce4d0SZheng Fan pVDev->SetOutputSize( aRectSize );
323766ce4d0SZheng Fan aOrgRect = aRect;
324766ce4d0SZheng Fan
325766ce4d0SZheng Fan pVDev->SetLineColor( aBackColor );
326766ce4d0SZheng Fan pVDev->SetFillColor( aBackColor );
327766ce4d0SZheng Fan pVDev->DrawRect(aOrgRect);
328766ce4d0SZheng Fan
329766ce4d0SZheng Fan if(aBackColor == aLineColor)
330766ce4d0SZheng Fan aLineColor.Invert();
331766ce4d0SZheng Fan if(GetSettings().GetStyleSettings().GetHighContrastMode())
332766ce4d0SZheng Fan pVDev->SetLineColor(aTextColor);
333766ce4d0SZheng Fan else
334766ce4d0SZheng Fan pVDev->SetLineColor(aLineColor);
335766ce4d0SZheng Fan // Linien nur einmalig Zeichnen
336766ce4d0SZheng Fan Point aStart(aBLPos.X() + nRectWidth *30 / 100,0);
337766ce4d0SZheng Fan Point aEnd(aBLPos.X() + nRectWidth * 9 / 10,0);
338766ce4d0SZheng Fan for( sal_uInt32 i = 11; i < 100; i += 33)
339766ce4d0SZheng Fan {
340766ce4d0SZheng Fan aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * i / 100;
341766ce4d0SZheng Fan pVDev->DrawLine(aStart, aEnd);
342766ce4d0SZheng Fan aStart.Y() = aEnd.Y() = aBLPos.Y() + nRectHeight * (i + 11) / 100;
343766ce4d0SZheng Fan pVDev->DrawLine(aStart, aEnd);
344766ce4d0SZheng Fan }
345766ce4d0SZheng Fan }
346766ce4d0SZheng Fan if ( nItemId != DEFAULT_NONE)
347766ce4d0SZheng Fan pDev->DrawOutDev( aRect.TopLeft(), aRectSize,
348766ce4d0SZheng Fan aOrgRect.TopLeft(), aRectSize,
349766ce4d0SZheng Fan *pVDev );
350766ce4d0SZheng Fan const OUString sValue(C2U(cValue));
351766ce4d0SZheng Fan
352766ce4d0SZheng Fan Point aStart(aBLPos.X() + nRectWidth / 9,0);
353766ce4d0SZheng Fan if ( nItemId == DEFAULT_NONE)
354766ce4d0SZheng Fan {
355766ce4d0SZheng Fan String sText(SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE));
356766ce4d0SZheng Fan Font aFont = pDev->GetFont();
357766ce4d0SZheng Fan Size aSize = aFont.GetSize();
358766ce4d0SZheng Fan aSize.Height() = nRectHeight/4;
359766ce4d0SZheng Fan aFont.SetSize( aSize );
360766ce4d0SZheng Fan pDev->SetFont(aFont);
361766ce4d0SZheng Fan long nTextWidth = pDev->GetTextWidth(sText);
362766ce4d0SZheng Fan long nTextHeight = pDev->GetTextHeight();
363766ce4d0SZheng Fan //GVT refine
364766ce4d0SZheng Fan while (nTextWidth>nRectWidth && aSize.Height()>4) {
365766ce4d0SZheng Fan aSize.Height() = aSize.Height()*0.9;
366766ce4d0SZheng Fan aFont.SetSize( aSize );
367766ce4d0SZheng Fan pDev->SetFont(aFont);
368766ce4d0SZheng Fan nTextWidth = pDev->GetTextWidth(sText);
369766ce4d0SZheng Fan }
370766ce4d0SZheng Fan Point aSStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2);
371766ce4d0SZheng Fan pDev->DrawText(aSStart, sText);
372766ce4d0SZheng Fan pDev->SetFont(aOldFont);
373766ce4d0SZheng Fan }
374766ce4d0SZheng Fan else
375766ce4d0SZheng Fan {
376766ce4d0SZheng Fan NBOTypeMgrBase* pNumbering = NBOutlineTypeMgrFact::CreateInstance(eNBOType::NUMBERING);
377766ce4d0SZheng Fan if ( pNumbering && nItemId <= DEFAULT_BULLET_TYPES )
378766ce4d0SZheng Fan {
379766ce4d0SZheng Fan for( sal_uInt32 i = 0; i < 3; i++ )
380766ce4d0SZheng Fan {
381766ce4d0SZheng Fan sal_uInt32 nY = 11 + i * 33;
382766ce4d0SZheng Fan aStart.Y() = aBLPos.Y() + nRectHeight * nY / 100;
383766ce4d0SZheng Fan String sText;
384766ce4d0SZheng Fan sal_uInt16 nLvl = 0;
385766ce4d0SZheng Fan SvxNumRule aTempRule( 0, 10, false );
386766ce4d0SZheng Fan pNumbering->ApplyNumRule(aTempRule,nItemId -1,1<<nLvl);
387766ce4d0SZheng Fan SvxNumberFormat aNumFmt(aTempRule.GetLevel(nLvl));
388766ce4d0SZheng Fan sText=aNumFmt.GetNumStr(i+1);
389766ce4d0SZheng Fan sText.Insert( aNumFmt.GetPrefix(), 0 );
390766ce4d0SZheng Fan sText += aNumFmt.GetSuffix();
391766ce4d0SZheng Fan aStart.X() = aBLPos.X() + 2;
392766ce4d0SZheng Fan aStart.Y() -= pDev->GetTextHeight()/2;
393766ce4d0SZheng Fan pDev->DrawText(aStart, sText);
394766ce4d0SZheng Fan }
395766ce4d0SZheng Fan }
396766ce4d0SZheng Fan pDev->SetFont(aOldFont);
397766ce4d0SZheng Fan pDev->SetLineColor(aOldColor);
398766ce4d0SZheng Fan }
399766ce4d0SZheng Fan //End
400766ce4d0SZheng Fan }
401766ce4d0SZheng Fan
402766ce4d0SZheng Fan //===============================================================================================
403766ce4d0SZheng Fan
SvxNumValueSet3(Window * pParent,const ResId & rResId)404766ce4d0SZheng Fan SvxNumValueSet3::SvxNumValueSet3( Window* pParent, const ResId& rResId) :
405766ce4d0SZheng Fan ValueSet( pParent, rResId )
406766ce4d0SZheng Fan {
407766ce4d0SZheng Fan SetColCount( 3 );
408766ce4d0SZheng Fan SetLineCount( 4 );
409766ce4d0SZheng Fan SetStyle( GetStyle() | WB_ITEMBORDER );
410766ce4d0SZheng Fan }
411766ce4d0SZheng Fan
~SvxNumValueSet3()412766ce4d0SZheng Fan SvxNumValueSet3::~SvxNumValueSet3()
413766ce4d0SZheng Fan {
414766ce4d0SZheng Fan }
415766ce4d0SZheng Fan
UserDraw(const UserDrawEvent & rUDEvt)416766ce4d0SZheng Fan void SvxNumValueSet3::UserDraw( const UserDrawEvent& rUDEvt )
417766ce4d0SZheng Fan {
418766ce4d0SZheng Fan Rectangle aRect = rUDEvt.GetRect();
419766ce4d0SZheng Fan OutputDevice* pDev = rUDEvt.GetDevice();
420766ce4d0SZheng Fan sal_uInt32 nItemId = rUDEvt.GetItemId();
421766ce4d0SZheng Fan
422766ce4d0SZheng Fan long nRectHeight = aRect.GetHeight();
423766ce4d0SZheng Fan long nRectWidth = aRect.GetWidth();
424766ce4d0SZheng Fan Point aBLPos = aRect.TopLeft();
425766ce4d0SZheng Fan NBOTypeMgrBase* pBullets = NBOutlineTypeMgrFact::CreateInstance(eNBOType::MIXBULLETS);
426766ce4d0SZheng Fan if ( pBullets )
427766ce4d0SZheng Fan {
428766ce4d0SZheng Fan if ( nItemId <= DEFAULT_BULLET_TYPES ) {
429766ce4d0SZheng Fan sal_uInt16 nLvl = 0;
430766ce4d0SZheng Fan SvxNumRule aTempRule( 0, 10, false );
431766ce4d0SZheng Fan pBullets->ApplyNumRule(aTempRule,nItemId -1,1<<nLvl);
432766ce4d0SZheng Fan SvxNumberFormat aFmt(aTempRule.GetLevel(nLvl));
433766ce4d0SZheng Fan sal_Int16 eNumType = aFmt.GetNumberingType();
434766ce4d0SZheng Fan if( eNumType == SVX_NUM_CHAR_SPECIAL)
435766ce4d0SZheng Fan {
436766ce4d0SZheng Fan sal_Unicode cChar = aFmt.GetBulletChar();
437766ce4d0SZheng Fan //End
438766ce4d0SZheng Fan const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
439766ce4d0SZheng Fan const Color aBackColor = rStyleSettings.GetFieldColor();
440766ce4d0SZheng Fan const Color aTextColor = rStyleSettings.GetFieldTextColor();
441766ce4d0SZheng Fan
442766ce4d0SZheng Fan Font aOldFont = pDev->GetFont();
443766ce4d0SZheng Fan Font aFont( lcl_GetDefaultBulletFont() );
444766ce4d0SZheng Fan
445766ce4d0SZheng Fan Size aSize = aFont.GetSize();
446766ce4d0SZheng Fan aSize.Height() = nRectHeight*3/6;
447766ce4d0SZheng Fan aFont.SetColor(aTextColor);
448766ce4d0SZheng Fan aFont.SetFillColor(aBackColor);
449766ce4d0SZheng Fan aFont.SetSize( aSize );
450766ce4d0SZheng Fan pDev->SetFont(aFont);
451766ce4d0SZheng Fan pDev->SetFillColor( aBackColor ); //wj
452766ce4d0SZheng Fan
453766ce4d0SZheng Fan String sText;
454766ce4d0SZheng Fan sText = cChar;
455766ce4d0SZheng Fan Font aOldBulletFont = pDev->GetFont();
456766ce4d0SZheng Fan Font aBulletFnt(aFmt.GetBulletFont() ? *aFmt.GetBulletFont() : aOldBulletFont);
457766ce4d0SZheng Fan Size aBulSize = aOldBulletFont.GetSize();
458766ce4d0SZheng Fan aBulletFnt.SetSize(aBulSize);
459766ce4d0SZheng Fan pDev->SetFont(aBulletFnt);
460766ce4d0SZheng Fan long nTextWidth = pDev->GetTextWidth(sText);
461766ce4d0SZheng Fan long nTextHeight = pDev->GetTextHeight();
462766ce4d0SZheng Fan Point aStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2);
463766ce4d0SZheng Fan pDev->DrawText(aStart, sText);
464766ce4d0SZheng Fan pDev->SetFont(aOldFont);
465766ce4d0SZheng Fan }else if ( eNumType == SVX_NUM_BITMAP )
466766ce4d0SZheng Fan {
467766ce4d0SZheng Fan const SvxBrushItem* pBrushItem = aFmt.GetBrush();
468766ce4d0SZheng Fan if(pBrushItem)
469766ce4d0SZheng Fan {
470766ce4d0SZheng Fan const Graphic* pGrf = pBrushItem->GetGraphic();
471766ce4d0SZheng Fan if(pGrf)
472766ce4d0SZheng Fan {
473766ce4d0SZheng Fan Size aSize(nRectHeight*6/20, nRectHeight*6/20);
474766ce4d0SZheng Fan Point aStart(aBLPos.X() + nRectWidth*7/20, aBLPos.Y() + nRectHeight*7/20);
475766ce4d0SZheng Fan
476766ce4d0SZheng Fan pGrf->Draw( pDev, aStart, aSize );
477766ce4d0SZheng Fan }
478766ce4d0SZheng Fan }
479766ce4d0SZheng Fan }
480766ce4d0SZheng Fan }else if ( nItemId == DEFAULT_NONE)
481766ce4d0SZheng Fan {
482766ce4d0SZheng Fan const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
483766ce4d0SZheng Fan const Color aBackColor = rStyleSettings.GetFieldColor();
484766ce4d0SZheng Fan const Color aTextColor = rStyleSettings.GetFieldTextColor();
485766ce4d0SZheng Fan
486766ce4d0SZheng Fan Font aOldFont = pDev->GetFont();
487766ce4d0SZheng Fan Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
488766ce4d0SZheng Fan Size aSize = aFont.GetSize();
489766ce4d0SZheng Fan //aSize.Height() = nRectHeight/5;
490766ce4d0SZheng Fan aSize.Height() = nRectHeight/4;
491766ce4d0SZheng Fan aFont.SetColor(aTextColor);
492766ce4d0SZheng Fan aFont.SetFillColor(aBackColor);
493766ce4d0SZheng Fan aFont.SetSize( aSize );
494766ce4d0SZheng Fan pDev->SetFont(aFont);
495766ce4d0SZheng Fan pDev->SetFillColor( aBackColor );
496766ce4d0SZheng Fan
497766ce4d0SZheng Fan String sText(SVX_RESSTR( RID_SVXSTR_NUMBULLET_NONE));
498766ce4d0SZheng Fan
499766ce4d0SZheng Fan long nTextWidth = pDev->GetTextWidth(sText);
500766ce4d0SZheng Fan long nTextHeight = pDev->GetTextHeight();
501766ce4d0SZheng Fan //GVT refine
502766ce4d0SZheng Fan while (nTextWidth>nRectWidth && aSize.Height()>4) {
503766ce4d0SZheng Fan aSize.Height() = aSize.Height()*0.9;
504766ce4d0SZheng Fan aFont.SetSize( aSize );
505766ce4d0SZheng Fan pDev->SetFont(aFont);
506766ce4d0SZheng Fan nTextWidth = pDev->GetTextWidth(sText);
507766ce4d0SZheng Fan }
508766ce4d0SZheng Fan Point aStart(aBLPos.X()+(nRectWidth-nTextWidth)/2, aBLPos.Y() +(nRectHeight-nTextHeight)/2);
509766ce4d0SZheng Fan pDev->DrawText(aStart, sText);
510766ce4d0SZheng Fan
511766ce4d0SZheng Fan pDev->SetFont(aOldFont);
512766ce4d0SZheng Fan }
513766ce4d0SZheng Fan }
514766ce4d0SZheng Fan
515766ce4d0SZheng Fan }
516766ce4d0SZheng Fan
5172055df08SOliver-Rainer Wittmann } } // end of namespace svx::sidebar
518*7658c399Smseidel
519*7658c399Smseidel /* vim: set noet sw=4 ts=4: */
520