2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 19:18:32 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:18:32 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:18:32 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:18:32 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:18:32 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:18:32 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 13:37:05 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_svtools.hxx"
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#define _CTRLBOX_CXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/field.hxx>
|
2010-10-18 12:28:33 +02:00
|
|
|
#include <sal/macros.h>
|
2000-10-22 16:44:39 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <unotools/charclass.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-06-27 20:23:24 +00:00
|
|
|
#include <svtools/svtdata.hxx>
|
2010-04-09 11:05:09 +02:00
|
|
|
#include <svtools/svtools.hrc>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <ctrlbox.hxx>
|
|
|
|
#include <ctrltool.hxx>
|
2010-10-06 23:53:00 +02:00
|
|
|
#include <borderhelper.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-08-28 09:25:06 +00:00
|
|
|
#include <vcl/i18nhelp.hxx>
|
2010-10-06 23:53:00 +02:00
|
|
|
#include <basegfx/polygon/b2dpolygon.hxx>
|
|
|
|
#include <basegfx/polygon/b2dpolygontools.hxx>
|
2001-08-28 09:25:06 +00:00
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
#define IMGINNERTEXTSPACE 2
|
|
|
|
#define IMGOUTERTEXTSPACE 5
|
|
|
|
#define EXTRAFONTSIZE 5
|
|
|
|
#define MAXPREVIEWWIDTH 150
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-07-19 16:20:19 +00:00
|
|
|
static sal_Unicode aImplSymbolFontText[] = {0xF021,0xF032,0xF043,0xF054,0xF065,0xF076,0xF0B7,0xF0C8,0};
|
|
|
|
static sal_Unicode aImplStarSymbolText[] = {0x2706,0x2704,0x270D,0xE033,0x2211,0x2288,0};
|
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// ========================================================================
|
|
|
|
// ColorListBox
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
// --------------------
|
|
|
|
// - ImplColorListData -
|
|
|
|
// --------------------
|
|
|
|
|
|
|
|
struct ImplColorListData
|
|
|
|
{
|
|
|
|
Color aColor;
|
|
|
|
BOOL bColor;
|
|
|
|
|
|
|
|
ImplColorListData() : aColor( COL_BLACK ) { bColor = FALSE; }
|
|
|
|
ImplColorListData( const Color& rColor ) : aColor( rColor ) { bColor = TRUE; }
|
|
|
|
};
|
|
|
|
|
2006-06-19 19:54:17 +00:00
|
|
|
DECLARE_LIST( ImpColorList, ImplColorListData* )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ColorListBox::ImplInit()
|
|
|
|
{
|
|
|
|
pColorList = new ImpColorList( 256, 64 );
|
|
|
|
aImageSize.Width() = GetTextWidth( XubString( RTL_CONSTASCII_USTRINGPARAM( "xxx" ) ) );
|
|
|
|
aImageSize.Height() = GetTextHeight();
|
|
|
|
aImageSize.Height() -= 2;
|
|
|
|
|
|
|
|
EnableUserDraw( TRUE );
|
|
|
|
SetUserItemSize( aImageSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ColorListBox::ImplDestroyColorEntries()
|
|
|
|
{
|
|
|
|
for ( USHORT n = (USHORT) pColorList->Count(); n; )
|
|
|
|
{
|
|
|
|
ImplColorListData* pData = pColorList->GetObject( --n );
|
|
|
|
delete pData;
|
|
|
|
}
|
|
|
|
pColorList->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ColorListBox::ColorListBox( Window* pParent, WinBits nWinStyle ) :
|
|
|
|
ListBox( pParent, nWinStyle )
|
|
|
|
{
|
|
|
|
ImplInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ColorListBox::ColorListBox( Window* pParent, const ResId& rResId ) :
|
|
|
|
ListBox( pParent, rResId )
|
|
|
|
{
|
|
|
|
ImplInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
ColorListBox::~ColorListBox()
|
|
|
|
{
|
|
|
|
ImplDestroyColorEntries();
|
|
|
|
delete pColorList;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
USHORT ColorListBox::InsertEntry( const XubString& rStr, USHORT nPos )
|
|
|
|
{
|
|
|
|
nPos = ListBox::InsertEntry( rStr, nPos );
|
|
|
|
if ( nPos != LISTBOX_ERROR )
|
|
|
|
{
|
|
|
|
ImplColorListData* pData = new ImplColorListData;
|
|
|
|
pColorList->Insert( pData, nPos );
|
|
|
|
}
|
|
|
|
return nPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
USHORT ColorListBox::InsertEntry( const Color& rColor, const XubString& rStr,
|
2001-07-19 16:20:19 +00:00
|
|
|
USHORT nPos )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
nPos = ListBox::InsertEntry( rStr, nPos );
|
|
|
|
if ( nPos != LISTBOX_ERROR )
|
|
|
|
{
|
|
|
|
ImplColorListData* pData = new ImplColorListData( rColor );
|
|
|
|
pColorList->Insert( pData, nPos );
|
|
|
|
}
|
|
|
|
return nPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2001-03-22 05:44:04 +00:00
|
|
|
void ColorListBox::InsertAutomaticEntry()
|
|
|
|
{
|
|
|
|
// insert the "Automatic"-entry always on the first position
|
|
|
|
InsertEntry( Color( COL_AUTO ), SvtResId( STR_SVT_AUTOMATIC_COLOR ), 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void ColorListBox::RemoveEntry( USHORT nPos )
|
|
|
|
{
|
|
|
|
ListBox::RemoveEntry( nPos );
|
|
|
|
delete pColorList->Remove( nPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ColorListBox::Clear()
|
|
|
|
{
|
|
|
|
ImplDestroyColorEntries();
|
|
|
|
ListBox::Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ColorListBox::CopyEntries( const ColorListBox& rBox )
|
|
|
|
{
|
|
|
|
// Liste leeren
|
|
|
|
ImplDestroyColorEntries();
|
|
|
|
|
|
|
|
// Daten kopieren
|
|
|
|
USHORT nCount = (USHORT) rBox.pColorList->Count();
|
|
|
|
for ( USHORT n = 0; n < nCount; n++ )
|
|
|
|
{
|
|
|
|
ImplColorListData* pData = rBox.pColorList->GetObject( n );
|
|
|
|
USHORT nPos = InsertEntry( rBox.GetEntry( n ), LISTBOX_APPEND );
|
|
|
|
if ( nPos != LISTBOX_ERROR )
|
|
|
|
pColorList->Insert( new ImplColorListData( *pData ), nPos );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
USHORT ColorListBox::GetEntryPos( const Color& rColor ) const
|
|
|
|
{
|
|
|
|
for( USHORT n = (USHORT) pColorList->Count(); n; )
|
|
|
|
{
|
|
|
|
ImplColorListData* pData = pColorList->GetObject( --n );
|
|
|
|
if ( pData->bColor && ( pData->aColor == rColor ) )
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
return LISTBOX_ENTRY_NOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
Color ColorListBox::GetEntryColor( USHORT nPos ) const
|
|
|
|
{
|
|
|
|
Color aColor;
|
|
|
|
ImplColorListData* pData = pColorList->GetObject( nPos );
|
|
|
|
if ( pData && pData->bColor )
|
|
|
|
aColor = pData->aColor;
|
|
|
|
return aColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void ColorListBox::UserDraw( const UserDrawEvent& rUDEvt )
|
|
|
|
{
|
|
|
|
ImplColorListData* pData = pColorList->GetObject( rUDEvt.GetItemId() );
|
|
|
|
if ( pData )
|
|
|
|
{
|
|
|
|
if ( pData->bColor )
|
|
|
|
{
|
|
|
|
Point aPos( rUDEvt.GetRect().TopLeft() );
|
|
|
|
aPos.X() += 2;
|
|
|
|
aPos.Y() += ( rUDEvt.GetRect().GetHeight() - aImageSize.Height() ) / 2;
|
|
|
|
rUDEvt.GetDevice()->Push();
|
|
|
|
rUDEvt.GetDevice()->SetFillColor( pData->aColor );
|
2002-07-19 10:10:38 +00:00
|
|
|
rUDEvt.GetDevice()->SetLineColor( rUDEvt.GetDevice()->GetTextColor() );
|
2000-09-18 16:07:07 +00:00
|
|
|
rUDEvt.GetDevice()->DrawRect( Rectangle( aPos, aImageSize ) );
|
|
|
|
rUDEvt.GetDevice()->Pop();
|
|
|
|
ListBox::DrawEntry( rUDEvt, FALSE, TRUE, FALSE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ListBox::DrawEntry( rUDEvt, FALSE, TRUE, TRUE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ListBox::DrawEntry( rUDEvt, TRUE, TRUE, FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// =======================================================================
|
|
|
|
// LineListBox
|
|
|
|
// =======================================================================
|
|
|
|
|
|
|
|
// -------------------
|
|
|
|
// - ImpListListData -
|
|
|
|
// -------------------
|
|
|
|
|
|
|
|
struct ImpLineListData
|
|
|
|
{
|
|
|
|
long nLine1;
|
|
|
|
long nLine2;
|
|
|
|
long nDistance;
|
2010-10-06 23:53:00 +02:00
|
|
|
USHORT nStyle;
|
2000-09-18 16:07:07 +00:00
|
|
|
};
|
|
|
|
|
2006-06-19 19:54:17 +00:00
|
|
|
DECLARE_LIST( ImpLineList, ImpLineListData* )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2002-07-19 08:43:19 +00:00
|
|
|
// -----------------------------------------------------------------------
|
2006-05-04 13:25:27 +00:00
|
|
|
|
2002-07-19 08:43:19 +00:00
|
|
|
inline const Color& LineListBox::GetPaintColor( void ) const
|
|
|
|
{
|
|
|
|
return maPaintCol;
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-10-06 23:53:00 +02:00
|
|
|
|
|
|
|
inline void lclDrawPolygon( OutputDevice& rDev, const basegfx::B2DPolygon& rPolygon, long nWidth, USHORT nDashing )
|
|
|
|
{
|
|
|
|
USHORT nOldAA = rDev.GetAntialiasing();
|
|
|
|
rDev.SetAntialiasing( nOldAA & !ANTIALIASING_ENABLE_B2DDRAW );
|
|
|
|
|
|
|
|
Color aOldColor = rDev.GetFillColor( );
|
|
|
|
rDev.SetFillColor( rDev.GetLineColor( ) );
|
|
|
|
|
|
|
|
basegfx::B2DPolyPolygon aPolygons = svtools::ApplyLineDashing( rPolygon, nDashing, rDev.GetMapMode().GetMapUnit() );
|
|
|
|
for ( sal_uInt32 i = 0; i < aPolygons.count( ); i++ )
|
|
|
|
{
|
|
|
|
basegfx::B2DPolygon aDash = aPolygons.getB2DPolygon( i );
|
|
|
|
basegfx::B2DPoint aStart = aDash.getB2DPoint( 0 );
|
|
|
|
basegfx::B2DPoint aEnd = aDash.getB2DPoint( aDash.count() - 1 );
|
|
|
|
|
|
|
|
basegfx::B2DVector aVector( aEnd - aStart );
|
|
|
|
aVector.normalize( );
|
|
|
|
const basegfx::B2DVector aPerpendicular(basegfx::getPerpendicular(aVector));
|
|
|
|
|
|
|
|
const basegfx::B2DVector aWidthOffset( nWidth / 2 * aPerpendicular);
|
|
|
|
basegfx::B2DPolygon aDashPolygon;
|
|
|
|
aDashPolygon.append( aStart + aWidthOffset );
|
|
|
|
aDashPolygon.append( aEnd + aWidthOffset );
|
|
|
|
aDashPolygon.append( aEnd - aWidthOffset );
|
|
|
|
aDashPolygon.append( aStart - aWidthOffset );
|
|
|
|
aDashPolygon.setClosed( true );
|
|
|
|
|
|
|
|
rDev.DrawPolygon( aDashPolygon );
|
|
|
|
}
|
|
|
|
|
|
|
|
rDev.SetFillColor( aOldColor );
|
|
|
|
rDev.SetAntialiasing( nOldAA );
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace svtools
|
|
|
|
{
|
|
|
|
basegfx::B2DPolyPolygon ApplyLineDashing( const basegfx::B2DPolygon& rPolygon, USHORT nDashing, MapUnit eUnit )
|
|
|
|
{
|
|
|
|
::std::vector < double >aPattern;
|
|
|
|
switch ( nDashing )
|
|
|
|
{
|
|
|
|
case STYLE_DOTTED:
|
|
|
|
if ( eUnit == MAP_TWIP )
|
|
|
|
{
|
|
|
|
aPattern.push_back( 30.0 );
|
|
|
|
aPattern.push_back( 110.0 );
|
|
|
|
}
|
|
|
|
else if ( eUnit == MAP_100TH_MM )
|
|
|
|
{
|
|
|
|
aPattern.push_back( 50 );
|
|
|
|
aPattern.push_back( 200 );
|
|
|
|
}
|
|
|
|
else if ( eUnit == MAP_PIXEL )
|
|
|
|
{
|
|
|
|
aPattern.push_back( 1.0 );
|
|
|
|
aPattern.push_back( 3.0 );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STYLE_DASHED:
|
|
|
|
if ( eUnit == MAP_TWIP )
|
|
|
|
{
|
|
|
|
aPattern.push_back( 110 );
|
|
|
|
aPattern.push_back( 110 );
|
|
|
|
}
|
|
|
|
else if ( eUnit == MAP_100TH_MM )
|
|
|
|
{
|
|
|
|
aPattern.push_back( 200 );
|
|
|
|
aPattern.push_back( 200 );
|
|
|
|
}
|
|
|
|
else if ( eUnit == MAP_PIXEL )
|
|
|
|
{
|
|
|
|
aPattern.push_back( 10 );
|
|
|
|
aPattern.push_back( 20 );
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
basegfx::B2DPolyPolygon aPolygons;
|
|
|
|
if ( ! aPattern.empty() )
|
|
|
|
basegfx::tools::applyLineDashing( rPolygon, aPattern, &aPolygons );
|
|
|
|
else
|
|
|
|
aPolygons.append( rPolygon );
|
|
|
|
|
|
|
|
return aPolygons;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawLine( OutputDevice& rDev, const Point& rP1, const Point& rP2,
|
|
|
|
sal_uInt32 nWidth, USHORT nDashing )
|
|
|
|
{
|
|
|
|
basegfx::B2DPolygon aPolygon;
|
|
|
|
aPolygon.append( basegfx::B2DPoint( rP1.X(), rP1.Y() ) );
|
|
|
|
aPolygon.append( basegfx::B2DPoint( rP2.X(), rP2.Y() ) );
|
|
|
|
lclDrawPolygon( rDev, aPolygon, nWidth, nDashing );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void LineListBox::ImpGetLine( long nLine1, long nLine2, long nDistance,
|
2010-10-06 23:53:00 +02:00
|
|
|
USHORT nStyle, Bitmap& rBmp, XubString& rStr )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
Size aSize = GetOutputSizePixel();
|
|
|
|
aSize.Width() -= 20;
|
|
|
|
aSize.Width() -= aTxtSize.Width();
|
|
|
|
aSize.Height() = aTxtSize.Height();
|
|
|
|
|
|
|
|
// SourceUnit nach Twips
|
|
|
|
if ( eSourceUnit == FUNIT_POINT )
|
|
|
|
{
|
|
|
|
nLine1 *= 20;
|
|
|
|
nLine2 *= 20;
|
|
|
|
nDistance *= 20;
|
|
|
|
}
|
|
|
|
else if ( eSourceUnit == FUNIT_MM )
|
|
|
|
{
|
|
|
|
nLine1 *= 14440;
|
|
|
|
nLine1 /= 254;
|
|
|
|
nLine2 *= 14440;
|
|
|
|
nLine2 /= 254;
|
|
|
|
nDistance *= 14440;
|
|
|
|
nDistance /= 254;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Linien malen
|
|
|
|
aSize = aVirDev.PixelToLogic( aSize );
|
|
|
|
long nPix = aVirDev.PixelToLogic( Size( 0, 1 ) ).Height();
|
2010-10-06 23:53:00 +02:00
|
|
|
sal_uInt32 n1 = nLine1 / 100;
|
|
|
|
sal_uInt32 n2 = nLine2 / 100;
|
2000-09-18 16:07:07 +00:00
|
|
|
long nDist = nDistance / 100;
|
|
|
|
n1 += nPix-1;
|
|
|
|
n1 -= n1%nPix;
|
|
|
|
if ( n2 )
|
|
|
|
{
|
|
|
|
nDist += nPix-1;
|
|
|
|
nDist -= nDist%nPix;
|
|
|
|
n2 += nPix-1;
|
|
|
|
n2 -= n2%nPix;
|
|
|
|
}
|
|
|
|
long nVirHeight = n1+nDist+n2;
|
|
|
|
if ( nVirHeight > aSize.Height() )
|
|
|
|
aSize.Height() = nVirHeight;
|
|
|
|
// negative Breiten muss und darf man nicht painten
|
|
|
|
if ( aSize.Width() > 0 )
|
|
|
|
{
|
|
|
|
Size aVirSize = aVirDev.LogicToPixel( aSize );
|
|
|
|
if ( aVirDev.GetOutputSizePixel() != aVirSize )
|
|
|
|
aVirDev.SetOutputSizePixel( aVirSize );
|
|
|
|
aVirDev.SetFillColor( GetSettings().GetStyleSettings().GetFieldColor() );
|
|
|
|
aVirDev.DrawRect( Rectangle( Point(), aSize ) );
|
2002-07-19 08:43:19 +00:00
|
|
|
|
2010-10-06 23:53:00 +02:00
|
|
|
Color oldColor = aVirDev.GetLineColor( );
|
|
|
|
aVirDev.SetLineColor( GetPaintColor( ) );
|
|
|
|
|
|
|
|
double y1 = n1 / 2;
|
|
|
|
svtools::DrawLine( aVirDev, Point( 0, y1 ), Point( aSize.Width( ), y1 ), n1, nStyle );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( n2 )
|
|
|
|
{
|
2010-10-06 23:53:00 +02:00
|
|
|
double y2 = n1 + nDist + n2 / 2;
|
|
|
|
svtools::DrawLine( aVirDev, Point( 0, y2 ), Point( aSize.Width(), y2 ), n2, STYLE_SOLID );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2010-10-06 23:53:00 +02:00
|
|
|
aVirDev.SetLineColor( oldColor );
|
2000-09-18 16:07:07 +00:00
|
|
|
rBmp = aVirDev.GetBitmap( Point(), Size( aSize.Width(), n1+nDist+n2 ) );
|
|
|
|
}
|
|
|
|
// Twips nach Unit
|
|
|
|
if ( eUnit == FUNIT_POINT )
|
|
|
|
{
|
|
|
|
nLine1 /= 20;
|
|
|
|
nLine2 /= 20;
|
|
|
|
nDistance /= 20;
|
|
|
|
rStr.AssignAscii( " pt" );
|
|
|
|
}
|
|
|
|
else if ( eUnit == FUNIT_MM )
|
|
|
|
{
|
|
|
|
nLine1 *= 254;
|
|
|
|
nLine1 /= 14400;
|
|
|
|
nLine2 *= 254;
|
|
|
|
nLine2 /= 14400;
|
|
|
|
nDistance *= 254;
|
|
|
|
nDistance /= 14400;
|
|
|
|
rStr.AssignAscii( " mm" );
|
|
|
|
}
|
|
|
|
|
2001-08-28 09:25:06 +00:00
|
|
|
String aNum( GetSettings().GetLocaleI18nHelper().GetNum( nLine1+nLine2+nDistance, 2 ) );
|
|
|
|
rStr.Insert( aNum, 0 );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void LineListBox::ImplInit()
|
|
|
|
{
|
|
|
|
aTxtSize.Width() = GetTextWidth( XubString( RTL_CONSTASCII_USTRINGPARAM( "99,99 mm" ) ) );
|
|
|
|
aTxtSize.Height() = GetTextHeight();
|
|
|
|
pLineList = new ImpLineList;
|
|
|
|
eUnit = FUNIT_POINT;
|
|
|
|
eSourceUnit = FUNIT_POINT;
|
|
|
|
|
|
|
|
aVirDev.SetLineColor();
|
|
|
|
aVirDev.SetMapMode( MapMode( MAP_TWIP ) );
|
2002-08-07 12:04:08 +00:00
|
|
|
|
|
|
|
UpdatePaintLineColor();
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
LineListBox::LineListBox( Window* pParent, WinBits nWinStyle ) :
|
|
|
|
ListBox( pParent, nWinStyle ),
|
2002-07-19 08:43:19 +00:00
|
|
|
aColor( COL_BLACK ),
|
|
|
|
maPaintCol( COL_BLACK )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
LineListBox::LineListBox( Window* pParent, const ResId& rResId ) :
|
|
|
|
ListBox( pParent, rResId ),
|
2002-07-19 08:43:19 +00:00
|
|
|
aColor( COL_BLACK ),
|
|
|
|
maPaintCol( COL_BLACK )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ImplInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
LineListBox::~LineListBox()
|
|
|
|
{
|
|
|
|
ULONG n = 0;
|
|
|
|
ULONG nCount = pLineList->Count();
|
|
|
|
while ( n < nCount )
|
|
|
|
{
|
|
|
|
ImpLineListData* pData = pLineList->GetObject( n );
|
|
|
|
if ( pData )
|
|
|
|
delete pData;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
delete pLineList;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
USHORT LineListBox::InsertEntry( const XubString& rStr, USHORT nPos )
|
|
|
|
{
|
|
|
|
nPos = ListBox::InsertEntry( rStr, nPos );
|
|
|
|
if ( nPos != LISTBOX_ERROR )
|
|
|
|
pLineList->Insert( NULL, nPos );
|
|
|
|
return nPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
USHORT LineListBox::InsertEntry( long nLine1, long nLine2, long nDistance,
|
2010-10-06 23:53:00 +02:00
|
|
|
USHORT nStyle, USHORT nPos )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
XubString aStr;
|
|
|
|
Bitmap aBmp;
|
2010-10-06 23:53:00 +02:00
|
|
|
ImpGetLine( nLine1, nLine2, nDistance, nStyle, aBmp, aStr );
|
2000-09-18 16:07:07 +00:00
|
|
|
nPos = ListBox::InsertEntry( aStr, aBmp, nPos );
|
|
|
|
if ( nPos != LISTBOX_ERROR )
|
|
|
|
{
|
2001-07-19 16:20:19 +00:00
|
|
|
ImpLineListData* pData = new ImpLineListData;
|
2000-09-18 16:07:07 +00:00
|
|
|
pData->nLine1 = nLine1;
|
|
|
|
pData->nLine2 = nLine2;
|
|
|
|
pData->nDistance = nDistance;
|
2010-10-06 23:53:00 +02:00
|
|
|
pData->nStyle = nStyle;
|
2000-09-18 16:07:07 +00:00
|
|
|
pLineList->Insert( pData, nPos );
|
|
|
|
}
|
|
|
|
|
|
|
|
return nPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void LineListBox::RemoveEntry( USHORT nPos )
|
|
|
|
{
|
|
|
|
ListBox::RemoveEntry( nPos );
|
|
|
|
ImpLineListData* pData = pLineList->Remove( nPos );
|
|
|
|
if ( pData )
|
|
|
|
delete pData;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void LineListBox::Clear()
|
|
|
|
{
|
|
|
|
ULONG n = 0;
|
|
|
|
ULONG nCount = pLineList->Count();
|
|
|
|
while ( n < nCount )
|
|
|
|
{
|
|
|
|
ImpLineListData* pData = pLineList->GetObject( n );
|
|
|
|
if ( pData )
|
|
|
|
delete pData;
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pLineList->Clear();
|
|
|
|
ListBox::Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
USHORT LineListBox::GetEntryPos( long nLine1, long nLine2,
|
2010-10-06 23:53:00 +02:00
|
|
|
long nDistance, USHORT nStyle ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
ULONG n = 0;
|
|
|
|
ULONG nCount = pLineList->Count();
|
|
|
|
while ( n < nCount )
|
|
|
|
{
|
|
|
|
ImpLineListData* pData = pLineList->GetObject( n );
|
|
|
|
if ( pData )
|
|
|
|
{
|
|
|
|
if ( (pData->nLine1 == nLine1) &&
|
2001-07-19 16:20:19 +00:00
|
|
|
(pData->nLine2 == nLine2) &&
|
2010-10-06 23:53:00 +02:00
|
|
|
(pData->nDistance == nDistance) &&
|
|
|
|
(pData->nStyle == nStyle) )
|
2001-07-19 16:20:19 +00:00
|
|
|
return (USHORT)n;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LISTBOX_ENTRY_NOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
long LineListBox::GetEntryLine1( USHORT nPos ) const
|
|
|
|
{
|
|
|
|
ImpLineListData* pData = pLineList->GetObject( nPos );
|
|
|
|
if ( pData )
|
|
|
|
return pData->nLine1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
long LineListBox::GetEntryLine2( USHORT nPos ) const
|
|
|
|
{
|
|
|
|
ImpLineListData* pData = pLineList->GetObject( nPos );
|
|
|
|
if ( pData )
|
|
|
|
return pData->nLine2;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
long LineListBox::GetEntryDistance( USHORT nPos ) const
|
|
|
|
{
|
|
|
|
ImpLineListData* pData = pLineList->GetObject( nPos );
|
|
|
|
if ( pData )
|
|
|
|
return pData->nDistance;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2010-10-06 23:53:00 +02:00
|
|
|
USHORT LineListBox::GetEntryStyle( USHORT nPos ) const
|
|
|
|
{
|
|
|
|
USHORT nStyle = STYLE_SOLID;
|
|
|
|
ImpLineListData* pData = pLineList->GetObject( nPos );
|
|
|
|
if ( pData )
|
|
|
|
nStyle = pData->nStyle;
|
|
|
|
|
|
|
|
return nStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2002-07-19 08:43:19 +00:00
|
|
|
void LineListBox::UpdateLineColors( void )
|
|
|
|
{
|
2002-08-07 12:04:08 +00:00
|
|
|
if( UpdatePaintLineColor() )
|
|
|
|
{
|
|
|
|
ULONG nCount = pLineList->Count();
|
|
|
|
if( !nCount )
|
|
|
|
return;
|
2002-07-19 08:43:19 +00:00
|
|
|
|
2002-08-07 12:04:08 +00:00
|
|
|
XubString aStr;
|
|
|
|
Bitmap aBmp;
|
2002-07-19 08:43:19 +00:00
|
|
|
|
2002-08-07 12:04:08 +00:00
|
|
|
// exchange entries which containing lines
|
|
|
|
SetUpdateMode( FALSE );
|
2002-07-19 08:43:19 +00:00
|
|
|
|
2002-08-07 12:04:08 +00:00
|
|
|
USHORT nSelEntry = GetSelectEntryPos();
|
|
|
|
for( ULONG n = 0 ; n < nCount ; ++n )
|
2002-07-19 08:43:19 +00:00
|
|
|
{
|
2002-08-07 12:04:08 +00:00
|
|
|
ImpLineListData* pData = pLineList->GetObject( n );
|
|
|
|
if( pData )
|
|
|
|
{
|
|
|
|
// exchange listbox data
|
|
|
|
ListBox::RemoveEntry( USHORT( n ) );
|
2010-10-06 23:53:00 +02:00
|
|
|
ImpGetLine( pData->nLine1, pData->nLine2, pData->nDistance,
|
|
|
|
pData->nStyle, aBmp, aStr );
|
2002-08-07 12:04:08 +00:00
|
|
|
ListBox::InsertEntry( aStr, aBmp, USHORT( n ) );
|
|
|
|
}
|
2002-07-19 08:43:19 +00:00
|
|
|
}
|
2002-08-07 12:04:08 +00:00
|
|
|
|
|
|
|
if( nSelEntry != LISTBOX_ENTRY_NOTFOUND )
|
|
|
|
SelectEntryPos( nSelEntry );
|
|
|
|
|
|
|
|
SetUpdateMode( TRUE );
|
|
|
|
Invalidate();
|
2002-07-19 08:43:19 +00:00
|
|
|
}
|
2002-08-07 12:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
BOOL LineListBox::UpdatePaintLineColor( void )
|
|
|
|
{
|
|
|
|
BOOL bRet = TRUE;
|
|
|
|
const StyleSettings& rSettings = GetSettings().GetStyleSettings();
|
|
|
|
Color aNewCol( rSettings.GetWindowColor().IsDark()? rSettings.GetLabelTextColor() : aColor );
|
|
|
|
|
|
|
|
bRet = aNewCol != maPaintCol;
|
2002-07-19 08:43:19 +00:00
|
|
|
|
2002-08-07 12:04:08 +00:00
|
|
|
if( bRet )
|
|
|
|
maPaintCol = aNewCol;
|
2002-07-19 08:43:19 +00:00
|
|
|
|
2002-08-07 12:04:08 +00:00
|
|
|
return bRet;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2002-07-19 08:43:19 +00:00
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void LineListBox::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
ListBox::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if( ( rDCEvt.GetType() == DATACHANGED_SETTINGS ) && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
|
|
|
|
UpdateLineColors();
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// ===================================================================
|
|
|
|
// FontNameBox
|
|
|
|
// ===================================================================
|
|
|
|
|
|
|
|
struct ImplFontNameListData
|
|
|
|
{
|
|
|
|
FontInfo maInfo;
|
|
|
|
USHORT mnType;
|
|
|
|
|
|
|
|
ImplFontNameListData( const FontInfo& rInfo,
|
2001-07-19 16:20:19 +00:00
|
|
|
USHORT nType ) :
|
2000-09-18 16:07:07 +00:00
|
|
|
maInfo( rInfo ),
|
|
|
|
mnType( nType )
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2006-06-19 19:54:17 +00:00
|
|
|
DECLARE_LIST( ImplFontList, ImplFontNameListData* )
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
FontNameBox::FontNameBox( Window* pParent, WinBits nWinStyle ) :
|
2002-07-31 06:49:06 +00:00
|
|
|
ComboBox( pParent, nWinStyle )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-31 06:49:06 +00:00
|
|
|
InitBitmaps();
|
2000-09-18 16:07:07 +00:00
|
|
|
mpFontList = NULL;
|
|
|
|
mbWYSIWYG = FALSE;
|
|
|
|
mbSymbols = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
FontNameBox::FontNameBox( Window* pParent, const ResId& rResId ) :
|
2002-07-31 06:49:06 +00:00
|
|
|
ComboBox( pParent, rResId )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2002-07-31 06:49:06 +00:00
|
|
|
InitBitmaps();
|
2000-09-18 16:07:07 +00:00
|
|
|
mpFontList = NULL;
|
|
|
|
mbWYSIWYG = FALSE;
|
|
|
|
mbSymbols = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
FontNameBox::~FontNameBox()
|
|
|
|
{
|
|
|
|
ImplDestroyFontList();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2002-07-31 06:49:06 +00:00
|
|
|
void FontNameBox::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
ComboBox::DataChanged( rDCEvt );
|
|
|
|
|
|
|
|
if( rDCEvt.GetType() == DATACHANGED_SETTINGS && ( rDCEvt.GetFlags() & SETTINGS_STYLE ) )
|
|
|
|
InitBitmaps();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontNameBox::InitBitmaps( void )
|
|
|
|
{
|
2010-11-11 14:55:06 +01:00
|
|
|
maImagePrinterFont = Image( SvtResId( RID_IMG_PRINTERFONT ) );
|
|
|
|
maImageBitmapFont = Image( SvtResId( RID_IMG_BITMAPFONT ) );
|
|
|
|
maImageScalableFont = Image( SvtResId( RID_IMG_SCALABLEFONT ) );
|
2002-07-31 06:49:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void FontNameBox::ImplDestroyFontList()
|
|
|
|
{
|
|
|
|
if ( mpFontList )
|
|
|
|
{
|
|
|
|
ImplFontNameListData* pInfo = mpFontList->First();
|
|
|
|
while ( pInfo )
|
|
|
|
{
|
|
|
|
delete pInfo;
|
|
|
|
pInfo = mpFontList->Next();
|
|
|
|
}
|
|
|
|
delete mpFontList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontNameBox::Fill( const FontList* pList )
|
|
|
|
{
|
2001-07-19 16:20:19 +00:00
|
|
|
// store old text and clear box
|
2000-09-18 16:07:07 +00:00
|
|
|
XubString aOldText = GetText();
|
|
|
|
Clear();
|
|
|
|
|
|
|
|
ImplDestroyFontList();
|
|
|
|
mpFontList = new ImplFontList;
|
|
|
|
|
2001-07-19 16:20:19 +00:00
|
|
|
// insert fonts
|
|
|
|
USHORT nFontCount = pList->GetFontNameCount();
|
2000-09-18 16:07:07 +00:00
|
|
|
for ( USHORT i = 0; i < nFontCount; i++ )
|
|
|
|
{
|
|
|
|
const FontInfo& rFontInfo = pList->GetFontName( i );
|
|
|
|
ULONG nIndex = InsertEntry( rFontInfo.GetName() );
|
|
|
|
if ( nIndex != LISTBOX_ERROR )
|
|
|
|
{
|
|
|
|
USHORT nType = pList->GetFontNameType( i );
|
|
|
|
ImplFontNameListData* pData = new ImplFontNameListData( rFontInfo, nType );
|
|
|
|
mpFontList->Insert( pData, nIndex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImplCalcUserItemSize();
|
|
|
|
|
2001-07-19 16:20:19 +00:00
|
|
|
// restore text
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( aOldText.Len() )
|
|
|
|
SetText( aOldText );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontNameBox::EnableWYSIWYG( BOOL bEnable )
|
|
|
|
{
|
|
|
|
if ( bEnable != mbWYSIWYG )
|
|
|
|
{
|
|
|
|
mbWYSIWYG = bEnable;
|
|
|
|
EnableUserDraw( mbWYSIWYG | mbSymbols );
|
|
|
|
ImplCalcUserItemSize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontNameBox::EnableSymbols( BOOL bEnable )
|
|
|
|
{
|
|
|
|
if ( bEnable != mbSymbols )
|
|
|
|
{
|
|
|
|
mbSymbols = bEnable;
|
|
|
|
EnableUserDraw( mbWYSIWYG | mbSymbols );
|
|
|
|
ImplCalcUserItemSize();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontNameBox::ImplCalcUserItemSize()
|
|
|
|
{
|
|
|
|
Size aUserItemSz;
|
|
|
|
if ( mbWYSIWYG && mpFontList )
|
|
|
|
{
|
2011-02-03 14:08:51 +00:00
|
|
|
aUserItemSz = Size(MAXPREVIEWWIDTH, GetTextHeight() );
|
|
|
|
aUserItemSz.Height() *= 16;
|
|
|
|
aUserItemSz.Height() /= 10;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
if ( mbSymbols )
|
|
|
|
{
|
|
|
|
Size aSz = maImageScalableFont.GetSizePixel();
|
2011-02-03 14:08:51 +00:00
|
|
|
aUserItemSz.Width() += aSz.Width() + IMGINNERTEXTSPACE;
|
|
|
|
|
|
|
|
if ( mbWYSIWYG && mpFontList )
|
|
|
|
aUserItemSz.Width() += IMGOUTERTEXTSPACE;
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( aSz.Height() > aUserItemSz.Height() )
|
|
|
|
aUserItemSz.Height() = aSz.Height();
|
|
|
|
}
|
|
|
|
SetUserItemSize( aUserItemSz );
|
|
|
|
}
|
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
#define MKTAG(s) ((((((s[0]<<8)+s[1])<<8)+s[2])<<8)+s[3])
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
rtl::OUString makeRepresentativeSymbolText(bool bOpenSymbol, OutputDevice &rDevice)
|
|
|
|
{
|
|
|
|
rtl::OUString sSampleText;
|
|
|
|
|
|
|
|
FontCharMap aFontCharMap;
|
|
|
|
bool bHasCharMap = rDevice.GetFontCharMap( aFontCharMap );
|
|
|
|
if( bHasCharMap )
|
|
|
|
{
|
|
|
|
// use some sample characters available in the font
|
|
|
|
sal_Unicode aText[8];
|
|
|
|
|
|
|
|
// start just above the PUA used by most symbol fonts
|
|
|
|
sal_uInt32 cNewChar = 0xFF00;
|
|
|
|
#ifdef QUARTZ
|
|
|
|
// on MacOSX there are too many non-presentable symbols above the codepoint 0x0192
|
|
|
|
if( !bOpenSymbol )
|
|
|
|
cNewChar = 0x0192;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
const int nMaxCount = sizeof(aText)/sizeof(*aText) - 1;
|
|
|
|
int nSkip = aFontCharMap.GetCharCount() / nMaxCount;
|
|
|
|
if( nSkip > 10 )
|
|
|
|
nSkip = 10;
|
|
|
|
else if( nSkip <= 0 )
|
|
|
|
nSkip = 1;
|
|
|
|
for( int i = 0; i < nMaxCount; ++i )
|
|
|
|
{
|
|
|
|
sal_uInt32 cOldChar = cNewChar;
|
|
|
|
for( int j = nSkip; --j >= 0; )
|
|
|
|
cNewChar = aFontCharMap.GetPrevChar( cNewChar );
|
|
|
|
if( cOldChar == cNewChar )
|
|
|
|
break;
|
|
|
|
aText[ i ] = static_cast<sal_Unicode>(cNewChar); // TODO: support UCS4 samples
|
|
|
|
aText[ i+1 ] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sSampleText = rtl::OUString(aText);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const sal_Unicode* pText = aImplSymbolFontText;
|
|
|
|
if( bOpenSymbol )
|
|
|
|
pText = aImplStarSymbolText;
|
|
|
|
sSampleText = rtl::OUString(pText);
|
|
|
|
}
|
|
|
|
|
|
|
|
return sSampleText;
|
|
|
|
}
|
|
|
|
|
|
|
|
long shrinkFontToFit(rtl::OUString &rSampleText, long nH, Font &rFont, OutputDevice &rDevice, Rectangle &rTextRect)
|
|
|
|
{
|
|
|
|
long nWidth = 0;
|
|
|
|
|
|
|
|
Size aSize( rFont.GetSize() );
|
|
|
|
|
|
|
|
//Make sure it fits in the available height
|
|
|
|
while (aSize.Height() > 0)
|
|
|
|
{
|
|
|
|
if (!rDevice.GetTextBoundRect(rTextRect, rSampleText, 0, 0))
|
|
|
|
break;
|
|
|
|
if (rTextRect.GetHeight() <= nH)
|
|
|
|
{
|
|
|
|
nWidth = rTextRect.GetWidth();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
aSize.Height() -= EXTRAFONTSIZE;
|
|
|
|
rFont.SetSize(aSize);
|
|
|
|
rDevice.SetFont(rFont);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontNameBox::UserDraw( const UserDrawEvent& rUDEvt )
|
|
|
|
{
|
|
|
|
ImplFontNameListData* pData = mpFontList->GetObject( rUDEvt.GetItemId() );
|
|
|
|
const FontInfo& rInfo = pData->maInfo;
|
|
|
|
USHORT nType = pData->mnType;
|
|
|
|
Point aTopLeft = rUDEvt.GetRect().TopLeft();
|
|
|
|
long nX = aTopLeft.X();
|
|
|
|
long nH = rUDEvt.GetRect().GetHeight();
|
|
|
|
|
|
|
|
if ( mbSymbols )
|
|
|
|
{
|
2011-02-03 14:08:51 +00:00
|
|
|
nX += IMGINNERTEXTSPACE;
|
2000-09-18 16:07:07 +00:00
|
|
|
Image* pImg = NULL;
|
|
|
|
if ( (nType & (FONTLIST_FONTNAMETYPE_PRINTER | FONTLIST_FONTNAMETYPE_SCREEN)) == FONTLIST_FONTNAMETYPE_PRINTER )
|
|
|
|
pImg = &maImagePrinterFont;
|
|
|
|
else if ( nType & FONTLIST_FONTNAMETYPE_SCALABLE )
|
|
|
|
pImg = &maImageScalableFont;
|
|
|
|
else
|
|
|
|
pImg = &maImageBitmapFont;
|
|
|
|
|
|
|
|
if ( pImg )
|
|
|
|
{
|
|
|
|
Point aPos( nX, aTopLeft.Y() + (nH-pImg->GetSizePixel().Height())/2 );
|
|
|
|
rUDEvt.GetDevice()->DrawImage( aPos, *pImg );
|
|
|
|
}
|
|
|
|
|
|
|
|
// X immer um gleiche Breite aendern, auch wenn kein Image ausgegeben.
|
|
|
|
nX += maImagePrinterFont.GetSizePixel().Width();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( mbWYSIWYG && mpFontList )
|
|
|
|
{
|
2011-02-03 14:08:51 +00:00
|
|
|
nX += IMGOUTERTEXTSPACE;
|
2001-07-19 16:20:19 +00:00
|
|
|
|
2011-02-03 13:34:48 +00:00
|
|
|
bool bSymbolFont = (rInfo.GetCharSet() == RTL_TEXTENCODING_SYMBOL)
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("cmsy10")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("cmex10")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("feta26")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("jsMath-cmsy10")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("jsMath-cmex10")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("msam10")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("msbm10")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("wasy10")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("Denemo")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("GlyphBasic1")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("GlyphBasic2")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("GlyphBasic3")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("GlyphBasic4")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("Letters Laughing")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("MusiQwik")
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii("MusiSync");
|
|
|
|
|
2001-07-19 16:20:19 +00:00
|
|
|
// starsymbol is a unicode font, but cannot display its own name
|
2008-04-03 16:13:16 +00:00
|
|
|
const bool bOpenSymbol = rInfo.GetName().EqualsIgnoreCaseAscii( "starsymbol" )
|
|
|
|
|| rInfo.GetName().EqualsIgnoreCaseAscii( "opensymbol" );
|
|
|
|
bSymbolFont |= bOpenSymbol;
|
2001-07-19 16:20:19 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
Color aTextColor = rUDEvt.GetDevice()->GetTextColor();
|
|
|
|
Font aOldFont( rUDEvt.GetDevice()->GetFont() );
|
2001-07-19 16:20:19 +00:00
|
|
|
Size aSize( aOldFont.GetSize() );
|
|
|
|
aSize.Height() += EXTRAFONTSIZE;
|
2000-09-18 16:07:07 +00:00
|
|
|
Font aFont( rInfo );
|
2001-07-19 16:20:19 +00:00
|
|
|
aFont.SetSize( aSize );
|
2000-09-18 16:07:07 +00:00
|
|
|
rUDEvt.GetDevice()->SetFont( aFont );
|
|
|
|
rUDEvt.GetDevice()->SetTextColor( aTextColor );
|
2008-04-03 16:13:16 +00:00
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
bool bUsingCorrectFont = true;
|
|
|
|
Rectangle aTextRect;
|
2001-07-19 16:20:19 +00:00
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
// Preview the font name
|
|
|
|
rtl::OUString sFontName = rInfo.GetName();
|
2008-04-03 16:13:16 +00:00
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
//If it shouldn't or can't draw its own name because it doesn't have the glyphs
|
|
|
|
if (bSymbolFont || (STRING_LEN != rUDEvt.GetDevice()->HasGlyphs(aFont, sFontName)))
|
|
|
|
bUsingCorrectFont = false;
|
|
|
|
else
|
2001-07-19 16:20:19 +00:00
|
|
|
{
|
2011-02-03 14:08:51 +00:00
|
|
|
//Make sure it fits in the available height, shrinking the font if necessary
|
|
|
|
bUsingCorrectFont = shrinkFontToFit(sFontName, nH, aFont, *rUDEvt.GetDevice(), aTextRect) != 0;
|
|
|
|
}
|
2008-04-03 16:13:16 +00:00
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
if (!bUsingCorrectFont)
|
|
|
|
{
|
|
|
|
rUDEvt.GetDevice()->SetFont(aOldFont);
|
|
|
|
rUDEvt.GetDevice()->GetTextBoundRect(aTextRect, sFontName, 0, 0);
|
|
|
|
}
|
2002-11-07 08:03:21 +00:00
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
long nTextHeight = aTextRect.GetHeight();
|
|
|
|
long nDesiredGap = (nH-nTextHeight)/2;
|
|
|
|
long nVertAdjust = nDesiredGap - aTextRect.Top();
|
|
|
|
// long nHortAdjust = 0 - aTextRect.Left();
|
|
|
|
Point aPos( nX, aTopLeft.Y() + nVertAdjust );
|
|
|
|
rUDEvt.GetDevice()->DrawText( aPos, sFontName );
|
|
|
|
Rectangle aHack(aPos.X(), aTopLeft.Y() + nH/2 - 5, aPos.X() + 40, aTopLeft.Y() + nH/2 + 5);
|
|
|
|
long nTextX = aPos.X() + aTextRect.GetWidth();
|
|
|
|
|
|
|
|
if (!bUsingCorrectFont)
|
|
|
|
rUDEvt.GetDevice()->SetFont( aFont );
|
|
|
|
|
|
|
|
rtl::OUString sSampleText;
|
|
|
|
bool bHasSampleTextGlyphs=false;
|
|
|
|
|
2011-02-03 14:16:16 +00:00
|
|
|
//TO-DO: for non-symbol fonts pull GPOS/GSUB features through vcl to
|
|
|
|
//and map to suitable strings for Arabic, Hebrew, etc fonts
|
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
//If we're a symbol font, or for some reason the font still couldn't
|
|
|
|
//render something representative of what it would like to render then
|
|
|
|
//make up some semi-random text that it *can* display
|
|
|
|
if (bSymbolFont || !bUsingCorrectFont)
|
|
|
|
{
|
|
|
|
sSampleText = makeRepresentativeSymbolText(bOpenSymbol, *rUDEvt.GetDevice());
|
|
|
|
bHasSampleTextGlyphs = (STRING_LEN == rUDEvt.GetDevice()->HasGlyphs(aFont, sSampleText));
|
2008-04-03 16:13:16 +00:00
|
|
|
}
|
2011-02-03 14:08:51 +00:00
|
|
|
|
|
|
|
if (sSampleText.getLength() && bHasSampleTextGlyphs)
|
2008-04-03 16:13:16 +00:00
|
|
|
{
|
2011-02-03 14:08:51 +00:00
|
|
|
const Size &rItemSize = rUDEvt.GetDevice()->GetOutputSize();
|
|
|
|
//leave a little border at the edge
|
|
|
|
long nSpace = rItemSize.Width() - nTextX - IMGOUTERTEXTSPACE;
|
|
|
|
if (nSpace >= 0)
|
|
|
|
{
|
|
|
|
//Make sure it fits in the available height, and get how wide that would be
|
|
|
|
long nWidth = shrinkFontToFit(sSampleText, nH, aFont, *rUDEvt.GetDevice(), aTextRect);
|
|
|
|
//Chop letters off until it fits in the available width
|
|
|
|
while (nWidth > nSpace || nWidth > MAXPREVIEWWIDTH)
|
|
|
|
{
|
|
|
|
sSampleText = sSampleText.copy(0, sSampleText.getLength()-1);
|
|
|
|
nWidth = rUDEvt.GetDevice()->GetTextBoundRect(aTextRect, sSampleText, 0, 0) ?
|
|
|
|
aTextRect.GetWidth() : 0;
|
|
|
|
}
|
2002-11-07 08:03:21 +00:00
|
|
|
|
2011-02-03 14:08:51 +00:00
|
|
|
//center the text on the line
|
|
|
|
if (sSampleText.getLength() && nWidth)
|
|
|
|
{
|
|
|
|
nTextHeight = aTextRect.GetHeight();
|
|
|
|
nDesiredGap = (nH-nTextHeight)/2;
|
|
|
|
nVertAdjust = nDesiredGap - aTextRect.Top();
|
|
|
|
aPos = Point(nTextX + nSpace - nWidth, aTopLeft.Y() + nVertAdjust);
|
|
|
|
rUDEvt.GetDevice()->DrawText( aPos, sSampleText );
|
|
|
|
}
|
|
|
|
}
|
2001-07-19 16:20:19 +00:00
|
|
|
}
|
2002-11-07 08:03:21 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
rUDEvt.GetDevice()->SetFont( aOldFont );
|
2001-07-19 16:20:19 +00:00
|
|
|
DrawEntry( rUDEvt, FALSE, FALSE); // draw seperator
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DrawEntry( rUDEvt, TRUE, TRUE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ===================================================================
|
|
|
|
// FontStyleBox
|
|
|
|
// ===================================================================
|
|
|
|
|
|
|
|
FontStyleBox::FontStyleBox( Window* pParent, WinBits nWinStyle ) :
|
|
|
|
ComboBox( pParent, nWinStyle )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
FontStyleBox::FontStyleBox( Window* pParent, const ResId& rResId ) :
|
|
|
|
ComboBox( pParent, rResId )
|
|
|
|
{
|
|
|
|
aLastStyle = GetText();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
FontStyleBox::~FontStyleBox()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontStyleBox::Select()
|
|
|
|
{
|
2001-07-19 16:20:19 +00:00
|
|
|
// keep text over fill operation
|
2000-09-18 16:07:07 +00:00
|
|
|
aLastStyle = GetText();
|
|
|
|
ComboBox::Select();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontStyleBox::LoseFocus()
|
|
|
|
{
|
2001-07-19 16:20:19 +00:00
|
|
|
// keep text over fill operation
|
2000-09-18 16:07:07 +00:00
|
|
|
aLastStyle = GetText();
|
|
|
|
ComboBox::LoseFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontStyleBox::Modify()
|
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
CharClass aChrCls( ::comphelper::getProcessServiceFactory(),
|
2001-07-19 16:20:19 +00:00
|
|
|
GetSettings().GetLocale() );
|
2001-03-09 14:43:51 +00:00
|
|
|
XubString aStr = GetText();
|
|
|
|
USHORT nEntryCount = GetEntryCount();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( GetEntryPos( aStr ) == COMBOBOX_ENTRY_NOTFOUND )
|
|
|
|
{
|
2000-10-22 16:44:39 +00:00
|
|
|
aChrCls.toUpper( aStr );
|
2000-09-18 16:07:07 +00:00
|
|
|
for ( USHORT i = 0; i < nEntryCount; i++ )
|
|
|
|
{
|
|
|
|
XubString aEntryText = GetEntry( i );
|
2000-10-22 16:44:39 +00:00
|
|
|
aChrCls.toUpper( aEntryText );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
if ( aStr == aEntryText )
|
|
|
|
{
|
|
|
|
SetText( GetEntry( i ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ComboBox::Modify();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontStyleBox::Fill( const XubString& rName, const FontList* pList )
|
|
|
|
{
|
2001-07-19 16:20:19 +00:00
|
|
|
// note: this method must call ComboBox::SetText(),
|
|
|
|
// else aLastStyle will overwritten
|
|
|
|
// store prior selection position and clear box
|
2000-09-18 16:07:07 +00:00
|
|
|
XubString aOldText = GetText();
|
2001-03-09 14:43:51 +00:00
|
|
|
USHORT nPos = GetEntryPos( aOldText );
|
2000-09-18 16:07:07 +00:00
|
|
|
Clear();
|
|
|
|
|
2001-07-19 16:20:19 +00:00
|
|
|
// does a font with this name already exist?
|
2000-09-18 16:07:07 +00:00
|
|
|
sal_Handle hFontInfo = pList->GetFirstFontInfo( rName );
|
|
|
|
if ( hFontInfo )
|
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
XubString aStyleText;
|
|
|
|
FontWeight eLastWeight = WEIGHT_DONTKNOW;
|
|
|
|
FontItalic eLastItalic = ITALIC_NONE;
|
|
|
|
FontWidth eLastWidth = WIDTH_DONTKNOW;
|
2000-09-18 16:07:07 +00:00
|
|
|
BOOL bNormal = FALSE;
|
|
|
|
BOOL bItalic = FALSE;
|
|
|
|
BOOL bBold = FALSE;
|
|
|
|
BOOL bBoldItalic = FALSE;
|
2001-03-09 14:43:51 +00:00
|
|
|
BOOL bInsert = FALSE;
|
2000-09-18 16:07:07 +00:00
|
|
|
FontInfo aInfo;
|
|
|
|
while ( hFontInfo )
|
|
|
|
{
|
|
|
|
aInfo = pList->GetFontInfo( hFontInfo );
|
|
|
|
|
|
|
|
FontWeight eWeight = aInfo.GetWeight();
|
|
|
|
FontItalic eItalic = aInfo.GetItalic();
|
2001-03-09 14:43:51 +00:00
|
|
|
FontWidth eWidth = aInfo.GetWidthType();
|
|
|
|
// Only if the attributes are different, we insert the
|
|
|
|
// Font to avoid double Entries in different languages
|
|
|
|
if ( (eWeight != eLastWeight) || (eItalic != eLastItalic) ||
|
|
|
|
(eWidth != eLastWidth) )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( bInsert )
|
|
|
|
InsertEntry( aStyleText );
|
|
|
|
|
|
|
|
if ( eWeight <= WEIGHT_NORMAL )
|
|
|
|
{
|
|
|
|
if ( eItalic != ITALIC_NONE )
|
|
|
|
bItalic = TRUE;
|
|
|
|
else
|
|
|
|
bNormal = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( eItalic != ITALIC_NONE )
|
|
|
|
bBoldItalic = TRUE;
|
|
|
|
else
|
|
|
|
bBold = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// For wrong StyleNames we replace this with the correct once
|
|
|
|
aStyleText = pList->GetStyleName( aInfo );
|
|
|
|
bInsert = GetEntryPos( aStyleText ) == LISTBOX_ENTRY_NOTFOUND;
|
|
|
|
if ( !bInsert )
|
|
|
|
{
|
|
|
|
aStyleText = pList->GetStyleName( eWeight, eItalic );
|
|
|
|
bInsert = GetEntryPos( aStyleText ) == LISTBOX_ENTRY_NOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
eLastWeight = eWeight;
|
|
|
|
eLastItalic = eItalic;
|
|
|
|
eLastWidth = eWidth;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( bInsert )
|
|
|
|
{
|
|
|
|
// If we have two names for the same attributes
|
|
|
|
// we prefer the translated standard names
|
|
|
|
const XubString& rAttrStyleText = pList->GetStyleName( eWeight, eItalic );
|
|
|
|
if ( rAttrStyleText != aStyleText )
|
|
|
|
{
|
|
|
|
XubString aTempStyleText = pList->GetStyleName( aInfo );
|
|
|
|
if ( rAttrStyleText == aTempStyleText )
|
|
|
|
aStyleText = rAttrStyleText;
|
|
|
|
bInsert = GetEntryPos( aStyleText ) == LISTBOX_ENTRY_NOTFOUND;
|
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2001-03-09 14:43:51 +00:00
|
|
|
|
|
|
|
if ( !bItalic && (aStyleText == pList->GetItalicStr()) )
|
2000-09-18 16:07:07 +00:00
|
|
|
bItalic = TRUE;
|
2001-03-09 14:43:51 +00:00
|
|
|
else if ( !bBold && (aStyleText == pList->GetBoldStr()) )
|
2000-09-18 16:07:07 +00:00
|
|
|
bBold = TRUE;
|
2001-03-09 14:43:51 +00:00
|
|
|
else if ( !bBoldItalic && (aStyleText == pList->GetBoldItalicStr()) )
|
2000-09-18 16:07:07 +00:00
|
|
|
bBoldItalic = TRUE;
|
|
|
|
|
|
|
|
hFontInfo = pList->GetNextFontInfo( hFontInfo );
|
|
|
|
}
|
|
|
|
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( bInsert )
|
|
|
|
InsertEntry( aStyleText );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
// Bestimmte Styles als Nachbildung
|
|
|
|
if ( bNormal )
|
|
|
|
{
|
|
|
|
if ( !bItalic )
|
|
|
|
InsertEntry( pList->GetItalicStr() );
|
|
|
|
if ( !bBold )
|
|
|
|
InsertEntry( pList->GetBoldStr() );
|
|
|
|
}
|
|
|
|
if ( !bBoldItalic )
|
|
|
|
{
|
|
|
|
if ( bNormal || bItalic || bBold )
|
|
|
|
InsertEntry( pList->GetBoldItalicStr() );
|
|
|
|
}
|
|
|
|
if ( aOldText.Len() )
|
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( GetEntryPos( aLastStyle ) != LISTBOX_ENTRY_NOTFOUND )
|
2000-09-18 16:07:07 +00:00
|
|
|
ComboBox::SetText( aLastStyle );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( nPos >= GetEntryCount() )
|
|
|
|
ComboBox::SetText( GetEntry( 0 ) );
|
|
|
|
else
|
|
|
|
ComboBox::SetText( GetEntry( nPos ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Wenn Font nicht, dann Standard-Styles einfuegen
|
|
|
|
InsertEntry( pList->GetNormalStr() );
|
|
|
|
InsertEntry( pList->GetItalicStr() );
|
|
|
|
InsertEntry( pList->GetBoldStr() );
|
|
|
|
InsertEntry( pList->GetBoldItalicStr() );
|
|
|
|
if ( aOldText.Len() )
|
|
|
|
{
|
|
|
|
if ( nPos > GetEntryCount() )
|
|
|
|
ComboBox::SetText( GetEntry( 0 ) );
|
|
|
|
else
|
|
|
|
ComboBox::SetText( GetEntry( nPos ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ===================================================================
|
|
|
|
// FontSizeBox
|
|
|
|
// ===================================================================
|
|
|
|
|
|
|
|
FontSizeBox::FontSizeBox( Window* pParent, WinBits nWinSize ) :
|
|
|
|
MetricBox( pParent, nWinSize )
|
|
|
|
{
|
|
|
|
ImplInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FontSizeBox::FontSizeBox( Window* pParent, const ResId& rResId ) :
|
|
|
|
MetricBox( pParent, rResId )
|
|
|
|
{
|
|
|
|
ImplInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
FontSizeBox::~FontSizeBox()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontSizeBox::ImplInit()
|
|
|
|
{
|
|
|
|
EnableAutocomplete( FALSE );
|
|
|
|
|
|
|
|
bRelativeMode = FALSE;
|
|
|
|
bPtRelative = FALSE;
|
|
|
|
bRelative = FALSE;
|
|
|
|
bStdSize = FALSE;
|
|
|
|
pFontList = NULL;
|
|
|
|
|
2001-08-01 18:21:13 +00:00
|
|
|
SetShowTrailingZeros( FALSE );
|
2000-09-18 16:07:07 +00:00
|
|
|
SetDecimalDigits( 1 );
|
|
|
|
SetMin( 20 );
|
|
|
|
SetMax( 9999 );
|
2009-12-18 15:29:59 +01:00
|
|
|
SetProminentEntryType( PROMINENT_MIDDLE );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2001-03-09 14:43:51 +00:00
|
|
|
void FontSizeBox::Reformat()
|
|
|
|
{
|
2007-03-26 10:53:44 +00:00
|
|
|
FontSizeNames aFontSizeNames( GetSettings().GetUILanguage() );
|
|
|
|
if ( !bRelativeMode || !aFontSizeNames.IsEmpty() )
|
2001-03-09 14:43:51 +00:00
|
|
|
{
|
|
|
|
long nNewValue = aFontSizeNames.Name2Size( GetText() );
|
2007-03-26 10:53:44 +00:00
|
|
|
if ( nNewValue)
|
2001-03-09 14:43:51 +00:00
|
|
|
{
|
|
|
|
mnLastValue = nNewValue;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MetricBox::Reformat();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
void FontSizeBox::Modify()
|
|
|
|
{
|
|
|
|
MetricBox::Modify();
|
|
|
|
|
|
|
|
if ( bRelativeMode )
|
|
|
|
{
|
|
|
|
XubString aStr = GetText();
|
|
|
|
aStr.EraseLeadingChars();
|
|
|
|
|
|
|
|
BOOL bNewMode = bRelative;
|
|
|
|
BOOL bOldPtRelMode = bPtRelative;
|
|
|
|
|
|
|
|
if ( bRelative )
|
|
|
|
{
|
|
|
|
bPtRelative = FALSE;
|
|
|
|
const xub_Unicode* pStr = aStr.GetBuffer();
|
|
|
|
while ( *pStr )
|
|
|
|
{
|
|
|
|
if ( ((*pStr < '0') || (*pStr > '9')) && (*pStr != '%') )
|
|
|
|
{
|
|
|
|
if ( ('-' == *pStr || '+' == *pStr) && !bPtRelative )
|
|
|
|
bPtRelative = TRUE;
|
|
|
|
else if ( bPtRelative && 'p' == *pStr && 't' == *++pStr )
|
|
|
|
;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bNewMode = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pStr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( STRING_NOTFOUND != aStr.Search( '%' ) )
|
|
|
|
{
|
|
|
|
bNewMode = TRUE;
|
|
|
|
bPtRelative = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( '-' == aStr.GetChar( 0 ) || '+' == aStr.GetChar( 0 ) )
|
|
|
|
{
|
|
|
|
bNewMode = TRUE;
|
|
|
|
bPtRelative = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( bNewMode != bRelative || bPtRelative != bOldPtRelMode )
|
|
|
|
SetRelative( bNewMode );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-01-23 07:50:49 +00:00
|
|
|
void FontSizeBox::Fill( const FontInfo* pInfo, const FontList* pList )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2000-12-07 15:07:37 +00:00
|
|
|
// remember for relative mode
|
2000-09-18 16:07:07 +00:00
|
|
|
pFontList = pList;
|
|
|
|
|
2000-12-07 15:07:37 +00:00
|
|
|
// no font sizes need to be set for relative mode
|
2000-09-18 16:07:07 +00:00
|
|
|
if ( bRelative )
|
|
|
|
return;
|
|
|
|
|
2000-12-07 15:07:37 +00:00
|
|
|
// query font sizes
|
2001-03-09 14:43:51 +00:00
|
|
|
const long* pTempAry;
|
2007-01-23 07:50:49 +00:00
|
|
|
const long* pAry = 0;
|
|
|
|
|
|
|
|
if( pInfo )
|
|
|
|
{
|
|
|
|
aFontInfo = *pInfo;
|
|
|
|
pAry = pList->GetSizeAry( *pInfo );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pAry = pList->GetStdSizeAry();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2007-03-26 10:53:44 +00:00
|
|
|
// first insert font size names (for simplified/traditional chinese)
|
|
|
|
FontSizeNames aFontSizeNames( GetSettings().GetUILanguage() );
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( pAry == pList->GetStdSizeAry() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
// for standard sizes we don't need to bother
|
2007-03-26 10:53:44 +00:00
|
|
|
if ( bStdSize && GetEntryCount() && aFontSizeNames.IsEmpty() )
|
2000-09-18 16:07:07 +00:00
|
|
|
return;
|
|
|
|
bStdSize = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bStdSize = FALSE;
|
|
|
|
|
2007-03-26 10:53:44 +00:00
|
|
|
Selection aSelection = GetSelection();
|
|
|
|
XubString aStr = GetText();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
Clear();
|
2001-03-09 14:43:51 +00:00
|
|
|
USHORT nPos = 0;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( !aFontSizeNames.IsEmpty() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( pAry == pList->GetStdSizeAry() )
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
|
|
|
// for scalable fonts all font size names
|
2001-03-09 14:43:51 +00:00
|
|
|
ULONG nCount = aFontSizeNames.Count();
|
|
|
|
for( ULONG i = 0; i < nCount; i++ )
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
String aSizeName = aFontSizeNames.GetIndexName( i );
|
|
|
|
long nSize = aFontSizeNames.GetIndexSize( i );
|
|
|
|
ComboBox::InsertEntry( aSizeName, nPos );
|
|
|
|
ComboBox::SetEntryData( nPos, (void*)(-nSize) ); // mark as special
|
|
|
|
nPos++;
|
2000-12-07 15:07:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// for fixed size fonts only selectable font size names
|
2001-03-09 14:43:51 +00:00
|
|
|
pTempAry = pAry;
|
|
|
|
while ( *pTempAry )
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
String aSizeName = aFontSizeNames.Size2Name( *pTempAry );
|
|
|
|
if ( aSizeName.Len() )
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
ComboBox::InsertEntry( aSizeName, nPos );
|
|
|
|
ComboBox::SetEntryData( nPos, (void*)(-(*pTempAry)) ); // mark as special
|
|
|
|
nPos++;
|
2000-12-07 15:07:37 +00:00
|
|
|
}
|
2001-03-09 14:43:51 +00:00
|
|
|
pTempAry++;
|
2000-12-07 15:07:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// then insert numerical font size values
|
2001-03-09 14:43:51 +00:00
|
|
|
pTempAry = pAry;
|
|
|
|
while ( *pTempAry )
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
InsertValue( *pTempAry, FUNIT_NONE, nPos );
|
|
|
|
ComboBox::SetEntryData( nPos, (void*)(*pTempAry) );
|
|
|
|
nPos++;
|
|
|
|
pTempAry++;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetText( aStr );
|
|
|
|
SetSelection( aSelection );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontSizeBox::EnableRelativeMode( USHORT nMin, USHORT nMax, USHORT nStep )
|
|
|
|
{
|
|
|
|
bRelativeMode = TRUE;
|
|
|
|
nRelMin = nMin;
|
|
|
|
nRelMax = nMax;
|
|
|
|
nRelStep = nStep;
|
|
|
|
SetUnit( FUNIT_POINT );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontSizeBox::EnablePtRelativeMode( short nMin, short nMax, short nStep )
|
|
|
|
{
|
|
|
|
bRelativeMode = TRUE;
|
|
|
|
nPtRelMin = nMin;
|
|
|
|
nPtRelMax = nMax;
|
|
|
|
nPtRelStep = nStep;
|
|
|
|
SetUnit( FUNIT_POINT );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FontSizeBox::SetRelative( BOOL bNewRelative )
|
|
|
|
{
|
|
|
|
if ( bRelativeMode )
|
|
|
|
{
|
|
|
|
Selection aSelection = GetSelection();
|
|
|
|
XubString aStr = GetText();
|
|
|
|
aStr.EraseLeadingChars();
|
|
|
|
|
|
|
|
if ( bNewRelative )
|
|
|
|
{
|
|
|
|
bRelative = TRUE;
|
|
|
|
bStdSize = FALSE;
|
|
|
|
|
|
|
|
if ( bPtRelative )
|
|
|
|
{
|
|
|
|
SetDecimalDigits( 1 );
|
|
|
|
SetMin( nPtRelMin );
|
|
|
|
SetMax( nPtRelMax );
|
|
|
|
SetUnit( FUNIT_POINT );
|
|
|
|
|
|
|
|
Clear();
|
2001-07-19 16:20:19 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
short i = nPtRelMin, n = 0;
|
2000-12-07 15:07:37 +00:00
|
|
|
// JP 30.06.98: more than 100 values are not useful
|
2000-09-18 16:07:07 +00:00
|
|
|
while ( i <= nPtRelMax && n++ < 100 )
|
|
|
|
{
|
|
|
|
InsertValue( i );
|
2006-10-12 14:11:29 +00:00
|
|
|
i = i + nPtRelStep;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetDecimalDigits( 0 );
|
|
|
|
SetMin( nRelMin );
|
|
|
|
SetMax( nRelMax );
|
|
|
|
SetCustomUnitText( '%' );
|
|
|
|
SetUnit( FUNIT_CUSTOM );
|
|
|
|
|
|
|
|
Clear();
|
|
|
|
USHORT i = nRelMin;
|
|
|
|
while ( i <= nRelMax )
|
|
|
|
{
|
|
|
|
InsertValue( i );
|
2006-10-12 14:11:29 +00:00
|
|
|
i = i + nRelStep;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bRelative = bPtRelative = FALSE;
|
|
|
|
SetDecimalDigits( 1 );
|
|
|
|
SetMin( 20 );
|
|
|
|
SetMax( 9999 );
|
|
|
|
SetUnit( FUNIT_POINT );
|
|
|
|
if ( pFontList )
|
2007-01-23 07:50:49 +00:00
|
|
|
Fill( &aFontInfo, pFontList );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetText( aStr );
|
|
|
|
SetSelection( aSelection );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-01-23 10:44:29 +00:00
|
|
|
XubString FontSizeBox::CreateFieldText( sal_Int64 nValue ) const
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
XubString sRet( MetricBox::CreateFieldText( nValue ) );
|
|
|
|
if ( bRelativeMode && bPtRelative && (0 <= nValue) && sRet.Len() )
|
|
|
|
sRet.Insert( '+', 0 );
|
|
|
|
return sRet;
|
|
|
|
}
|
2000-12-07 15:07:37 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-01-23 10:44:29 +00:00
|
|
|
void FontSizeBox::SetValue( sal_Int64 nNewValue, FieldUnit eInUnit )
|
2001-03-09 14:43:51 +00:00
|
|
|
{
|
|
|
|
if ( !bRelative )
|
|
|
|
{
|
2007-01-23 10:44:29 +00:00
|
|
|
sal_Int64 nTempValue = MetricField::ConvertValue( nNewValue, GetBaseValue(), GetDecimalDigits(), eInUnit, GetUnit() );
|
2001-08-01 18:21:13 +00:00
|
|
|
FontSizeNames aFontSizeNames( GetSettings().GetUILanguage() );
|
2007-01-23 10:44:29 +00:00
|
|
|
// conversion loses precision; however font sizes should
|
|
|
|
// never have a problem with that
|
|
|
|
String aName = aFontSizeNames.Size2Name( static_cast<long>(nTempValue) );
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( aName.Len() && (GetEntryPos( aName ) != LISTBOX_ENTRY_NOTFOUND) )
|
|
|
|
{
|
|
|
|
mnLastValue = nTempValue;
|
|
|
|
SetText( aName );
|
|
|
|
mnFieldValue = mnLastValue;
|
|
|
|
SetEmptyFieldValueData( FALSE );
|
2007-03-26 10:53:44 +00:00
|
|
|
return;
|
2001-03-09 14:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MetricBox::SetValue( nNewValue, eInUnit );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-01-23 10:44:29 +00:00
|
|
|
void FontSizeBox::SetValue( sal_Int64 nNewValue )
|
2001-03-09 14:43:51 +00:00
|
|
|
{
|
|
|
|
SetValue( nNewValue, FUNIT_NONE );
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-01-23 10:44:29 +00:00
|
|
|
sal_Int64 FontSizeBox::GetValue( USHORT nPos, FieldUnit eOutUnit ) const
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( !bRelative )
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
2007-01-23 10:44:29 +00:00
|
|
|
sal_Int64 nComboVal = static_cast<sal_Int64>(reinterpret_cast<long>(ComboBox::GetEntryData( nPos )));
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( nComboVal < 0 ) // marked as special?
|
|
|
|
{
|
2007-01-23 10:44:29 +00:00
|
|
|
return MetricField::ConvertValue( -nComboVal, mnBaseValue, GetDecimalDigits(),
|
|
|
|
meUnit, eOutUnit );
|
2001-03-09 14:43:51 +00:00
|
|
|
}
|
2000-12-07 15:07:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// do normal font size processing
|
2007-01-23 10:44:29 +00:00
|
|
|
sal_Int64 nRetValue = MetricBox::GetValue( nPos, eOutUnit );
|
2000-12-07 15:07:37 +00:00
|
|
|
return nRetValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-01-23 10:44:29 +00:00
|
|
|
sal_Int64 FontSizeBox::GetValue( FieldUnit eOutUnit ) const
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( !bRelative )
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
2001-08-01 18:21:13 +00:00
|
|
|
FontSizeNames aFontSizeNames( GetSettings().GetUILanguage() );
|
2007-01-23 10:44:29 +00:00
|
|
|
sal_Int64 nValue = aFontSizeNames.Name2Size( GetText() );
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( nValue)
|
|
|
|
return MetricField::ConvertValue( nValue, GetBaseValue(), GetDecimalDigits(), GetUnit(), eOutUnit );
|
2000-12-07 15:07:37 +00:00
|
|
|
}
|
|
|
|
|
2001-03-09 14:43:51 +00:00
|
|
|
return MetricBox::GetValue( eOutUnit );
|
2000-12-07 15:07:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
2007-01-23 10:44:29 +00:00
|
|
|
sal_Int64 FontSizeBox::GetValue() const
|
2000-12-07 15:07:37 +00:00
|
|
|
{
|
2001-07-19 16:20:19 +00:00
|
|
|
// implementation not inline, because it is a virtual function
|
2001-03-09 14:43:51 +00:00
|
|
|
return GetValue( FUNIT_NONE );
|
2000-12-07 15:07:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
2001-03-09 14:43:51 +00:00
|
|
|
|
2007-01-23 10:44:29 +00:00
|
|
|
void FontSizeBox::SetUserValue( sal_Int64 nNewValue, FieldUnit eInUnit )
|
2001-03-09 14:43:51 +00:00
|
|
|
{
|
|
|
|
if ( !bRelative )
|
|
|
|
{
|
2007-01-23 10:44:29 +00:00
|
|
|
sal_Int64 nTempValue = MetricField::ConvertValue( nNewValue, GetBaseValue(), GetDecimalDigits(), eInUnit, GetUnit() );
|
2001-08-01 18:21:13 +00:00
|
|
|
FontSizeNames aFontSizeNames( GetSettings().GetUILanguage() );
|
2007-01-23 10:44:29 +00:00
|
|
|
// conversion loses precision
|
|
|
|
// however font sizes should never have a problem with that
|
|
|
|
String aName = aFontSizeNames.Size2Name( static_cast<long>(nTempValue) );
|
2001-03-09 14:43:51 +00:00
|
|
|
if ( aName.Len() && (GetEntryPos( aName ) != LISTBOX_ENTRY_NOTFOUND) )
|
|
|
|
{
|
|
|
|
mnLastValue = nTempValue;
|
|
|
|
SetText( aName );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MetricBox::SetUserValue( nNewValue, eInUnit );
|
|
|
|
}
|
2006-05-04 13:25:27 +00:00
|
|
|
|
2010-10-14 08:27:31 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|