Files
libreoffice/sw/source/ui/config/viewopt.cxx

650 lines
20 KiB
C++
Raw Normal View History

2000-09-18 16:15:01 +00:00
/*************************************************************************
*
* $RCSfile: viewopt.cxx,v $
*
2002-04-12 09:39:11 +00:00
* $Revision: 1.5 $
2000-09-18 16:15:01 +00:00
*
2002-04-12 09:39:11 +00:00
* last change: $Author: os $ $Date: 2002-04-12 10:37:11 $
2000-09-18 16:15:01 +00:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifdef PRECOMPILED
#include "ui_pch.hxx"
#endif
#pragma hdrstop
#ifndef _OFF_APP_HXX //autogen
#include <offmgr/app.hxx>
#endif
#ifndef _SVX_HTMLMODE_HXX //autogen
#include <svx/htmlmode.hxx>
#endif
#ifndef _OFA_HTMLCFG_HXX //autogen
#include <offmgr/htmlcfg.hxx>
#endif
#ifndef _SVX_SVXIDS_HRC //autogen
#include <svx/svxids.hrc>
#endif
#ifndef _SVX_SVXENUM_HXX //autogen
#include <svx/svxenum.hxx>
#endif
#ifndef _MySVXACORR_HXX //autogen
#include <svx/svxacorr.hxx>
#endif
2000-11-20 08:07:00 +00:00
#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX
#include <unotools/localedatawrapper.hxx>
#endif
2001-07-05 12:48:54 +00:00
#ifndef _REGION_HXX //autogen
#include <vcl/region.hxx>
#endif
#ifndef _OUTDEV_HXX //autogen
#include <vcl/outdev.hxx>
#endif
#ifndef _WINDOW_HXX //autogen
#include <vcl/window.hxx>
#endif
2002-04-12 09:39:11 +00:00
#ifndef _SWMODULE_HXX //autogen
#include <swmodule.hxx>
#endif
2000-11-20 08:07:00 +00:00
#ifndef _SWTYPES_HXX
#include <swtypes.hxx>
#endif
#ifndef _VIEWOPT_HXX
#include <viewopt.hxx>
#endif
#ifndef _WDOCSH_HXX
#include <wdocsh.hxx>
#endif
#ifndef _SWRECT_HXX
#include <swrect.hxx>
#endif
#ifndef _CRSTATE_HXX
#include <crstate.hxx>
#endif
2000-09-18 16:15:01 +00:00
#ifndef PRODUCT
BOOL SwViewOption::bTest9 = FALSE; //DrawingLayerNotLoading
#endif
2002-04-12 09:39:11 +00:00
Color SwViewOption::aSpellColor(COL_LIGHTRED);
2000-09-18 16:15:01 +00:00
USHORT SwViewOption::nPixelTwips = 0; //ein Pixel auf dem Bildschirm
#define LINEBREAK_SIZE 12, 8
#define TAB_SIZE 12, 6
#define MIN_BLANKWIDTH 40
#define MIN_BLANKHEIGHT 40
#define MIN_TABWIDTH 120
#define MIN_TABHEIGHT 200
static const char __FAR_DATA aPostItStr[] = " ";
/*************************************************************************
* SwViewOption::IsEqualFlags()
*************************************************************************/
BOOL SwViewOption::IsEqualFlags( const SwViewOption &rOpt ) const
{
return nCoreOptions == rOpt.nCoreOptions
&& nCore2Options == rOpt.nCore2Options
&& aSnapSize == rOpt.aSnapSize
&& nDivisionX == rOpt.GetDivisionX()
&& nDivisionY == rOpt.GetDivisionY()
&& nPagePrevRow == rOpt.GetPagePrevRow()
&& nPagePrevCol == rOpt.GetPagePrevCol()
&& aRetoucheColor == rOpt.GetRetoucheColor()
#ifndef PRODUCT
// korrespondieren zu den Angaben in ui/config/cfgvw.src
&& bTest1 == rOpt.IsTest1()
&& bTest2 == rOpt.IsTest2()
&& bTest3 == rOpt.IsTest3()
&& bTest4 == rOpt.IsTest4()
&& bTest5 == rOpt.IsTest5()
&& bTest6 == rOpt.IsTest6()
&& bTest7 == rOpt.IsTest7()
&& bTest8 == rOpt.IsTest8()
&& bTest10 == rOpt.IsTest10()
#endif
;
}
/*************************************************************************
* class SwPxlToTwips
*************************************************************************/
class SwPxlToTwips
{
OutputDevice *pOut;
Color aLineColor;
BOOL bClip;
Region aClip;
Point aStart;
SwRect aRect;
public:
SwPxlToTwips( OutputDevice *pOut, const SwRect &rRect, const Size &rSize );
~SwPxlToTwips();
inline const Point &GetStartPoint() const { return aStart; }
inline BOOL IsTooSmall() const {return 0 == pOut;}
inline const SwRect &GetRect() const { return aRect; }
void DrawLine( const Point &rStart, const Point &rEnd );
};
/*************************************************************************
* SwPxlToTwips::CTOR
*************************************************************************/
SwPxlToTwips::SwPxlToTwips( OutputDevice *pOutDev,
const SwRect &rRect, const Size &rSize )
: pOut( pOutDev )
{
aRect = pOut->LogicToPixel( rRect.SVRect() );
// Wenn der Tab nicht mehr darstellbar ist, geben wir auf.
if( 3 > aRect.Width() )
{
pOut = NULL;
return;
}
if( rSize.Height() - 1 > aRect.Height() )
{
pOut = NULL;
return;
}
aStart = aRect.Pos();
aStart.X() += (aRect.Width() / 2) - (rSize.Width() / 2);
aStart.Y() += (aRect.Height() / 2) - (rSize.Height() / 2);
if ( aStart.X() < aRect.Left() )
aStart.X() = aRect.Left();
if ( pOut->GetConnectMetaFile() )
pOut->Push();
bClip = pOut->IsClipRegion();
if ( bClip )
{
aClip = pOut->GetClipRegion();
pOut->SetClipRegion();
}
aLineColor = pOut->GetLineColor( );
pOut->SetLineColor( Color(COL_BLACK) );
}
/*************************************************************************
* SwPxlToTwips::DTOR
*************************************************************************/
SwPxlToTwips::~SwPxlToTwips()
{
if( pOut )
{
if ( pOut->GetConnectMetaFile() )
pOut->Pop();
else
{
pOut->SetLineColor( aLineColor );
if( bClip )
pOut->SetClipRegion( aClip );
}
}
}
/*************************************************************************
* SwPxlToTwips::DrawLine
*************************************************************************/
void SwPxlToTwips::DrawLine( const Point &rStart, const Point &rEnd )
{
if( pOut )
{
const Point aStart( pOut->PixelToLogic( rStart ) );
const Point aEnd( pOut->PixelToLogic( rEnd ) );
pOut->DrawLine( aStart, aEnd );
}
}
/*************************************************************************
* SwViewOption::DrawRect()
*************************************************************************/
void SwViewOption::DrawRect( OutputDevice *pOut,
const SwRect &rRect, long nCol ) const
{
if ( pOut->GetOutDevType() != OUTDEV_PRINTER )
{
const Color aCol( nCol );
const Color aOldColor( pOut->GetFillColor() );
pOut->SetFillColor( aCol );
pOut->DrawRect( rRect.SVRect() );
pOut->SetFillColor( aOldColor );
}
else
DrawRectPrinter( pOut, rRect );
}
/*************************************************************************
* SwViewOption::DrawRectPrinter()
*************************************************************************/
void SwViewOption::DrawRectPrinter( OutputDevice *pOut,
const SwRect &rRect ) const
{
Color aOldColor(pOut->GetLineColor());
Color aOldFillColor( pOut->GetFillColor() );
pOut->SetLineColor( Color(COL_BLACK) );
pOut->SetFillColor( Color(COL_TRANSPARENT ));
pOut->DrawRect( rRect.SVRect() );
pOut->SetFillColor( aOldFillColor );
pOut->SetLineColor( aOldColor );
}
/*************************************************************************
* SwViewOption::PaintTab()
*************************************************************************/
void SwViewOption::PaintTab( OutputDevice *pOut, const SwRect &rRect ) const
{
SwPxlToTwips aSave( pOut, rRect, Size( TAB_SIZE ) );
if( aSave.IsTooSmall() )
return;
Point aStart( aSave.GetStartPoint() );
const SwRect &rPaintRect = aSave.GetRect();
// horizontale
aStart.Y() += 2;
aStart.X() += 1;
Point aEnd( aStart );
aEnd.X() += 10;
if( aEnd.X() >= rPaintRect.Right() )
aEnd.X() = rPaintRect.Right() - 1;
long nDiff = aEnd.X() - aStart.X();
aSave.DrawLine( aStart, aEnd );
// Pfeil
aEnd.X() -= 1;
aStart.X() = aEnd.X();
aStart.Y() -= 1;
aEnd.Y() += 1;
aSave.DrawLine( aStart, aEnd );
if( nDiff > 1 && rPaintRect.Height() > 8 )
{
aStart.X() -= 1;
aStart.Y() -= 1;
aEnd.X() = aStart.X();
aEnd.Y() += 1;
aSave.DrawLine( aStart, aEnd );
if( nDiff > 2 && rPaintRect.Height() > 12 )
{
aStart.X() -= 1;
aEnd.X() -= 1;
aSave.DrawLine( aStart, aEnd );
}
}
}
/*************************************************************************
* SwViewOption::GetLineBreakWidth()
*************************************************************************/
USHORT SwViewOption::GetLineBreakWidth( const OutputDevice *pOut ) const
{
ASSERT( pOut, "no Outdev" );
const Size aSz( LINEBREAK_SIZE );
return USHORT(pOut->PixelToLogic( aSz ).Width());
}
/*************************************************************************
* SwViewOption::PaintLineBreak()
*************************************************************************/
void SwViewOption::PaintLineBreak( OutputDevice *pOut, const SwRect &rRect ) const
{
const Size aSz( LINEBREAK_SIZE );
SwPxlToTwips aSave( pOut, rRect, aSz );
if( aSave.IsTooSmall() )
return;
Point aStart( aSave.GetStartPoint() );
const SwRect &rPaintRect = aSave.GetRect();
// horizontale
aStart.Y() += 4;
aStart.X() += 1;
Point aEnd( aStart );
aEnd.X() += 8;
if( aEnd.X() >= rPaintRect.Right() - 1 )
aEnd.X() = rPaintRect.Right() - 2;
aSave.DrawLine( aStart, aEnd );
// Pfeil
aStart.Y() -= 1;
aStart.X() += 1;
aEnd.Y() = aStart.Y() + 2;
aEnd.X() = aStart.X();
aSave.DrawLine( aStart, aEnd );
// Pfeil
aStart.Y() -= 1;
aStart.X() += 1;
aEnd.Y() += 1;
aEnd.X() += 1;
aSave.DrawLine( aStart, aEnd );
// Pfeil
aStart.X() += 1;
aEnd.X() += 1;
aSave.DrawLine( aStart, aEnd );
// vertikale
aStart.Y() -= 2;
aStart.X() += 6;
if( aStart.X() >= rPaintRect.Right() )
aStart.X() = rPaintRect.Right() - 1;
aEnd.X() = aStart.X();
aEnd.Y() = aStart.Y() + 3;
aSave.DrawLine( aStart, aEnd );
}
/*************************************************************************
* SwViewOption::GetPostItsWidth()
*************************************************************************/
USHORT SwViewOption::GetPostItsWidth( const OutputDevice *pOut ) const
{
ASSERT( pOut, "no Outdev" );
return USHORT(pOut->GetTextWidth( String::CreateFromAscii(aPostItStr )));
}
/*************************************************************************
* SwViewOption::PaintPostIts()
*************************************************************************/
void SwViewOption::PaintPostIts( OutputDevice *pOut, const SwRect &rRect,
2002-04-12 09:39:11 +00:00
sal_Bool bIsScript ) const
2000-09-18 16:15:01 +00:00
{
if( pOut )
{
Color aOldLineColor( pOut->GetLineColor() );
pOut->SetLineColor( Color(COL_GRAY ) );
// Wir ziehen ueberall zwei Pixel ab, damit es schick aussieht
USHORT nPix = GetPixelTwips() * 2;
if( rRect.Width() <= 2 * nPix || rRect.Height() <= 2 * nPix )
nPix = 0;
const Point aTopLeft( rRect.Left() + nPix, rRect.Top() + nPix );
const Point aBotRight( rRect.Right() - nPix, rRect.Bottom() - nPix );
const SwRect aRect( aTopLeft, aBotRight );
2002-04-12 09:39:11 +00:00
sal_Int32 nColor = bIsScript ? COL_LIGHTGREEN : COL_YELLOW;
DrawRect( pOut, aRect, nColor );
2000-09-18 16:15:01 +00:00
pOut->SetLineColor( aOldLineColor );
}
}
/*************************************************************************
|*
|* ViewOption::ViewOption()
|*
|* Letzte Aenderung MA 04. Aug. 93
|*
|*************************************************************************/
SwViewOption::SwViewOption() :
nZoom( 100 ),
nPagePrevRow( 1 ),
nPagePrevCol( 2 ),
eZoom( 0 ),
nTblDest(TBL_DEST_CELL),
bReadonly(FALSE),
aRetoucheColor( COL_TRANSPARENT ),
aShdwCrsrCol( COL_BLUE ),
aIdxBackgrndCol( COL_LIGHTGRAY ),
nShdwCrsrFillMode( FILL_TAB ),
bStarOneSetting(FALSE)
{
// Initialisierung ist jetzt etwas einfacher
// alle Bits auf 0
nCoreOptions = VIEWOPT_1_IDLE | VIEWOPT_1_HARDBLANK | VIEWOPT_1_SOFTHYPH |
VIEWOPT_1_TOX | VIEWOPT_1_REF | VIEWOPT_1_FIELD |
VIEWOPT_1_FOOTNOTE | VIEWOPT_1_SUBSLINES | VIEWOPT_1_GRAPHIC |
VIEWOPT_1_TABLE | VIEWOPT_1_DRAW | VIEWOPT_1_CONTROL |
VIEWOPT_1_SUBSTABLE| VIEWOPT_1_PAGEBACK |
VIEWOPT_1_SOLIDMARKHDL | VIEWOPT_1_POSTITS;
nCore2Options = VIEWOPT_CORE2_BLACKFONT | VIEWOPT_CORE2_HIDDENPARA|
VIEWOPT_CORE2_INDEX_BACKGROUND | VIEWOPT_CORE2_SECTION_BOUNDS;
nUIOptions = VIEWOPT_2_MODIFIED | VIEWOPT_2_EXECHYPERLINKS;
2000-11-20 08:07:00 +00:00
if(MEASURE_METRIC != GetAppLocaleData().getMeasurementSystemEnum())
2000-09-18 16:15:01 +00:00
aSnapSize.Width() = aSnapSize.Height() = 720; // 1/2"
else
aSnapSize.Width() = aSnapSize.Height() = 567; // 1 cm
nDivisionX = nDivisionY = 1;
#ifndef PRODUCT
// korrespondieren zu den Angaben in ui/config/cfgvw.src
bTest1 = bTest2 = bTest3 = bTest4 =
bTest5 = bTest6 = bTest7 = bTest8 = bTest10 = FALSE;
#endif
}
SwViewOption::SwViewOption(const SwViewOption& rVOpt)
{
bReadonly = FALSE;
nZoom = rVOpt.nZoom ;
aSnapSize = rVOpt.aSnapSize ;
nDivisionX = rVOpt.nDivisionX ;
nDivisionY = rVOpt.nDivisionY ;
nPagePrevRow = rVOpt.nPagePrevRow;
nPagePrevCol = rVOpt.nPagePrevCol;
eZoom = rVOpt.eZoom ;
nTblDest = rVOpt.nTblDest ;
nUIOptions = rVOpt.nUIOptions ;
nCoreOptions = rVOpt.nCoreOptions ;
nCore2Options = rVOpt.nCore2Options ;
aRetoucheColor = rVOpt.GetRetoucheColor();
sSymbolFont = rVOpt.sSymbolFont;
aShdwCrsrCol = rVOpt.aShdwCrsrCol;
aIdxBackgrndCol = rVOpt.aIdxBackgrndCol;
nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
bStarOneSetting = rVOpt.bStarOneSetting;
#ifndef PRODUCT
bTest1 = rVOpt.bTest1 ;
bTest2 = rVOpt.bTest2 ;
bTest3 = rVOpt.bTest3 ;
bTest4 = rVOpt.bTest4 ;
bTest5 = rVOpt.bTest5 ;
bTest6 = rVOpt.bTest6 ;
bTest7 = rVOpt.bTest7 ;
bTest8 = rVOpt.bTest8 ;
bTest10 = rVOpt.bTest10 ;
#endif
}
SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt )
{
nZoom = rVOpt.nZoom ;
aSnapSize = rVOpt.aSnapSize ;
nDivisionX = rVOpt.nDivisionX ;
nDivisionY = rVOpt.nDivisionY ;
nPagePrevRow = rVOpt.nPagePrevRow;
nPagePrevCol = rVOpt.nPagePrevCol;
eZoom = rVOpt.eZoom ;
nTblDest = rVOpt.nTblDest ;
nUIOptions = rVOpt.nUIOptions ;
nCoreOptions = rVOpt.nCoreOptions;
nCore2Options = rVOpt.nCore2Options;
aRetoucheColor = rVOpt.GetRetoucheColor();
sSymbolFont = rVOpt.sSymbolFont;
aShdwCrsrCol = rVOpt.aShdwCrsrCol;
aIdxBackgrndCol = rVOpt.aIdxBackgrndCol;
nShdwCrsrFillMode = rVOpt.nShdwCrsrFillMode;
bStarOneSetting = rVOpt.bStarOneSetting;
#ifndef PRODUCT
bTest1 = rVOpt.bTest1 ;
bTest2 = rVOpt.bTest2 ;
bTest3 = rVOpt.bTest3 ;
bTest4 = rVOpt.bTest4 ;
bTest5 = rVOpt.bTest5 ;
bTest6 = rVOpt.bTest6 ;
bTest7 = rVOpt.bTest7 ;
bTest8 = rVOpt.bTest8 ;
bTest10 = rVOpt.bTest10 ;
#endif
return *this;
}
SwViewOption::~SwViewOption()
{
}
/*************************************************************************
|*
|* ViewOption::Init()
|*
|* Letzte Aenderung MA 04. Aug. 93
|*
|*************************************************************************/
void SwViewOption::Init( Window *pWin )
{
if( !nPixelTwips && pWin )
{
nPixelTwips = (USHORT)pWin->PixelToLogic( Size(1,1) ).Height();
}
}
BOOL SwViewOption::IsAutoCompleteWords() const
{
const SvxSwAutoFmtFlags& rFlags = OFF_APP()->GetAutoCorrect()->GetSwFlags();
return /*rFlags.bAutoCompleteWords &&*/ rFlags.bAutoCmpltCollectWords;
}
/*************************************************************************/
/*
/*************************************************************************/
AuthorCharAttr::AuthorCharAttr() :
nItemId (SID_ATTR_CHAR_UNDERLINE),
nAttr (UNDERLINE_SINGLE),
nColor (COL_TRANSPARENT)
{
}
/*-----------------07.01.97 13.50-------------------
--------------------------------------------------*/
USHORT GetHtmlMode(const SwDocShell* pShell)
{
USHORT nRet = 0;
if(!pShell || PTR_CAST(SwWebDocShell, pShell))
{
nRet = HTMLMODE_ON;
OfaHtmlOptions* pHtmlOpt = OFF_APP()->GetHtmlOptions();
switch ( pHtmlOpt->GetExportMode() )
{
case HTML_CFG_MSIE_40:
nRet |= HTMLMODE_PARA_BORDER|HTMLMODE_SMALL_CAPS|
HTMLMODE_SOME_STYLES|
HTMLMODE_FULL_STYLES|HTMLMODE_GRAPH_POS|
HTMLMODE_FULL_ABS_POS|HTMLMODE_SOME_ABS_POS;
break;
case HTML_CFG_NS30:
nRet |= HTMLMODE_BLINK|HTMLMODE_FRM_COLUMNS|HTMLMODE_FIRSTLINE;
break;
case HTML_CFG_NS40:
nRet |= HTMLMODE_PARA_BORDER|HTMLMODE_SOME_STYLES|
HTMLMODE_FRM_COLUMNS|HTMLMODE_BLINK|HTMLMODE_GRAPH_POS|
HTMLMODE_SOME_ABS_POS;
break;
case HTML_CFG_WRITER:
nRet |= HTMLMODE_PARA_BORDER|HTMLMODE_SMALL_CAPS|
HTMLMODE_SOME_STYLES|
HTMLMODE_FRM_COLUMNS|HTMLMODE_FULL_STYLES|
HTMLMODE_BLINK|HTMLMODE_DROPCAPS|HTMLMODE_GRAPH_POS|
HTMLMODE_FULL_ABS_POS|HTMLMODE_SOME_ABS_POS;
break;
case HTML_CFG_HTML32:
break;
}
}
return nRet;
}
2002-04-12 09:39:11 +00:00
/* -----------------------------12.04.2002 10:39------------------------------
2000-09-18 16:15:01 +00:00
2002-04-12 09:39:11 +00:00
---------------------------------------------------------------------------*/
Color& SwViewOption::GetSpellColor()
{
return aSpellColor;
}
/* -----------------------------12.04.2002 10:41------------------------------
2000-09-18 16:15:01 +00:00
2002-04-12 09:39:11 +00:00
---------------------------------------------------------------------------*/
void SwViewOption::SetSpellColor(ColorData nColor)
{
aSpellColor.SetColor(nColor);
}
2000-09-18 16:15:01 +00:00