2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 20:44:33 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 20:44:33 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 20:44:33 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2008-04-10 20:44:33 +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:15:01 +00:00
|
|
|
*
|
2008-04-10 20:44:33 +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:15:01 +00:00
|
|
|
*
|
2008-04-10 20:44:33 +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:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 22:22:00 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
2004-08-23 08:10:40 +00:00
|
|
|
#ifdef SW_DLLIMPLEMENTATION
|
|
|
|
#undef SW_DLLIMPLEMENTATION
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <vcl/edit.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
2008-05-06 11:56:46 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/zforlist.hxx>
|
2000-10-20 08:51:34 +00:00
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
2004-08-23 08:10:40 +00:00
|
|
|
#include <com/sun/star/i18n/XBreakIterator.hpp>
|
2000-10-20 13:18:07 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2001-11-19 12:32:53 +00:00
|
|
|
#include <svtools/scriptedtext.hxx>
|
2002-08-13 09:06:19 +00:00
|
|
|
#include <svtools/accessibilityoptions.hxx>
|
2004-08-02 16:16:40 +00:00
|
|
|
#include <svx/framelinkarray.hxx>
|
2002-08-13 09:06:19 +00:00
|
|
|
#include "swmodule.hxx"
|
|
|
|
#include "swtypes.hxx"
|
|
|
|
#include "view.hxx"
|
|
|
|
#include "wrtsh.hxx"
|
|
|
|
#include "tblafmt.hxx"
|
|
|
|
#include "tautofmt.hxx"
|
|
|
|
#include "shellres.hxx"
|
|
|
|
#include "tautofmt.hrc"
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2007-09-27 11:34:48 +00:00
|
|
|
using namespace com::sun::star;
|
2000-10-20 08:51:34 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
#define FRAME_OFFSET 4
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
class AutoFmtPreview : public Window
|
|
|
|
{
|
|
|
|
public:
|
2008-05-06 11:56:46 +00:00
|
|
|
AutoFmtPreview( Window* pParent, const ResId& rRes, SwWrtShell* pWrtShell );
|
2000-09-18 16:15:01 +00:00
|
|
|
~AutoFmtPreview();
|
|
|
|
|
|
|
|
void NotifyChange( const SwTableAutoFmt& rNewData );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void Paint( const Rectangle& rRect );
|
|
|
|
|
|
|
|
private:
|
2001-11-19 12:32:53 +00:00
|
|
|
SwTableAutoFmt aCurData;
|
|
|
|
VirtualDevice aVD;
|
|
|
|
SvtScriptedTextHelper aScriptedText;
|
2004-08-02 16:16:40 +00:00
|
|
|
svx::frame::Array maArray; /// Implementation to draw the frame borders.
|
2001-11-19 12:32:53 +00:00
|
|
|
BOOL bFitWidth;
|
2008-05-06 11:56:46 +00:00
|
|
|
bool mbRTL;
|
2001-11-19 12:32:53 +00:00
|
|
|
Size aPrvSize;
|
2004-08-02 16:16:40 +00:00
|
|
|
long nLabelColWidth;
|
|
|
|
long nDataColWidth1;
|
|
|
|
long nDataColWidth2;
|
|
|
|
long nRowHeight;
|
2001-11-19 12:32:53 +00:00
|
|
|
const String aStrJan;
|
|
|
|
const String aStrFeb;
|
|
|
|
const String aStrMar;
|
|
|
|
const String aStrNorth;
|
|
|
|
const String aStrMid;
|
|
|
|
const String aStrSouth;
|
|
|
|
const String aStrSum;
|
|
|
|
SvNumberFormatter* pNumFmt;
|
2004-08-23 08:10:40 +00:00
|
|
|
|
2007-09-27 11:34:48 +00:00
|
|
|
uno::Reference< lang::XMultiServiceFactory > m_xMSF;
|
|
|
|
uno::Reference< i18n::XBreakIterator > m_xBreak;
|
2004-08-23 08:10:40 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
//-------------------------------------------
|
|
|
|
void Init ();
|
|
|
|
void DoPaint ( const Rectangle& rRect );
|
|
|
|
void CalcCellArray ( BOOL bFitWidth );
|
|
|
|
void CalcLineMap ();
|
|
|
|
void PaintCells ();
|
2004-08-02 16:16:40 +00:00
|
|
|
|
|
|
|
BYTE GetFormatIndex( size_t nCol, size_t nRow ) const;
|
|
|
|
const SvxBoxItem& GetBoxItem( size_t nCol, size_t nRow ) const;
|
|
|
|
|
|
|
|
void DrawString( size_t nCol, size_t nRow );
|
|
|
|
void DrawStrings();
|
|
|
|
void DrawBackground();
|
|
|
|
|
2001-11-19 12:32:53 +00:00
|
|
|
void MakeFonts ( BYTE nIndex, Font& rFont, Font& rCJKFont, Font& rCTLFont );
|
2000-09-18 16:15:01 +00:00
|
|
|
String MakeNumberString( String cellString, BOOL bAddDec );
|
|
|
|
};
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
class SwStringInputDlg : public ModalDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SwStringInputDlg( Window* pParent,
|
|
|
|
const String& rTitle,
|
|
|
|
const String& rEditTitle,
|
|
|
|
const String& rDefault );
|
|
|
|
~SwStringInputDlg();
|
|
|
|
|
|
|
|
void GetInputString( String& rString ) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Edit aEdInput; // Edit erhaelt so den Focus
|
|
|
|
FixedText aFtEditTitle;
|
|
|
|
OKButton aBtnOk;
|
|
|
|
CancelButton aBtnCancel;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
SwStringInputDlg::SwStringInputDlg( Window* pParent,
|
|
|
|
const String& rTitle,
|
|
|
|
const String& rEditTitle,
|
|
|
|
const String& rDefault ) :
|
|
|
|
ModalDialog ( pParent, SW_RES( DLG_SWDLG_STRINPUT ) ),
|
|
|
|
//
|
|
|
|
aEdInput ( this, SW_RES( ED_INPUT ) ),
|
2007-09-27 11:34:48 +00:00
|
|
|
aFtEditTitle ( this, SW_RES( FT_LABEL ) ),
|
2000-09-18 16:15:01 +00:00
|
|
|
aBtnOk ( this, SW_RES( BTN_OK ) ),
|
2007-09-27 11:34:48 +00:00
|
|
|
aBtnCancel ( this, SW_RES( BTN_CANCEL ) )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
SetText( rTitle );
|
|
|
|
aFtEditTitle.SetText( rEditTitle );
|
|
|
|
aEdInput.SetText( rDefault );
|
|
|
|
//-------------
|
|
|
|
FreeResource();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SwStringInputDlg::GetInputString( String& rString ) const
|
|
|
|
{
|
|
|
|
rString = aEdInput.GetText();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__EXPORT SwStringInputDlg::~SwStringInputDlg()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// AutoFormat-Dialog:
|
|
|
|
|
|
|
|
|
|
|
|
SwAutoFormatDlg::SwAutoFormatDlg( Window* pParent, SwWrtShell* pWrtShell,
|
|
|
|
BOOL bSetAutoFormat, const SwTableAutoFmt* pSelFmt )
|
|
|
|
: SfxModalDialog( pParent, SW_RES( DLG_AUTOFMT_TABLE ) ),
|
|
|
|
//
|
2001-06-14 16:35:39 +00:00
|
|
|
aFlFormat ( this, SW_RES( FL_FORMAT ) ),
|
2000-09-18 16:15:01 +00:00
|
|
|
aLbFormat ( this, SW_RES( LB_FORMAT ) ),
|
2007-09-27 11:34:48 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
aBtnNumFormat ( this, SW_RES( BTN_NUMFORMAT ) ),
|
|
|
|
aBtnBorder ( this, SW_RES( BTN_BORDER ) ),
|
|
|
|
aBtnFont ( this, SW_RES( BTN_FONT ) ),
|
|
|
|
aBtnPattern ( this, SW_RES( BTN_PATTERN ) ),
|
|
|
|
aBtnAlignment ( this, SW_RES( BTN_ALIGNMENT ) ),
|
2001-06-14 16:35:39 +00:00
|
|
|
aFlFormats ( this, SW_RES( FL_FORMATS ) ),
|
2000-09-18 16:15:01 +00:00
|
|
|
aBtnOk ( this, SW_RES( BTN_OK ) ),
|
|
|
|
aBtnCancel ( this, SW_RES( BTN_CANCEL ) ),
|
|
|
|
aBtnHelp ( this, SW_RES( BTN_HELP ) ),
|
|
|
|
aBtnAdd ( this, SW_RES( BTN_ADD ) ),
|
|
|
|
aBtnRemove ( this, SW_RES( BTN_REMOVE ) ),
|
|
|
|
aBtnRename ( this, SW_RES( BTN_RENAME ) ),
|
2007-09-27 11:34:48 +00:00
|
|
|
aBtnMore ( this, SW_RES( BTN_MORE ) ),
|
2000-09-18 16:15:01 +00:00
|
|
|
aStrTitle ( SW_RES( STR_ADD_TITLE ) ),
|
|
|
|
aStrLabel ( SW_RES( STR_ADD_LABEL ) ),
|
|
|
|
aStrClose ( SW_RES( STR_BTN_CLOSE ) ),
|
|
|
|
aStrDelTitle ( SW_RES( STR_DEL_TITLE ) ),
|
|
|
|
aStrDelMsg ( SW_RES( STR_DEL_MSG ) ),
|
|
|
|
aStrRenameTitle ( SW_RES( STR_RENAME_TITLE ) ),
|
|
|
|
aStrInvalidFmt ( SW_RES( STR_INVALID_AFNAME )),
|
2008-05-06 11:56:46 +00:00
|
|
|
pWndPreview ( new AutoFmtPreview( this, SW_RES( WND_PREVIEW ), pWrtShell )),
|
2000-09-18 16:15:01 +00:00
|
|
|
//
|
2007-09-27 11:34:48 +00:00
|
|
|
pShell ( pWrtShell ),
|
2000-09-18 16:15:01 +00:00
|
|
|
nIndex ( 0 ),
|
|
|
|
nDfltStylePos ( 0 ),
|
|
|
|
bCoreDataChanged( FALSE ),
|
2007-09-27 11:34:48 +00:00
|
|
|
bSetAutoFmt ( bSetAutoFormat )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
pTableTbl = new SwTableAutoFmtTbl;
|
|
|
|
pTableTbl->Load();
|
|
|
|
|
|
|
|
Init( pSelFmt );
|
|
|
|
//------------- >
|
|
|
|
FreeResource();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
__EXPORT SwAutoFormatDlg::~SwAutoFormatDlg()
|
|
|
|
{
|
|
|
|
delete pWndPreview;
|
|
|
|
|
|
|
|
if( bCoreDataChanged )
|
|
|
|
pTableTbl->Save();
|
|
|
|
delete pTableTbl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void SwAutoFormatDlg::Init( const SwTableAutoFmt* pSelFmt )
|
|
|
|
{
|
|
|
|
Link aLk( LINK( this, SwAutoFormatDlg, CheckHdl ) );
|
|
|
|
aBtnBorder.SetClickHdl( aLk );
|
|
|
|
aBtnFont.SetClickHdl( aLk );
|
|
|
|
aBtnPattern.SetClickHdl( aLk );
|
|
|
|
aBtnAlignment.SetClickHdl( aLk );
|
|
|
|
aBtnNumFormat.SetClickHdl( aLk );
|
|
|
|
|
|
|
|
aBtnAdd.SetClickHdl ( LINK( this, SwAutoFormatDlg, AddHdl ) );
|
|
|
|
aBtnRemove.SetClickHdl ( LINK( this, SwAutoFormatDlg, RemoveHdl ) );
|
|
|
|
aBtnRename.SetClickHdl ( LINK( this, SwAutoFormatDlg, RenameHdl ) );
|
|
|
|
aBtnOk.SetClickHdl ( LINK( this, SwAutoFormatDlg, OkHdl ) );
|
|
|
|
aLbFormat.SetSelectHdl( LINK( this, SwAutoFormatDlg, SelFmtHdl ) );
|
|
|
|
|
|
|
|
aBtnMore.AddWindow( &aBtnNumFormat );
|
|
|
|
aBtnMore.AddWindow( &aBtnBorder );
|
|
|
|
aBtnMore.AddWindow( &aBtnFont );
|
|
|
|
aBtnMore.AddWindow( &aBtnPattern );
|
|
|
|
aBtnMore.AddWindow( &aBtnAlignment );
|
2001-06-14 16:35:39 +00:00
|
|
|
aBtnMore.AddWindow( &aFlFormats );
|
2000-09-18 16:15:01 +00:00
|
|
|
aBtnMore.AddWindow( &aBtnRename );
|
|
|
|
|
|
|
|
aBtnAdd.Enable( bSetAutoFmt );
|
|
|
|
|
|
|
|
nIndex = 0;
|
|
|
|
if( !bSetAutoFmt )
|
|
|
|
{
|
|
|
|
// dann muss die Liste um den Eintrag <Keins> erweitert werden.
|
|
|
|
aLbFormat.InsertEntry( ViewShell::GetShellRes()->aStrNone );
|
|
|
|
nDfltStylePos = 1;
|
|
|
|
nIndex = 255;
|
|
|
|
}
|
|
|
|
|
|
|
|
for( BYTE i = 0, nCount = (BYTE)pTableTbl->Count(); i < nCount; i++ )
|
|
|
|
{
|
|
|
|
SwTableAutoFmt* pFmt = (*pTableTbl)[ i ];
|
|
|
|
aLbFormat.InsertEntry( pFmt->GetName() );
|
|
|
|
if( pSelFmt && pFmt->GetName() == pSelFmt->GetName() )
|
|
|
|
nIndex = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
aLbFormat.SelectEntryPos( 255 != nIndex ? (nDfltStylePos + nIndex) : 0 );
|
|
|
|
SelFmtHdl( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void SwAutoFormatDlg::UpdateChecks( const SwTableAutoFmt& rFmt, BOOL bEnable )
|
|
|
|
{
|
|
|
|
aBtnNumFormat.Enable( bEnable );
|
|
|
|
aBtnNumFormat.Check( rFmt.IsValueFormat() );
|
|
|
|
|
|
|
|
aBtnBorder.Enable( bEnable );
|
|
|
|
aBtnBorder.Check( rFmt.IsFrame() );
|
|
|
|
|
|
|
|
aBtnFont.Enable( bEnable );
|
|
|
|
aBtnFont.Check( rFmt.IsFont() );
|
|
|
|
|
|
|
|
aBtnPattern.Enable( bEnable );
|
|
|
|
aBtnPattern.Check( rFmt.IsBackground() );
|
|
|
|
|
|
|
|
aBtnAlignment.Enable( bEnable );
|
|
|
|
aBtnAlignment.Check( rFmt.IsJustify() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwAutoFormatDlg::FillAutoFmtOfIndex( SwTableAutoFmt*& rToFill ) const
|
|
|
|
{
|
|
|
|
if( 255 != nIndex )
|
|
|
|
{
|
|
|
|
if( rToFill )
|
|
|
|
*rToFill = *(*pTableTbl)[ nIndex ];
|
|
|
|
else
|
|
|
|
rToFill = new SwTableAutoFmt( *(*pTableTbl)[ nIndex ] );
|
|
|
|
}
|
|
|
|
else if( rToFill )
|
|
|
|
delete rToFill, rToFill = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------
|
|
|
|
Handler:
|
|
|
|
---------*/
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK( SwAutoFormatDlg, CheckHdl, Button *, pBtn )
|
|
|
|
{
|
|
|
|
SwTableAutoFmtPtr pData = (*pTableTbl)[nIndex];
|
|
|
|
BOOL bCheck = ((CheckBox*)pBtn)->IsChecked(), bDataChgd = TRUE;
|
|
|
|
|
|
|
|
if( pBtn == &aBtnNumFormat )
|
|
|
|
pData->SetValueFormat( bCheck );
|
|
|
|
else if ( pBtn == &aBtnBorder )
|
|
|
|
pData->SetFrame( bCheck );
|
|
|
|
else if ( pBtn == &aBtnFont )
|
|
|
|
pData->SetFont( bCheck );
|
|
|
|
else if ( pBtn == &aBtnPattern )
|
|
|
|
pData->SetBackground( bCheck );
|
|
|
|
else if ( pBtn == &aBtnAlignment )
|
|
|
|
pData->SetJustify( bCheck );
|
|
|
|
else
|
|
|
|
bDataChgd = FALSE;
|
|
|
|
|
|
|
|
if( bDataChgd )
|
|
|
|
{
|
|
|
|
if( !bCoreDataChanged )
|
|
|
|
{
|
|
|
|
aBtnCancel.SetText( aStrClose );
|
|
|
|
bCoreDataChanged = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pWndPreview->NotifyChange( *pData );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK( SwAutoFormatDlg, AddHdl, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
BOOL bOk = FALSE, bFmtInserted = FALSE;
|
|
|
|
while( !bOk )
|
|
|
|
{
|
|
|
|
SwStringInputDlg* pDlg = new SwStringInputDlg( this,
|
|
|
|
aStrTitle,
|
|
|
|
aStrLabel,
|
|
|
|
aEmptyStr );
|
|
|
|
if( RET_OK == pDlg->Execute() )
|
|
|
|
{
|
|
|
|
String aFormatName;
|
|
|
|
pDlg->GetInputString( aFormatName );
|
|
|
|
|
|
|
|
if( aFormatName.Len() > 0 )
|
|
|
|
{
|
2003-12-01 16:36:03 +00:00
|
|
|
USHORT n;
|
|
|
|
for( n = 0; n < pTableTbl->Count(); ++n )
|
2000-09-18 16:15:01 +00:00
|
|
|
if( (*pTableTbl)[n]->GetName() == aFormatName )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( n >= pTableTbl->Count() )
|
|
|
|
{
|
|
|
|
// Format mit dem Namen noch nicht vorhanden, also
|
|
|
|
// aufnehmen
|
|
|
|
SwTableAutoFmtPtr pNewData = new
|
|
|
|
SwTableAutoFmt( aFormatName );
|
|
|
|
pShell->GetTableAutoFmt( *pNewData );
|
|
|
|
|
|
|
|
// Sortiert einfuegen!!
|
|
|
|
for( n = 1; n < pTableTbl->Count(); ++n )
|
|
|
|
if( (*pTableTbl)[ n ]->GetName() > aFormatName )
|
|
|
|
break;
|
|
|
|
|
|
|
|
pTableTbl->Insert( pNewData, n );
|
|
|
|
aLbFormat.InsertEntry( aFormatName, nDfltStylePos + n );
|
|
|
|
aLbFormat.SelectEntryPos( nDfltStylePos + n );
|
|
|
|
bFmtInserted = TRUE;
|
|
|
|
aBtnAdd.Enable( FALSE );
|
|
|
|
if ( !bCoreDataChanged )
|
|
|
|
{
|
|
|
|
aBtnCancel.SetText( aStrClose );
|
|
|
|
bCoreDataChanged = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
SelFmtHdl( 0 );
|
|
|
|
bOk = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !bFmtInserted )
|
|
|
|
{
|
|
|
|
bOk = RET_CANCEL == ErrorBox( this,
|
|
|
|
WinBits( WB_OK_CANCEL | WB_DEF_OK),
|
|
|
|
aStrInvalidFmt
|
|
|
|
).Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bOk = TRUE;
|
|
|
|
delete pDlg;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPL_LINK( SwAutoFormatDlg, RemoveHdl, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
String aMessage = aStrDelMsg ;
|
|
|
|
aMessage.AppendAscii("\n\n");
|
|
|
|
aMessage += aLbFormat.GetSelectEntry() ;
|
|
|
|
aMessage += '\n';
|
|
|
|
|
|
|
|
MessBox* pBox = new MessBox( this, WinBits( WB_OK_CANCEL ),
|
|
|
|
aStrDelTitle, aMessage);
|
|
|
|
|
|
|
|
if ( pBox->Execute() == RET_OK )
|
|
|
|
{
|
|
|
|
aLbFormat.RemoveEntry( nDfltStylePos + nIndex );
|
|
|
|
aLbFormat.SelectEntryPos( nDfltStylePos + nIndex-1 );
|
|
|
|
|
|
|
|
pTableTbl->DeleteAndDestroy( nIndex );
|
|
|
|
nIndex--;
|
|
|
|
|
|
|
|
if( !nIndex )
|
|
|
|
{
|
|
|
|
aBtnRemove.Enable(FALSE);
|
|
|
|
aBtnRename.Enable(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !bCoreDataChanged )
|
|
|
|
{
|
|
|
|
aBtnCancel.SetText( aStrClose );
|
|
|
|
bCoreDataChanged = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete pBox;
|
|
|
|
|
|
|
|
SelFmtHdl( 0 );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SwAutoFormatDlg, RenameHdl, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
BOOL bOk = FALSE;
|
|
|
|
while( !bOk )
|
|
|
|
{
|
|
|
|
SwStringInputDlg* pDlg = new SwStringInputDlg( this,
|
|
|
|
aStrRenameTitle, aLbFormat.GetSelectEntry(),
|
|
|
|
aEmptyStr );
|
|
|
|
if( pDlg->Execute() == RET_OK )
|
|
|
|
{
|
|
|
|
BOOL bFmtRenamed = FALSE;
|
|
|
|
String aFormatName;
|
|
|
|
pDlg->GetInputString( aFormatName );
|
|
|
|
|
|
|
|
if ( aFormatName.Len() > 0 )
|
|
|
|
{
|
2003-12-01 16:36:03 +00:00
|
|
|
USHORT n;
|
|
|
|
for( n = 0; n < pTableTbl->Count(); ++n )
|
2000-09-18 16:15:01 +00:00
|
|
|
if ((*pTableTbl)[n]->GetName() == aFormatName)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( n >= pTableTbl->Count() )
|
|
|
|
{
|
|
|
|
// Format mit dem Namen noch nicht vorhanden, also
|
|
|
|
// umbenennen
|
|
|
|
|
|
|
|
aLbFormat.RemoveEntry( nDfltStylePos + nIndex );
|
|
|
|
SwTableAutoFmtPtr p = (*pTableTbl)[ nIndex ];
|
|
|
|
pTableTbl->Remove( nIndex );
|
|
|
|
|
|
|
|
p->SetName( aFormatName );
|
|
|
|
|
|
|
|
// Sortiert einfuegen!!
|
|
|
|
for( n = 1; n < pTableTbl->Count(); ++n )
|
|
|
|
if( (*pTableTbl)[ n ]->GetName() > aFormatName )
|
|
|
|
break;
|
|
|
|
|
|
|
|
pTableTbl->Insert( p, n );
|
|
|
|
aLbFormat.InsertEntry( aFormatName, nDfltStylePos + n );
|
|
|
|
aLbFormat.SelectEntryPos( nDfltStylePos + n );
|
|
|
|
|
|
|
|
if ( !bCoreDataChanged )
|
|
|
|
{
|
|
|
|
aBtnCancel.SetText( aStrClose );
|
|
|
|
bCoreDataChanged = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
SelFmtHdl( 0 );
|
|
|
|
bOk = TRUE;
|
|
|
|
bFmtRenamed = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !bFmtRenamed )
|
|
|
|
{
|
|
|
|
bOk = RET_CANCEL == ErrorBox( this,
|
|
|
|
WinBits( WB_OK_CANCEL | WB_DEF_OK),
|
|
|
|
aStrInvalidFmt
|
|
|
|
).Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bOk = TRUE;
|
|
|
|
delete pDlg;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPL_LINK( SwAutoFormatDlg, SelFmtHdl, void *, EMPTYARG )
|
|
|
|
{
|
|
|
|
BOOL bBtnEnable = FALSE;
|
|
|
|
BYTE nSelPos = (BYTE) aLbFormat.GetSelectEntryPos(), nOldIdx = nIndex;
|
|
|
|
if( nSelPos >= nDfltStylePos )
|
|
|
|
{
|
|
|
|
nIndex = nSelPos - nDfltStylePos;
|
|
|
|
pWndPreview->NotifyChange( *(*pTableTbl)[nIndex] );
|
|
|
|
bBtnEnable = 0 != nIndex;
|
|
|
|
UpdateChecks( *(*pTableTbl)[nIndex], TRUE );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nIndex = 255;
|
|
|
|
|
|
|
|
SwTableAutoFmt aTmp( ViewShell::GetShellRes()->aStrNone );
|
|
|
|
aTmp.SetFont( FALSE );
|
|
|
|
aTmp.SetJustify( FALSE );
|
|
|
|
aTmp.SetFrame( FALSE );
|
|
|
|
aTmp.SetBackground( FALSE );
|
|
|
|
aTmp.SetValueFormat( FALSE );
|
|
|
|
aTmp.SetWidthHeight( FALSE );
|
|
|
|
|
|
|
|
if( nOldIdx != nIndex )
|
|
|
|
pWndPreview->NotifyChange( aTmp );
|
|
|
|
UpdateChecks( aTmp, FALSE );
|
|
|
|
}
|
|
|
|
|
|
|
|
aBtnRemove.Enable( bBtnEnable );
|
|
|
|
aBtnRename.Enable( bBtnEnable );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPL_LINK_INLINE_START( SwAutoFormatDlg, OkHdl, Button *, EMPTYARG )
|
|
|
|
{
|
|
|
|
if( bSetAutoFmt )
|
|
|
|
pShell->SetTableAutoFmt( *(*pTableTbl)[ nIndex ] );
|
|
|
|
EndDialog( RET_OK );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
IMPL_LINK_INLINE_END( SwAutoFormatDlg, OkHdl, Button *, EMPTYARG )
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// AutoFmtPreview
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2008-05-06 11:56:46 +00:00
|
|
|
AutoFmtPreview::AutoFmtPreview( Window* pParent, const ResId& rRes, SwWrtShell* pWrtShell ) :
|
2000-09-18 16:15:01 +00:00
|
|
|
Window ( pParent, rRes ),
|
2007-09-27 11:34:48 +00:00
|
|
|
|
|
|
|
aCurData ( aEmptyStr ),
|
2000-09-18 16:15:01 +00:00
|
|
|
aVD ( *this ),
|
2001-11-19 12:32:53 +00:00
|
|
|
aScriptedText ( aVD ),
|
2000-09-18 16:15:01 +00:00
|
|
|
bFitWidth ( FALSE ),
|
2008-05-06 11:56:46 +00:00
|
|
|
mbRTL ( false ),
|
2007-09-27 11:34:48 +00:00
|
|
|
aPrvSize ( GetSizePixel().Width() - 6, GetSizePixel().Height() - 30 ),
|
|
|
|
nLabelColWidth ( (aPrvSize.Width() - 4) / 4 - 12 ),
|
|
|
|
nDataColWidth1 ( (aPrvSize.Width() - 4 - 2 * nLabelColWidth) / 3 ),
|
|
|
|
nDataColWidth2 ( (aPrvSize.Width() - 4 - 2 * nLabelColWidth) / 4 ),
|
|
|
|
nRowHeight ( (aPrvSize.Height() - 4) / 5 ),
|
2000-09-18 16:15:01 +00:00
|
|
|
aStrJan ( SW_RES( STR_JAN ) ),
|
|
|
|
aStrFeb ( SW_RES( STR_FEB ) ),
|
|
|
|
aStrMar ( SW_RES( STR_MAR ) ),
|
|
|
|
aStrNorth ( SW_RES( STR_NORTH ) ),
|
|
|
|
aStrMid ( SW_RES( STR_MID ) ),
|
|
|
|
aStrSouth ( SW_RES( STR_SOUTH ) ),
|
|
|
|
aStrSum ( SW_RES( STR_SUM ) ),
|
2004-08-23 08:10:40 +00:00
|
|
|
m_xMSF ( comphelper::getProcessServiceFactory() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2008-05-06 11:56:46 +00:00
|
|
|
if (!pWrtShell->IsCrsrInTbl()) // We haven't created the table yet
|
|
|
|
mbRTL = Application::GetSettings().GetLayoutRTL();
|
|
|
|
else
|
|
|
|
mbRTL = pWrtShell->IsTableRightToLeft();
|
|
|
|
|
2010-10-24 23:48:32 +02:00
|
|
|
OSL_ENSURE( m_xMSF.is(), "AutoFmtPreview: no MultiServiceFactory");
|
2004-08-23 08:10:40 +00:00
|
|
|
if ( m_xMSF.is() )
|
|
|
|
{
|
2007-09-27 11:34:48 +00:00
|
|
|
m_xBreak = uno::Reference< i18n::XBreakIterator >(
|
2004-08-23 08:10:40 +00:00
|
|
|
m_xMSF->createInstance (
|
2010-10-27 11:38:46 +01:00
|
|
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator")) ),
|
2007-09-27 11:34:48 +00:00
|
|
|
uno::UNO_QUERY);
|
2004-08-23 08:10:40 +00:00
|
|
|
}
|
|
|
|
pNumFmt = new SvNumberFormatter( m_xMSF, LANGUAGE_SYSTEM );
|
2000-10-20 08:51:34 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
__EXPORT AutoFmtPreview::~AutoFmtPreview()
|
|
|
|
{
|
|
|
|
delete pNumFmt;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2004-08-23 08:10:40 +00:00
|
|
|
static void lcl_SetFontProperties(
|
2001-11-19 12:32:53 +00:00
|
|
|
Font& rFont,
|
|
|
|
const SvxFontItem& rFontItem,
|
|
|
|
const SvxWeightItem& rWeightItem,
|
|
|
|
const SvxPostureItem& rPostureItem )
|
|
|
|
{
|
|
|
|
rFont.SetFamily ( rFontItem.GetFamily() );
|
|
|
|
rFont.SetName ( rFontItem.GetFamilyName() );
|
|
|
|
rFont.SetStyleName ( rFontItem.GetStyleName() );
|
|
|
|
rFont.SetCharSet ( rFontItem.GetCharSet() );
|
|
|
|
rFont.SetPitch ( rFontItem.GetPitch() );
|
|
|
|
rFont.SetWeight ( (FontWeight)rWeightItem.GetValue() );
|
|
|
|
rFont.SetItalic ( (FontItalic)rPostureItem.GetValue() );
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SETONALLFONTS( MethodName, Value ) \
|
|
|
|
rFont.MethodName( Value ); \
|
|
|
|
rCJKFont.MethodName( Value ); \
|
|
|
|
rCTLFont.MethodName( Value );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2001-11-19 12:32:53 +00:00
|
|
|
void AutoFmtPreview::MakeFonts( BYTE nIndex, Font& rFont, Font& rCJKFont, Font& rCTLFont )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
const SwBoxAutoFmt& rBoxFmt = aCurData.GetBoxFmt( nIndex );
|
|
|
|
|
2001-11-19 12:32:53 +00:00
|
|
|
rFont = rCJKFont = rCTLFont = GetFont();
|
|
|
|
Size aFontSize( rFont.GetSize().Width(), 10 );
|
|
|
|
|
|
|
|
lcl_SetFontProperties( rFont, rBoxFmt.GetFont(), rBoxFmt.GetWeight(), rBoxFmt.GetPosture() );
|
|
|
|
lcl_SetFontProperties( rCJKFont, rBoxFmt.GetCJKFont(), rBoxFmt.GetCJKWeight(), rBoxFmt.GetCJKPosture() );
|
|
|
|
lcl_SetFontProperties( rCTLFont, rBoxFmt.GetCTLFont(), rBoxFmt.GetCTLWeight(), rBoxFmt.GetCTLPosture() );
|
|
|
|
|
|
|
|
SETONALLFONTS( SetUnderline, (FontUnderline)rBoxFmt.GetUnderline().GetValue() );
|
2009-01-05 17:49:45 +00:00
|
|
|
SETONALLFONTS( SetOverline, (FontUnderline)rBoxFmt.GetOverline().GetValue() );
|
2001-11-19 12:32:53 +00:00
|
|
|
SETONALLFONTS( SetStrikeout, (FontStrikeout)rBoxFmt.GetCrossedOut().GetValue() );
|
|
|
|
SETONALLFONTS( SetOutline, rBoxFmt.GetContour().GetValue() );
|
|
|
|
SETONALLFONTS( SetShadow, rBoxFmt.GetShadowed().GetValue() );
|
|
|
|
SETONALLFONTS( SetColor, rBoxFmt.GetColor().GetValue() );
|
|
|
|
SETONALLFONTS( SetSize, aFontSize );
|
|
|
|
SETONALLFONTS( SetTransparent, TRUE );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
BYTE AutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
|
|
|
|
{
|
|
|
|
static const BYTE pnFmtMap[] =
|
|
|
|
{
|
|
|
|
0, 1, 2, 1, 3,
|
|
|
|
4, 5, 6, 5, 7,
|
|
|
|
8, 9, 10, 9, 11,
|
|
|
|
4, 5, 6, 5, 7,
|
|
|
|
12, 13, 14, 13, 15
|
|
|
|
};
|
2008-05-06 11:56:46 +00:00
|
|
|
return pnFmtMap[ maArray.GetCellIndex( nCol, nRow, mbRTL ) ];
|
2004-08-02 16:16:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const SvxBoxItem& AutoFmtPreview::GetBoxItem( size_t nCol, size_t nRow ) const
|
|
|
|
{
|
|
|
|
return aCurData.GetBoxFmt( GetFormatIndex( nCol, nRow ) ).GetBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void AutoFmtPreview::DrawString( size_t nCol, size_t nRow )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
//------------------------
|
|
|
|
// Ausgabe des Zelltextes:
|
|
|
|
//------------------------
|
|
|
|
ULONG nNum;
|
|
|
|
double nVal;
|
|
|
|
String cellString;
|
2008-05-06 11:56:46 +00:00
|
|
|
BYTE nIndex = static_cast< BYTE >( maArray.GetCellIndex( nCol, nRow, mbRTL ) );
|
2004-08-02 16:16:40 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
switch( nIndex )
|
|
|
|
{
|
|
|
|
case 1: cellString = aStrJan; break;
|
|
|
|
case 2: cellString = aStrFeb; break;
|
|
|
|
case 3: cellString = aStrMar; break;
|
|
|
|
case 5: cellString = aStrNorth; break;
|
|
|
|
case 10: cellString = aStrMid; break;
|
|
|
|
case 15: cellString = aStrSouth; break;
|
|
|
|
case 4:
|
|
|
|
case 20: cellString = aStrSum; break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
case 8:
|
|
|
|
case 16:
|
|
|
|
case 18: nVal = nIndex;
|
|
|
|
nNum = 5;
|
|
|
|
goto MAKENUMSTR;
|
|
|
|
case 17:
|
|
|
|
case 7: nVal = nIndex;
|
|
|
|
nNum = 6;
|
|
|
|
goto MAKENUMSTR;
|
|
|
|
case 11:
|
|
|
|
case 12:
|
|
|
|
case 13: nVal = nIndex;
|
|
|
|
nNum = 12 == nIndex ? 10 : 9;
|
|
|
|
goto MAKENUMSTR;
|
|
|
|
|
|
|
|
case 9: nVal = 21; nNum = 7; goto MAKENUMSTR;
|
|
|
|
case 14: nVal = 36; nNum = 11; goto MAKENUMSTR;
|
|
|
|
case 19: nVal = 51; nNum = 7; goto MAKENUMSTR;
|
|
|
|
case 21: nVal = 33; nNum = 13; goto MAKENUMSTR;
|
|
|
|
case 22: nVal = 36; nNum = 14; goto MAKENUMSTR;
|
|
|
|
case 23: nVal = 39; nNum = 13; goto MAKENUMSTR;
|
|
|
|
case 24: nVal = 108; nNum = 15; goto MAKENUMSTR;
|
|
|
|
MAKENUMSTR:
|
|
|
|
if( aCurData.IsValueFormat() )
|
|
|
|
{
|
|
|
|
String sFmt; LanguageType eLng, eSys;
|
|
|
|
aCurData.GetBoxFmt( (BYTE)nNum ).GetValueFormat( sFmt, eLng, eSys );
|
|
|
|
|
2005-09-23 11:19:52 +00:00
|
|
|
short nType;
|
|
|
|
BOOL bNew;
|
|
|
|
xub_StrLen nCheckPos;
|
2005-12-14 13:52:10 +00:00
|
|
|
sal_uInt32 nKey = pNumFmt->GetIndexPuttingAndConverting( sFmt, eLng,
|
2005-09-23 11:19:52 +00:00
|
|
|
eSys, nType, bNew, nCheckPos);
|
2000-09-18 16:15:01 +00:00
|
|
|
Color* pDummy;
|
|
|
|
pNumFmt->GetOutputString( nVal, nKey, cellString, &pDummy );
|
|
|
|
}
|
|
|
|
else
|
2007-09-27 11:34:48 +00:00
|
|
|
cellString = String::CreateFromInt32((sal_Int32)nVal);
|
2000-09-18 16:15:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if( cellString.Len() )
|
|
|
|
{
|
|
|
|
Size aStrSize;
|
2004-08-02 16:16:40 +00:00
|
|
|
BYTE nFmtIndex = GetFormatIndex( nCol, nRow );
|
|
|
|
Rectangle cellRect = maArray.GetCellRect( nCol, nRow );
|
|
|
|
Point aPos = cellRect.TopLeft();
|
2000-09-18 16:15:01 +00:00
|
|
|
USHORT nRightX = 0;
|
|
|
|
|
|
|
|
Size theMaxStrSize( cellRect.GetWidth() - FRAME_OFFSET,
|
|
|
|
cellRect.GetHeight() - FRAME_OFFSET );
|
|
|
|
if( aCurData.IsFont() )
|
|
|
|
{
|
2001-11-19 12:32:53 +00:00
|
|
|
Font aFont, aCJKFont, aCTLFont;
|
|
|
|
MakeFonts( nFmtIndex, aFont, aCJKFont, aCTLFont );
|
|
|
|
aScriptedText.SetFonts( &aFont, &aCJKFont, &aCTLFont );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2001-11-19 12:32:53 +00:00
|
|
|
else
|
|
|
|
aScriptedText.SetDefaultFont();
|
|
|
|
|
2004-08-23 08:10:40 +00:00
|
|
|
aScriptedText.SetText( cellString, m_xBreak );
|
2001-11-19 12:32:53 +00:00
|
|
|
aStrSize = aScriptedText.GetTextSize();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if( aCurData.IsFont() &&
|
|
|
|
theMaxStrSize.Height() < aStrSize.Height() )
|
|
|
|
{
|
|
|
|
// wenn der String in diesem Font nicht
|
|
|
|
// in die Zelle passt, wird wieder der
|
|
|
|
// Standard-Font genommen:
|
2001-11-19 12:32:53 +00:00
|
|
|
aScriptedText.SetDefaultFont();
|
|
|
|
aStrSize = aScriptedText.GetTextSize();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
while( theMaxStrSize.Width() <= aStrSize.Width() &&
|
|
|
|
cellString.Len() > 1 )
|
|
|
|
{
|
|
|
|
cellString.Erase( cellString.Len() - 1 );
|
2004-08-23 08:10:40 +00:00
|
|
|
aScriptedText.SetText( cellString, m_xBreak );
|
2001-11-19 12:32:53 +00:00
|
|
|
aStrSize = aScriptedText.GetTextSize();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nRightX = (USHORT)( cellRect.GetWidth()
|
|
|
|
- aStrSize.Width()
|
|
|
|
- FRAME_OFFSET );
|
|
|
|
|
|
|
|
//-----------------------------
|
|
|
|
// vertikal (immer zentrieren):
|
|
|
|
//-----------------------------
|
|
|
|
aPos.Y() += (nRowHeight - (USHORT)aStrSize.Height()) / 2;
|
|
|
|
|
|
|
|
//-----------
|
|
|
|
// horizontal
|
|
|
|
//-----------
|
2008-05-06 11:56:46 +00:00
|
|
|
if( mbRTL )
|
|
|
|
aPos.X() += nRightX;
|
|
|
|
else if (aCurData.IsJustify())
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
USHORT nHorPos = (USHORT)
|
|
|
|
((cellRect.GetWidth()-aStrSize.Width())/2);
|
|
|
|
const SvxAdjustItem& rAdj = aCurData.GetBoxFmt(nFmtIndex).GetAdjust();
|
|
|
|
switch ( rAdj.GetAdjust() )
|
|
|
|
{
|
|
|
|
case SVX_ADJUST_LEFT:
|
|
|
|
aPos.X() += FRAME_OFFSET;
|
|
|
|
break;
|
|
|
|
case SVX_ADJUST_RIGHT:
|
|
|
|
aPos.X() += nRightX;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aPos.X() += nHorPos;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//---------------------
|
|
|
|
// Standardausrichtung:
|
|
|
|
//---------------------
|
2004-08-02 16:16:40 +00:00
|
|
|
if ( (nCol == 0) || (nIndex == 4) )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
// Text-Label links oder Summe linksbuendig
|
|
|
|
aPos.X() += FRAME_OFFSET;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Zahlen/Datum rechtsbuendig
|
|
|
|
aPos.X() += nRightX;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------
|
2001-11-19 12:32:53 +00:00
|
|
|
aScriptedText.DrawText( aPos );
|
2000-09-18 16:15:01 +00:00
|
|
|
//-------------------------------
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef FRAME_OFFSET
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
void AutoFmtPreview::DrawStrings()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 16:16:40 +00:00
|
|
|
for( size_t nRow = 0; nRow < 5; ++nRow )
|
|
|
|
for( size_t nCol = 0; nCol < 5; ++nCol )
|
|
|
|
DrawString( nCol, nRow );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
void AutoFmtPreview::DrawBackground()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 16:16:40 +00:00
|
|
|
for( size_t nRow = 0; nRow < 5; ++nRow )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 16:16:40 +00:00
|
|
|
for( size_t nCol = 0; nCol < 5; ++nCol )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 16:16:40 +00:00
|
|
|
SvxBrushItem aBrushItem( aCurData.GetBoxFmt( GetFormatIndex( nCol, nRow ) ).GetBackground() );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
aVD.Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
|
|
|
|
aVD.SetLineColor();
|
|
|
|
aVD.SetFillColor( aBrushItem.GetColor() );
|
|
|
|
aVD.DrawRect( maArray.GetCellRect( nCol, nRow ) );
|
|
|
|
aVD.Pop();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
void AutoFmtPreview::PaintCells()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 16:16:40 +00:00
|
|
|
// 1) background
|
|
|
|
if ( aCurData.IsBackground() )
|
|
|
|
DrawBackground();
|
2002-08-13 09:06:19 +00:00
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
// 2) values
|
|
|
|
DrawStrings();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
// 3) border
|
|
|
|
if ( aCurData.IsFrame() )
|
|
|
|
maArray.DrawArray( aVD );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
void __EXPORT AutoFmtPreview::Init()
|
|
|
|
{
|
|
|
|
SetBorderStyle( GetBorderStyle() | WINDOW_BORDER_MONO );
|
|
|
|
maArray.Initialize( 5, 5 );
|
|
|
|
maArray.SetUseDiagDoubleClipping( false );
|
2000-09-18 16:15:01 +00:00
|
|
|
CalcCellArray( FALSE );
|
|
|
|
CalcLineMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2007-09-27 11:34:48 +00:00
|
|
|
void AutoFmtPreview::CalcCellArray( BOOL _bFitWidth )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 16:16:40 +00:00
|
|
|
maArray.SetXOffset( 2 );
|
2007-09-27 11:34:48 +00:00
|
|
|
maArray.SetAllColWidths( _bFitWidth ? nDataColWidth2 : nDataColWidth1 );
|
2004-08-02 16:16:40 +00:00
|
|
|
maArray.SetColWidth( 0, nLabelColWidth );
|
|
|
|
maArray.SetColWidth( 4, nLabelColWidth );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
maArray.SetYOffset( 2 );
|
|
|
|
maArray.SetAllRowHeights( nRowHeight );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
aPrvSize.Width() = maArray.GetWidth() + 4;
|
|
|
|
aPrvSize.Height() = maArray.GetHeight() + 4;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2004-08-02 16:16:40 +00:00
|
|
|
inline void lclSetStyleFromBorder( svx::frame::Style& rStyle, const SvxBorderLine* pBorder )
|
|
|
|
{
|
|
|
|
rStyle.Set( pBorder, 0.05, 5 );
|
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
void AutoFmtPreview::CalcLineMap()
|
|
|
|
{
|
2004-08-02 16:16:40 +00:00
|
|
|
for( size_t nRow = 0; nRow < 5; ++nRow )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 16:16:40 +00:00
|
|
|
for( size_t nCol = 0; nCol < 5; ++nCol )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2004-08-02 16:16:40 +00:00
|
|
|
svx::frame::Style aStyle;
|
|
|
|
|
|
|
|
const SvxBoxItem& rItem = GetBoxItem( nCol, nRow );
|
|
|
|
lclSetStyleFromBorder( aStyle, rItem.GetLeft() );
|
|
|
|
maArray.SetCellStyleLeft( nCol, nRow, aStyle );
|
|
|
|
lclSetStyleFromBorder( aStyle, rItem.GetRight() );
|
|
|
|
maArray.SetCellStyleRight( nCol, nRow, aStyle );
|
|
|
|
lclSetStyleFromBorder( aStyle, rItem.GetTop() );
|
|
|
|
maArray.SetCellStyleTop( nCol, nRow, aStyle );
|
|
|
|
lclSetStyleFromBorder( aStyle, rItem.GetBottom() );
|
|
|
|
maArray.SetCellStyleBottom( nCol, nRow, aStyle );
|
|
|
|
|
|
|
|
// FIXME - uncomment to draw diagonal borders
|
|
|
|
// lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, true ).GetLine() );
|
|
|
|
// maArray.SetCellStyleTLBR( nCol, nRow, aStyle );
|
|
|
|
// lclSetStyleFromBorder( aStyle, GetDiagItem( nCol, nRow, false ).GetLine() );
|
|
|
|
// maArray.SetCellStyleBLTR( nCol, nRow, aStyle );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void AutoFmtPreview::NotifyChange( const SwTableAutoFmt& rNewData )
|
|
|
|
{
|
|
|
|
aCurData = rNewData;
|
|
|
|
bFitWidth = aCurData.IsJustify();//TRUE; //???
|
|
|
|
CalcCellArray( bFitWidth );
|
|
|
|
CalcLineMap();
|
|
|
|
DoPaint( Rectangle( Point(0,0), GetSizePixel() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2007-09-27 11:34:48 +00:00
|
|
|
void AutoFmtPreview::DoPaint( const Rectangle& /*rRect*/ )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2002-08-13 09:06:19 +00:00
|
|
|
sal_uInt32 nOldDrawMode = aVD.GetDrawMode();
|
|
|
|
if( GetSettings().GetStyleSettings().GetHighContrastMode() &&
|
|
|
|
SW_MOD()->GetAccessibilityOptions().GetIsForBorders() )
|
|
|
|
aVD.SetDrawMode( DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT );
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
Bitmap thePreview;
|
|
|
|
Point aCenterPos;
|
|
|
|
Size theWndSize = GetSizePixel();
|
|
|
|
Size thePrevSize;
|
|
|
|
Color oldColor;
|
|
|
|
Font aFont;
|
|
|
|
|
|
|
|
aFont = aVD.GetFont();
|
|
|
|
aFont.SetTransparent( TRUE );
|
|
|
|
|
|
|
|
aVD.SetFont ( aFont );
|
2002-08-13 09:06:19 +00:00
|
|
|
aVD.SetLineColor ();
|
2002-06-03 11:18:11 +00:00
|
|
|
const Color& rWinColor = GetSettings().GetStyleSettings().GetWindowColor();
|
|
|
|
aVD.SetBackground ( Wallpaper(rWinColor) );
|
|
|
|
aVD.SetFillColor ( rWinColor );
|
2000-09-18 16:15:01 +00:00
|
|
|
aVD.SetOutputSizePixel ( aPrvSize );
|
|
|
|
|
|
|
|
//--------------------------------
|
|
|
|
// Zellen auf virtual Device malen
|
|
|
|
// und Ergebnis sichern
|
|
|
|
//--------------------------------
|
|
|
|
PaintCells();
|
|
|
|
thePreview = aVD.GetBitmap( Point(0,0), aPrvSize );
|
|
|
|
|
|
|
|
//--------------------------------------
|
|
|
|
// Rahmen malen und Vorschau zentrieren:
|
|
|
|
// (virtual Device fuer Fensterausgabe)
|
|
|
|
//--------------------------------------
|
|
|
|
aVD.SetOutputSizePixel( theWndSize );
|
|
|
|
oldColor = aVD.GetLineColor();
|
2002-08-13 09:06:19 +00:00
|
|
|
aVD.SetLineColor();
|
2000-09-18 16:15:01 +00:00
|
|
|
aVD.DrawRect( Rectangle( Point(0,0), theWndSize ) );
|
|
|
|
SetLineColor( oldColor );
|
|
|
|
aCenterPos = Point( (theWndSize.Width() - aPrvSize.Width() ) / 2,
|
|
|
|
(theWndSize.Height() - aPrvSize.Height()) / 2 );
|
|
|
|
aVD.DrawBitmap( aCenterPos, thePreview );
|
|
|
|
|
|
|
|
//----------------------------
|
|
|
|
// Ausgabe im Vorschaufenster:
|
|
|
|
//----------------------------
|
|
|
|
DrawBitmap( Point(0,0), aVD.GetBitmap( Point(0,0), theWndSize ) );
|
|
|
|
|
2002-08-13 09:06:19 +00:00
|
|
|
aVD.SetDrawMode( nOldDrawMode );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void __EXPORT AutoFmtPreview::Paint( const Rectangle& rRect )
|
|
|
|
{
|
|
|
|
DoPaint( rRect );
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|