2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
#include <vcl/edit.hxx>
|
2012-09-25 11:35:47 +01:00
|
|
|
#include <vcl/layout.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
#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>
|
2012-10-15 15:20:48 +02:00
|
|
|
#include <com/sun/star/i18n/BreakIterator.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>
|
2012-09-25 11:35:47 +01:00
|
|
|
#include "app.hrc"
|
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"
|
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:
|
2012-09-25 11:35:47 +01:00
|
|
|
AutoFmtPreview(Window* pParent);
|
|
|
|
~AutoFmtPreview();
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
void NotifyChange( const SwTableAutoFmt& rNewData );
|
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
void DetectRTL(SwWrtShell* pWrtShell);
|
|
|
|
|
|
|
|
virtual void Resize();
|
2000-09-18 16:15:01 +00:00
|
|
|
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.
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_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< 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 );
|
2011-01-17 15:06:54 +01:00
|
|
|
void CalcCellArray ( sal_Bool bFitWidth );
|
2000-09-18 16:15:01 +00:00
|
|
|
void CalcLineMap ();
|
|
|
|
void PaintCells ();
|
2004-08-02 16:16:40 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 GetFormatIndex( size_t nCol, size_t nRow ) const;
|
2004-08-02 16:16:40 +00:00
|
|
|
const SvxBoxItem& GetBoxItem( size_t nCol, size_t nRow ) const;
|
|
|
|
|
|
|
|
void DrawString( size_t nCol, size_t nRow );
|
|
|
|
void DrawStrings();
|
|
|
|
void DrawBackground();
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void MakeFonts ( sal_uInt8 nIndex, Font& rFont, Font& rCJKFont, Font& rCTLFont );
|
|
|
|
String MakeNumberString( String cellString, sal_Bool bAddDec );
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
class SwStringInputDlg : public ModalDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SwStringInputDlg( Window* pParent,
|
|
|
|
const String& rTitle,
|
|
|
|
const String& rEditTitle,
|
|
|
|
const String& rDefault );
|
|
|
|
~SwStringInputDlg();
|
|
|
|
|
|
|
|
void GetInputString( String& rString ) const;
|
|
|
|
|
|
|
|
private:
|
2012-09-25 12:10:02 +01:00
|
|
|
Edit* m_pEdInput; // Edit erhaelt so den Focus
|
2000-09-18 16:15:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-09-25 12:10:02 +01:00
|
|
|
SwStringInputDlg::SwStringInputDlg(Window* pParent, const String& rTitle,
|
|
|
|
const String& rEditTitle, const String& rDefault)
|
|
|
|
: ModalDialog(pParent, "StringInputDialog", "modules/swriter/ui/stringinput.ui")
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-25 12:10:02 +01:00
|
|
|
get<FixedText>("name")->SetText(rEditTitle);
|
|
|
|
get(m_pEdInput, "edit");
|
|
|
|
|
|
|
|
SetText(rTitle);
|
|
|
|
m_pEdInput->SetText(rDefault);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SwStringInputDlg::GetInputString( String& rString ) const
|
|
|
|
{
|
2012-09-25 12:10:02 +01:00
|
|
|
rString = m_pEdInput->GetText();
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-12 00:08:03 +01:00
|
|
|
SwStringInputDlg::~SwStringInputDlg()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// AutoFormat-Dialog:
|
|
|
|
|
|
|
|
|
|
|
|
SwAutoFormatDlg::SwAutoFormatDlg( Window* pParent, SwWrtShell* pWrtShell,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bSetAutoFormat, const SwTableAutoFmt* pSelFmt )
|
2012-09-25 11:35:47 +01:00
|
|
|
: SfxModalDialog(pParent, "AutoFormatTableDialog", "modules/swriter/ui/autoformattable.ui")
|
|
|
|
, aStrTitle(SW_RES(STR_ADD_AUTOFORMAT_TITLE))
|
|
|
|
, aStrLabel(SW_RES(STR_ADD_AUTOFORMAT_LABEL))
|
|
|
|
, aStrClose(SW_RES(STR_BTN_AUTOFORMAT_CLOSE))
|
|
|
|
, aStrDelTitle(SW_RES(STR_DEL_AUTOFORMAT_TITLE))
|
|
|
|
, aStrDelMsg(SW_RES(STR_DEL_AUTOFORMAT_MSG))
|
|
|
|
, aStrRenameTitle(SW_RES(STR_RENAME_AUTOFORMAT_TITLE))
|
|
|
|
, aStrInvalidFmt(SW_RES(STR_INVALID_AUTOFORMAT_NAME))
|
|
|
|
, pShell(pWrtShell)
|
|
|
|
, nIndex(0)
|
|
|
|
, nDfltStylePos(0)
|
|
|
|
, bCoreDataChanged(sal_False)
|
|
|
|
, bSetAutoFmt(bSetAutoFormat)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
get(m_pLbFormat, "formatlb");
|
|
|
|
get(m_pFormatting, "formatting");
|
|
|
|
get(m_pBtnNumFormat, "numformatcb");
|
|
|
|
get(m_pBtnBorder, "bordercb");
|
|
|
|
get(m_pBtnFont, "fontcb");
|
|
|
|
get(m_pBtnPattern, "patterncb");
|
|
|
|
get(m_pBtnAlignment, "alignmentcb");
|
|
|
|
get(m_pBtnOk, "ok");
|
|
|
|
get(m_pBtnCancel, "cancel");
|
|
|
|
get(m_pBtnAdd, "add");
|
|
|
|
get(m_pBtnRemove, "remove");
|
|
|
|
get(m_pBtnRename, "rename");
|
|
|
|
get(m_pWndPreview, "preview");
|
|
|
|
|
|
|
|
m_pWndPreview->DetectRTL(pWrtShell);
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
pTableTbl = new SwTableAutoFmtTbl;
|
|
|
|
pTableTbl->Load();
|
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
Init(pSelFmt);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2010-12-12 00:08:03 +01:00
|
|
|
SwAutoFormatDlg::~SwAutoFormatDlg()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
if (bCoreDataChanged)
|
2000-09-18 16:15:01 +00:00
|
|
|
pTableTbl->Save();
|
|
|
|
delete pTableTbl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void SwAutoFormatDlg::Init( const SwTableAutoFmt* pSelFmt )
|
|
|
|
{
|
|
|
|
Link aLk( LINK( this, SwAutoFormatDlg, CheckHdl ) );
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnBorder->SetClickHdl( aLk );
|
|
|
|
m_pBtnFont->SetClickHdl( aLk );
|
|
|
|
m_pBtnPattern->SetClickHdl( aLk );
|
|
|
|
m_pBtnAlignment->SetClickHdl( aLk );
|
|
|
|
m_pBtnNumFormat->SetClickHdl( aLk );
|
|
|
|
|
|
|
|
m_pBtnAdd->SetClickHdl ( LINK( this, SwAutoFormatDlg, AddHdl ) );
|
|
|
|
m_pBtnRemove->SetClickHdl ( LINK( this, SwAutoFormatDlg, RemoveHdl ) );
|
|
|
|
m_pBtnRename->SetClickHdl ( LINK( this, SwAutoFormatDlg, RenameHdl ) );
|
|
|
|
m_pBtnOk->SetClickHdl ( LINK( this, SwAutoFormatDlg, OkHdl ) );
|
|
|
|
m_pLbFormat->SetSelectHdl( LINK( this, SwAutoFormatDlg, SelFmtHdl ) );
|
|
|
|
|
|
|
|
m_pBtnAdd->Enable( bSetAutoFmt );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
nIndex = 0;
|
|
|
|
if( !bSetAutoFmt )
|
|
|
|
{
|
|
|
|
// dann muss die Liste um den Eintrag <Keins> erweitert werden.
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pLbFormat->InsertEntry( ViewShell::GetShellRes()->aStrNone );
|
2000-09-18 16:15:01 +00:00
|
|
|
nDfltStylePos = 1;
|
|
|
|
nIndex = 255;
|
|
|
|
}
|
|
|
|
|
2012-05-15 00:25:35 +02:00
|
|
|
for (sal_uInt8 i = 0, nCount = static_cast<sal_uInt8>(pTableTbl->size());
|
|
|
|
i < nCount; i++)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-05-15 00:25:35 +02:00
|
|
|
SwTableAutoFmt const& rFmt = (*pTableTbl)[ i ];
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pLbFormat->InsertEntry(rFmt.GetName());
|
2012-05-15 00:25:35 +02:00
|
|
|
if (pSelFmt && rFmt.GetName() == pSelFmt->GetName())
|
2000-09-18 16:15:01 +00:00
|
|
|
nIndex = i;
|
|
|
|
}
|
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pLbFormat->SelectEntryPos( 255 != nIndex ? (nDfltStylePos + nIndex) : 0 );
|
2000-09-18 16:15:01 +00:00
|
|
|
SelFmtHdl( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void SwAutoFormatDlg::UpdateChecks( const SwTableAutoFmt& rFmt, sal_Bool bEnable )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnNumFormat->Enable( bEnable );
|
|
|
|
m_pBtnNumFormat->Check( rFmt.IsValueFormat() );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnBorder->Enable( bEnable );
|
|
|
|
m_pBtnBorder->Check( rFmt.IsFrame() );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnFont->Enable( bEnable );
|
|
|
|
m_pBtnFont->Check( rFmt.IsFont() );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnPattern->Enable( bEnable );
|
|
|
|
m_pBtnPattern->Check( rFmt.IsBackground() );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnAlignment->Enable( bEnable );
|
|
|
|
m_pBtnAlignment->Check( rFmt.IsJustify() );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwAutoFormatDlg::FillAutoFmtOfIndex( SwTableAutoFmt*& rToFill ) const
|
|
|
|
{
|
|
|
|
if( 255 != nIndex )
|
|
|
|
{
|
|
|
|
if( rToFill )
|
2012-05-09 14:24:47 +02:00
|
|
|
*rToFill = (*pTableTbl)[ nIndex ];
|
2000-09-18 16:15:01 +00:00
|
|
|
else
|
2012-05-09 14:24:47 +02:00
|
|
|
rToFill = new SwTableAutoFmt( (*pTableTbl)[ nIndex ] );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2011-11-17 22:13:42 +04:00
|
|
|
else
|
2000-09-18 16:15:01 +00:00
|
|
|
delete rToFill, rToFill = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------
|
|
|
|
Handler:
|
|
|
|
---------*/
|
|
|
|
|
|
|
|
|
|
|
|
IMPL_LINK( SwAutoFormatDlg, CheckHdl, Button *, pBtn )
|
|
|
|
{
|
2012-05-09 14:24:47 +02:00
|
|
|
SwTableAutoFmt* pData = &(*pTableTbl)[nIndex];
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bCheck = ((CheckBox*)pBtn)->IsChecked(), bDataChgd = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
if( pBtn == m_pBtnNumFormat )
|
2000-09-18 16:15:01 +00:00
|
|
|
pData->SetValueFormat( bCheck );
|
2012-09-25 11:35:47 +01:00
|
|
|
else if ( pBtn == m_pBtnBorder )
|
2000-09-18 16:15:01 +00:00
|
|
|
pData->SetFrame( bCheck );
|
2012-09-25 11:35:47 +01:00
|
|
|
else if ( pBtn == m_pBtnFont )
|
2000-09-18 16:15:01 +00:00
|
|
|
pData->SetFont( bCheck );
|
2012-09-25 11:35:47 +01:00
|
|
|
else if ( pBtn == m_pBtnPattern )
|
2000-09-18 16:15:01 +00:00
|
|
|
pData->SetBackground( bCheck );
|
2012-09-25 11:35:47 +01:00
|
|
|
else if ( pBtn == m_pBtnAlignment )
|
2000-09-18 16:15:01 +00:00
|
|
|
pData->SetJustify( bCheck );
|
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
bDataChgd = sal_False;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if( bDataChgd )
|
|
|
|
{
|
|
|
|
if( !bCoreDataChanged )
|
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnCancel->SetText( aStrClose );
|
2011-01-17 15:06:54 +01:00
|
|
|
bCoreDataChanged = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pWndPreview->NotifyChange( *pData );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SwAutoFormatDlg, AddHdl)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-02-20 00:58:47 +09:00
|
|
|
bool bOk = false, bFmtInserted = false;
|
2000-09-18 16:15:01 +00:00
|
|
|
while( !bOk )
|
|
|
|
{
|
|
|
|
SwStringInputDlg* pDlg = new SwStringInputDlg( this,
|
|
|
|
aStrTitle,
|
|
|
|
aStrLabel,
|
|
|
|
aEmptyStr );
|
|
|
|
if( RET_OK == pDlg->Execute() )
|
|
|
|
{
|
|
|
|
String aFormatName;
|
|
|
|
pDlg->GetInputString( aFormatName );
|
|
|
|
|
|
|
|
if( aFormatName.Len() > 0 )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 n;
|
2012-05-09 14:24:47 +02:00
|
|
|
for( n = 0; n < pTableTbl->size(); ++n )
|
|
|
|
if( (*pTableTbl)[n].GetName() == aFormatName )
|
2000-09-18 16:15:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-09 14:24:47 +02:00
|
|
|
if( n >= pTableTbl->size() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
// Format mit dem Namen noch nicht vorhanden, also
|
|
|
|
// aufnehmen
|
2012-05-09 14:24:47 +02:00
|
|
|
SwTableAutoFmt* pNewData = new
|
2000-09-18 16:15:01 +00:00
|
|
|
SwTableAutoFmt( aFormatName );
|
|
|
|
pShell->GetTableAutoFmt( *pNewData );
|
|
|
|
|
|
|
|
// Sortiert einfuegen!!
|
2012-05-09 14:24:47 +02:00
|
|
|
for( n = 1; n < pTableTbl->size(); ++n )
|
|
|
|
if( (*pTableTbl)[ n ].GetName() > aFormatName )
|
2000-09-18 16:15:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-15 00:25:35 +02:00
|
|
|
pTableTbl->InsertAutoFmt(n, pNewData);
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pLbFormat->InsertEntry( aFormatName, nDfltStylePos + n );
|
|
|
|
m_pLbFormat->SelectEntryPos( nDfltStylePos + n );
|
2013-02-20 00:58:47 +09:00
|
|
|
bFmtInserted = true;
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnAdd->Enable( sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
if ( !bCoreDataChanged )
|
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnCancel->SetText( aStrClose );
|
2011-01-17 15:06:54 +01:00
|
|
|
bCoreDataChanged = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SelFmtHdl( 0 );
|
2013-02-20 00:58:47 +09:00
|
|
|
bOk = true;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !bFmtInserted )
|
|
|
|
{
|
|
|
|
bOk = RET_CANCEL == ErrorBox( this,
|
|
|
|
WinBits( WB_OK_CANCEL | WB_DEF_OK),
|
|
|
|
aStrInvalidFmt
|
|
|
|
).Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2013-02-20 00:58:47 +09:00
|
|
|
bOk = true;
|
2000-09-18 16:15:01 +00:00
|
|
|
delete pDlg;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SwAutoFormatDlg, RemoveHdl)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
String aMessage = aStrDelMsg ;
|
|
|
|
aMessage.AppendAscii("\n\n");
|
2012-09-25 11:35:47 +01:00
|
|
|
aMessage += m_pLbFormat->GetSelectEntry() ;
|
2000-09-18 16:15:01 +00:00
|
|
|
aMessage += '\n';
|
|
|
|
|
|
|
|
MessBox* pBox = new MessBox( this, WinBits( WB_OK_CANCEL ),
|
|
|
|
aStrDelTitle, aMessage);
|
|
|
|
|
|
|
|
if ( pBox->Execute() == RET_OK )
|
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pLbFormat->RemoveEntry( nDfltStylePos + nIndex );
|
|
|
|
m_pLbFormat->SelectEntryPos( nDfltStylePos + nIndex-1 );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-05-15 00:25:35 +02:00
|
|
|
pTableTbl->EraseAutoFmt(nIndex);
|
2000-09-18 16:15:01 +00:00
|
|
|
nIndex--;
|
|
|
|
|
|
|
|
if( !nIndex )
|
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnRemove->Enable(sal_False);
|
|
|
|
m_pBtnRename->Enable(sal_False);
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( !bCoreDataChanged )
|
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnCancel->SetText( aStrClose );
|
2011-01-17 15:06:54 +01:00
|
|
|
bCoreDataChanged = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
delete pBox;
|
|
|
|
|
|
|
|
SelFmtHdl( 0 );
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SwAutoFormatDlg, RenameHdl)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-02-20 00:58:47 +09:00
|
|
|
bool bOk = false;
|
2000-09-18 16:15:01 +00:00
|
|
|
while( !bOk )
|
|
|
|
{
|
|
|
|
SwStringInputDlg* pDlg = new SwStringInputDlg( this,
|
2012-09-25 11:35:47 +01:00
|
|
|
aStrRenameTitle, m_pLbFormat->GetSelectEntry(),
|
2000-09-18 16:15:01 +00:00
|
|
|
aEmptyStr );
|
|
|
|
if( pDlg->Execute() == RET_OK )
|
|
|
|
{
|
2013-02-20 00:58:47 +09:00
|
|
|
bool bFmtRenamed = false;
|
2000-09-18 16:15:01 +00:00
|
|
|
String aFormatName;
|
|
|
|
pDlg->GetInputString( aFormatName );
|
|
|
|
|
|
|
|
if ( aFormatName.Len() > 0 )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 n;
|
2012-05-09 14:24:47 +02:00
|
|
|
for( n = 0; n < pTableTbl->size(); ++n )
|
|
|
|
if ((*pTableTbl)[n].GetName() == aFormatName)
|
2000-09-18 16:15:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-09 14:24:47 +02:00
|
|
|
if( n >= pTableTbl->size() )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2012-05-14 18:53:42 +02:00
|
|
|
// no format with this name exists, so rename it
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pLbFormat->RemoveEntry( nDfltStylePos + nIndex );
|
2012-05-09 14:24:47 +02:00
|
|
|
SwTableAutoFmt* p = &(*pTableTbl)[ nIndex ];
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
p->SetName( aFormatName );
|
|
|
|
|
2012-05-14 18:53:42 +02:00
|
|
|
// keep all arrays sorted!
|
2012-05-09 14:24:47 +02:00
|
|
|
for( n = 1; n < pTableTbl->size(); ++n )
|
2012-05-14 18:53:42 +02:00
|
|
|
if ((n != nIndex) &&
|
|
|
|
((*pTableTbl)[n].GetName() > aFormatName))
|
|
|
|
{
|
2000-09-18 16:15:01 +00:00
|
|
|
break;
|
2012-05-14 18:53:42 +02:00
|
|
|
}
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2012-05-15 00:25:35 +02:00
|
|
|
pTableTbl->MoveAutoFmt(n, nIndex);
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pLbFormat->InsertEntry( aFormatName, nDfltStylePos + n );
|
|
|
|
m_pLbFormat->SelectEntryPos( nDfltStylePos + n );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if ( !bCoreDataChanged )
|
|
|
|
{
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnCancel->SetText( aStrClose );
|
2011-01-17 15:06:54 +01:00
|
|
|
bCoreDataChanged = sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SelFmtHdl( 0 );
|
2013-02-20 00:58:47 +09:00
|
|
|
bOk = true;
|
|
|
|
bFmtRenamed = true;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !bFmtRenamed )
|
|
|
|
{
|
|
|
|
bOk = RET_CANCEL == ErrorBox( this,
|
|
|
|
WinBits( WB_OK_CANCEL | WB_DEF_OK),
|
|
|
|
aStrInvalidFmt
|
|
|
|
).Execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2013-02-20 00:58:47 +09:00
|
|
|
bOk = true;
|
2000-09-18 16:15:01 +00:00
|
|
|
delete pDlg;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG(SwAutoFormatDlg, SelFmtHdl)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bBtnEnable = sal_False;
|
2012-09-25 11:35:47 +01:00
|
|
|
sal_uInt8 nSelPos = (sal_uInt8) m_pLbFormat->GetSelectEntryPos(), nOldIdx = nIndex;
|
2000-09-18 16:15:01 +00:00
|
|
|
if( nSelPos >= nDfltStylePos )
|
|
|
|
{
|
|
|
|
nIndex = nSelPos - nDfltStylePos;
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pWndPreview->NotifyChange( (*pTableTbl)[nIndex] );
|
2000-09-18 16:15:01 +00:00
|
|
|
bBtnEnable = 0 != nIndex;
|
2012-05-09 14:24:47 +02:00
|
|
|
UpdateChecks( (*pTableTbl)[nIndex], sal_True );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nIndex = 255;
|
|
|
|
|
|
|
|
SwTableAutoFmt aTmp( ViewShell::GetShellRes()->aStrNone );
|
2011-01-17 15:06:54 +01:00
|
|
|
aTmp.SetFont( sal_False );
|
|
|
|
aTmp.SetJustify( sal_False );
|
|
|
|
aTmp.SetFrame( sal_False );
|
|
|
|
aTmp.SetBackground( sal_False );
|
|
|
|
aTmp.SetValueFormat( sal_False );
|
|
|
|
aTmp.SetWidthHeight( sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
if( nOldIdx != nIndex )
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pWndPreview->NotifyChange( aTmp );
|
2011-01-17 15:06:54 +01:00
|
|
|
UpdateChecks( aTmp, sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
m_pBtnRemove->Enable( bBtnEnable );
|
|
|
|
m_pBtnRename->Enable( bBtnEnable );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG_INLINE_START(SwAutoFormatDlg, OkHdl)
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
if( bSetAutoFmt )
|
2012-05-09 14:24:47 +02:00
|
|
|
pShell->SetTableAutoFmt( (*pTableTbl)[ nIndex ] );
|
2000-09-18 16:15:01 +00:00
|
|
|
EndDialog( RET_OK );
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_True;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2012-03-01 18:00:32 +01:00
|
|
|
IMPL_LINK_NOARG_INLINE_END(SwAutoFormatDlg, OkHdl)
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
// AutoFmtPreview
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
AutoFmtPreview::AutoFmtPreview(Window* pParent) :
|
|
|
|
Window ( pParent ),
|
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 ),
|
2011-01-17 15:06:54 +01:00
|
|
|
bFitWidth ( sal_False ),
|
2008-05-06 11:56:46 +00:00
|
|
|
mbRTL ( false ),
|
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 ) ),
|
2013-01-10 16:40:27 +02:00
|
|
|
aStrSum ( SW_RES( STR_SUM ) )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
2013-01-10 16:40:27 +02:00
|
|
|
uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
|
|
|
|
m_xBreak = i18n::BreakIterator::create(xContext);
|
|
|
|
pNumFmt = new SvNumberFormatter( xContext, LANGUAGE_SYSTEM );
|
2000-10-20 08:51:34 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
2012-09-25 11:35:47 +01:00
|
|
|
extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeAutoFmtPreview(Window *pParent, VclBuilder::stringmap &)
|
|
|
|
{
|
|
|
|
return new AutoFmtPreview(pParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AutoFmtPreview::Resize()
|
|
|
|
{
|
|
|
|
aPrvSize = Size(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;
|
|
|
|
NotifyChange(aCurData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AutoFmtPreview::DetectRTL(SwWrtShell* pWrtShell)
|
|
|
|
{
|
|
|
|
if (!pWrtShell->IsCrsrInTbl()) // We haven't created the table yet
|
|
|
|
mbRTL = Application::GetSettings().GetLayoutRTL();
|
|
|
|
else
|
|
|
|
mbRTL = pWrtShell->IsTableRightToLeft();
|
|
|
|
}
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2010-12-12 00:08:03 +01:00
|
|
|
AutoFmtPreview::~AutoFmtPreview()
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void AutoFmtPreview::MakeFonts( sal_uInt8 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 );
|
2011-01-17 15:06:54 +01:00
|
|
|
SETONALLFONTS( SetTransparent, sal_True );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 AutoFmtPreview::GetFormatIndex( size_t nCol, size_t nRow ) const
|
2004-08-02 16:16:40 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
static const sal_uInt8 pnFmtMap[] =
|
2004-08-02 16:16:40 +00:00
|
|
|
{
|
|
|
|
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:
|
|
|
|
//------------------------
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNum;
|
2000-09-18 16:15:01 +00:00
|
|
|
double nVal;
|
|
|
|
String cellString;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 nIndex = static_cast< sal_uInt8 >( 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;
|
2011-01-17 15:06:54 +01:00
|
|
|
aCurData.GetBoxFmt( (sal_uInt8)nNum ).GetValueFormat( sFmt, eLng, eSys );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2005-09-23 11:19:52 +00:00
|
|
|
short nType;
|
2011-08-10 01:32:41 +02:00
|
|
|
bool bNew;
|
2005-09-23 11:19:52 +00:00
|
|
|
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
|
2013-02-20 00:18:07 +01:00
|
|
|
cellString = OUString::number((sal_Int32)nVal);
|
2000-09-18 16:15:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if( cellString.Len() )
|
|
|
|
{
|
|
|
|
Size aStrSize;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt8 nFmtIndex = GetFormatIndex( nCol, nRow );
|
2004-08-02 16:16:40 +00:00
|
|
|
Rectangle cellRect = maArray.GetCellRect( nCol, nRow );
|
|
|
|
Point aPos = cellRect.TopLeft();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRightX = 0;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
nRightX = (sal_uInt16)( cellRect.GetWidth()
|
2000-09-18 16:15:01 +00:00
|
|
|
- aStrSize.Width()
|
|
|
|
- FRAME_OFFSET );
|
|
|
|
|
|
|
|
//-----------------------------
|
|
|
|
// vertikal (immer zentrieren):
|
|
|
|
//-----------------------------
|
2011-01-17 15:06:54 +01:00
|
|
|
aPos.Y() += (nRowHeight - (sal_uInt16)aStrSize.Height()) / 2;
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
//-----------
|
|
|
|
// 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
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nHorPos = (sal_uInt16)
|
2000-09-18 16:15:01 +00:00
|
|
|
((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
|
|
|
|
|
|
|
|
2010-12-11 15:42:15 +01:00
|
|
|
void AutoFmtPreview::Init()
|
2004-08-02 16:16:40 +00:00
|
|
|
{
|
|
|
|
SetBorderStyle( GetBorderStyle() | WINDOW_BORDER_MONO );
|
|
|
|
maArray.Initialize( 5, 5 );
|
|
|
|
maArray.SetUseDiagDoubleClipping( false );
|
2011-01-17 15:06:54 +01:00
|
|
|
CalcCellArray( sal_False );
|
2000-09-18 16:15:01 +00:00
|
|
|
CalcLineMap();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void AutoFmtPreview::CalcCellArray( sal_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
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2011-03-25 15:51:54 +01:00
|
|
|
inline void lclSetStyleFromBorder( svx::frame::Style& rStyle, const ::editeng::SvxBorderLine* pBorder )
|
2004-08-02 16:16:40 +00:00
|
|
|
{
|
|
|
|
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;
|
2011-01-17 15:06:54 +01:00
|
|
|
bFitWidth = aCurData.IsJustify();//sal_True; //???
|
2000-09-18 16:15:01 +00:00
|
|
|
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();
|
2012-03-23 12:39:16 +00:00
|
|
|
if( GetSettings().GetStyleSettings().GetHighContrastMode() )
|
2002-08-13 09:06:19 +00:00
|
|
|
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();
|
|
|
|
Color oldColor;
|
|
|
|
Font aFont;
|
|
|
|
|
|
|
|
aFont = aVD.GetFont();
|
2011-01-17 15:06:54 +01:00
|
|
|
aFont.SetTransparent( sal_True );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2010-12-11 15:42:15 +01:00
|
|
|
void AutoFmtPreview::Paint( const Rectangle& rRect )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
DoPaint( rRect );
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|