diff options
Diffstat (limited to 'svtools/source/control/ruler.cxx')
-rw-r--r--[-rwxr-xr-x] | svtools/source/control/ruler.cxx | 77 |
1 files changed, 66 insertions, 11 deletions
diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index 1c5b95460232..51e4fed41eb1 100755..100644 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -80,7 +81,9 @@ #define RULER_UNIT_MILE 6 #define RULER_UNIT_POINT 7 #define RULER_UNIT_PICA 8 -#define RULER_UNIT_COUNT 9 +#define RULER_UNIT_CHAR 9 +#define RULER_UNIT_LINE 10 +#define RULER_UNIT_COUNT 11 // ----------------- // - ImplRulerData - @@ -144,7 +147,9 @@ static ImplRulerUnitData aImplRulerUnitTab[RULER_UNIT_COUNT] = { MAP_100TH_INCH, 1200, 120, 600, 1200, 30480, 3, "'" }, // FOOT { MAP_10TH_INCH, 633600, 63360, 316800, 633600, 1609344, 4, " miles" }, // MILE { MAP_POINT, 1, 12, 12, 36, 353, 2, " pt" }, // POINT -{ MAP_100TH_MM, 423, 423, 423, 846, 423, 3, " pi" } // PICA +{ MAP_100TH_MM, 423, 423, 423, 846, 423, 3, " pi" }, // PICA +{ MAP_100TH_MM, 371, 371, 371, 743, 371, 3, " ch" }, // CHAR +{ MAP_100TH_MM, 551, 551, 551, 1102, 551, 3, " li" } // LINE }; // ======================================================================= @@ -187,6 +192,9 @@ ImplRulerData::~ImplRulerData() ImplRulerData& ImplRulerData::operator=( const ImplRulerData& rData ) { + if( this == &rData ) + return *this; + delete[] pLines; delete[] pArrows; delete[] pBorders; @@ -263,6 +271,8 @@ void Ruler::ImplInit( WinBits nWinBits ) mnExtraStyle = 0; // Style des Extra-Feldes mnExtraClicks = 0; // Click-Anzahl fuer Extra-Feld mnExtraModifier = 0; // Modifier-Tasten beim Click im Extrafeld + mnCharWidth = 371; + mnLineHeight = 551; mbCalc = sal_True; // Muessen Pagebreiten neu berechnet werden mbFormat = sal_True; // Muss neu ausgegeben werden mbDrag = sal_False; // Sind wir im Drag-Modus @@ -458,7 +468,6 @@ void Ruler::ImplInvertLines( sal_Bool bErase ) void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter ) { long n = 0; - long nTick = 0; long nTick3 = aImplRulerUnitTab[mnUnitIndex].nTick3; long nTickCount = aImplRulerUnitTab[mnUnitIndex].nTick1; Size aPixSize = maVirDev.LogicToPixel( Size( nTick3, nTick3 ), maMapMode ); @@ -467,6 +476,29 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter ) long nY; sal_Bool bNoTicks = sal_False; + //Amelia + long nTickUnit = 0; + long nTick2 = 0; + if ( mnUnitIndex == RULER_UNIT_CHAR ) + { + if ( mnCharWidth == 0 ) + mnCharWidth = 371; + nTick3 = mnCharWidth*2; + nTickCount = mnCharWidth; + nTickUnit = mnCharWidth; + nTick2 = mnCharWidth; + } + else if ( mnUnitIndex == RULER_UNIT_LINE ) + { + if ( mnLineHeight == 0 ) + mnLineHeight = 551; + nTick3 = mnLineHeight*2; + nTickCount = mnLineHeight; + nTickUnit = mnLineHeight; + nTick2 = mnLineHeight; + } + aPixSize = maVirDev.LogicToPixel( Size( nTick3, nTick3 ), maMapMode ); + // Groessenvorberechnung // Sizes calculation sal_Bool bVertRight = sal_False; @@ -488,10 +520,13 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter ) long nMaxWidth = maVirDev.PixelToLogic( Size( mpData->nPageWidth, 0 ), maMapMode ).Width(); if ( nMaxWidth < 0 ) nMaxWidth = -nMaxWidth; - nMaxWidth /= aImplRulerUnitTab[mnUnitIndex].nTickUnit; + // Amelia + if (( mnUnitIndex == RULER_UNIT_CHAR ) || ( mnUnitIndex == RULER_UNIT_LINE )) + nMaxWidth /= nTickUnit; + else + nMaxWidth /= aImplRulerUnitTab[mnUnitIndex].nTickUnit; UniString aNumStr( UniString::CreateFromInt32( nMaxWidth ) ); long nTxtWidth = GetTextWidth( aNumStr ); - const long nTextOff = 4; if ( nTickWidth < nTxtWidth+nTextOff ) { @@ -536,6 +571,7 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter ) { long nTxtWidth2; long nTxtHeight2 = GetTextHeight()/2; + long nTick = 0; while ( ((nStart-n) >= nMin) || ((nStart+n) <= nMax) ) { // Null-Punkt @@ -569,7 +605,11 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter ) // Tick3 - Output (Text) if ( !(nTick % nTick3) ) { - aNumStr = UniString::CreateFromInt32( nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit ); + //aNumStr = UniString::CreateFromInt32( nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit ); + if ( ( mnUnitIndex == RULER_UNIT_CHAR ) || ( mnUnitIndex == RULER_UNIT_LINE ) ) + aNumStr = UniString::CreateFromInt32( nTick / nTickUnit ); + else + aNumStr = UniString::CreateFromInt32( nTick / aImplRulerUnitTab[mnUnitIndex].nTickUnit ); nTxtWidth2 = GetTextWidth( aNumStr )/2; nX = nStart+n; @@ -598,7 +638,10 @@ void Ruler::ImplDrawTicks( long nMin, long nMax, long nStart, long nCenter ) // Tick/Tick2 - Output (Strokes) else { - if ( !(nTick % aImplRulerUnitTab[mnUnitIndex].nTick2) ) + /// Amelia + if ( ( mnUnitIndex != RULER_UNIT_CHAR ) && ( mnUnitIndex != RULER_UNIT_LINE ) ) + nTick2 = aImplRulerUnitTab[mnUnitIndex].nTick2; + if ( !(nTick % nTick2 ) ) nTickWidth = RULER_TICK2_WIDTH; else nTickWidth = RULER_TICK1_WIDTH; @@ -1262,7 +1305,7 @@ void Ruler::ImplFormat() Size aVirDevSize; sal_Bool b3DLook = !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO); - // VirtualDevice initialize + // initialize VirtualDevice if ( mnWinStyle & WB_HORZ ) { aVirDevSize.Width() = mnVirWidth; @@ -2808,6 +2851,12 @@ void Ruler::SetUnit( FieldUnit eNewUnit ) case FUNIT_PICA: mnUnitIndex = RULER_UNIT_PICA; break; + case FUNIT_CHAR: + mnUnitIndex = RULER_UNIT_CHAR; + break; + case FUNIT_LINE: + mnUnitIndex = RULER_UNIT_LINE; + break; default: #ifdef DBG_UTIL DBG_ERRORFILE( "Ruler::SetUnit() - Wrong Unit" ); @@ -3154,9 +3203,7 @@ void Ruler::DrawTab( OutputDevice* pDevice, const Point& rPos, sal_uInt16 nStyle ImplDrawRulerTab( pDevice, aPos, nTabStyle, nStyle ); pDevice->Pop(); } -/* -----------------16.10.2002 15:17----------------- - * - * --------------------------------------------------*/ + void Ruler::SetTextRTL(sal_Bool bRTL) { if(mpData->bTextRTL != bRTL) @@ -3183,3 +3230,11 @@ const RulerBorder* Ruler::GetBorders() const { return mpData->pBorders; } sal_uInt16 Ruler::GetIndentCount() const { return mpData->nIndents; } const RulerIndent* Ruler::GetIndents() const { return mpData->pIndents; } + +void Ruler::DrawTicks() +{ + mbFormat = sal_True; + ImplDraw(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |