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 .
|
|
|
|
*/
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <float.h>
|
|
|
|
#include <hintids.hxx>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <hints.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/lrspitem.hxx>
|
|
|
|
#include <editeng/shaditem.hxx>
|
2013-02-12 13:41:53 -05:00
|
|
|
#include <editeng/adjustitem.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/colritem.hxx>
|
2010-01-13 22:25:07 +01:00
|
|
|
#include <sfx2/linkmgr.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/boxitem.hxx>
|
2007-02-28 14:50:39 +00:00
|
|
|
#include <fmtfsize.hxx>
|
|
|
|
#include <fmtornt.hxx>
|
|
|
|
#include <fmtpdsc.hxx>
|
2009-11-24 11:34:17 +01:00
|
|
|
#include <fldbas.hxx>
|
|
|
|
#include <fmtfld.hxx>
|
2007-02-28 14:50:39 +00:00
|
|
|
#include <frmatr.hxx>
|
|
|
|
#include <doc.hxx>
|
2013-10-22 15:58:57 +03:00
|
|
|
#include <docary.hxx>
|
2007-02-28 14:50:39 +00:00
|
|
|
#include <frame.hxx>
|
|
|
|
#include <swtable.hxx>
|
|
|
|
#include <ndtxt.hxx>
|
|
|
|
#include <tabcol.hxx>
|
|
|
|
#include <tabfrm.hxx>
|
|
|
|
#include <cellfrm.hxx>
|
|
|
|
#include <rowfrm.hxx>
|
|
|
|
#include <swserv.hxx>
|
|
|
|
#include <expfld.hxx>
|
|
|
|
#include <mdiexp.hxx>
|
|
|
|
#include <cellatr.hxx>
|
|
|
|
#include <txatbase.hxx>
|
|
|
|
#include <htmltbl.hxx>
|
|
|
|
#include <swtblfmt.hxx>
|
|
|
|
#include <ndindex.hxx>
|
|
|
|
#include <tblrwcl.hxx>
|
|
|
|
#include <shellres.hxx>
|
|
|
|
#include <viewsh.hxx>
|
|
|
|
#include <redline.hxx>
|
|
|
|
#include <list>
|
2010-12-17 09:02:23 +01:00
|
|
|
#include <switerator.hxx>
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2011-11-24 00:52:00 +01:00
|
|
|
#ifdef DBG_UTIL
|
2007-02-28 14:50:39 +00:00
|
|
|
#define CHECK_TABLE(t) (t).CheckConsistency();
|
|
|
|
#else
|
|
|
|
#define CHECK_TABLE(t)
|
|
|
|
#endif
|
|
|
|
|
2007-09-27 08:11:01 +00:00
|
|
|
using namespace com::sun::star;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
TYPEINIT1( SwTable, SwClient );
|
|
|
|
TYPEINIT1( SwTableBox, SwClient );
|
|
|
|
TYPEINIT1( SwTableLine, SwClient );
|
|
|
|
TYPEINIT1( SwTableFmt, SwFrmFmt );
|
|
|
|
TYPEINIT1( SwTableBoxFmt, SwFrmFmt );
|
|
|
|
TYPEINIT1( SwTableLineFmt, SwFrmFmt );
|
|
|
|
|
|
|
|
SV_IMPL_REF( SwServerObject )
|
|
|
|
|
|
|
|
#define COLFUZZY 20
|
|
|
|
|
2013-10-16 11:18:56 +02:00
|
|
|
void ChgTextToNum( SwTableBox& rBox, const OUString& rTxt, const Color* pCol,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bChgAlign,sal_uLong nNdPos );
|
2007-02-28 14:50:39 +00:00
|
|
|
//----------------------------------
|
|
|
|
|
|
|
|
class SwTableBox_Impl
|
|
|
|
{
|
|
|
|
Color *mpUserColor, *mpNumFmtColor;
|
|
|
|
long mnRowSpan;
|
|
|
|
bool mbDummyFlag;
|
|
|
|
|
|
|
|
void SetNewCol( Color** ppCol, const Color* pNewCol );
|
|
|
|
public:
|
|
|
|
SwTableBox_Impl() : mpUserColor(0), mpNumFmtColor(0), mnRowSpan(1),
|
|
|
|
mbDummyFlag( false ) {}
|
|
|
|
~SwTableBox_Impl() { delete mpUserColor; delete mpNumFmtColor; }
|
|
|
|
|
|
|
|
const Color* GetSaveUserColor() const { return mpUserColor; }
|
|
|
|
const Color* GetSaveNumFmtColor() const { return mpNumFmtColor; }
|
|
|
|
void SetSaveUserColor(const Color* p ) { SetNewCol( &mpUserColor, p ); }
|
|
|
|
void SetSaveNumFmtColor( const Color* p ) { SetNewCol( &mpNumFmtColor, p ); }
|
|
|
|
long getRowSpan() const { return mnRowSpan; }
|
|
|
|
void setRowSpan( long nNewRowSpan ) { mnRowSpan = nNewRowSpan; }
|
|
|
|
bool getDummyFlag() const { return mbDummyFlag; }
|
|
|
|
void setDummyFlag( bool bDummy ) { mbDummyFlag = bDummy; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------- Inlines -----------------------------
|
|
|
|
|
|
|
|
inline const Color* SwTableBox::GetSaveUserColor() const
|
|
|
|
{
|
|
|
|
return pImpl ? pImpl->GetSaveUserColor() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const Color* SwTableBox::GetSaveNumFmtColor() const
|
|
|
|
{
|
|
|
|
return pImpl ? pImpl->GetSaveNumFmtColor() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void SwTableBox::SetSaveUserColor(const Color* p )
|
|
|
|
{
|
|
|
|
if( pImpl )
|
|
|
|
pImpl->SetSaveUserColor( p );
|
|
|
|
else if( p )
|
|
|
|
( pImpl = new SwTableBox_Impl ) ->SetSaveUserColor( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void SwTableBox::SetSaveNumFmtColor( const Color* p )
|
|
|
|
{
|
|
|
|
if( pImpl )
|
|
|
|
pImpl->SetSaveNumFmtColor( p );
|
|
|
|
else if( p )
|
|
|
|
( pImpl = new SwTableBox_Impl )->SetSaveNumFmtColor( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
long SwTableBox::getRowSpan() const
|
|
|
|
{
|
|
|
|
return pImpl ? pImpl->getRowSpan() : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTableBox::setRowSpan( long nNewRowSpan )
|
|
|
|
{
|
|
|
|
if( !pImpl )
|
|
|
|
{
|
|
|
|
if( nNewRowSpan == 1 )
|
|
|
|
return;
|
|
|
|
pImpl = new SwTableBox_Impl();
|
|
|
|
}
|
|
|
|
pImpl->setRowSpan( nNewRowSpan );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SwTableBox::getDummyFlag() const
|
|
|
|
{
|
|
|
|
return pImpl ? pImpl->getDummyFlag() : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTableBox::setDummyFlag( bool bDummy )
|
|
|
|
{
|
|
|
|
if( !pImpl )
|
|
|
|
{
|
|
|
|
if( !bDummy )
|
|
|
|
return;
|
|
|
|
pImpl = new SwTableBox_Impl();
|
|
|
|
}
|
|
|
|
pImpl->setDummyFlag( bDummy );
|
|
|
|
}
|
|
|
|
|
2010-10-17 17:09:39 -05:00
|
|
|
//JP 15.09.98: Bug 55741 - Keep tabs (front and rear)
|
2013-10-16 11:18:56 +02:00
|
|
|
static OUString& lcl_TabToBlankAtSttEnd( OUString& rTxt )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
sal_Unicode c;
|
2013-12-16 23:39:58 +01:00
|
|
|
sal_Int32 n;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2013-10-16 11:18:56 +02:00
|
|
|
for( n = 0; n < rTxt.getLength() && ' ' >= ( c = rTxt[n] ); ++n )
|
2007-02-28 14:50:39 +00:00
|
|
|
if( '\x9' == c )
|
2013-10-16 11:18:56 +02:00
|
|
|
rTxt = rTxt.replaceAt( n, 1, " " );
|
|
|
|
for( n = rTxt.getLength(); n && ' ' >= ( c = rTxt[--n] ); )
|
2007-02-28 14:50:39 +00:00
|
|
|
if( '\x9' == c )
|
2013-10-16 11:18:56 +02:00
|
|
|
rTxt = rTxt.replaceAt( n, 1, " " );
|
2007-02-28 14:50:39 +00:00
|
|
|
return rTxt;
|
|
|
|
}
|
|
|
|
|
2013-07-05 16:25:03 -05:00
|
|
|
static OUString& lcl_DelTabsAtSttEnd( OUString& rTxt )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
sal_Unicode c;
|
2013-07-05 16:25:03 -05:00
|
|
|
sal_Int32 n;
|
|
|
|
OUStringBuffer sBuff(rTxt);
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2013-07-05 16:25:03 -05:00
|
|
|
for( n = 0; n < sBuff.getLength() && ' ' >= ( c = sBuff[ n ]); ++n )
|
|
|
|
{
|
2007-02-28 14:50:39 +00:00
|
|
|
if( '\x9' == c )
|
2013-07-05 16:25:03 -05:00
|
|
|
sBuff.remove( n--, 1 );
|
|
|
|
}
|
|
|
|
for( n = sBuff.getLength(); n && ' ' >= ( c = sBuff[ --n ]); )
|
|
|
|
{
|
2007-02-28 14:50:39 +00:00
|
|
|
if( '\x9' == c )
|
2013-07-05 16:25:03 -05:00
|
|
|
sBuff.remove( n, 1 );
|
|
|
|
}
|
|
|
|
rTxt = sBuff.makeStringAndClear();
|
2007-02-28 14:50:39 +00:00
|
|
|
return rTxt;
|
|
|
|
}
|
|
|
|
|
|
|
|
void _InsTblBox( SwDoc* pDoc, SwTableNode* pTblNd,
|
|
|
|
SwTableLine* pLine, SwTableBoxFmt* pBoxFrmFmt,
|
|
|
|
SwTableBox* pBox,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nInsPos, sal_uInt16 nCnt )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-05-05 21:36:48 +02:00
|
|
|
OSL_ENSURE( pBox->GetSttNd(), "Box with no start node" );
|
2007-02-28 14:50:39 +00:00
|
|
|
SwNodeIndex aIdx( *pBox->GetSttNd(), +1 );
|
|
|
|
SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
|
|
|
|
if( !pCNd )
|
|
|
|
pCNd = pDoc->GetNodes().GoNext( &aIdx );
|
2012-05-05 21:36:48 +02:00
|
|
|
OSL_ENSURE( pCNd, "Box with no content node" );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
if( pCNd->IsTxtNode() )
|
|
|
|
{
|
|
|
|
if( pBox->GetSaveNumFmtColor() && pCNd->GetpSwAttrSet() )
|
|
|
|
{
|
|
|
|
SwAttrSet aAttrSet( *pCNd->GetpSwAttrSet() );
|
|
|
|
if( pBox->GetSaveUserColor() )
|
2007-05-10 15:01:22 +00:00
|
|
|
aAttrSet.Put( SvxColorItem( *pBox->GetSaveUserColor(), RES_CHRATR_COLOR ));
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
|
|
|
aAttrSet.ClearItem( RES_CHRATR_COLOR );
|
|
|
|
pDoc->GetNodes().InsBoxen( pTblNd, pLine, pBoxFrmFmt,
|
|
|
|
((SwTxtNode*)pCNd)->GetTxtColl(),
|
|
|
|
&aAttrSet, nInsPos, nCnt );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pDoc->GetNodes().InsBoxen( pTblNd, pLine, pBoxFrmFmt,
|
|
|
|
((SwTxtNode*)pCNd)->GetTxtColl(),
|
|
|
|
pCNd->GetpSwAttrSet(),
|
|
|
|
nInsPos, nCnt );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pDoc->GetNodes().InsBoxen( pTblNd, pLine, pBoxFrmFmt,
|
|
|
|
(SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl(), 0,
|
|
|
|
nInsPos, nCnt );
|
|
|
|
|
|
|
|
long nRowSpan = pBox->getRowSpan();
|
|
|
|
if( nRowSpan != 1 )
|
|
|
|
{
|
|
|
|
SwTableBoxes& rTblBoxes = pLine->GetTabBoxes();
|
2011-01-17 15:06:54 +01:00
|
|
|
for( sal_uInt16 i = 0; i < nCnt; ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
pBox = rTblBoxes[ i + nInsPos ];
|
|
|
|
pBox->setRowSpan( nRowSpan );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwTable::SwTable()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
SwTable::SwTable( SwTableFmt* pFmt )
|
|
|
|
: SwClient( pFmt ),
|
|
|
|
pHTMLLayout( 0 ),
|
|
|
|
pTableNode( 0 ),
|
|
|
|
nGrfsThatResize( 0 ),
|
|
|
|
nRowsToRepeat( 1 ),
|
2012-11-21 07:34:08 +09:00
|
|
|
bModifyLocked( false ),
|
2011-01-17 15:06:54 +01:00
|
|
|
bNewModel( sal_True )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2010-10-17 17:09:39 -05:00
|
|
|
// default value set in the options
|
2007-02-28 14:50:39 +00:00
|
|
|
eTblChgMode = (TblChgMode)GetTblChgDefaultMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
SwTable::SwTable( const SwTable& rTable )
|
|
|
|
: SwClient( rTable.GetFrmFmt() ),
|
|
|
|
pHTMLLayout( 0 ),
|
|
|
|
pTableNode( 0 ),
|
|
|
|
eTblChgMode( rTable.eTblChgMode ),
|
|
|
|
nGrfsThatResize( 0 ),
|
|
|
|
nRowsToRepeat( rTable.GetRowsToRepeat() ),
|
2012-11-21 07:34:08 +09:00
|
|
|
bModifyLocked( false ),
|
2007-02-28 14:50:39 +00:00
|
|
|
bNewModel( rTable.bNewModel )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void DelBoxNode( SwTableSortBoxes& rSortCntBoxes )
|
|
|
|
{
|
2012-09-20 23:59:14 +02:00
|
|
|
for (size_t n = 0; n < rSortCntBoxes.size(); ++n)
|
|
|
|
{
|
2007-02-28 14:50:39 +00:00
|
|
|
rSortCntBoxes[ n ]->pSttNd = 0;
|
2012-09-20 23:59:14 +02:00
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwTable::~SwTable()
|
|
|
|
{
|
|
|
|
if( refObj.Is() )
|
|
|
|
{
|
|
|
|
SwDoc* pDoc = GetFrmFmt()->GetDoc();
|
2010-10-17 17:09:39 -05:00
|
|
|
if( !pDoc->IsInDtor() ) // then remove from the list
|
2007-02-28 14:50:39 +00:00
|
|
|
pDoc->GetLinkManager().RemoveServer( &refObj );
|
|
|
|
|
|
|
|
refObj->Closed();
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// the table can be deleted if it's the last client of the FrameFormat
|
2007-02-28 14:50:39 +00:00
|
|
|
SwTableFmt* pFmt = (SwTableFmt*)GetFrmFmt();
|
2012-08-10 15:42:44 +02:00
|
|
|
pFmt->Remove( this ); // remove
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
if( !pFmt->GetDepends() )
|
2012-08-10 15:42:44 +02:00
|
|
|
pFmt->GetDoc()->DelTblFrmFmt( pFmt ); // and delete
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Delete the pointers from the SortArray of the boxes. The objects
|
|
|
|
// are preserved and are deleted by the lines/boxes arrays dtor.
|
|
|
|
// Note: unfortunately not enough, pointers to the StartNode of the
|
|
|
|
// section need deletion.
|
2012-09-20 23:59:14 +02:00
|
|
|
DelBoxNode(m_TabSortContentBoxes);
|
|
|
|
m_TabSortContentBoxes.clear();
|
2007-02-28 14:50:39 +00:00
|
|
|
delete pHTMLLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwTable::Modify()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2012-06-22 10:17:25 +02:00
|
|
|
static void FmtInArr( std::vector<SwFmt*>& rFmtArr, SwFmt* pBoxFmt )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-06-22 10:17:25 +02:00
|
|
|
std::vector<SwFmt*>::const_iterator it = std::find( rFmtArr.begin(), rFmtArr.end(), pBoxFmt );
|
|
|
|
if ( it == rFmtArr.end() )
|
|
|
|
rFmtArr.push_back( pBoxFmt );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2012-06-22 10:17:25 +02:00
|
|
|
static void lcl_ModifyBoxes( SwTableBoxes &rBoxes, const long nOld,
|
|
|
|
const long nNew, std::vector<SwFmt*>& rFmtArr );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-06-22 10:17:25 +02:00
|
|
|
static void lcl_ModifyLines( SwTableLines &rLines, const long nOld,
|
|
|
|
const long nNew, std::vector<SwFmt*>& rFmtArr, const bool bCheckSum )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-06-18 18:04:44 +02:00
|
|
|
for ( sal_uInt16 i = 0; i < rLines.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_ModifyBoxes( rLines[i]->GetTabBoxes(), nOld, nNew, rFmtArr );
|
|
|
|
if( bCheckSum )
|
|
|
|
{
|
2012-06-22 10:17:25 +02:00
|
|
|
for( sal_uInt16 i = 0; i < rFmtArr.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-06-22 10:17:25 +02:00
|
|
|
SwFmt* pFmt = rFmtArr[i];
|
2007-02-28 14:50:39 +00:00
|
|
|
sal_uInt64 nBox = pFmt->GetFrmSize().GetWidth();
|
|
|
|
nBox *= nNew;
|
|
|
|
nBox /= nOld;
|
|
|
|
SwFmtFrmSize aNewBox( ATT_VAR_SIZE, SwTwips(nBox), 0 );
|
|
|
|
pFmt->LockModify();
|
2008-06-13 09:13:23 +00:00
|
|
|
pFmt->SetFmtAttr( aNewBox );
|
2007-02-28 14:50:39 +00:00
|
|
|
pFmt->UnlockModify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-22 10:17:25 +02:00
|
|
|
static void lcl_ModifyBoxes( SwTableBoxes &rBoxes, const long nOld,
|
|
|
|
const long nNew, std::vector<SwFmt*>& rFmtArr )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
sal_uInt64 nSum = 0; // To avoid rounding errors we summarize all box widths
|
|
|
|
sal_uInt64 nOriginalSum = 0; // Sum of original widths
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
SwTableBox &rBox = *rBoxes[i];
|
2012-06-18 18:04:44 +02:00
|
|
|
if ( !rBox.GetTabLines().empty() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
// For SubTables the rounding problem will not be solved :-(
|
|
|
|
::lcl_ModifyLines( rBox.GetTabLines(), nOld, nNew, rFmtArr, false );
|
|
|
|
}
|
2012-08-10 15:42:44 +02:00
|
|
|
// Adjust the box
|
2007-02-28 14:50:39 +00:00
|
|
|
SwFrmFmt *pFmt = rBox.GetFrmFmt();
|
|
|
|
sal_uInt64 nBox = pFmt->GetFrmSize().GetWidth();
|
|
|
|
nOriginalSum += nBox;
|
|
|
|
nBox *= nNew;
|
|
|
|
nBox /= nOld;
|
|
|
|
sal_uInt64 nWishedSum = nOriginalSum;
|
|
|
|
nWishedSum *= nNew;
|
|
|
|
nWishedSum /= nOld;
|
|
|
|
nWishedSum -= nSum;
|
|
|
|
if( nWishedSum > 0 )
|
|
|
|
{
|
|
|
|
if( nBox == nWishedSum )
|
|
|
|
FmtInArr( rFmtArr, pFmt );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nBox = nWishedSum;
|
|
|
|
pFmt = rBox.ClaimFrmFmt();
|
2007-09-27 08:11:01 +00:00
|
|
|
SwFmtFrmSize aNewBox( ATT_VAR_SIZE, static_cast< SwTwips >(nBox), 0 );
|
2007-02-28 14:50:39 +00:00
|
|
|
pFmt->LockModify();
|
2008-06-13 09:13:23 +00:00
|
|
|
pFmt->SetFmtAttr( aNewBox );
|
2007-02-28 14:50:39 +00:00
|
|
|
pFmt->UnlockModify();
|
|
|
|
}
|
|
|
|
}
|
2008-04-22 14:00:50 +00:00
|
|
|
else {
|
2011-03-12 11:51:35 +01:00
|
|
|
OSL_FAIL( "Rounding error" );
|
2008-04-22 14:00:50 +00:00
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
nSum += nBox;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
void SwTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// catch SSize changes, to adjust the lines/boxes
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ;
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwFmtFrmSize* pNewSize = 0, *pOldSize = 0;
|
|
|
|
|
|
|
|
if( RES_ATTRSET_CHG == nWhich )
|
|
|
|
{
|
|
|
|
if( SFX_ITEM_SET == ((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState(
|
2011-01-17 15:06:54 +01:00
|
|
|
RES_FRM_SIZE, sal_False, (const SfxPoolItem**)&pNewSize ))
|
2007-02-28 14:50:39 +00:00
|
|
|
pOldSize = &((SwAttrSetChg*)pOld)->GetChgSet()->GetFrmSize();
|
|
|
|
}
|
|
|
|
else if( RES_FRM_SIZE == nWhich )
|
|
|
|
{
|
|
|
|
pOldSize = (const SwFmtFrmSize*)pOld;
|
|
|
|
pNewSize = (const SwFmtFrmSize*)pNew;
|
|
|
|
}
|
2010-12-17 09:02:23 +01:00
|
|
|
else
|
|
|
|
CheckRegistration( pOld, pNew );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
if( pOldSize || pNewSize )
|
|
|
|
{
|
|
|
|
if ( !IsModifyLocked() )
|
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( pOldSize && pOldSize->Which() == RES_FRM_SIZE &&
|
2007-02-28 14:50:39 +00:00
|
|
|
pNewSize && pNewSize->Which() == RES_FRM_SIZE,
|
2012-08-10 15:42:44 +02:00
|
|
|
"No Old or New for FmtFrmSize-Modify of the SwTable." );
|
2007-02-28 14:50:39 +00:00
|
|
|
AdjustWidths( pOldSize->GetWidth(), pNewSize->GetWidth() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTable::AdjustWidths( const long nOld, const long nNew )
|
|
|
|
{
|
2012-06-22 10:17:25 +02:00
|
|
|
std::vector<SwFmt*> aFmtArr;
|
|
|
|
aFmtArr.reserve( aLines[0]->GetTabBoxes().size() );
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_ModifyLines( aLines, nOld, nNew, aFmtArr, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwTable::GetTabCols()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_RefreshHidden( SwTabCols &rToFill, sal_uInt16 nPos )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
for ( sal_uInt16 i = 0; i < rToFill.Count(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2013-04-11 00:21:40 -03:00
|
|
|
if ( std::abs((long)(nPos - rToFill[i])) <= COLFUZZY )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
rToFill.SetHidden( i, sal_False );
|
2007-02-28 14:50:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_SortedTabColInsert( SwTabCols &rToFill, const SwTableBox *pBox,
|
2011-01-17 15:06:54 +01:00
|
|
|
const SwFrmFmt *pTabFmt, const sal_Bool bHidden,
|
2010-10-05 07:57:55 -05:00
|
|
|
const bool bRefreshHidden )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
const long nWish = pTabFmt->GetFrmSize().GetWidth();
|
2011-07-08 22:49:56 +01:00
|
|
|
OSL_ENSURE(nWish, "weird <= 0 width frmfrm");
|
2007-02-28 14:50:39 +00:00
|
|
|
const long nAct = rToFill.GetRight() - rToFill.GetLeft(); // +1 why?
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// The value for the left edge of the box is calculated from the
|
|
|
|
// widths of the previous boxes.
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPos = 0;
|
|
|
|
sal_uInt16 nSum = 0;
|
|
|
|
sal_uInt16 nLeftMin = 0;
|
|
|
|
sal_uInt16 nRightMax = 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTableBox *pCur = pBox;
|
|
|
|
const SwTableLine *pLine = pBox->GetUpper();
|
|
|
|
while ( pLine )
|
2011-07-08 22:49:56 +01:00
|
|
|
{
|
|
|
|
const SwTableBoxes &rBoxes = pLine->GetTabBoxes();
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
SwTwips nWidth = rBoxes[i]->GetFrmFmt()->GetFrmSize().GetWidth();
|
2011-01-17 15:06:54 +01:00
|
|
|
nSum = (sal_uInt16)(nSum + nWidth);
|
2007-02-28 14:50:39 +00:00
|
|
|
sal_uInt64 nTmp = nSum;
|
|
|
|
nTmp *= nAct;
|
2011-07-08 22:49:56 +01:00
|
|
|
|
|
|
|
if (nWish == 0) //fdo#33012 0 width frmfmt
|
|
|
|
continue;
|
|
|
|
|
2007-02-28 14:50:39 +00:00
|
|
|
nTmp /= nWish;
|
|
|
|
if (rBoxes[i] != pCur)
|
|
|
|
{
|
|
|
|
if ( pLine == pBox->GetUpper() || 0 == nLeftMin )
|
2011-01-17 15:06:54 +01:00
|
|
|
nLeftMin = (sal_uInt16)(nTmp - nPos);
|
|
|
|
nPos = (sal_uInt16)nTmp;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
nSum = (sal_uInt16)(nSum - nWidth);
|
2007-02-28 14:50:39 +00:00
|
|
|
if ( 0 == nRightMax )
|
2011-01-17 15:06:54 +01:00
|
|
|
nRightMax = (sal_uInt16)(nTmp - nPos);
|
2007-02-28 14:50:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pCur = pLine->GetUpper();
|
|
|
|
pLine = pCur ? pCur->GetUpper() : 0;
|
|
|
|
}
|
|
|
|
|
2012-12-03 19:21:53 +09:00
|
|
|
bool bInsert = !bRefreshHidden;
|
2011-01-17 15:06:54 +01:00
|
|
|
for ( sal_uInt16 j = 0; bInsert && (j < rToFill.Count()); ++j )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
long nCmp = rToFill[j];
|
|
|
|
if ( (nPos >= ((nCmp >= COLFUZZY) ? nCmp - COLFUZZY : nCmp)) &&
|
|
|
|
(nPos <= (nCmp + COLFUZZY)) )
|
|
|
|
{
|
2012-12-03 19:21:53 +09:00
|
|
|
bInsert = false; // Already has it.
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
else if ( nPos < nCmp )
|
|
|
|
{
|
2012-12-03 19:21:53 +09:00
|
|
|
bInsert = false;
|
2007-02-28 14:50:39 +00:00
|
|
|
rToFill.Insert( nPos, bHidden, j );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( bInsert )
|
|
|
|
rToFill.Insert( nPos, bHidden, rToFill.Count() );
|
|
|
|
else if ( bRefreshHidden )
|
|
|
|
::lcl_RefreshHidden( rToFill, nPos );
|
|
|
|
|
|
|
|
if ( bHidden && !bRefreshHidden )
|
|
|
|
{
|
|
|
|
// calculate minimum/maximum values for the existing entries:
|
|
|
|
nLeftMin = nPos - nLeftMin;
|
|
|
|
nRightMax = nPos + nRightMax;
|
|
|
|
|
|
|
|
// check if nPos is entry:
|
|
|
|
bool bFoundPos = false;
|
|
|
|
bool bFoundMax = false;
|
2011-01-17 15:06:54 +01:00
|
|
|
for ( sal_uInt16 j = 0; !(bFoundPos && bFoundMax ) && j < rToFill.Count(); ++j )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
SwTabColsEntry& rEntry = rToFill.GetEntry( j );
|
|
|
|
long nCmp = rToFill[j];
|
|
|
|
|
|
|
|
if ( (nPos >= ((nCmp >= COLFUZZY) ? nCmp - COLFUZZY : nCmp)) &&
|
|
|
|
(nPos <= (nCmp + COLFUZZY)) )
|
|
|
|
{
|
|
|
|
// check if nLeftMin is > old minimum for entry nPos:
|
|
|
|
const long nOldMin = rEntry.nMin;
|
|
|
|
if ( nLeftMin > nOldMin )
|
|
|
|
rEntry.nMin = nLeftMin;
|
|
|
|
// check if nRightMin is < old maximum for entry nPos:
|
|
|
|
const long nOldMax = rEntry.nMax;
|
|
|
|
if ( nRightMax < nOldMax )
|
|
|
|
rEntry.nMax = nRightMax;
|
|
|
|
|
|
|
|
bFoundPos = true;
|
|
|
|
}
|
|
|
|
else if ( (nRightMax >= ((nCmp >= COLFUZZY) ? nCmp - COLFUZZY : nCmp)) &&
|
|
|
|
(nRightMax <= (nCmp + COLFUZZY)) )
|
|
|
|
{
|
|
|
|
// check if nPos is > old minimum for entry nRightMax:
|
|
|
|
const long nOldMin = rEntry.nMin;
|
|
|
|
if ( nPos > nOldMin )
|
|
|
|
rEntry.nMin = nPos;
|
|
|
|
|
|
|
|
bFoundMax = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_ProcessBoxGet( const SwTableBox *pBox, SwTabCols &rToFill,
|
2010-10-05 07:57:55 -05:00
|
|
|
const SwFrmFmt *pTabFmt, bool bRefreshHidden )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-06-18 18:04:44 +02:00
|
|
|
if ( !pBox->GetTabLines().empty() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
const SwTableLines &rLines = pBox->GetTabLines();
|
2012-06-18 18:04:44 +02:00
|
|
|
for ( sal_uInt16 i = 0; i < rLines.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{ const SwTableBoxes &rBoxes = rLines[i]->GetTabBoxes();
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( sal_uInt16 j = 0; j < rBoxes.size(); ++j )
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_ProcessBoxGet( rBoxes[j], rToFill, pTabFmt, bRefreshHidden);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
::lcl_SortedTabColInsert( rToFill, pBox, pTabFmt, sal_False, bRefreshHidden );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_ProcessLineGet( const SwTableLine *pLine, SwTabCols &rToFill,
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwFrmFmt *pTabFmt )
|
|
|
|
{
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( sal_uInt16 i = 0; i < pLine->GetTabBoxes().size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
const SwTableBox *pBox = pLine->GetTabBoxes()[i];
|
|
|
|
if ( pBox->GetSttNd() )
|
2014-01-28 19:59:54 +01:00
|
|
|
::lcl_SortedTabColInsert( rToFill, pBox, pTabFmt, sal_True, false );
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
2012-06-18 18:04:44 +02:00
|
|
|
for ( sal_uInt16 j = 0; j < pBox->GetTabLines().size(); ++j )
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_ProcessLineGet( pBox->GetTabLines()[j], rToFill, pTabFmt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTable::GetTabCols( SwTabCols &rToFill, const SwTableBox *pStart,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRefreshHidden, sal_Bool bCurRowOnly ) const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Optimization: if bHidden is set, we only update the Hidden Array.
|
2007-02-28 14:50:39 +00:00
|
|
|
if ( bRefreshHidden )
|
|
|
|
{
|
2010-10-17 17:09:39 -05:00
|
|
|
// remove corrections
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 i;
|
2007-02-28 14:50:39 +00:00
|
|
|
for ( i = 0; i < rToFill.Count(); ++i )
|
|
|
|
{
|
|
|
|
SwTabColsEntry& rEntry = rToFill.GetEntry( i );
|
|
|
|
rEntry.nPos -= rToFill.GetLeft();
|
|
|
|
rEntry.nMin -= rToFill.GetLeft();
|
|
|
|
rEntry.nMax -= rToFill.GetLeft();
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// All are hidden, so add the visible ones.
|
2007-02-28 14:50:39 +00:00
|
|
|
for ( i = 0; i < rToFill.Count(); ++i )
|
2011-01-17 15:06:54 +01:00
|
|
|
rToFill.SetHidden( i, sal_True );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rToFill.Remove( 0, rToFill.Count() );
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Insertion cases:
|
|
|
|
// 1. All boxes which are inferior to Line which is superior to the Start,
|
|
|
|
// as well as their inferior boxes if present.
|
|
|
|
// 2. Starting from the Line, the superior box plus its neighbours; but no inferiors.
|
|
|
|
// 3. Apply 2. to the Line superior to the chain of boxes,
|
|
|
|
// until the Line's superior is not a box but the table.
|
|
|
|
// Only those boxes are inserted that don't contain further rows. The insertion
|
|
|
|
// function takes care to avoid duplicates. In order to achieve this, we work
|
|
|
|
// with some degree of fuzzyness (to avoid rounding errors).
|
|
|
|
// Only the left edge of the boxes are inserted.
|
|
|
|
// Finally, the first entry is removed again, because it's already
|
|
|
|
// covered by the border.
|
|
|
|
// 4. Scan the table again and insert _all_ boxes, this time as hidden.
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
const SwFrmFmt *pTabFmt = GetFrmFmt();
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// 1.
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTableBoxes &rBoxes = pStart->GetUpper()->GetTabBoxes();
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 i;
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( i = 0; i < rBoxes.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_ProcessBoxGet( rBoxes[i], rToFill, pTabFmt, bRefreshHidden );
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// 2. and 3.
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTableLine *pLine = pStart->GetUpper()->GetUpper() ?
|
|
|
|
pStart->GetUpper()->GetUpper()->GetUpper() : 0;
|
|
|
|
while ( pLine )
|
|
|
|
{
|
2007-09-27 08:11:01 +00:00
|
|
|
const SwTableBoxes &rBoxes2 = pLine->GetTabBoxes();
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( sal_uInt16 k = 0; k < rBoxes2.size(); ++k )
|
2007-09-27 08:11:01 +00:00
|
|
|
::lcl_SortedTabColInsert( rToFill, rBoxes2[k],
|
2011-01-17 15:06:54 +01:00
|
|
|
pTabFmt, sal_False, bRefreshHidden );
|
2007-02-28 14:50:39 +00:00
|
|
|
pLine = pLine->GetUpper() ? pLine->GetUpper()->GetUpper() : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bRefreshHidden )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// 4.
|
2007-02-28 14:50:39 +00:00
|
|
|
if ( !bCurRowOnly )
|
|
|
|
{
|
2012-06-18 18:04:44 +02:00
|
|
|
for ( i = 0; i < aLines.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_ProcessLineGet( aLines[i], rToFill, pTabFmt );
|
|
|
|
}
|
|
|
|
|
|
|
|
rToFill.Remove( 0, 1 );
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Now the coordinates are relative to the left table border - i.e.
|
|
|
|
// relative to SwTabCols.nLeft. However, they are expected
|
|
|
|
// relative to the left document border, i.e. SwTabCols.nLeftMin.
|
|
|
|
// So all values need to be extended by nLeft.
|
2007-02-28 14:50:39 +00:00
|
|
|
for ( i = 0; i < rToFill.Count(); ++i )
|
|
|
|
{
|
|
|
|
SwTabColsEntry& rEntry = rToFill.GetEntry( i );
|
|
|
|
rEntry.nPos += rToFill.GetLeft();
|
|
|
|
rEntry.nMin += rToFill.GetLeft();
|
|
|
|
rEntry.nMax += rToFill.GetLeft();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwTable::SetTabCols()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2012-08-10 15:42:44 +02:00
|
|
|
// Structure for parameter passing
|
2007-02-28 14:50:39 +00:00
|
|
|
struct Parm
|
|
|
|
{
|
|
|
|
const SwTabCols &rNew;
|
|
|
|
const SwTabCols &rOld;
|
|
|
|
long nNewWish,
|
|
|
|
nOldWish;
|
2012-06-22 08:54:13 +02:00
|
|
|
std::deque<SwTableBox*> aBoxArr;
|
2007-02-28 14:50:39 +00:00
|
|
|
SwShareBoxFmts aShareFmts;
|
|
|
|
|
2012-06-25 18:01:40 +02:00
|
|
|
Parm( const SwTabCols &rN, const SwTabCols &rO )
|
|
|
|
: rNew( rN ), rOld( rO ), nNewWish(0), nOldWish(0)
|
|
|
|
{}
|
2007-02-28 14:50:39 +00:00
|
|
|
};
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_ProcessBoxSet( SwTableBox *pBox, Parm &rParm );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_ProcessLine( SwTableLine *pLine, Parm &rParm )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
SwTableBoxes &rBoxes = pLine->GetTabBoxes();
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( int i = rBoxes.size()-1; i >= 0; --i )
|
2011-01-17 15:06:54 +01:00
|
|
|
::lcl_ProcessBoxSet( rBoxes[ static_cast< sal_uInt16 >(i) ], rParm );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_ProcessBoxSet( SwTableBox *pBox, Parm &rParm )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-06-18 18:04:44 +02:00
|
|
|
if ( !pBox->GetTabLines().empty() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{ SwTableLines &rLines = pBox->GetTabLines();
|
2012-06-18 18:04:44 +02:00
|
|
|
for ( int i = rLines.size()-1; i >= 0; --i )
|
2011-01-17 15:06:54 +01:00
|
|
|
lcl_ProcessLine( rLines[ static_cast< sal_uInt16 >(i) ], rParm );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Search the old TabCols for the current position (calculate from
|
|
|
|
// left and right edge). Adjust the box if the values differ from
|
|
|
|
// the new TabCols. If the adjusted edge has no neighbour we also
|
|
|
|
// adjust all superior boxes.
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
const long nOldAct = rParm.rOld.GetRight() -
|
|
|
|
rParm.rOld.GetLeft(); // +1 why?
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// The value for the left edge of the box is calculated from the
|
|
|
|
// widths of the previous boxes plus the left edge.
|
2007-02-28 14:50:39 +00:00
|
|
|
long nLeft = rParm.rOld.GetLeft();
|
|
|
|
const SwTableBox *pCur = pBox;
|
|
|
|
const SwTableLine *pLine = pBox->GetUpper();
|
|
|
|
|
|
|
|
while ( pLine )
|
|
|
|
{ const SwTableBoxes &rBoxes = pLine->GetTabBoxes();
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( sal_uInt16 i = 0; (i < rBoxes.size()) && (rBoxes[i] != pCur); ++i)
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
sal_uInt64 nWidth = rBoxes[i]->GetFrmFmt()->
|
|
|
|
GetFrmSize().GetWidth();
|
|
|
|
nWidth *= nOldAct;
|
|
|
|
nWidth /= rParm.nOldWish;
|
2011-01-17 15:06:54 +01:00
|
|
|
nLeft += (sal_uInt16)nWidth;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
pCur = pLine->GetUpper();
|
|
|
|
pLine = pCur ? pCur->GetUpper() : 0;
|
|
|
|
}
|
|
|
|
long nLeftDiff;
|
|
|
|
long nRightDiff = 0;
|
2012-08-10 15:42:44 +02:00
|
|
|
if ( nLeft != rParm.rOld.GetLeft() ) // There are still boxes before this.
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Right edge is left edge plus width.
|
2007-02-28 14:50:39 +00:00
|
|
|
sal_uInt64 nWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth();
|
|
|
|
nWidth *= nOldAct;
|
|
|
|
nWidth /= rParm.nOldWish;
|
|
|
|
long nRight = nLeft + (long)nWidth;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nLeftPos = USHRT_MAX,
|
2007-02-28 14:50:39 +00:00
|
|
|
nRightPos = USHRT_MAX;
|
2011-01-17 15:06:54 +01:00
|
|
|
for ( sal_uInt16 i = 0; i < rParm.rOld.Count(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
if ( nLeft >= (rParm.rOld[i] - COLFUZZY) &&
|
|
|
|
nLeft <= (rParm.rOld[i] + COLFUZZY) )
|
|
|
|
nLeftPos = i;
|
|
|
|
else if ( nRight >= (rParm.rOld[i] - COLFUZZY) &&
|
|
|
|
nRight <= (rParm.rOld[i] + COLFUZZY) )
|
|
|
|
nRightPos = i;
|
|
|
|
}
|
|
|
|
nLeftDiff = nLeftPos != USHRT_MAX ?
|
|
|
|
(int)rParm.rOld[nLeftPos] - (int)rParm.rNew[nLeftPos] : 0;
|
|
|
|
nRightDiff= nRightPos!= USHRT_MAX ?
|
|
|
|
(int)rParm.rNew[nRightPos] - (int)rParm.rOld[nRightPos] : 0;
|
|
|
|
}
|
2012-08-10 15:42:44 +02:00
|
|
|
else // The first box.
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
nLeftDiff = (long)rParm.rOld.GetLeft() - (long)rParm.rNew.GetLeft();
|
|
|
|
if ( rParm.rOld.Count() )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Calculate the difference to the edge touching the first box.
|
2007-02-28 14:50:39 +00:00
|
|
|
sal_uInt64 nWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth();
|
|
|
|
nWidth *= nOldAct;
|
|
|
|
nWidth /= rParm.nOldWish;
|
|
|
|
long nTmp = (long)nWidth;
|
|
|
|
nTmp += rParm.rOld.GetLeft();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nLeftPos = USHRT_MAX;
|
|
|
|
for ( sal_uInt16 i = 0; i < rParm.rOld.Count() &&
|
2007-02-28 14:50:39 +00:00
|
|
|
nLeftPos == USHRT_MAX; ++i )
|
|
|
|
{
|
|
|
|
if ( nTmp >= (rParm.rOld[i] - COLFUZZY) &&
|
|
|
|
nTmp <= (rParm.rOld[i] + COLFUZZY) )
|
|
|
|
nLeftPos = i;
|
|
|
|
}
|
|
|
|
if ( nLeftPos != USHRT_MAX )
|
|
|
|
nRightDiff = (long)rParm.rNew[nLeftPos] -
|
|
|
|
(long)rParm.rOld[nLeftPos];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( pBox->getRowSpan() == 1 )
|
|
|
|
{
|
|
|
|
SwTableBoxes& rTblBoxes = pBox->GetUpper()->GetTabBoxes();
|
2012-05-10 17:42:10 +02:00
|
|
|
sal_uInt16 nPos = rTblBoxes.GetPos( pBox );
|
2007-02-28 14:50:39 +00:00
|
|
|
if( nPos && rTblBoxes[ nPos - 1 ]->getRowSpan() != 1 )
|
|
|
|
nLeftDiff = 0;
|
2012-05-10 17:42:10 +02:00
|
|
|
if( nPos + 1 < (sal_uInt16)rTblBoxes.size() &&
|
2007-02-28 14:50:39 +00:00
|
|
|
rTblBoxes[ nPos + 1 ]->getRowSpan() != 1 )
|
|
|
|
nRightDiff = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
nLeftDiff = nRightDiff = 0;
|
|
|
|
|
|
|
|
if ( nLeftDiff || nRightDiff )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// The difference is the actual difference amount. For stretched
|
|
|
|
// tables, it does not make sense to adjust the attributes of the
|
|
|
|
// boxes by this amount. The difference amount needs to be converted
|
|
|
|
// accordingly.
|
2007-02-28 14:50:39 +00:00
|
|
|
long nTmp = rParm.rNew.GetRight() - rParm.rNew.GetLeft(); // +1 why?
|
|
|
|
nLeftDiff *= rParm.nNewWish;
|
|
|
|
nLeftDiff /= nTmp;
|
|
|
|
nRightDiff *= rParm.nNewWish;
|
|
|
|
nRightDiff /= nTmp;
|
|
|
|
long nDiff = nLeftDiff + nRightDiff;
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Adjust the box and all superiors by the difference amount.
|
2007-02-28 14:50:39 +00:00
|
|
|
while ( pBox )
|
|
|
|
{
|
2008-03-18 15:35:14 +00:00
|
|
|
SwFmtFrmSize aFmtFrmSize( pBox->GetFrmFmt()->GetFrmSize() );
|
|
|
|
aFmtFrmSize.SetWidth( aFmtFrmSize.GetWidth() + nDiff );
|
|
|
|
if ( aFmtFrmSize.GetWidth() < 0 )
|
|
|
|
aFmtFrmSize.SetWidth( -aFmtFrmSize.GetWidth() );
|
|
|
|
rParm.aShareFmts.SetSize( *pBox, aFmtFrmSize );
|
|
|
|
|
|
|
|
// The outer cells of the last row are responsible to adjust a surrounding cell.
|
|
|
|
// Last line check:
|
|
|
|
if ( pBox->GetUpper()->GetUpper() &&
|
2012-06-18 18:04:44 +02:00
|
|
|
pBox->GetUpper() != pBox->GetUpper()->GetUpper()->GetTabLines().back())
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2008-03-18 15:35:14 +00:00
|
|
|
pBox = 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
2008-03-18 15:35:14 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Middle cell check:
|
2012-05-10 17:42:10 +02:00
|
|
|
if ( pBox != pBox->GetUpper()->GetTabBoxes().front() )
|
2008-03-18 15:35:14 +00:00
|
|
|
nDiff = nRightDiff;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-05-10 17:42:10 +02:00
|
|
|
if ( pBox != pBox->GetUpper()->GetTabBoxes().back() )
|
2008-03-18 15:35:14 +00:00
|
|
|
nDiff -= nRightDiff;
|
|
|
|
|
|
|
|
pBox = nDiff ? pBox->GetUpper()->GetUpper() : 0;
|
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_ProcessBoxPtr( SwTableBox *pBox, std::deque<SwTableBox*> &rBoxArr,
|
2012-12-03 19:21:53 +09:00
|
|
|
bool bBefore )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-06-18 18:04:44 +02:00
|
|
|
if ( !pBox->GetTabLines().empty() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
const SwTableLines &rLines = pBox->GetTabLines();
|
2012-06-18 18:04:44 +02:00
|
|
|
for ( sal_uInt16 i = 0; i < rLines.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
const SwTableBoxes &rBoxes = rLines[i]->GetTabBoxes();
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( sal_uInt16 j = 0; j < rBoxes.size(); ++j )
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_ProcessBoxPtr( rBoxes[j], rBoxArr, bBefore );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( bBefore )
|
2012-06-22 08:54:13 +02:00
|
|
|
rBoxArr.push_front( pBox );
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
2012-06-22 08:54:13 +02:00
|
|
|
rBoxArr.push_back( pBox );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_AdjustBox( SwTableBox *pBox, const long nDiff, Parm &rParm );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_AdjustLines( SwTableLines &rLines, const long nDiff, Parm &rParm )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-06-18 18:04:44 +02:00
|
|
|
for ( sal_uInt16 i = 0; i < rLines.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
SwTableBox *pBox = rLines[i]->GetTabBoxes()
|
2012-05-10 17:42:10 +02:00
|
|
|
[rLines[i]->GetTabBoxes().size()-1];
|
2007-02-28 14:50:39 +00:00
|
|
|
lcl_AdjustBox( pBox, nDiff, rParm );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-12 16:49:40 +02:00
|
|
|
static void lcl_AdjustBox( SwTableBox *pBox, const long nDiff, Parm &rParm )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-06-18 18:04:44 +02:00
|
|
|
if ( !pBox->GetTabLines().empty() )
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_AdjustLines( pBox->GetTabLines(), nDiff, rParm );
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Adjust the size of the box.
|
2007-02-28 14:50:39 +00:00
|
|
|
SwFmtFrmSize aFmtFrmSize( pBox->GetFrmFmt()->GetFrmSize() );
|
|
|
|
aFmtFrmSize.SetWidth( aFmtFrmSize.GetWidth() + nDiff );
|
|
|
|
|
|
|
|
rParm.aShareFmts.SetSize( *pBox, aFmtFrmSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTable::SetTabCols( const SwTabCols &rNew, const SwTabCols &rOld,
|
2011-01-17 15:06:54 +01:00
|
|
|
const SwTableBox *pStart, sal_Bool bCurRowOnly )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
CHECK_TABLE( *this )
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
SetHTMLTableLayout( 0 ); // delete HTML-Layout
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
// FME: Made rOld const. The caller is responsible for passing correct
|
|
|
|
// values of rOld. Therefore we do not have to call GetTabCols anymore:
|
|
|
|
//GetTabCols( rOld, pStart );
|
|
|
|
|
|
|
|
Parm aParm( rNew, rOld );
|
|
|
|
|
2010-11-25 17:08:45 +01:00
|
|
|
OSL_ENSURE( rOld.Count() == rNew.Count(), "Columnanzahl veraendert.");
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Convert the edges. We need to adjust the size of the table and some boxes.
|
|
|
|
// For the size adjustment, we must not make use of the Modify, since that'd
|
|
|
|
// adjust all boxes, which we really don't want.
|
2007-02-28 14:50:39 +00:00
|
|
|
SwFrmFmt *pFmt = GetFrmFmt();
|
|
|
|
aParm.nOldWish = aParm.nNewWish = pFmt->GetFrmSize().GetWidth();
|
|
|
|
if ( (rOld.GetLeft() != rNew.GetLeft()) ||
|
|
|
|
(rOld.GetRight()!= rNew.GetRight()) )
|
|
|
|
{
|
|
|
|
LockModify();
|
|
|
|
{
|
|
|
|
SvxLRSpaceItem aLR( pFmt->GetLRSpace() );
|
|
|
|
SvxShadowItem aSh( pFmt->GetShadow() );
|
|
|
|
|
|
|
|
SwTwips nShRight = aSh.CalcShadowSpace( SHADOW_RIGHT );
|
|
|
|
SwTwips nShLeft = aSh.CalcShadowSpace( SHADOW_LEFT );
|
|
|
|
|
|
|
|
aLR.SetLeft ( rNew.GetLeft() - nShLeft );
|
|
|
|
aLR.SetRight( rNew.GetRightMax() - rNew.GetRight() - nShRight );
|
2008-06-13 09:13:23 +00:00
|
|
|
pFmt->SetFmtAttr( aLR );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// The alignment of the table needs to be adjusted accordingly.
|
|
|
|
// This is done by preserving the exact positions that have been
|
|
|
|
// set by the user.
|
2007-02-28 14:50:39 +00:00
|
|
|
SwFmtHoriOrient aOri( pFmt->GetHoriOrient() );
|
2007-09-27 08:11:01 +00:00
|
|
|
if(text::HoriOrientation::NONE != aOri.GetHoriOrient())
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_Bool bLeftDist = rNew.GetLeft() != nShLeft;
|
|
|
|
const sal_Bool bRightDist = rNew.GetRight() + nShRight != rNew.GetRightMax();
|
2007-02-28 14:50:39 +00:00
|
|
|
if(!bLeftDist && !bRightDist)
|
2007-09-27 08:11:01 +00:00
|
|
|
aOri.SetHoriOrient( text::HoriOrientation::FULL );
|
2007-02-28 14:50:39 +00:00
|
|
|
else if(!bRightDist && rNew.GetLeft() > nShLeft )
|
2007-09-27 08:11:01 +00:00
|
|
|
aOri.SetHoriOrient( text::HoriOrientation::RIGHT );
|
2007-02-28 14:50:39 +00:00
|
|
|
else if(!bLeftDist && rNew.GetRight() + nShRight < rNew.GetRightMax())
|
2007-09-27 08:11:01 +00:00
|
|
|
aOri.SetHoriOrient( text::HoriOrientation::LEFT );
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
2010-11-29 14:01:33 +01:00
|
|
|
aOri.SetHoriOrient( text::HoriOrientation::LEFT_AND_WIDTH );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
2008-06-13 09:13:23 +00:00
|
|
|
pFmt->SetFmtAttr( aOri );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
const long nAct = rOld.GetRight() - rOld.GetLeft(); // +1 why?
|
|
|
|
long nTabDiff = 0;
|
|
|
|
|
|
|
|
if ( rOld.GetLeft() != rNew.GetLeft() )
|
|
|
|
{
|
|
|
|
nTabDiff = rOld.GetLeft() - rNew.GetLeft();
|
|
|
|
nTabDiff *= aParm.nOldWish;
|
|
|
|
nTabDiff /= nAct;
|
|
|
|
}
|
|
|
|
if ( rOld.GetRight() != rNew.GetRight() )
|
|
|
|
{
|
|
|
|
long nDiff = rNew.GetRight() - rOld.GetRight();
|
|
|
|
nDiff *= aParm.nOldWish;
|
|
|
|
nDiff /= nAct;
|
|
|
|
nTabDiff += nDiff;
|
|
|
|
if( !IsNewModel() )
|
|
|
|
::lcl_AdjustLines( GetTabLines(), nDiff, aParm );
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Adjust the size of the table, watch out for stretched tables.
|
2007-02-28 14:50:39 +00:00
|
|
|
if ( nTabDiff )
|
|
|
|
{
|
|
|
|
aParm.nNewWish += nTabDiff;
|
|
|
|
if ( aParm.nNewWish < 0 )
|
2012-08-10 15:42:44 +02:00
|
|
|
aParm.nNewWish = USHRT_MAX; // Oops! Have to roll back.
|
2007-02-28 14:50:39 +00:00
|
|
|
SwFmtFrmSize aSz( pFmt->GetFrmSize() );
|
|
|
|
if ( aSz.GetWidth() != aParm.nNewWish )
|
|
|
|
{
|
|
|
|
aSz.SetWidth( aParm.nNewWish );
|
|
|
|
aSz.SetWidthPercent( 0 );
|
2008-06-13 09:13:23 +00:00
|
|
|
pFmt->SetFmtAttr( aSz );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
UnlockModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( IsNewModel() )
|
|
|
|
NewSetTabCols( aParm, rNew, rOld, pStart, bCurRowOnly );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( bCurRowOnly )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// To adjust the current row, we need to process all its boxes,
|
|
|
|
// similar to the filling of the TabCols (see GetTabCols()).
|
|
|
|
// Unfortunately we again have to take care to adjust the boxes
|
|
|
|
// from back to front, respectively from outer to inner.
|
|
|
|
// The best way to achieve this is probably to track the boxes
|
|
|
|
// in a PtrArray.
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTableBoxes &rBoxes = pStart->GetUpper()->GetTabBoxes();
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( sal_uInt16 i = 0; i < rBoxes.size(); ++i )
|
2012-12-03 19:21:53 +09:00
|
|
|
::lcl_ProcessBoxPtr( rBoxes[i], aParm.aBoxArr, false );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
const SwTableLine *pLine = pStart->GetUpper()->GetUpper() ?
|
|
|
|
pStart->GetUpper()->GetUpper()->GetUpper() : 0;
|
|
|
|
const SwTableBox *pExcl = pStart->GetUpper()->GetUpper();
|
|
|
|
while ( pLine )
|
|
|
|
{
|
2007-09-27 08:11:01 +00:00
|
|
|
const SwTableBoxes &rBoxes2 = pLine->GetTabBoxes();
|
2012-12-03 19:21:53 +09:00
|
|
|
bool bBefore = true;
|
2012-05-10 17:42:10 +02:00
|
|
|
for ( sal_uInt16 i = 0; i < rBoxes2.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2007-09-27 08:11:01 +00:00
|
|
|
if ( rBoxes2[i] != pExcl )
|
|
|
|
::lcl_ProcessBoxPtr( rBoxes2[i], aParm.aBoxArr, bBefore );
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
2012-12-03 19:21:53 +09:00
|
|
|
bBefore = false;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
pExcl = pLine->GetUpper();
|
|
|
|
pLine = pLine->GetUpper() ? pLine->GetUpper()->GetUpper() : 0;
|
|
|
|
}
|
2012-08-10 15:42:44 +02:00
|
|
|
// After we've inserted a bunch of boxes (hopefully all and in
|
|
|
|
// correct order), we just need to process them in reverse order.
|
2012-06-22 08:54:13 +02:00
|
|
|
for ( int j = aParm.aBoxArr.size()-1; j >= 0; --j )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-06-22 08:54:13 +02:00
|
|
|
SwTableBox *pBox = aParm.aBoxArr[j];
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_ProcessBoxSet( pBox, aParm );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2012-08-10 15:42:44 +02:00
|
|
|
{
|
|
|
|
// Adjusting the entire table is 'easy'. All boxes without lines are
|
|
|
|
// adjusted, as are their superiors. Of course we need to process
|
|
|
|
// in reverse order to prevent fooling ourselves!
|
2007-02-28 14:50:39 +00:00
|
|
|
SwTableLines &rLines = GetTabLines();
|
2012-06-18 18:04:44 +02:00
|
|
|
for ( int i = rLines.size()-1; i >= 0; --i )
|
2011-01-17 15:06:54 +01:00
|
|
|
::lcl_ProcessLine( rLines[ static_cast< sal_uInt16 >(i) ], aParm );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-24 00:52:00 +01:00
|
|
|
#ifdef DBG_UTIL
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// to be found in tblrwcl.cxx
|
2007-02-28 14:50:39 +00:00
|
|
|
extern void _CheckBoxWidth( const SwTableLine&, SwTwips );
|
2012-08-10 15:42:44 +02:00
|
|
|
// do some checking for correct table widths
|
2007-02-28 14:50:39 +00:00
|
|
|
SwTwips nSize = GetFrmFmt()->GetFrmSize().GetWidth();
|
2012-06-20 19:45:46 +02:00
|
|
|
for (size_t n = 0; n < aLines.size(); ++n)
|
|
|
|
{
|
2007-02-28 14:50:39 +00:00
|
|
|
_CheckBoxWidth( *aLines[ n ], nSize );
|
2012-06-20 19:45:46 +02:00
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
typedef std::pair<sal_uInt16, sal_uInt16> ColChange;
|
2007-02-28 14:50:39 +00:00
|
|
|
typedef std::list< ColChange > ChangeList;
|
|
|
|
|
|
|
|
static void lcl_AdjustWidthsInLine( SwTableLine* pLine, ChangeList& rOldNew,
|
2011-01-17 15:06:54 +01:00
|
|
|
Parm& rParm, sal_uInt16 nColFuzzy )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
ChangeList::iterator pCurr = rOldNew.begin();
|
|
|
|
if( pCurr == rOldNew.end() )
|
|
|
|
return;
|
2012-05-10 17:42:10 +02:00
|
|
|
sal_uInt16 nCount = pLine->GetTabBoxes().size();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 i = 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
SwTwips nBorder = 0;
|
|
|
|
SwTwips nRest = 0;
|
|
|
|
while( i < nCount )
|
|
|
|
{
|
|
|
|
SwTableBox* pBox = pLine->GetTabBoxes()[i++];
|
|
|
|
SwTwips nWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth();
|
|
|
|
SwTwips nNewWidth = nWidth - nRest;
|
|
|
|
nRest = 0;
|
|
|
|
nBorder += nWidth;
|
|
|
|
if( pCurr != rOldNew.end() && nBorder + nColFuzzy >= pCurr->first )
|
|
|
|
{
|
|
|
|
nBorder -= nColFuzzy;
|
|
|
|
while( pCurr != rOldNew.end() && nBorder > pCurr->first )
|
|
|
|
++pCurr;
|
|
|
|
if( pCurr != rOldNew.end() )
|
|
|
|
{
|
|
|
|
nBorder += nColFuzzy;
|
|
|
|
if( nBorder + nColFuzzy >= pCurr->first )
|
|
|
|
{
|
|
|
|
if( pCurr->second == pCurr->first )
|
|
|
|
nRest = 0;
|
|
|
|
else
|
|
|
|
nRest = pCurr->second - nBorder;
|
|
|
|
nNewWidth += nRest;
|
|
|
|
++pCurr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( nNewWidth != nWidth )
|
|
|
|
{
|
|
|
|
if( nNewWidth < 0 )
|
|
|
|
{
|
|
|
|
nRest += 1 - nNewWidth;
|
|
|
|
nNewWidth = 1;
|
|
|
|
}
|
|
|
|
SwFmtFrmSize aFmtFrmSize( pBox->GetFrmFmt()->GetFrmSize() );
|
|
|
|
aFmtFrmSize.SetWidth( nNewWidth );
|
|
|
|
rParm.aShareFmts.SetSize( *pBox, aFmtFrmSize );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
static void lcl_CalcNewWidths( std::list<sal_uInt16> &rSpanPos, ChangeList& rChanges,
|
2007-02-28 14:50:39 +00:00
|
|
|
SwTableLine* pLine, long nWish, long nWidth, bool bTop )
|
|
|
|
{
|
2011-05-16 16:04:50 +02:00
|
|
|
if( rChanges.empty() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
rSpanPos.clear();
|
|
|
|
return;
|
|
|
|
}
|
2011-05-16 16:04:50 +02:00
|
|
|
if( rSpanPos.empty() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
rChanges.clear();
|
|
|
|
return;
|
|
|
|
}
|
2011-01-17 15:06:54 +01:00
|
|
|
std::list<sal_uInt16> aNewSpanPos;
|
2007-02-28 14:50:39 +00:00
|
|
|
ChangeList aNewChanges;
|
|
|
|
ChangeList::iterator pCurr = rChanges.begin();
|
|
|
|
aNewChanges.push_back( *pCurr ); // Nullposition
|
2011-01-17 15:06:54 +01:00
|
|
|
std::list<sal_uInt16>::iterator pSpan = rSpanPos.begin();
|
|
|
|
sal_uInt16 nCurr = 0;
|
|
|
|
sal_uInt16 nOrgSum = 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
bool bRowSpan = false;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRowSpanCount = 0;
|
2012-05-10 17:42:10 +02:00
|
|
|
sal_uInt16 nCount = pLine->GetTabBoxes().size();
|
2011-01-17 15:06:54 +01:00
|
|
|
for( sal_uInt16 nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
SwTableBox* pBox = pLine->GetTabBoxes()[nCurrBox];
|
|
|
|
SwTwips nCurrWidth = pBox->GetFrmFmt()->GetFrmSize().GetWidth();
|
|
|
|
const long nRowSpan = pBox->getRowSpan();
|
|
|
|
const bool bCurrRowSpan = bTop ? nRowSpan < 0 :
|
|
|
|
( nRowSpan > 1 || nRowSpan < -1 );
|
|
|
|
if( bRowSpan || bCurrRowSpan )
|
|
|
|
aNewSpanPos.push_back( nRowSpanCount );
|
|
|
|
bRowSpan = bCurrRowSpan;
|
2011-01-17 15:06:54 +01:00
|
|
|
nOrgSum = (sal_uInt16)(nOrgSum + nCurrWidth);
|
2007-02-28 14:50:39 +00:00
|
|
|
sal_uInt64 nSum = nOrgSum;
|
|
|
|
nSum *= nWidth;
|
|
|
|
nSum /= nWish;
|
|
|
|
nSum *= nWish;
|
|
|
|
nSum /= nWidth;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPos = (sal_uInt16)nSum;
|
2007-02-28 14:50:39 +00:00
|
|
|
while( pCurr != rChanges.end() && pCurr->first < nPos )
|
|
|
|
{
|
|
|
|
++nCurr;
|
|
|
|
++pCurr;
|
|
|
|
}
|
|
|
|
bool bNew = true;
|
|
|
|
if( pCurr != rChanges.end() && pCurr->first <= nPos &&
|
|
|
|
pCurr->first != pCurr->second )
|
|
|
|
{
|
|
|
|
while( pSpan != rSpanPos.end() && *pSpan < nCurr )
|
|
|
|
++pSpan;
|
|
|
|
if( pSpan != rSpanPos.end() && *pSpan == nCurr )
|
|
|
|
{
|
|
|
|
aNewChanges.push_back( *pCurr );
|
|
|
|
++nRowSpanCount;
|
|
|
|
bNew = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( bNew )
|
|
|
|
{
|
|
|
|
ColChange aTmp( nPos, nPos );
|
|
|
|
aNewChanges.push_back( aTmp );
|
|
|
|
++nRowSpanCount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pCurr = aNewChanges.begin();
|
|
|
|
ChangeList::iterator pLast = pCurr;
|
|
|
|
ChangeList::iterator pLeftMove = pCurr;
|
|
|
|
while( pCurr != aNewChanges.end() )
|
|
|
|
{
|
|
|
|
if( pLeftMove == pCurr )
|
|
|
|
{
|
|
|
|
while( ++pLeftMove != aNewChanges.end() && pLeftMove->first <= pLeftMove->second )
|
|
|
|
;
|
|
|
|
}
|
|
|
|
if( pCurr->second == pCurr->first )
|
|
|
|
{
|
|
|
|
if( pLeftMove != aNewChanges.end() && pCurr->second > pLeftMove->second )
|
|
|
|
{
|
|
|
|
if( pLeftMove->first == pLast->first )
|
|
|
|
pCurr->second = pLeftMove->second;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_uInt64 nTmp = pCurr->first - pLast->first;
|
|
|
|
nTmp *= pLeftMove->second - pLast->second;
|
|
|
|
nTmp /= pLeftMove->first - pLast->first;
|
|
|
|
nTmp += pLast->second;
|
2011-01-17 15:06:54 +01:00
|
|
|
pCurr->second = (sal_uInt16)nTmp;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pLast = pCurr;
|
|
|
|
++pCurr;
|
|
|
|
}
|
|
|
|
else if( pCurr->second > pCurr->first )
|
|
|
|
{
|
|
|
|
pLast = pCurr;
|
|
|
|
++pCurr;
|
|
|
|
ChangeList::iterator pNext = pCurr;
|
|
|
|
while( pNext != pLeftMove && pNext->second == pNext->first &&
|
|
|
|
pNext->second < pLast->second )
|
|
|
|
++pNext;
|
|
|
|
while( pCurr != pNext )
|
|
|
|
{
|
|
|
|
if( pNext == aNewChanges.end() || pNext->first == pLast->first )
|
|
|
|
pCurr->second = pLast->second;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sal_uInt64 nTmp = pCurr->first - pLast->first;
|
|
|
|
nTmp *= pNext->second - pLast->second;
|
|
|
|
nTmp /= pNext->first - pLast->first;
|
|
|
|
nTmp += pLast->second;
|
2011-01-17 15:06:54 +01:00
|
|
|
pCurr->second = (sal_uInt16)nTmp;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
++pCurr;
|
|
|
|
}
|
|
|
|
pLast = pCurr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pLast = pCurr;
|
|
|
|
++pCurr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rChanges.clear();
|
|
|
|
ChangeList::iterator pCopy = aNewChanges.begin();
|
|
|
|
while( pCopy != aNewChanges.end() )
|
|
|
|
rChanges.push_back( *pCopy++ );
|
|
|
|
rSpanPos.clear();
|
2011-01-17 15:06:54 +01:00
|
|
|
std::list<sal_uInt16>::iterator pSpCopy = aNewSpanPos.begin();
|
2007-02-28 14:50:39 +00:00
|
|
|
while( pSpCopy != aNewSpanPos.end() )
|
|
|
|
rSpanPos.push_back( *pSpCopy++ );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTable::NewSetTabCols( Parm &rParm, const SwTabCols &rNew,
|
2011-01-17 15:06:54 +01:00
|
|
|
const SwTabCols &rOld, const SwTableBox *pStart, sal_Bool bCurRowOnly )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2010-11-25 17:08:45 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 1
|
2007-03-02 10:48:43 +00:00
|
|
|
static int nCallCount = 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
++nCallCount;
|
|
|
|
#endif
|
|
|
|
// First step: evaluate which lines have been moved/which widths changed
|
|
|
|
ChangeList aOldNew;
|
|
|
|
const long nNewWidth = rParm.rNew.GetRight() - rParm.rNew.GetLeft();
|
|
|
|
const long nOldWidth = rParm.rOld.GetRight() - rParm.rOld.GetLeft();
|
|
|
|
if( nNewWidth < 1 || nOldWidth < 1 )
|
|
|
|
return;
|
2011-01-17 15:06:54 +01:00
|
|
|
for( sal_uInt16 i = 0; i <= rOld.Count(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
sal_uInt64 nNewPos;
|
|
|
|
sal_uInt64 nOldPos;
|
|
|
|
if( i == rOld.Count() )
|
|
|
|
{
|
|
|
|
nOldPos = rParm.rOld.GetRight() - rParm.rOld.GetLeft();
|
|
|
|
nNewPos = rParm.rNew.GetRight() - rParm.rNew.GetLeft();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nOldPos = rOld[i] - rParm.rOld.GetLeft();
|
|
|
|
nNewPos = rNew[i] - rParm.rNew.GetLeft();
|
|
|
|
}
|
|
|
|
nNewPos *= rParm.nNewWish;
|
|
|
|
nNewPos /= nNewWidth;
|
|
|
|
nOldPos *= rParm.nOldWish;
|
|
|
|
nOldPos /= nOldWidth;
|
|
|
|
if( nOldPos != nNewPos && nNewPos > 0 && nOldPos > 0 )
|
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
ColChange aChg( (sal_uInt16)nOldPos, (sal_uInt16)nNewPos );
|
2007-02-28 14:50:39 +00:00
|
|
|
aOldNew.push_back( aChg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Finished first step
|
|
|
|
int nCount = aOldNew.size();
|
|
|
|
if( !nCount )
|
|
|
|
return; // no change, nothing to do
|
|
|
|
SwTableLines &rLines = GetTabLines();
|
|
|
|
if( bCurRowOnly )
|
|
|
|
{
|
|
|
|
const SwTableLine* pCurrLine = pStart->GetUpper();
|
2012-07-30 08:00:48 +01:00
|
|
|
sal_uInt16 nCurr = rLines.GetPos( pCurrLine );
|
2007-02-28 14:50:39 +00:00
|
|
|
if( nCurr >= USHRT_MAX )
|
|
|
|
return;
|
|
|
|
|
|
|
|
ColChange aChg( 0, 0 );
|
|
|
|
aOldNew.push_front( aChg );
|
2011-01-17 15:06:54 +01:00
|
|
|
std::list<sal_uInt16> aRowSpanPos;
|
2007-02-28 14:50:39 +00:00
|
|
|
if( nCurr )
|
|
|
|
{
|
|
|
|
ChangeList aCopy;
|
|
|
|
ChangeList::iterator pCop = aOldNew.begin();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPos = 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
while( pCop != aOldNew.end() )
|
|
|
|
{
|
|
|
|
aCopy.push_back( *pCop );
|
|
|
|
++pCop;
|
|
|
|
aRowSpanPos.push_back( nPos++ );
|
|
|
|
}
|
|
|
|
lcl_CalcNewWidths( aRowSpanPos, aCopy, rLines[nCurr],
|
|
|
|
rParm.nOldWish, nOldWidth, true );
|
2011-05-16 16:04:50 +02:00
|
|
|
bool bGoOn = !aRowSpanPos.empty();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 j = nCurr;
|
2007-02-28 14:50:39 +00:00
|
|
|
while( bGoOn )
|
|
|
|
{
|
|
|
|
lcl_CalcNewWidths( aRowSpanPos, aCopy, rLines[--j],
|
|
|
|
rParm.nOldWish, nOldWidth, true );
|
|
|
|
lcl_AdjustWidthsInLine( rLines[j], aCopy, rParm, 0 );
|
2011-05-16 16:04:50 +02:00
|
|
|
bGoOn = !aRowSpanPos.empty() && j > 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
};
|
|
|
|
aRowSpanPos.clear();
|
|
|
|
}
|
2012-06-18 18:04:44 +02:00
|
|
|
if( nCurr+1 < (sal_uInt16)rLines.size() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
ChangeList aCopy;
|
|
|
|
ChangeList::iterator pCop = aOldNew.begin();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPos = 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
while( pCop != aOldNew.end() )
|
|
|
|
{
|
|
|
|
aCopy.push_back( *pCop );
|
|
|
|
++pCop;
|
|
|
|
aRowSpanPos.push_back( nPos++ );
|
|
|
|
}
|
|
|
|
lcl_CalcNewWidths( aRowSpanPos, aCopy, rLines[nCurr],
|
|
|
|
rParm.nOldWish, nOldWidth, false );
|
2011-05-16 16:04:50 +02:00
|
|
|
bool bGoOn = !aRowSpanPos.empty();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 j = nCurr;
|
2007-02-28 14:50:39 +00:00
|
|
|
while( bGoOn )
|
|
|
|
{
|
|
|
|
lcl_CalcNewWidths( aRowSpanPos, aCopy, rLines[++j],
|
|
|
|
rParm.nOldWish, nOldWidth, false );
|
|
|
|
lcl_AdjustWidthsInLine( rLines[j], aCopy, rParm, 0 );
|
2012-06-18 18:04:44 +02:00
|
|
|
bGoOn = !aRowSpanPos.empty() && j+1 < (sal_uInt16)rLines.size();
|
2007-02-28 14:50:39 +00:00
|
|
|
};
|
|
|
|
}
|
2011-06-13 16:35:09 +01:00
|
|
|
::lcl_AdjustWidthsInLine( rLines[nCurr], aOldNew, rParm, COLFUZZY );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
2012-06-18 18:04:44 +02:00
|
|
|
else for( sal_uInt16 i = 0; i < rLines.size(); ++i )
|
2007-02-28 14:50:39 +00:00
|
|
|
::lcl_AdjustWidthsInLine( rLines[i], aOldNew, rParm, COLFUZZY );
|
|
|
|
CHECK_TABLE( *this )
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* const SwTableBox* SwTable::GetTblBox( const Strn?ng& rName ) const
|
2012-08-10 15:42:44 +02:00
|
|
|
|* return the pointer of the box specified.
|
2007-02-28 14:50:39 +00:00
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2007-07-25 07:15:28 +00:00
|
|
|
|
2013-10-16 11:18:56 +02:00
|
|
|
static bool lcl_IsValidRowName( const OUString& rStr )
|
2007-07-25 07:15:28 +00:00
|
|
|
{
|
2012-12-03 19:21:53 +09:00
|
|
|
bool bIsValid = true;
|
2013-10-28 15:41:25 +02:00
|
|
|
sal_Int32 nLen = rStr.getLength();
|
2013-10-28 12:21:40 +02:00
|
|
|
for( sal_Int32 i = 0; i < nLen && bIsValid; ++i )
|
2007-07-25 07:15:28 +00:00
|
|
|
{
|
2013-10-16 11:18:56 +02:00
|
|
|
const sal_Unicode cChar = rStr[i];
|
2007-07-25 07:15:28 +00:00
|
|
|
if (cChar < '0' || cChar > '9')
|
2012-12-03 19:21:53 +09:00
|
|
|
bIsValid = false;
|
2007-07-25 07:15:28 +00:00
|
|
|
}
|
|
|
|
return bIsValid;
|
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i80314#
|
2007-08-17 12:59:41 +00:00
|
|
|
// add 3rd parameter and its handling
|
2013-08-13 16:30:50 +02:00
|
|
|
sal_uInt16 SwTable::_GetBoxNum( OUString& rStr, sal_Bool bFirstPart,
|
2007-08-17 12:59:41 +00:00
|
|
|
const bool bPerformValidCheck )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nRet = 0;
|
|
|
|
if( bFirstPart ) // sal_True == column; sal_False == row
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2013-08-13 16:30:50 +02:00
|
|
|
sal_Int32 nPos = 0;
|
2012-08-10 15:42:44 +02:00
|
|
|
// the first one uses letters for addressing!
|
2012-12-03 19:21:53 +09:00
|
|
|
bool bFirst = true;
|
2013-08-13 16:30:50 +02:00
|
|
|
while (nPos<rStr.getLength())
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2013-08-13 16:30:50 +02:00
|
|
|
sal_Unicode cChar = rStr[nPos];
|
|
|
|
if ((cChar<'A' || cChar>'Z') && (cChar<'a' || cChar>'z'))
|
|
|
|
break;
|
2007-02-28 14:50:39 +00:00
|
|
|
if( (cChar -= 'A') >= 26 )
|
|
|
|
cChar -= 'a' - '[';
|
|
|
|
if( bFirst )
|
2012-12-03 19:21:53 +09:00
|
|
|
bFirst = false;
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
|
|
|
++nRet;
|
|
|
|
nRet = nRet * 52 + cChar;
|
|
|
|
++nPos;
|
|
|
|
}
|
2013-08-13 16:30:50 +02:00
|
|
|
rStr = rStr.copy( nPos ); // Remove char from String
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
2013-08-13 16:30:50 +02:00
|
|
|
else
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2013-11-03 19:52:12 +02:00
|
|
|
const sal_Int32 nPos = rStr.indexOf( "." );
|
2013-08-13 16:30:50 +02:00
|
|
|
if ( nPos<0 )
|
2007-08-17 12:59:41 +00:00
|
|
|
{
|
2013-08-13 16:30:50 +02:00
|
|
|
nRet = 0;
|
|
|
|
if ( !bPerformValidCheck || lcl_IsValidRowName( rStr ) )
|
|
|
|
{
|
|
|
|
nRet = static_cast<sal_uInt16>(rStr.toInt32());
|
|
|
|
}
|
|
|
|
rStr = OUString();
|
2007-08-17 12:59:41 +00:00
|
|
|
}
|
2013-08-13 16:30:50 +02:00
|
|
|
else
|
2007-08-17 12:59:41 +00:00
|
|
|
{
|
2013-08-13 16:30:50 +02:00
|
|
|
nRet = 0;
|
|
|
|
const OUString aTxt( rStr.copy( 0, nPos ) );
|
|
|
|
if ( !bPerformValidCheck || lcl_IsValidRowName( aTxt ) )
|
|
|
|
{
|
|
|
|
nRet = static_cast<sal_uInt16>(aTxt.toInt32());
|
|
|
|
}
|
|
|
|
rStr = rStr.copy( nPos+1 );
|
2007-08-17 12:59:41 +00:00
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i80314#
|
2007-08-17 12:59:41 +00:00
|
|
|
// add 2nd parameter and its handling
|
2013-09-19 08:02:20 +02:00
|
|
|
const SwTableBox* SwTable::GetTblBox( const OUString& rName,
|
2007-08-17 12:59:41 +00:00
|
|
|
const bool bPerformValidCheck ) const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
const SwTableBox* pBox = 0;
|
|
|
|
const SwTableLine* pLine;
|
|
|
|
const SwTableLines* pLines;
|
|
|
|
const SwTableBoxes* pBoxes;
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nLine, nBox;
|
2013-08-13 16:30:50 +02:00
|
|
|
OUString aNm( rName );
|
|
|
|
while( !aNm.isEmpty() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2007-08-17 12:59:41 +00:00
|
|
|
nBox = SwTable::_GetBoxNum( aNm, 0 == pBox, bPerformValidCheck );
|
2012-08-10 15:42:44 +02:00
|
|
|
// first box ?
|
2007-02-28 14:50:39 +00:00
|
|
|
if( !pBox )
|
|
|
|
pLines = &GetTabLines();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pLines = &pBox->GetTabLines();
|
|
|
|
if( nBox )
|
|
|
|
--nBox;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
nLine = SwTable::_GetBoxNum( aNm, sal_False, bPerformValidCheck );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// determine line
|
2012-06-18 18:04:44 +02:00
|
|
|
if( !nLine || nLine > pLines->size() )
|
2007-02-28 14:50:39 +00:00
|
|
|
return 0;
|
|
|
|
pLine = (*pLines)[ nLine-1 ];
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// determine box
|
2007-02-28 14:50:39 +00:00
|
|
|
pBoxes = &pLine->GetTabBoxes();
|
2012-05-10 17:42:10 +02:00
|
|
|
if( nBox >= pBoxes->size() )
|
2007-02-28 14:50:39 +00:00
|
|
|
return 0;
|
|
|
|
pBox = (*pBoxes)[ nBox ];
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// check if the box found has any contents
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pBox && !pBox->GetSttNd() )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
OSL_FAIL( "Box without content, looking for the next one!" );
|
|
|
|
// "drop this" until the first box
|
2012-06-18 18:04:44 +02:00
|
|
|
while( !pBox->GetTabLines().empty() )
|
|
|
|
pBox = pBox->GetTabLines().front()->GetTabBoxes().front();
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
return pBox;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
SwTableBox* SwTable::GetTblBox( sal_uLong nSttIdx )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// For optimizations, don't always process the entire SortArray.
|
|
|
|
// Converting text to table, tries certain conditions
|
2007-02-28 14:50:39 +00:00
|
|
|
// to ask for a table box of a table that is not yet having a format
|
|
|
|
if(!GetFrmFmt())
|
|
|
|
return 0;
|
|
|
|
SwTableBox* pRet = 0;
|
|
|
|
SwNodes& rNds = GetFrmFmt()->GetDoc()->GetNodes();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nIndex = nSttIdx + 1;
|
2007-02-28 14:50:39 +00:00
|
|
|
SwCntntNode* pCNd = 0;
|
2007-05-25 12:01:16 +00:00
|
|
|
SwTableNode* pTblNd = 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
while ( nIndex < rNds.Count() )
|
|
|
|
{
|
2007-05-25 12:01:16 +00:00
|
|
|
pTblNd = rNds[ nIndex ]->GetTableNode();
|
|
|
|
if ( pTblNd )
|
2007-02-28 14:50:39 +00:00
|
|
|
break;
|
2007-05-25 12:01:16 +00:00
|
|
|
|
|
|
|
pCNd = rNds[ nIndex ]->GetCntntNode();
|
|
|
|
if ( pCNd )
|
2007-02-28 14:50:39 +00:00
|
|
|
break;
|
2007-05-25 12:01:16 +00:00
|
|
|
|
|
|
|
++nIndex;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2007-05-25 12:01:16 +00:00
|
|
|
if ( pCNd || pTblNd )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2007-05-25 12:01:16 +00:00
|
|
|
SwModify* pModify = pCNd;
|
2011-04-18 12:37:38 -03:00
|
|
|
// #144862# Better handling of table in table
|
2007-05-25 12:01:16 +00:00
|
|
|
if ( pTblNd && pTblNd->GetTable().GetFrmFmt() )
|
|
|
|
pModify = pTblNd->GetTable().GetFrmFmt();
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
SwFrm* pFrm = SwIterator<SwFrm,SwModify>::FirstElement( *pModify );
|
2007-02-28 14:50:39 +00:00
|
|
|
while ( pFrm && !pFrm->IsCellFrm() )
|
|
|
|
pFrm = pFrm->GetUpper();
|
|
|
|
if ( pFrm )
|
|
|
|
pRet = (SwTableBox*)((SwCellFrm*)pFrm)->GetTabBox();
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// In case the layout doesn't exist yet or anything else goes wrong.
|
2007-02-28 14:50:39 +00:00
|
|
|
if ( !pRet )
|
|
|
|
{
|
2012-09-20 23:59:14 +02:00
|
|
|
for (size_t n = m_TabSortContentBoxes.size(); n; )
|
|
|
|
{
|
|
|
|
if (m_TabSortContentBoxes[ --n ]->GetSttIdx() == nSttIdx)
|
|
|
|
{
|
|
|
|
return m_TabSortContentBoxes[ n ];
|
|
|
|
}
|
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
return pRet;
|
|
|
|
}
|
|
|
|
|
2012-10-19 03:59:48 +09:00
|
|
|
bool SwTable::IsTblComplex() const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-10-19 03:59:48 +09:00
|
|
|
// Returns true for complex tables, i.e. tables that contain nestings,
|
2012-08-10 15:42:44 +02:00
|
|
|
// like containing boxes not part of the first line, e.g. results of
|
|
|
|
// splits/merges which lead to more complex structures.
|
2012-09-20 23:59:14 +02:00
|
|
|
for (size_t n = 0; n < m_TabSortContentBoxes.size(); ++n)
|
|
|
|
{
|
|
|
|
if (m_TabSortContentBoxes[ n ]->GetUpper()->GetUpper())
|
|
|
|
{
|
2012-10-19 03:59:48 +09:00
|
|
|
return true;
|
2012-09-20 23:59:14 +02:00
|
|
|
}
|
|
|
|
}
|
2012-10-19 03:59:48 +09:00
|
|
|
return false;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwTableLine::SwTableLine()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2011-01-17 15:06:54 +01:00
|
|
|
SwTableLine::SwTableLine( SwTableLineFmt *pFmt, sal_uInt16 nBoxes,
|
2007-02-28 14:50:39 +00:00
|
|
|
SwTableBox *pUp )
|
|
|
|
: SwClient( pFmt ),
|
2012-05-10 17:42:10 +02:00
|
|
|
aBoxes(),
|
2007-02-28 14:50:39 +00:00
|
|
|
pUpper( pUp )
|
|
|
|
{
|
2012-05-10 17:42:10 +02:00
|
|
|
aBoxes.reserve( (sal_uInt8)nBoxes );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwTableLine::~SwTableLine()
|
|
|
|
{
|
2012-05-14 18:33:15 +02:00
|
|
|
for (size_t i = 0; i < aBoxes.size(); ++i)
|
|
|
|
{
|
|
|
|
delete aBoxes[i];
|
|
|
|
}
|
2012-08-10 15:42:44 +02:00
|
|
|
// the TabelleLine can be deleted if it's the last client of the FrameFormat
|
2007-02-28 14:50:39 +00:00
|
|
|
SwModify* pMod = GetFrmFmt();
|
2012-08-10 15:42:44 +02:00
|
|
|
pMod->Remove( this ); // remove,
|
2007-02-28 14:50:39 +00:00
|
|
|
if( !pMod->GetDepends() )
|
2012-08-10 15:42:44 +02:00
|
|
|
delete pMod; // and delete
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwTableLine::ClaimFrmFmt(), ChgFrmFmt()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
SwFrmFmt* SwTableLine::ClaimFrmFmt()
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
// This method makes sure that this object is an exclusive SwTableLine client
|
|
|
|
// of an SwTableLineFmt object
|
|
|
|
// If other SwTableLine objects currently listen to the same SwTableLineFmt as
|
|
|
|
// this one, something needs to be done
|
|
|
|
SwTableLineFmt *pRet = (SwTableLineFmt*)GetFrmFmt();
|
|
|
|
SwIterator<SwTableLine,SwFmt> aIter( *pRet );
|
|
|
|
for( SwTableLine* pLast = aIter.First(); pLast; pLast = aIter.Next() )
|
|
|
|
{
|
|
|
|
if ( pLast != this )
|
|
|
|
{
|
|
|
|
// found another SwTableLine that is a client of the current Fmt
|
|
|
|
// create a new Fmt as a copy and use it for this object
|
|
|
|
SwTableLineFmt *pNewFmt = pRet->GetDoc()->MakeTableLineFmt();
|
|
|
|
*pNewFmt = *pRet;
|
|
|
|
|
|
|
|
// register SwRowFrms that know me as clients at the new Fmt
|
|
|
|
SwIterator<SwRowFrm,SwFmt> aFrmIter( *pRet );
|
|
|
|
for( SwRowFrm* pFrm = aFrmIter.First(); pFrm; pFrm = aFrmIter.Next() )
|
|
|
|
if( pFrm->GetTabLine() == this )
|
|
|
|
pFrm->RegisterToFormat( *pNewFmt );
|
|
|
|
|
|
|
|
// register myself
|
|
|
|
pNewFmt->Add( this );
|
|
|
|
pRet = pNewFmt;
|
|
|
|
break;
|
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
return pRet;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwTableLine::ChgFrmFmt( SwTableLineFmt *pNewFmt )
|
|
|
|
{
|
|
|
|
SwFrmFmt *pOld = GetFrmFmt();
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwRowFrm,SwFmt> aIter( *pOld );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// First, re-register the Frms.
|
2010-12-17 09:02:23 +01:00
|
|
|
for( SwRowFrm* pRow = aIter.First(); pRow; pRow = aIter.Next() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
if( pRow->GetTabLine() == this )
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
pRow->RegisterToFormat( *pNewFmt );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
pRow->InvalidateSize();
|
|
|
|
pRow->_InvalidatePrt();
|
|
|
|
pRow->SetCompletePaint();
|
|
|
|
pRow->ReinitializeFrmSizeAttrFlags();
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i35063#
|
2007-02-28 14:50:39 +00:00
|
|
|
// consider 'split row allowed' attribute
|
|
|
|
SwTabFrm* pTab = pRow->FindTabFrm();
|
|
|
|
bool bInFollowFlowRow = false;
|
|
|
|
const bool bInFirstNonHeadlineRow = pTab->IsFollow() &&
|
|
|
|
pRow == pTab->GetFirstNonHeadlineRow();
|
|
|
|
if ( bInFirstNonHeadlineRow ||
|
|
|
|
!pRow->GetNext() ||
|
2014-01-17 17:11:45 +01:00
|
|
|
( bInFollowFlowRow = pRow->IsInFollowFlowRow() ) ||
|
2007-02-28 14:50:39 +00:00
|
|
|
0 != pRow->IsInSplitTableRow() )
|
|
|
|
{
|
|
|
|
if ( bInFirstNonHeadlineRow || bInFollowFlowRow )
|
|
|
|
pTab = pTab->FindMaster();
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
pTab->SetRemoveFollowFlowLinePending( sal_True );
|
2007-02-28 14:50:39 +00:00
|
|
|
pTab->InvalidatePos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Now, re-register self.
|
2007-02-28 14:50:39 +00:00
|
|
|
pNewFmt->Add( this );
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
if ( !pOld->GetDepends() )
|
2007-02-28 14:50:39 +00:00
|
|
|
delete pOld;
|
|
|
|
}
|
|
|
|
|
2007-05-25 12:01:16 +00:00
|
|
|
SwTwips SwTableLine::GetTableLineHeight( bool& bLayoutAvailable ) const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
SwTwips nRet = 0;
|
2007-05-25 12:01:16 +00:00
|
|
|
bLayoutAvailable = false;
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwRowFrm,SwFmt> aIter( *GetFrmFmt() );
|
2007-02-28 14:50:39 +00:00
|
|
|
// A row could appear several times in headers/footers so only one chain of master/follow tables
|
|
|
|
// will be accepted...
|
|
|
|
const SwTabFrm* pChain = NULL; // My chain
|
2010-12-17 09:02:23 +01:00
|
|
|
for( SwRowFrm* pLast = aIter.First(); pLast; pLast = aIter.Next() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
if( pLast->GetTabLine() == this )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
const SwTabFrm* pTab = pLast->FindTabFrm();
|
2007-05-25 12:01:16 +00:00
|
|
|
bLayoutAvailable = ( pTab && pTab->IsVertical() ) ?
|
|
|
|
( 0 < pTab->Frm().Height() ) :
|
|
|
|
( 0 < pTab->Frm().Width() );
|
|
|
|
|
2007-02-28 14:50:39 +00:00
|
|
|
// The first one defines the chain, if a chain is defined, only members of the chain
|
|
|
|
// will be added.
|
|
|
|
if( !pChain || pChain->IsAnFollow( pTab ) || pTab->IsAnFollow( pChain ) )
|
|
|
|
{
|
|
|
|
pChain = pTab; // defines my chain (even it is already)
|
|
|
|
if( pTab->IsVertical() )
|
2010-12-17 09:02:23 +01:00
|
|
|
nRet += pLast->Frm().Width();
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
2010-12-17 09:02:23 +01:00
|
|
|
nRet += pLast->Frm().Height();
|
2007-02-28 14:50:39 +00:00
|
|
|
// Optimization, if there are no master/follows in my chain, nothing more to add
|
|
|
|
if( !pTab->HasFollow() && !pTab->IsFollow() )
|
|
|
|
break;
|
|
|
|
// This is not an optimization, this is necessary to avoid double additions of
|
|
|
|
// repeating rows
|
2010-12-17 09:02:23 +01:00
|
|
|
if( pTab->IsInHeadline(*pLast) )
|
2007-02-28 14:50:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwTableBox::SwTableBox()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2011-01-17 15:06:54 +01:00
|
|
|
SwTableBox::SwTableBox( SwTableBoxFmt* pFmt, sal_uInt16 nLines, SwTableLine *pUp )
|
2007-02-28 14:50:39 +00:00
|
|
|
: SwClient( 0 ),
|
2012-06-18 18:04:44 +02:00
|
|
|
aLines(),
|
2007-02-28 14:50:39 +00:00
|
|
|
pSttNd( 0 ),
|
|
|
|
pUpper( pUp ),
|
|
|
|
pImpl( 0 )
|
|
|
|
{
|
2012-06-18 18:04:44 +02:00
|
|
|
aLines.reserve( (sal_uInt8)nLines );
|
2007-02-28 14:50:39 +00:00
|
|
|
CheckBoxFmt( pFmt )->Add( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
SwTableBox::SwTableBox( SwTableBoxFmt* pFmt, const SwNodeIndex &rIdx,
|
|
|
|
SwTableLine *pUp )
|
|
|
|
: SwClient( 0 ),
|
2012-06-18 18:04:44 +02:00
|
|
|
aLines(),
|
2007-02-28 14:50:39 +00:00
|
|
|
pUpper( pUp ),
|
|
|
|
pImpl( 0 )
|
|
|
|
{
|
|
|
|
CheckBoxFmt( pFmt )->Add( this );
|
|
|
|
|
2010-12-15 09:13:59 +01:00
|
|
|
pSttNd = rIdx.GetNode().GetStartNode();
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// insert into the table
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTableNode* pTblNd = pSttNd->FindTableNode();
|
2012-08-10 15:42:44 +02:00
|
|
|
OSL_ENSURE( pTblNd, "In which table is that box?" );
|
2007-02-28 14:50:39 +00:00
|
|
|
SwTableSortBoxes& rSrtArr = (SwTableSortBoxes&)pTblNd->GetTable().
|
|
|
|
GetTabSortBoxes();
|
|
|
|
SwTableBox* p = this; // error: &this
|
2012-08-10 15:42:44 +02:00
|
|
|
rSrtArr.insert( p ); // insert
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwTableBox::SwTableBox( SwTableBoxFmt* pFmt, const SwStartNode& rSttNd, SwTableLine *pUp ) :
|
|
|
|
SwClient( 0 ),
|
2012-06-18 18:04:44 +02:00
|
|
|
aLines(),
|
2007-09-27 08:11:01 +00:00
|
|
|
pSttNd( &rSttNd ),
|
2007-02-28 14:50:39 +00:00
|
|
|
pUpper( pUp ),
|
2007-09-27 08:11:01 +00:00
|
|
|
pImpl( 0 )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
CheckBoxFmt( pFmt )->Add( this );
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// insert into the table
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTableNode* pTblNd = pSttNd->FindTableNode();
|
2012-07-18 23:30:06 +02:00
|
|
|
OSL_ENSURE( pTblNd, "In which table is the box?" );
|
2007-02-28 14:50:39 +00:00
|
|
|
SwTableSortBoxes& rSrtArr = (SwTableSortBoxes&)pTblNd->GetTable().
|
|
|
|
GetTabSortBoxes();
|
|
|
|
SwTableBox* p = this; // error: &this
|
2012-08-10 15:42:44 +02:00
|
|
|
rSrtArr.insert( p ); // insert
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2012-09-18 14:19:50 +02:00
|
|
|
void SwTableBox::RemoveFromTable()
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-09-18 14:19:50 +02:00
|
|
|
if (pSttNd) // box containing contents?
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// remove from table
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTableNode* pTblNd = pSttNd->FindTableNode();
|
2012-08-10 15:42:44 +02:00
|
|
|
OSL_ENSURE( pTblNd, "In which table is that box?" );
|
2007-02-28 14:50:39 +00:00
|
|
|
SwTableSortBoxes& rSrtArr = (SwTableSortBoxes&)pTblNd->GetTable().
|
|
|
|
GetTabSortBoxes();
|
|
|
|
SwTableBox *p = this; // error: &this
|
2012-08-10 15:42:44 +02:00
|
|
|
rSrtArr.erase( p ); // remove
|
2012-09-18 14:19:50 +02:00
|
|
|
pSttNd = 0; // clear it so this is only run once
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SwTableBox::~SwTableBox()
|
|
|
|
{
|
|
|
|
if (!GetFrmFmt()->GetDoc()->IsInDtor())
|
|
|
|
{
|
|
|
|
RemoveFromTable();
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// the TabelleBox can be deleted if it's the last client of the FrameFormat
|
2007-02-28 14:50:39 +00:00
|
|
|
SwModify* pMod = GetFrmFmt();
|
2012-08-10 15:42:44 +02:00
|
|
|
pMod->Remove( this ); // remove,
|
2007-02-28 14:50:39 +00:00
|
|
|
if( !pMod->GetDepends() )
|
2012-08-10 15:42:44 +02:00
|
|
|
delete pMod; // and delete
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
delete pImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwTableBoxFmt* SwTableBox::CheckBoxFmt( SwTableBoxFmt* pFmt )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// We might need to create a new format here, because the box must be
|
|
|
|
// added to the format solely if pFmt has a value or formular.
|
2011-01-17 15:06:54 +01:00
|
|
|
if( SFX_ITEM_SET == pFmt->GetItemState( RES_BOXATR_VALUE, sal_False ) ||
|
|
|
|
SFX_ITEM_SET == pFmt->GetItemState( RES_BOXATR_FORMULA, sal_False ) )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
SwTableBox* pOther = SwIterator<SwTableBox,SwFmt>::FirstElement( *pFmt );
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pOther )
|
|
|
|
{
|
|
|
|
SwTableBoxFmt* pNewFmt = pFmt->GetDoc()->MakeTableBoxFmt();
|
|
|
|
pNewFmt->LockModify();
|
|
|
|
*pNewFmt = *pFmt;
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Remove values and formulars
|
2008-06-13 09:13:23 +00:00
|
|
|
pNewFmt->ResetFmtAttr( RES_BOXATR_FORMULA, RES_BOXATR_VALUE );
|
2007-02-28 14:50:39 +00:00
|
|
|
pNewFmt->UnlockModify();
|
|
|
|
|
|
|
|
pFmt = pNewFmt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pFmt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* SwTableBox::ClaimFrmFmt(), ChgFrmFmt()
|
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
|
|
|
SwFrmFmt* SwTableBox::ClaimFrmFmt()
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
// This method makes sure that this object is an exclusive SwTableBox client
|
|
|
|
// of an SwTableBoxFmt object
|
|
|
|
// If other SwTableBox objects currently listen to the same SwTableBoxFmt as
|
|
|
|
// this one, something needs to be done
|
|
|
|
SwTableBoxFmt *pRet = (SwTableBoxFmt*)GetFrmFmt();
|
|
|
|
SwIterator<SwTableBox,SwFmt> aIter( *pRet );
|
|
|
|
for( SwTableBox* pLast = aIter.First(); pLast; pLast = aIter.Next() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
if ( pLast != this )
|
|
|
|
{
|
|
|
|
// Found another SwTableBox object
|
|
|
|
// create a new Fmt as a copy and assign me to it
|
|
|
|
// don't copy values and formulas
|
|
|
|
SwTableBoxFmt* pNewFmt = pRet->GetDoc()->MakeTableBoxFmt();
|
|
|
|
pNewFmt->LockModify();
|
|
|
|
*pNewFmt = *pRet;
|
|
|
|
pNewFmt->ResetFmtAttr( RES_BOXATR_FORMULA, RES_BOXATR_VALUE );
|
|
|
|
pNewFmt->UnlockModify();
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// re-register SwCellFrm objects that know me
|
|
|
|
SwIterator<SwCellFrm,SwFmt> aFrmIter( *pRet );
|
|
|
|
for( SwCellFrm* pCell = aFrmIter.First(); pCell; pCell = aFrmIter.Next() )
|
|
|
|
if( pCell->GetTabBox() == this )
|
|
|
|
pCell->RegisterToFormat( *pNewFmt );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
// re-register myself
|
|
|
|
pNewFmt->Add( this );
|
|
|
|
pRet = pNewFmt;
|
|
|
|
break;
|
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
2010-12-17 09:02:23 +01:00
|
|
|
return pRet;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SwTableBox::ChgFrmFmt( SwTableBoxFmt* pNewFmt )
|
|
|
|
{
|
|
|
|
SwFrmFmt *pOld = GetFrmFmt();
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwCellFrm,SwFmt> aIter( *pOld );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// First, re-register the Frms.
|
2010-12-17 09:02:23 +01:00
|
|
|
for( SwCellFrm* pCell = aIter.First(); pCell; pCell = aIter.Next() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
if( pCell->GetTabBox() == this )
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
pCell->RegisterToFormat( *pNewFmt );
|
2007-02-28 14:50:39 +00:00
|
|
|
pCell->InvalidateSize();
|
|
|
|
pCell->_InvalidatePrt();
|
|
|
|
pCell->SetCompletePaint();
|
2011-01-17 15:06:54 +01:00
|
|
|
pCell->SetDerivedVert( sal_False );
|
2007-02-28 14:50:39 +00:00
|
|
|
pCell->CheckDirChange();
|
|
|
|
|
2011-04-16 22:42:13 -03:00
|
|
|
// #i47489#
|
2007-02-28 14:50:39 +00:00
|
|
|
// make sure that the row will be formatted, in order
|
|
|
|
// to have the correct Get(Top|Bottom)MarginForLowers values
|
|
|
|
// set at the row.
|
|
|
|
const SwTabFrm* pTab = pCell->FindTabFrm();
|
|
|
|
if ( pTab && pTab->IsCollapsingBorders() )
|
|
|
|
{
|
|
|
|
SwFrm* pRow = pCell->GetUpper();
|
|
|
|
pRow->_InvalidateSize();
|
|
|
|
pRow->_InvalidatePrt();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Now, re-register self.
|
2007-02-28 14:50:39 +00:00
|
|
|
pNewFmt->Add( this );
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
if( !pOld->GetDepends() )
|
2007-02-28 14:50:39 +00:00
|
|
|
delete pOld;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* String SwTableBox::GetName() const
|
2012-08-10 15:42:44 +02:00
|
|
|
|* Return the name of this box. This is determined dynamically
|
|
|
|
|* resulting from the position in the lines/boxes/tables.
|
2007-02-28 14:50:39 +00:00
|
|
|
|*
|
|
|
|
|*************************************************************************/
|
2013-10-14 13:42:28 +02:00
|
|
|
void sw_GetTblBoxColStr( sal_uInt16 nCol, OUString& rNm )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_uInt16 coDiff = 52; // 'A'-'Z' 'a' - 'z'
|
|
|
|
sal_uInt16 nCalc;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
do {
|
|
|
|
nCalc = nCol % coDiff;
|
|
|
|
if( nCalc >= 26 )
|
2013-10-14 13:42:28 +02:00
|
|
|
rNm = OUString( sal_Unicode('a' - 26 + nCalc ) ) + rNm;
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
2013-10-14 13:42:28 +02:00
|
|
|
rNm = OUString( sal_Unicode('A' + nCalc ) ) + rNm;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2007-09-27 08:11:01 +00:00
|
|
|
if( 0 == (nCol = nCol - nCalc) )
|
2007-02-28 14:50:39 +00:00
|
|
|
break;
|
|
|
|
nCol /= coDiff;
|
|
|
|
--nCol;
|
2014-01-28 19:59:54 +01:00
|
|
|
} while( true );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2013-09-19 08:02:20 +02:00
|
|
|
OUString SwTableBox::GetName() const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
if( !pSttNd ) // box without content?
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// search for the next first box?
|
2014-01-15 13:01:41 +00:00
|
|
|
return OUString();
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const SwTable& rTbl = pSttNd->FindTableNode()->GetTable();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nPos;
|
2013-10-14 13:42:28 +02:00
|
|
|
OUString sNm, sTmp;
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTableBox* pBox = this;
|
|
|
|
do {
|
|
|
|
const SwTableBoxes* pBoxes = &pBox->GetUpper()->GetTabBoxes();
|
|
|
|
const SwTableLine* pLine = pBox->GetUpper();
|
2012-08-10 15:42:44 +02:00
|
|
|
// at the first level?
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTableLines* pLines = pLine->GetUpper()
|
|
|
|
? &pLine->GetUpper()->GetTabLines() : &rTbl.GetTabLines();
|
|
|
|
|
2013-02-20 00:18:07 +01:00
|
|
|
sTmp = OUString::number( nPos = pLines->GetPos( pLine ) + 1 );
|
2013-10-14 13:42:28 +02:00
|
|
|
if( !sNm.isEmpty() )
|
2013-11-03 19:52:12 +02:00
|
|
|
sNm = sTmp + "." + sNm;
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
|
|
|
sNm = sTmp;
|
|
|
|
|
2013-02-20 00:18:07 +01:00
|
|
|
sTmp = OUString::number(( nPos = pBoxes->GetPos( pBox )) + 1 );
|
2007-02-28 14:50:39 +00:00
|
|
|
if( 0 != ( pBox = pLine->GetUpper()) )
|
2013-11-03 19:52:12 +02:00
|
|
|
sNm = sTmp + "." + sNm;
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
2012-10-12 16:49:40 +02:00
|
|
|
sw_GetTblBoxColStr( nPos, sNm );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
} while( pBox );
|
|
|
|
return sNm;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwTableBox::IsInHeadline( const SwTable* pTbl ) const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
if( !GetUpper() ) // should only happen upon merge.
|
2011-01-17 15:06:54 +01:00
|
|
|
return sal_False;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
if( !pTbl )
|
|
|
|
pTbl = &pSttNd->FindTableNode()->GetTable();
|
|
|
|
|
|
|
|
const SwTableLine* pLine = GetUpper();
|
|
|
|
while( pLine->GetUpper() )
|
|
|
|
pLine = pLine->GetUpper()->GetUpper();
|
|
|
|
|
|
|
|
// Headerline?
|
|
|
|
return pTbl->GetTabLines()[ 0 ] == pLine;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong SwTableBox::GetSttIdx() const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
return pSttNd ? pSttNd->GetIndex() : 0;
|
|
|
|
}
|
|
|
|
|
2013-02-28 18:11:24 -04:00
|
|
|
// retrieve information from the client
|
2012-11-07 10:56:27 +09:00
|
|
|
bool SwTable::GetInfo( SfxPoolItem& rInfo ) const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
switch( rInfo.Which() )
|
|
|
|
{
|
|
|
|
case RES_AUTOFMT_DOCNODE:
|
|
|
|
{
|
|
|
|
const SwTableNode* pTblNode = GetTableNode();
|
|
|
|
if( pTblNode && &pTblNode->GetNodes() == ((SwAutoFmtGetDocNode&)rInfo).pNodes )
|
|
|
|
{
|
2012-09-20 23:59:14 +02:00
|
|
|
if (!m_TabSortContentBoxes.empty())
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-09-20 23:59:14 +02:00
|
|
|
SwNodeIndex aIdx( *m_TabSortContentBoxes[0]->GetSttNd() );
|
2007-02-28 14:50:39 +00:00
|
|
|
((SwAutoFmtGetDocNode&)rInfo).pCntntNode =
|
|
|
|
GetFrmFmt()->GetDoc()->GetNodes().GoNext( &aIdx );
|
|
|
|
}
|
2012-11-07 10:56:27 +09:00
|
|
|
return false;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case RES_FINDNEARESTNODE:
|
2008-06-13 09:13:23 +00:00
|
|
|
if( GetFrmFmt() && ((SwFmtPageDesc&)GetFrmFmt()->GetFmtAttr(
|
2007-02-28 14:50:39 +00:00
|
|
|
RES_PAGEDESC )).GetPageDesc() &&
|
2012-09-20 23:59:14 +02:00
|
|
|
!m_TabSortContentBoxes.empty() &&
|
|
|
|
m_TabSortContentBoxes[0]->GetSttNd()->GetNodes().IsDocNodes() )
|
|
|
|
static_cast<SwFindNearestNode&>(rInfo).CheckNode( *
|
|
|
|
m_TabSortContentBoxes[0]->GetSttNd()->FindTableNode() );
|
2007-02-28 14:50:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RES_CONTENT_VISIBLE:
|
|
|
|
{
|
2010-12-17 09:02:23 +01:00
|
|
|
((SwPtrMsgPoolItem&)rInfo).pObject = SwIterator<SwFrm,SwFmt>::FirstElement( *GetFrmFmt() );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
2012-11-07 10:56:27 +09:00
|
|
|
return false;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
2012-11-07 10:56:27 +09:00
|
|
|
return true;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2010-01-05 16:37:42 +01:00
|
|
|
SwTable * SwTable::FindTable( SwFrmFmt const*const pFmt )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2010-01-05 16:37:42 +01:00
|
|
|
return (pFmt)
|
2010-12-17 09:02:23 +01:00
|
|
|
? SwIterator<SwTable,SwFmt>::FirstElement(*pFmt)
|
2010-01-05 16:37:42 +01:00
|
|
|
: 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SwTableNode* SwTable::GetTableNode() const
|
|
|
|
{
|
2012-07-19 13:24:54 +02:00
|
|
|
return !GetTabSortBoxes().empty() ?
|
2007-02-28 14:50:39 +00:00
|
|
|
(SwTableNode*)GetTabSortBoxes()[ 0 ]->GetSttNd()->FindTableNode() :
|
|
|
|
pTableNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTable::SetRefObject( SwServerObject* pObj )
|
|
|
|
{
|
|
|
|
if( refObj.Is() )
|
|
|
|
refObj->Closed();
|
|
|
|
|
|
|
|
refObj = pObj;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SwTable::SetHTMLTableLayout( SwHTMLTableLayout *p )
|
|
|
|
{
|
|
|
|
delete pHTMLLayout;
|
|
|
|
pHTMLLayout = p;
|
|
|
|
}
|
|
|
|
|
2013-10-16 11:18:56 +02:00
|
|
|
void ChgTextToNum( SwTableBox& rBox, const OUString& rTxt, const Color* pCol,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bChgAlign )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNdPos = rBox.IsValidNumTxtNd( sal_True );
|
2009-11-24 11:34:17 +01:00
|
|
|
ChgTextToNum( rBox,rTxt,pCol,bChgAlign,nNdPos);
|
|
|
|
}
|
2013-10-16 11:18:56 +02:00
|
|
|
void ChgTextToNum( SwTableBox& rBox, const OUString& rTxt, const Color* pCol,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bChgAlign,sal_uLong nNdPos )
|
2009-11-24 11:34:17 +01:00
|
|
|
{
|
|
|
|
|
2007-02-28 14:50:39 +00:00
|
|
|
if( ULONG_MAX != nNdPos )
|
|
|
|
{
|
|
|
|
SwDoc* pDoc = rBox.GetFrmFmt()->GetDoc();
|
|
|
|
SwTxtNode* pTNd = pDoc->GetNodes()[ nNdPos ]->GetTxtNode();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// assign adjustment
|
2007-02-28 14:50:39 +00:00
|
|
|
if( bChgAlign )
|
|
|
|
{
|
|
|
|
pItem = &pTNd->SwCntntNode::GetAttr( RES_PARATR_ADJUST );
|
|
|
|
SvxAdjust eAdjust = ((SvxAdjustItem*)pItem)->GetAdjust();
|
|
|
|
if( SVX_ADJUST_LEFT == eAdjust || SVX_ADJUST_BLOCK == eAdjust )
|
|
|
|
{
|
|
|
|
SvxAdjustItem aAdjust( *(SvxAdjustItem*)pItem );
|
|
|
|
aAdjust.SetAdjust( SVX_ADJUST_RIGHT );
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->SetAttr( aAdjust );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// assign color or save "user color"
|
2007-02-28 14:50:39 +00:00
|
|
|
if( !pTNd->GetpSwAttrSet() || SFX_ITEM_SET != pTNd->GetpSwAttrSet()->
|
2011-01-17 15:06:54 +01:00
|
|
|
GetItemState( RES_CHRATR_COLOR, sal_False, &pItem ))
|
2007-02-28 14:50:39 +00:00
|
|
|
pItem = 0;
|
|
|
|
|
|
|
|
const Color* pOldNumFmtColor = rBox.GetSaveNumFmtColor();
|
|
|
|
const Color* pNewUserColor = pItem ? &((SvxColorItem*)pItem)->GetValue() : 0;
|
|
|
|
|
|
|
|
if( ( pNewUserColor && pOldNumFmtColor &&
|
|
|
|
*pNewUserColor == *pOldNumFmtColor ) ||
|
|
|
|
( !pNewUserColor && !pOldNumFmtColor ))
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Keep the user color, set updated values, delete old NumFmtColor if needed
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pCol )
|
2012-08-10 15:42:44 +02:00
|
|
|
// if needed, set the color
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->SetAttr( SvxColorItem( *pCol, RES_CHRATR_COLOR ));
|
2007-02-28 14:50:39 +00:00
|
|
|
else if( pItem )
|
|
|
|
{
|
|
|
|
pNewUserColor = rBox.GetSaveUserColor();
|
|
|
|
if( pNewUserColor )
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->SetAttr( SvxColorItem( *pNewUserColor, RES_CHRATR_COLOR ));
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->ResetAttr( RES_CHRATR_COLOR );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Save user color, set NumFormat color if needed, but never reset the color
|
2007-02-28 14:50:39 +00:00
|
|
|
rBox.SetSaveUserColor( pNewUserColor );
|
|
|
|
|
|
|
|
if( pCol )
|
2012-08-10 15:42:44 +02:00
|
|
|
// if needed, set the color
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->SetAttr( SvxColorItem( *pCol, RES_CHRATR_COLOR ));
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
rBox.SetSaveNumFmtColor( pCol );
|
|
|
|
|
|
|
|
if( pTNd->GetTxt() != rTxt )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Exchange text. Bugfix to keep Tabs (front and back!)
|
2013-10-16 11:18:56 +02:00
|
|
|
const OUString& rOrig = pTNd->GetTxt();
|
2013-11-12 00:46:22 +01:00
|
|
|
sal_Int32 n;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2013-10-16 11:18:56 +02:00
|
|
|
for( n = 0; n < rOrig.getLength() && '\x9' == rOrig[n]; ++n )
|
2007-02-28 14:50:39 +00:00
|
|
|
;
|
2013-10-16 11:18:56 +02:00
|
|
|
for( ; n < rOrig.getLength() && '\x01' == rOrig[n]; ++n )
|
2009-11-24 11:34:17 +01:00
|
|
|
;
|
2007-02-28 14:50:39 +00:00
|
|
|
SwIndex aIdx( pTNd, n );
|
2013-10-16 11:18:56 +02:00
|
|
|
for( n = rOrig.getLength(); n && '\x9' == rOrig[--n]; )
|
2007-02-28 14:50:39 +00:00
|
|
|
;
|
|
|
|
n -= aIdx.GetIndex() - 1;
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Reset DontExpand-Flags before exchange, to retrigger expansion
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
SwIndex aResetIdx( aIdx, n );
|
2012-10-28 23:38:30 +09:00
|
|
|
pTNd->DontExpandFmt( aResetIdx, false, false );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2012-07-20 17:16:03 +02:00
|
|
|
if( !pDoc->IsIgnoreRedline() && !pDoc->GetRedlineTbl().empty() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2013-10-16 11:18:56 +02:00
|
|
|
SwPaM aTemp(*pTNd, 0, *pTNd, rOrig.getLength());
|
2007-02-28 14:50:39 +00:00
|
|
|
pDoc->DeleteRedline(aTemp, true, USHRT_MAX);
|
|
|
|
}
|
|
|
|
|
CWS-TOOLING: integrate CWS odfmetadata3
2009-09-11 Michael Stahl merge DEV300_m58
2009-09-07 Michael Stahl SwFmtFld::Modify(): do nothing on RES_OBJECTDYING
2009-08-27 Michael Stahl #i91565#, #i91566#: TextPortionEnumerationTest.java: add test document
2009-08-27 Michael Stahl #i91565#, #i91566#: add complex test: TextPortionEnumerationTest.java
2009-08-27 Michael Stahl CLiteral::initialize(): zero-length literals probably not an error
2009-08-27 Michael Stahl #i91565#, #i91566#: offapi: new InContentMetadata and MetadataField services
adapt TextPortion for InContentMetadata
2009-08-27 Michael Stahl #i91564#: xmloff: load/store xml:id and RDFa for text:bookmark(-start).
2009-08-27 Michael Stahl #i91564#: sw core: add support for xml:id at bookmarks:
sw::mark::Bookmark: derive from Metadatable.
SwHistoryBookmark, SaveBookmark: store a MetadatableUndo.
ndcopy.cxx: lcl_CopyBookmarks(): copy the xml:id.
SwXBookmark: derive from MetadatableMixin.
2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: refactor ruby import so nested meta(-field) works:
remove XMLRubyHint_Impl.
XMLImpRubyContext_Impl::~XMLImpRubyContext_Impl(): insert ruby directly.
2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: fix text:meta(-field) import/export:
new XMLTextParagraphExport::exportTextField() overload for XTextField.
CreateAndInsertMark(): set xml:id after insertion.
fix meta(-field) service names, bugs etc.
2009-08-27 Michael Stahl #i91565#, #i91566#: sw text formatting: paint background of meta(-field) body:
SwFont: add member m_nMetaCount.
txttypes.hxx: add POR_META.
atrstck.cxx: handle RES_TXTATR_META(FIELD).
itrform2.cxx: SwTxtFormatter::WhichTxtPor(): create new class SwMetaPortion.
2009-08-27 Michael Stahl #i91566#: sw text formatting: display meta-field prefix and suffix:
SwAttrIter::GetAttr(): replace with call to GetTxtAttrForCharAt().
SwTxtFormatter::NewExtraPortion(): handle meta-field prefix.
SwTxtFormatter: new member m_nHintEndIndex.
SwTxtFormatter::WhichFirstPortion(): call TryNewNoLengthPortion().
SwTxtFormatter::TryNewNoLengthPortion(): new; handle suffix of meta-field.
SwTxtFormatter::UnderFlow(): UGLY HACK: decrement m_nHintEndIndex.
SwFldPortion: add flag m_bNoLength: portion has zero length (for suffix).
2009-08-27 Michael Stahl #i91565#, #i91566#: extend text:meta(-field) uno wrapper with XText interface:
unoobj.hxx: new CursorType CURSOR_META.
unoobj2.cxx: refactor SwXText implementation to ensure that when the SwXText
belongs to a SwXMeta, content is always inserted inside the meta(-field).
unoobj.cxx: new SwXTextCursor::ForceIntoMeta(): cursor stays in meta(-field).
unometa.hxx: SwXMeta implements XText, forwarding to a member SwXMetaText.
DocInsertStringSplitCR(), SwX*::attachToRange(), SwX*::DeleteAndInsert():
use FORCEHINTEXPAND hack to ensure insert into the meta(-field) at the end.
2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) uno wrapper to sw:
fmtmeta.hxx, fmtatr2.cxx: new class sw::MetaField, new sw::MetaFieldManager.
doc.hxx, docnew.cxx: new SwDoc::GetMetaFieldManager().
unocoll.hxx,.cxx: new SW_SERVICE_FIELDTYPE_METAFIELD, SW_SERVICE_TYPE_META.
unomap.hxx,.cxx: new PROPERTY_MAP_METAFIELD.
unoprnms.hxx: new UNO_NAME_META.
unoport.hxx: new PORTION_META; add "InContentMetadata" prop to SwXTextPortion.
new unometa.hxx: new class SwXMeta and SwXMetaField.
unofield.cxx: SwXFieldEnumeration: include meta-fields.
unoportenum.cxx: handle RES_TXTATR_META(FIELD) by using a portion list stack.
unotext.cxx: SwXText::insertTextContent(): handle meta(-field) as attribute.
2009-08-27 Michael Stahl #i91565#, #i91566#: ndhints.cxx: remove sort number from SwTxtAttrNesting
2009-08-27 Michael Stahl #i91565#, #i91566#: add support for hints with end and CH_TXTATR to sw core:
doc.hxx, docedt.cxx: replace SwDoc::Delete(), DeleteAndJoin(), ReplaceRange()
with wrappers that split at left-overlapped end+CH_TXTATR hints.
txatbase.hxx: new member SwTxtAttr::m_bHasDummyChar.
ndtxt.hxx: rename SwTxtNode::GetTxtAttr() to GetTxtAttrForCharAt().
ndtxt.cxx: SwTxtNode::CopyText(): copy end+CH_TXTATR hints iff copy CH_TXTATR.
txtatr2.cxx, thints.cxx: SwTxtMeta gets a CH_TXTATR.
2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) to sw core:
txatbase.hxx: new member SwTxtAttr::m_bNesting.
hintids.hxx: new ids RES_TXTATR_META, RES_TXTATR_METAFIELD.
txtatr.hxx: new base class SwTxtAttrNesting.
new hint SwTxtMeta.
SwTxtRuby derives from SwTxtAttrNesting.
txtinet.hxx: SwTxtINetFmt derives from SwTxtAttrNesting.
new header fmtmeta.hxx: new pool item SwFmtMeta. new class sw::Meta.
ndhints.hxx, thints.cxx: new method SwpHints::TryInsertNesting().
thints.cxx: refactoring: BuildPortions() no longer handles Ruby/Hyperlink,
but TryInsertNesting(), which also handles meta(-field).
SwTxtNode::InsertItem(): check if the hint is actually inserted.
ndhints.cxx: sort nesting hints based on sort number.
ndtxt.cxx: lcl_CopyHint(): handle copy of meta/meta-field.
2009-08-27 Michael Stahl enable expanding hints with m_bLockExpandFlag set:
add new InsertFlag: INS_FORCEHINTEXPAND.
add new SetAttrMode: SETATTR_FORCEHINTEXPAND.
rename SwEditShell::Insert() to Insert2() because changed signature fails
to compile when SwWrtShell tries to overwrite these non-virtual members...
SwWrtShell::Insert() sets FOCEHINTEXPAND if range was selected/deleted.
adapt SwUndoInsert to store flags.
2009-08-27 Michael Stahl change formal parameters of item insertion methods to type SetAttrMode
2009-08-27 Michael Stahl fix incorrect resetting of text attributes in SwUndoInsSection, SwUndoInserts
2009-08-27 Michael Stahl clean up SwTxtNode::CutImpl() and lcl_CopyHint()
2009-08-27 Michael Stahl rename SwDoc::Copy() to CopyRange(), and _Copy() to CopyImpl()
2009-08-27 Michael Stahl rename SwNodes::Move() to MoveRange(), and remove unused parameter
2009-08-27 Michael Stahl rename SwDoc::Move() to MoveRange()/MoveNodeRange()
2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertString(), and remove sal_Unicode variant
2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertPoolItem()/InsertItemSet()/InsertSwSection()
2009-08-27 Michael Stahl rename SwDoc::Replace() to ReplaceRange()
2009-08-27 Michael Stahl remove SwDoc::Overwrite() sal_Unicode variant
2009-08-27 Michael Stahl split up SwDoc::DeleteAndJoin(): factor out DeleteAndJoinWithRedline()
2009-08-27 Michael Stahl rename overloaded SwDoc::Delete() to DeleteRange()/DeleteTOXMark()
2009-08-27 Michael Stahl rename SwTxtNode::Copy() to CopyText()
2009-08-27 Michael Stahl rename SwTxtNode::Cut() to CutText(), and _Cut() to CutImpl()
2009-08-27 Michael Stahl rename SwTxtNode::Delete() to DeleteAttribute()/DeleteAttributes()
2009-08-27 Michael Stahl rename SwTxtNode::Replace() to ReplaceText(), and remove the xub_Unicode variant
2009-08-27 Michael Stahl rename SwTxtNode::Erase() to EraseText()
2009-08-27 Michael Stahl rename SwTxtNode::Insert() to InsertText(), and remove the xub_Unicode variant
2009-08-27 Michael Stahl clean up SwTxtNode::Update()
2009-08-27 Michael Stahl remove SwTxtAttr::RemoveFromPool() and make destructor non-public,
to be invoked by new method SwTxtAttr::Destroy()
2009-08-27 Michael Stahl ensure that SwDoc::Insert() for item (set) returns success indicator:
replace SwRegHistory constructor with method InsertItems(), returning bool.
refactor InsAttr() so that it checks if InsertItems() succeeds.
2009-08-27 Michael Stahl move SwXTextPortionEnumeration from unoobj.hxx to unoport.hxx
2009-08-27 Michael Stahl add missing SolarMutex in SwXTextPortion methods
2009-08-27 Michael Stahl SwXTextPortion: new member m_xTextField (so the TextField property need not
be returned indirectly via SwUnoCursorHelper).
factor out function CreateSwXTextField().
2009-08-27 Michael Stahl SwXTextPortion: remove PORTION_CONTROL_CHAR and implementation of XTextField
2009-08-27 Michael Stahl remove obsolete hint SwTxtHardBlank and formats SwFmtHardBlank/SwFmtSoftHyph
2009-08-27 Michael Stahl clean up SwTxtAttr and friends:
remove many accessor methods for obsolete (due to autofmt) char format items.
remove unused flag SwTxtAttr::m_bDontMergeAttr.
MakeRedlineTxtAttr() now dedicated function, no longer calls MakeTxtAttr().
2009-08-27 Michael Stahl remove obsolete attribute SwTxt2Lines
2009-08-27 Michael Stahl SwXTextPortionEnumeration: finish refactoring CreatePortions
change ExportHints so it always returns a text portion for hint w/ CH_TXTATR.
remove special case for handling end of paragraph.
unfortunately had to refactor the fieldmarks export as well (got in the way).
2009-08-27 Michael Stahl SwXTextPortionEnumeration: refactor CreatePortions: frames export
extract function ExportFrames() from CreatePortions().
remove (un)dead code that calls evil MovePara(fnParaCurr, fnParaEnd)
2009-08-27 Michael Stahl clean up SwXParaFrameEnumeration
2009-08-27 Michael Stahl CollectFrameAtNode: replace SwDependArr with STL based FrameDependList_t
2009-08-27 Michael Stahl SwXTextPortionEnumeration: tweak refmark/toxmark export
so ExportHints returns the portion for point marks
2009-08-27 Michael Stahl clean up SwXTextPortionEnumeration:
prefix members, remove casts, replace SvWeirdArray with STL, etc.
make CreatePortions() method a function, and remove lots of members.
extract fieldmarks function from CreatePortions.
2009-08-27 Michael Stahl remove FOREACHUNOPAM_START/END macros
2009-08-27 Michael Stahl clean up SwXTextPortion:
prefix members, remove casts, etc.
remove SwXRubyPortion: replace it with another SwXTextPortion constructor
2009-08-27 Michael Stahl #i102541# SwXReferenceMark::InsertRefMark(): use flag SETATTR_DONTEXPAND
2009-08-27 Michael Stahl rename SwTxtNode::Insert to SwTxtNode::InsertHint, and
fix constness in SwTxtNode::InsertItem
2009-08-27 Michael Stahl turn SwTxtNode::MakeTxtAttr() methods into global functions in ndhints.hxx
2009-08-27 Michael Stahl remove obsolete sw/inc/bookmrk.hxx
2009-08-27 Michael Stahl pam.cxx: fix ComparePosition functions (returned wrong result in one case)
2009-08-27 Michael Stahl #i103613# only import RDF metadata on normal open of a document
2009-09-11 kz CWS-TOOLING: integrate CWS impress176
2009-09-08 20:18:24 +0200 sj r275957 : fixed warning (shadowed variable)
2009-09-08 18:02:05 +0200 cl r275948 : #i104315# added missing tab pages
2009-09-08 17:35:18 +0200 cl r275947 : #i104866# fixed angle import
2009-09-08 17:32:53 +0200 cl r275946 : #i104841# fixed angle import
2009-09-08 17:01:25 +0200 cl r275943 : #i103935# fixed the SID_EVENTCONFIG mess
2009-09-08 14:32:57 +0200 sj r275928 : #i104685# only comments
2009-09-07 12:37:36 +0200 sj r275886 : #i104683# fixed import of bold/italic attributes for normal text shapes
2009-09-04 15:07:46 +0200 sj r275808 : #104689# fixed bullet color problem
2009-09-03 15:25:07 +0200 sj r275753 : #160200# added vertical alignment of table cells
2009-09-11 kz CWS-TOOLING: integrate CWS dv14
2009-09-10 15:16:32 +0200 sg r276035 : #160513# updated wfs scheme to accept ports
2009-09-10 07:41:47 +0200 dv r276019 : #i104942# Better renaming algorithmen
2009-08-31 13:41:11 +0200 dv r275604 : #160505# Setting APP1PRODUCTNAME must not overwrite APP1PRODUCTDEF
2009-09-11 kz CWS-TOOLING: integrate CWS jl131
2009-09-02 16:42:40 +0200 jl r275720 : #i97896#
2009-08-31 13:01:53 +0200 jl r275599 : CWS-TOOLING: rebase CWS jl131 to trunk@275331 (milestone: DEV300:m56)
2009-07-31 14:35:30 +0200 jl r274531 : CWS-TOOLING: rebase CWS jl131 to trunk@274203 (milestone: DEV300:m53)
2009-07-23 14:20:32 +0200 jl r274272 : #i79839# better error text when trying to modify shared layer without having write permission, eg. unopkg add --shared, unopkg remove --shared, unopkg reinstall --shared
2009-07-22 16:38:02 +0200 jl r274252 : #i97896# localize error message for lock file
2009-07-22 16:37:22 +0200 jl r274251 : #i80462# unprecise wording in updatedialog
2009-07-22 16:36:06 +0200 jl r274250 : #i97896# localize error message for lock file
2009-07-22 16:35:20 +0200 jl r274249 : #i97896# localize error message for lock file
2009-07-22 15:07:30 +0200 jl r274242 : #i98873# minimum java version is 1.5 since OOo 3.0
2009-09-11 kz CWS-TOOLING: integrate CWS changehc
2009-08-31 19:38:50 +0200 pl r275633 : remove dbug printf
2009-08-31 17:41:50 +0200 pl r275623 : CWS-TOOLING: rebase CWS changehc to trunk@275331 (milestone: DEV300:m56)
2009-07-15 19:45:46 +0200 pl r274028 : #i35482# use HC flag to decide high contrast mode
2009-07-15 17:40:52 +0200 pl r274020 : #i35482# use HC flag to decide high contrast mode
2009-07-15 17:39:50 +0200 pl r274019 : #i35482# update autohc correctly in MergeSystemSettings
2009-07-15 17:38:57 +0200 pl r274018 : #i35482# update autohc correctly in MergeSystemSettings
2009-09-11 kz CWS-TOOLING: integrate CWS notes10
2009-08-24 07:25:57 +0200 mod r275287 : 2009-07-26 02:38:32 +0200 mod r274343 : #i#i103645#
2009-07-26 02:01:53 +0200 mod r274342 : #i103645#
2009-07-26 01:52:42 +0200 mod r274341 : #i103490#
2009-07-22 08:31:48 +0200 mod r274215 : #i103373#
2009-07-15 00:55:11 +0200 mod r273987 : #i101419#
2009-07-14 07:07:55 +0200 mod r273956 : #i101419#
2009-07-14 07:07:43 +0200 mod r273955 : #i101419#
2009-07-14 07:02:10 +0200 mod r273954 : changes from notes9
2009-07-14 06:14:25 +0200 mod r273953 : #i103476#
2009-09-11 kz CWS-TOOLING: integrate CWS ab70
2009-09-10 15:12:54 +0200 jsk r276034 : #i85434# - mandatory automatic update test
2009-09-10 15:11:06 +0200 jsk r276033 : #i85434# - mandatory automatic update test
2009-09-02 09:49:24 +0200 ab r275698 : #i85434# Dialog Import
2009-09-11 kz CWS-TOOLING: integrate CWS hb32bugs02
2009-09-02 Henning Brinkmann #i102420# revert changes
2009-08-26 Henning Brinkmann merged DEV300_m56
2009-08-19 Henning Brinkmann merged DEV300_m55
2009-08-14 Henning Brinkmann merged changes from wntmsci12
2009-08-12 Henning Brinkmann Implemented NoSpaceEdit constructor and destructor in .cxx to allow compile with debug on wntmsci12.
2009-08-12 Henning Brinkmann Added some SW_DLLPUBLIC to make compilable on wntmsci12.
2009-08-11 Henning Brinkmann #i102420# dbg_out: surround output for SwNodes with <nodes-array>.
2009-08-10 Henning Brinkmann #i102420# rewritten debug output for SwNodes.
2009-08-07 Henning Brinkmann #i102420# debug _MoveNodes: output the destination, too. Break after two iterations.
2009-08-07 Henning Brinkmann #i102420# _MoveNodes: Additionally check if destination index is inside source => false
Check if current range was already handled => loop
Debug output current range
2009-08-06 Henning Brinkmann merged DEV300_m54
2009-08-06 Henning Brinkmann added master fix
2009-08-06 Henning Brinkmann debug output for SwNodeRange
2009-08-04 Henning Brinkmann #i102844# robustness: check for NULL pointer to prevent crash
2009-08-03 Henning Brinkmann #i103475# applied patch and verified
2009-08-03 Henning Brinkmann Removed code preventing build of sw with DEBUG.
2009-09-11 convert-repo update tags
2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300
2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree.
2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23
2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite
2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix
2009-09-10 kz CWS-TOOLING: integrate CWS mh232
2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch
2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD
2009-08-26 03:11:20 +0200 mh r275383 : #i39230
2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field
2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name
2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl
2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam
2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613#
2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3
2009-09-10 kz CWS-TOOLING: integrate CWS tkr24
2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT
2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping>
2009-09-11 convert-repo update tags
2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300
2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree.
2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23
2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite
2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix
2009-09-10 kz CWS-TOOLING: integrate CWS mh232
2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch
2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD
2009-08-26 03:11:20 +0200 mh r275383 : #i39230
2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field
2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name
2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl
2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam
2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613#
2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3
2009-09-10 kz CWS-TOOLING: integrate CWS tkr24
2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT
2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping>
2009-09-11 14:29:45 +00:00
|
|
|
pTNd->EraseText( aIdx, n,
|
|
|
|
IDocumentContentOperations::INS_EMPTYEXPAND );
|
|
|
|
pTNd->InsertText( rTxt, aIdx,
|
|
|
|
IDocumentContentOperations::INS_EMPTYEXPAND );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
if( pDoc->IsRedlineOn() )
|
|
|
|
{
|
2013-10-16 11:18:56 +02:00
|
|
|
SwPaM aTemp(*pTNd, 0, *pTNd, rTxt.getLength());
|
2014-01-13 17:58:25 +02:00
|
|
|
pDoc->AppendRedline(new SwRangeRedline(nsRedlineType_t::REDLINE_INSERT, aTemp), true);
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// assign vertical orientation
|
2007-02-28 14:50:39 +00:00
|
|
|
if( bChgAlign &&
|
|
|
|
( SFX_ITEM_SET != rBox.GetFrmFmt()->GetItemState(
|
2011-01-17 15:06:54 +01:00
|
|
|
RES_VERT_ORIENT, sal_True, &pItem ) ||
|
2007-09-27 08:11:01 +00:00
|
|
|
text::VertOrientation::TOP == ((SwFmtVertOrient*)pItem)->GetVertOrient() ))
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2008-06-13 09:13:23 +00:00
|
|
|
rBox.GetFrmFmt()->SetFmtAttr( SwFmtVertOrient( 0, text::VertOrientation::BOTTOM ));
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
void ChgNumToText( SwTableBox& rBox, sal_uLong nFmt )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNdPos = rBox.IsValidNumTxtNd( sal_False );
|
2007-02-28 14:50:39 +00:00
|
|
|
if( ULONG_MAX != nNdPos )
|
|
|
|
{
|
|
|
|
SwDoc* pDoc = rBox.GetFrmFmt()->GetDoc();
|
|
|
|
SwTxtNode* pTNd = pDoc->GetNodes()[ nNdPos ]->GetTxtNode();
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bChgAlign = pDoc->IsInsTblAlignNum();
|
2007-02-28 14:50:39 +00:00
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
|
|
|
|
Color* pCol = 0;
|
|
|
|
if( NUMBERFORMAT_TEXT != nFmt )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// special text format:
|
2013-10-16 11:18:56 +02:00
|
|
|
OUString sTmp, sTxt( pTNd->GetTxt() );
|
2012-11-18 18:55:49 -06:00
|
|
|
OUString sTempIn(sTxt);
|
|
|
|
OUString sTempOut;
|
|
|
|
pDoc->GetNumberFormatter()->GetOutputString( sTempIn, nFmt, sTempOut, &pCol );
|
|
|
|
sTxt = sTempIn;
|
|
|
|
sTmp = sTempOut;
|
2007-02-28 14:50:39 +00:00
|
|
|
if( sTxt != sTmp )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// exchange text
|
2013-10-16 11:18:56 +02:00
|
|
|
SwIndex aIdx( pTNd, sTxt.getLength() );
|
2012-08-10 15:42:44 +02:00
|
|
|
// Reset DontExpand-Flags before exchange, to retrigger expansion
|
2012-10-28 23:38:30 +09:00
|
|
|
pTNd->DontExpandFmt( aIdx, false, false );
|
2007-02-28 14:50:39 +00:00
|
|
|
aIdx = 0;
|
2013-12-14 22:46:05 +01:00
|
|
|
pTNd->EraseText( aIdx, SAL_MAX_INT32,
|
CWS-TOOLING: integrate CWS odfmetadata3
2009-09-11 Michael Stahl merge DEV300_m58
2009-09-07 Michael Stahl SwFmtFld::Modify(): do nothing on RES_OBJECTDYING
2009-08-27 Michael Stahl #i91565#, #i91566#: TextPortionEnumerationTest.java: add test document
2009-08-27 Michael Stahl #i91565#, #i91566#: add complex test: TextPortionEnumerationTest.java
2009-08-27 Michael Stahl CLiteral::initialize(): zero-length literals probably not an error
2009-08-27 Michael Stahl #i91565#, #i91566#: offapi: new InContentMetadata and MetadataField services
adapt TextPortion for InContentMetadata
2009-08-27 Michael Stahl #i91564#: xmloff: load/store xml:id and RDFa for text:bookmark(-start).
2009-08-27 Michael Stahl #i91564#: sw core: add support for xml:id at bookmarks:
sw::mark::Bookmark: derive from Metadatable.
SwHistoryBookmark, SaveBookmark: store a MetadatableUndo.
ndcopy.cxx: lcl_CopyBookmarks(): copy the xml:id.
SwXBookmark: derive from MetadatableMixin.
2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: refactor ruby import so nested meta(-field) works:
remove XMLRubyHint_Impl.
XMLImpRubyContext_Impl::~XMLImpRubyContext_Impl(): insert ruby directly.
2009-08-27 Michael Stahl #i91565#, #i91566#: xmloff: fix text:meta(-field) import/export:
new XMLTextParagraphExport::exportTextField() overload for XTextField.
CreateAndInsertMark(): set xml:id after insertion.
fix meta(-field) service names, bugs etc.
2009-08-27 Michael Stahl #i91565#, #i91566#: sw text formatting: paint background of meta(-field) body:
SwFont: add member m_nMetaCount.
txttypes.hxx: add POR_META.
atrstck.cxx: handle RES_TXTATR_META(FIELD).
itrform2.cxx: SwTxtFormatter::WhichTxtPor(): create new class SwMetaPortion.
2009-08-27 Michael Stahl #i91566#: sw text formatting: display meta-field prefix and suffix:
SwAttrIter::GetAttr(): replace with call to GetTxtAttrForCharAt().
SwTxtFormatter::NewExtraPortion(): handle meta-field prefix.
SwTxtFormatter: new member m_nHintEndIndex.
SwTxtFormatter::WhichFirstPortion(): call TryNewNoLengthPortion().
SwTxtFormatter::TryNewNoLengthPortion(): new; handle suffix of meta-field.
SwTxtFormatter::UnderFlow(): UGLY HACK: decrement m_nHintEndIndex.
SwFldPortion: add flag m_bNoLength: portion has zero length (for suffix).
2009-08-27 Michael Stahl #i91565#, #i91566#: extend text:meta(-field) uno wrapper with XText interface:
unoobj.hxx: new CursorType CURSOR_META.
unoobj2.cxx: refactor SwXText implementation to ensure that when the SwXText
belongs to a SwXMeta, content is always inserted inside the meta(-field).
unoobj.cxx: new SwXTextCursor::ForceIntoMeta(): cursor stays in meta(-field).
unometa.hxx: SwXMeta implements XText, forwarding to a member SwXMetaText.
DocInsertStringSplitCR(), SwX*::attachToRange(), SwX*::DeleteAndInsert():
use FORCEHINTEXPAND hack to ensure insert into the meta(-field) at the end.
2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) uno wrapper to sw:
fmtmeta.hxx, fmtatr2.cxx: new class sw::MetaField, new sw::MetaFieldManager.
doc.hxx, docnew.cxx: new SwDoc::GetMetaFieldManager().
unocoll.hxx,.cxx: new SW_SERVICE_FIELDTYPE_METAFIELD, SW_SERVICE_TYPE_META.
unomap.hxx,.cxx: new PROPERTY_MAP_METAFIELD.
unoprnms.hxx: new UNO_NAME_META.
unoport.hxx: new PORTION_META; add "InContentMetadata" prop to SwXTextPortion.
new unometa.hxx: new class SwXMeta and SwXMetaField.
unofield.cxx: SwXFieldEnumeration: include meta-fields.
unoportenum.cxx: handle RES_TXTATR_META(FIELD) by using a portion list stack.
unotext.cxx: SwXText::insertTextContent(): handle meta(-field) as attribute.
2009-08-27 Michael Stahl #i91565#, #i91566#: ndhints.cxx: remove sort number from SwTxtAttrNesting
2009-08-27 Michael Stahl #i91565#, #i91566#: add support for hints with end and CH_TXTATR to sw core:
doc.hxx, docedt.cxx: replace SwDoc::Delete(), DeleteAndJoin(), ReplaceRange()
with wrappers that split at left-overlapped end+CH_TXTATR hints.
txatbase.hxx: new member SwTxtAttr::m_bHasDummyChar.
ndtxt.hxx: rename SwTxtNode::GetTxtAttr() to GetTxtAttrForCharAt().
ndtxt.cxx: SwTxtNode::CopyText(): copy end+CH_TXTATR hints iff copy CH_TXTATR.
txtatr2.cxx, thints.cxx: SwTxtMeta gets a CH_TXTATR.
2009-08-27 Michael Stahl #i91565#, #i91566#: add text:meta(-field) to sw core:
txatbase.hxx: new member SwTxtAttr::m_bNesting.
hintids.hxx: new ids RES_TXTATR_META, RES_TXTATR_METAFIELD.
txtatr.hxx: new base class SwTxtAttrNesting.
new hint SwTxtMeta.
SwTxtRuby derives from SwTxtAttrNesting.
txtinet.hxx: SwTxtINetFmt derives from SwTxtAttrNesting.
new header fmtmeta.hxx: new pool item SwFmtMeta. new class sw::Meta.
ndhints.hxx, thints.cxx: new method SwpHints::TryInsertNesting().
thints.cxx: refactoring: BuildPortions() no longer handles Ruby/Hyperlink,
but TryInsertNesting(), which also handles meta(-field).
SwTxtNode::InsertItem(): check if the hint is actually inserted.
ndhints.cxx: sort nesting hints based on sort number.
ndtxt.cxx: lcl_CopyHint(): handle copy of meta/meta-field.
2009-08-27 Michael Stahl enable expanding hints with m_bLockExpandFlag set:
add new InsertFlag: INS_FORCEHINTEXPAND.
add new SetAttrMode: SETATTR_FORCEHINTEXPAND.
rename SwEditShell::Insert() to Insert2() because changed signature fails
to compile when SwWrtShell tries to overwrite these non-virtual members...
SwWrtShell::Insert() sets FOCEHINTEXPAND if range was selected/deleted.
adapt SwUndoInsert to store flags.
2009-08-27 Michael Stahl change formal parameters of item insertion methods to type SetAttrMode
2009-08-27 Michael Stahl fix incorrect resetting of text attributes in SwUndoInsSection, SwUndoInserts
2009-08-27 Michael Stahl clean up SwTxtNode::CutImpl() and lcl_CopyHint()
2009-08-27 Michael Stahl rename SwDoc::Copy() to CopyRange(), and _Copy() to CopyImpl()
2009-08-27 Michael Stahl rename SwNodes::Move() to MoveRange(), and remove unused parameter
2009-08-27 Michael Stahl rename SwDoc::Move() to MoveRange()/MoveNodeRange()
2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertString(), and remove sal_Unicode variant
2009-08-27 Michael Stahl rename SwDoc::Insert() to InsertPoolItem()/InsertItemSet()/InsertSwSection()
2009-08-27 Michael Stahl rename SwDoc::Replace() to ReplaceRange()
2009-08-27 Michael Stahl remove SwDoc::Overwrite() sal_Unicode variant
2009-08-27 Michael Stahl split up SwDoc::DeleteAndJoin(): factor out DeleteAndJoinWithRedline()
2009-08-27 Michael Stahl rename overloaded SwDoc::Delete() to DeleteRange()/DeleteTOXMark()
2009-08-27 Michael Stahl rename SwTxtNode::Copy() to CopyText()
2009-08-27 Michael Stahl rename SwTxtNode::Cut() to CutText(), and _Cut() to CutImpl()
2009-08-27 Michael Stahl rename SwTxtNode::Delete() to DeleteAttribute()/DeleteAttributes()
2009-08-27 Michael Stahl rename SwTxtNode::Replace() to ReplaceText(), and remove the xub_Unicode variant
2009-08-27 Michael Stahl rename SwTxtNode::Erase() to EraseText()
2009-08-27 Michael Stahl rename SwTxtNode::Insert() to InsertText(), and remove the xub_Unicode variant
2009-08-27 Michael Stahl clean up SwTxtNode::Update()
2009-08-27 Michael Stahl remove SwTxtAttr::RemoveFromPool() and make destructor non-public,
to be invoked by new method SwTxtAttr::Destroy()
2009-08-27 Michael Stahl ensure that SwDoc::Insert() for item (set) returns success indicator:
replace SwRegHistory constructor with method InsertItems(), returning bool.
refactor InsAttr() so that it checks if InsertItems() succeeds.
2009-08-27 Michael Stahl move SwXTextPortionEnumeration from unoobj.hxx to unoport.hxx
2009-08-27 Michael Stahl add missing SolarMutex in SwXTextPortion methods
2009-08-27 Michael Stahl SwXTextPortion: new member m_xTextField (so the TextField property need not
be returned indirectly via SwUnoCursorHelper).
factor out function CreateSwXTextField().
2009-08-27 Michael Stahl SwXTextPortion: remove PORTION_CONTROL_CHAR and implementation of XTextField
2009-08-27 Michael Stahl remove obsolete hint SwTxtHardBlank and formats SwFmtHardBlank/SwFmtSoftHyph
2009-08-27 Michael Stahl clean up SwTxtAttr and friends:
remove many accessor methods for obsolete (due to autofmt) char format items.
remove unused flag SwTxtAttr::m_bDontMergeAttr.
MakeRedlineTxtAttr() now dedicated function, no longer calls MakeTxtAttr().
2009-08-27 Michael Stahl remove obsolete attribute SwTxt2Lines
2009-08-27 Michael Stahl SwXTextPortionEnumeration: finish refactoring CreatePortions
change ExportHints so it always returns a text portion for hint w/ CH_TXTATR.
remove special case for handling end of paragraph.
unfortunately had to refactor the fieldmarks export as well (got in the way).
2009-08-27 Michael Stahl SwXTextPortionEnumeration: refactor CreatePortions: frames export
extract function ExportFrames() from CreatePortions().
remove (un)dead code that calls evil MovePara(fnParaCurr, fnParaEnd)
2009-08-27 Michael Stahl clean up SwXParaFrameEnumeration
2009-08-27 Michael Stahl CollectFrameAtNode: replace SwDependArr with STL based FrameDependList_t
2009-08-27 Michael Stahl SwXTextPortionEnumeration: tweak refmark/toxmark export
so ExportHints returns the portion for point marks
2009-08-27 Michael Stahl clean up SwXTextPortionEnumeration:
prefix members, remove casts, replace SvWeirdArray with STL, etc.
make CreatePortions() method a function, and remove lots of members.
extract fieldmarks function from CreatePortions.
2009-08-27 Michael Stahl remove FOREACHUNOPAM_START/END macros
2009-08-27 Michael Stahl clean up SwXTextPortion:
prefix members, remove casts, etc.
remove SwXRubyPortion: replace it with another SwXTextPortion constructor
2009-08-27 Michael Stahl #i102541# SwXReferenceMark::InsertRefMark(): use flag SETATTR_DONTEXPAND
2009-08-27 Michael Stahl rename SwTxtNode::Insert to SwTxtNode::InsertHint, and
fix constness in SwTxtNode::InsertItem
2009-08-27 Michael Stahl turn SwTxtNode::MakeTxtAttr() methods into global functions in ndhints.hxx
2009-08-27 Michael Stahl remove obsolete sw/inc/bookmrk.hxx
2009-08-27 Michael Stahl pam.cxx: fix ComparePosition functions (returned wrong result in one case)
2009-08-27 Michael Stahl #i103613# only import RDF metadata on normal open of a document
2009-09-11 kz CWS-TOOLING: integrate CWS impress176
2009-09-08 20:18:24 +0200 sj r275957 : fixed warning (shadowed variable)
2009-09-08 18:02:05 +0200 cl r275948 : #i104315# added missing tab pages
2009-09-08 17:35:18 +0200 cl r275947 : #i104866# fixed angle import
2009-09-08 17:32:53 +0200 cl r275946 : #i104841# fixed angle import
2009-09-08 17:01:25 +0200 cl r275943 : #i103935# fixed the SID_EVENTCONFIG mess
2009-09-08 14:32:57 +0200 sj r275928 : #i104685# only comments
2009-09-07 12:37:36 +0200 sj r275886 : #i104683# fixed import of bold/italic attributes for normal text shapes
2009-09-04 15:07:46 +0200 sj r275808 : #104689# fixed bullet color problem
2009-09-03 15:25:07 +0200 sj r275753 : #160200# added vertical alignment of table cells
2009-09-11 kz CWS-TOOLING: integrate CWS dv14
2009-09-10 15:16:32 +0200 sg r276035 : #160513# updated wfs scheme to accept ports
2009-09-10 07:41:47 +0200 dv r276019 : #i104942# Better renaming algorithmen
2009-08-31 13:41:11 +0200 dv r275604 : #160505# Setting APP1PRODUCTNAME must not overwrite APP1PRODUCTDEF
2009-09-11 kz CWS-TOOLING: integrate CWS jl131
2009-09-02 16:42:40 +0200 jl r275720 : #i97896#
2009-08-31 13:01:53 +0200 jl r275599 : CWS-TOOLING: rebase CWS jl131 to trunk@275331 (milestone: DEV300:m56)
2009-07-31 14:35:30 +0200 jl r274531 : CWS-TOOLING: rebase CWS jl131 to trunk@274203 (milestone: DEV300:m53)
2009-07-23 14:20:32 +0200 jl r274272 : #i79839# better error text when trying to modify shared layer without having write permission, eg. unopkg add --shared, unopkg remove --shared, unopkg reinstall --shared
2009-07-22 16:38:02 +0200 jl r274252 : #i97896# localize error message for lock file
2009-07-22 16:37:22 +0200 jl r274251 : #i80462# unprecise wording in updatedialog
2009-07-22 16:36:06 +0200 jl r274250 : #i97896# localize error message for lock file
2009-07-22 16:35:20 +0200 jl r274249 : #i97896# localize error message for lock file
2009-07-22 15:07:30 +0200 jl r274242 : #i98873# minimum java version is 1.5 since OOo 3.0
2009-09-11 kz CWS-TOOLING: integrate CWS changehc
2009-08-31 19:38:50 +0200 pl r275633 : remove dbug printf
2009-08-31 17:41:50 +0200 pl r275623 : CWS-TOOLING: rebase CWS changehc to trunk@275331 (milestone: DEV300:m56)
2009-07-15 19:45:46 +0200 pl r274028 : #i35482# use HC flag to decide high contrast mode
2009-07-15 17:40:52 +0200 pl r274020 : #i35482# use HC flag to decide high contrast mode
2009-07-15 17:39:50 +0200 pl r274019 : #i35482# update autohc correctly in MergeSystemSettings
2009-07-15 17:38:57 +0200 pl r274018 : #i35482# update autohc correctly in MergeSystemSettings
2009-09-11 kz CWS-TOOLING: integrate CWS notes10
2009-08-24 07:25:57 +0200 mod r275287 : 2009-07-26 02:38:32 +0200 mod r274343 : #i#i103645#
2009-07-26 02:01:53 +0200 mod r274342 : #i103645#
2009-07-26 01:52:42 +0200 mod r274341 : #i103490#
2009-07-22 08:31:48 +0200 mod r274215 : #i103373#
2009-07-15 00:55:11 +0200 mod r273987 : #i101419#
2009-07-14 07:07:55 +0200 mod r273956 : #i101419#
2009-07-14 07:07:43 +0200 mod r273955 : #i101419#
2009-07-14 07:02:10 +0200 mod r273954 : changes from notes9
2009-07-14 06:14:25 +0200 mod r273953 : #i103476#
2009-09-11 kz CWS-TOOLING: integrate CWS ab70
2009-09-10 15:12:54 +0200 jsk r276034 : #i85434# - mandatory automatic update test
2009-09-10 15:11:06 +0200 jsk r276033 : #i85434# - mandatory automatic update test
2009-09-02 09:49:24 +0200 ab r275698 : #i85434# Dialog Import
2009-09-11 kz CWS-TOOLING: integrate CWS hb32bugs02
2009-09-02 Henning Brinkmann #i102420# revert changes
2009-08-26 Henning Brinkmann merged DEV300_m56
2009-08-19 Henning Brinkmann merged DEV300_m55
2009-08-14 Henning Brinkmann merged changes from wntmsci12
2009-08-12 Henning Brinkmann Implemented NoSpaceEdit constructor and destructor in .cxx to allow compile with debug on wntmsci12.
2009-08-12 Henning Brinkmann Added some SW_DLLPUBLIC to make compilable on wntmsci12.
2009-08-11 Henning Brinkmann #i102420# dbg_out: surround output for SwNodes with <nodes-array>.
2009-08-10 Henning Brinkmann #i102420# rewritten debug output for SwNodes.
2009-08-07 Henning Brinkmann #i102420# debug _MoveNodes: output the destination, too. Break after two iterations.
2009-08-07 Henning Brinkmann #i102420# _MoveNodes: Additionally check if destination index is inside source => false
Check if current range was already handled => loop
Debug output current range
2009-08-06 Henning Brinkmann merged DEV300_m54
2009-08-06 Henning Brinkmann added master fix
2009-08-06 Henning Brinkmann debug output for SwNodeRange
2009-08-04 Henning Brinkmann #i102844# robustness: check for NULL pointer to prevent crash
2009-08-03 Henning Brinkmann #i103475# applied patch and verified
2009-08-03 Henning Brinkmann Removed code preventing build of sw with DEBUG.
2009-09-11 convert-repo update tags
2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300
2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree.
2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23
2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite
2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix
2009-09-10 kz CWS-TOOLING: integrate CWS mh232
2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch
2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD
2009-08-26 03:11:20 +0200 mh r275383 : #i39230
2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field
2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name
2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl
2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam
2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613#
2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3
2009-09-10 kz CWS-TOOLING: integrate CWS tkr24
2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT
2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping>
2009-09-11 convert-repo update tags
2009-09-10 kz CWS-TOOLING: integrate CWS os2port06dev300
2009-09-05 22:49:00 +0200 ydario r275858 : #i99588# applied os2port06 diff to DEV300 tree.
2009-09-10 kz CWS-TOOLING: integrate CWS mingwport23
2009-08-29 07:07:53 +0200 tono r275555 : i#104522: mingw port graphite
2009-08-29 07:07:26 +0200 tono r275554 : i#104522: mingw port printf format fix
2009-09-10 kz CWS-TOOLING: integrate CWS mh232
2009-08-26 03:52:57 +0200 mh r275385 : #i102182# FreeBSD patch
2009-08-26 03:43:20 +0200 mh r275384 : #i101333# patch for FreeBSD
2009-08-26 03:11:20 +0200 mh r275383 : #i39230
2009-08-26 03:07:51 +0200 mh r275382 : #i39230# more space for initials field
2009-08-26 02:41:19 +0200 mh r275380 : #i39230# use vos::osecurity for reading the user name
2009-08-18 22:06:00 +0200 mh r275130 : #i104243#, line ending problem with newer perl
2009-08-18 21:53:21 +0200 mh r275129 : #i39230# read initials via getpwnam
2009-08-18 21:34:05 +0200 mh r275128 : enable CAIROCANVAS for Linux and Mac, #i88613#
2009-08-17 18:02:59 +0200 mh r275067 : #i95498# make compile with gcc3
2009-09-10 kz CWS-TOOLING: integrate CWS tkr24
2009-09-07 14:31:06 +0200 is r275898 : #160081# adding NO_LICENSE_INTO_COPYRIGHT
2009-09-10 releng #i10000# change KeyMapping to SingletonRef<framework::KeyMapping>
2009-09-11 14:29:45 +00:00
|
|
|
IDocumentContentOperations::INS_EMPTYEXPAND );
|
|
|
|
pTNd->InsertText( sTmp, aIdx,
|
|
|
|
IDocumentContentOperations::INS_EMPTYEXPAND );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const SfxItemSet* pAttrSet = pTNd->GetpSwAttrSet();
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// assign adjustment
|
2007-02-28 14:50:39 +00:00
|
|
|
if( bChgAlign && pAttrSet && SFX_ITEM_SET == pAttrSet->GetItemState(
|
2011-01-17 15:06:54 +01:00
|
|
|
RES_PARATR_ADJUST, sal_False, &pItem ) &&
|
2007-02-28 14:50:39 +00:00
|
|
|
SVX_ADJUST_RIGHT == ((SvxAdjustItem*)pItem)->GetAdjust() )
|
|
|
|
{
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->SetAttr( SvxAdjustItem( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ) );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// assign color or save "user color"
|
2007-02-28 14:50:39 +00:00
|
|
|
if( !pAttrSet || SFX_ITEM_SET != pAttrSet->
|
2011-01-17 15:06:54 +01:00
|
|
|
GetItemState( RES_CHRATR_COLOR, sal_False, &pItem ))
|
2007-02-28 14:50:39 +00:00
|
|
|
pItem = 0;
|
|
|
|
|
|
|
|
const Color* pOldNumFmtColor = rBox.GetSaveNumFmtColor();
|
|
|
|
const Color* pNewUserColor = pItem ? &((SvxColorItem*)pItem)->GetValue() : 0;
|
|
|
|
|
|
|
|
if( ( pNewUserColor && pOldNumFmtColor &&
|
|
|
|
*pNewUserColor == *pOldNumFmtColor ) ||
|
|
|
|
( !pNewUserColor && !pOldNumFmtColor ))
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Keep the user color, set updated values, delete old NumFmtColor if needed
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pCol )
|
2012-08-10 15:42:44 +02:00
|
|
|
// if needed, set the color
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->SetAttr( SvxColorItem( *pCol, RES_CHRATR_COLOR ));
|
2007-02-28 14:50:39 +00:00
|
|
|
else if( pItem )
|
|
|
|
{
|
|
|
|
pNewUserColor = rBox.GetSaveUserColor();
|
|
|
|
if( pNewUserColor )
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->SetAttr( SvxColorItem( *pNewUserColor, RES_CHRATR_COLOR ));
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->ResetAttr( RES_CHRATR_COLOR );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Save user color, set NumFormat color if needed, but never reset the color
|
2007-02-28 14:50:39 +00:00
|
|
|
rBox.SetSaveUserColor( pNewUserColor );
|
|
|
|
|
|
|
|
if( pCol )
|
2012-08-10 15:42:44 +02:00
|
|
|
// if needed, set the color
|
2008-06-13 09:13:23 +00:00
|
|
|
pTNd->SetAttr( SvxColorItem( *pCol, RES_CHRATR_COLOR ));
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
rBox.SetSaveNumFmtColor( pCol );
|
|
|
|
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// assign vertical orientation
|
2007-02-28 14:50:39 +00:00
|
|
|
if( bChgAlign &&
|
|
|
|
SFX_ITEM_SET == rBox.GetFrmFmt()->GetItemState(
|
2011-01-17 15:06:54 +01:00
|
|
|
RES_VERT_ORIENT, sal_False, &pItem ) &&
|
2007-09-27 08:11:01 +00:00
|
|
|
text::VertOrientation::BOTTOM == ((SwFmtVertOrient*)pItem)->GetVertOrient() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2008-06-13 09:13:23 +00:00
|
|
|
rBox.GetFrmFmt()->SetFmtAttr( SwFmtVertOrient( 0, text::VertOrientation::TOP ));
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// for detection of modifications (mainly TableBoxAttribute)
|
2010-12-17 09:02:23 +01:00
|
|
|
void SwTableBoxFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
if( !IsModifyLocked() && !IsInDocDTOR() )
|
|
|
|
{
|
|
|
|
const SwTblBoxNumFormat *pNewFmt = 0;
|
|
|
|
const SwTblBoxFormula *pNewFml = 0;
|
|
|
|
const SwTblBoxValue *pNewVal = 0;
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nOldFmt = NUMBERFORMAT_TEXT;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
switch( pNew ? pNew->Which() : 0 )
|
|
|
|
{
|
|
|
|
case RES_ATTRSET_CHG:
|
|
|
|
{
|
|
|
|
const SfxItemSet& rSet = *((SwAttrSetChg*)pNew)->GetChgSet();
|
|
|
|
if( SFX_ITEM_SET == rSet.GetItemState( RES_BOXATR_FORMAT,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_False, (const SfxPoolItem**)&pNewFmt ) )
|
2007-02-28 14:50:39 +00:00
|
|
|
nOldFmt = ((SwTblBoxNumFormat&)((SwAttrSetChg*)pOld)->
|
|
|
|
GetChgSet()->Get( RES_BOXATR_FORMAT )).GetValue();
|
2011-01-17 15:06:54 +01:00
|
|
|
rSet.GetItemState( RES_BOXATR_FORMULA, sal_False,
|
2007-02-28 14:50:39 +00:00
|
|
|
(const SfxPoolItem**)&pNewFml );
|
2011-05-11 17:31:00 +02:00
|
|
|
rSet.GetItemState( RES_BOXATR_VALUE, sal_False,
|
|
|
|
(const SfxPoolItem**)&pNewVal );
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RES_BOXATR_FORMAT:
|
|
|
|
pNewFmt = (SwTblBoxNumFormat*)pNew;
|
|
|
|
nOldFmt = ((SwTblBoxNumFormat*)pOld)->GetValue();
|
|
|
|
break;
|
|
|
|
case RES_BOXATR_FORMULA:
|
|
|
|
pNewFml = (SwTblBoxFormula*)pNew;
|
|
|
|
break;
|
|
|
|
case RES_BOXATR_VALUE:
|
|
|
|
pNewVal = (SwTblBoxValue*)pNew;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// something changed and some BoxAttribut remained in the set!
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pNewFmt || pNewFml || pNewVal )
|
|
|
|
{
|
|
|
|
GetDoc()->SetFieldsDirty(true, NULL, 0);
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
if( SFX_ITEM_SET == GetItemState( RES_BOXATR_FORMAT, sal_False ) ||
|
|
|
|
SFX_ITEM_SET == GetItemState( RES_BOXATR_VALUE, sal_False ) ||
|
|
|
|
SFX_ITEM_SET == GetItemState( RES_BOXATR_FORMULA, sal_False ) )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// fetch the box
|
2010-12-17 09:02:23 +01:00
|
|
|
SwIterator<SwTableBox,SwFmt> aIter( *this );
|
|
|
|
SwTableBox* pBox = aIter.First();
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pBox )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
OSL_ENSURE( !aIter.Next(), "zeor or more than one box at format" );
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNewFmt;
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pNewFmt )
|
|
|
|
{
|
|
|
|
nNewFmt = pNewFmt->GetValue();
|
2012-08-10 15:42:44 +02:00
|
|
|
// new formatting
|
|
|
|
// is it newer or has the current been removed?
|
2011-01-17 15:06:54 +01:00
|
|
|
if( SFX_ITEM_SET != GetItemState( RES_BOXATR_VALUE, sal_False ))
|
2007-02-28 14:50:39 +00:00
|
|
|
pNewFmt = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// fetch the current Item
|
2011-01-17 15:06:54 +01:00
|
|
|
GetItemState( RES_BOXATR_FORMAT, sal_False,
|
2007-02-28 14:50:39 +00:00
|
|
|
(const SfxPoolItem**)&pNewFmt );
|
|
|
|
nOldFmt = GetTblBoxNumFmt().GetValue();
|
|
|
|
nNewFmt = pNewFmt ? pNewFmt->GetValue() : nOldFmt;
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// is it newer or has the current been removed?
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pNewVal )
|
|
|
|
{
|
|
|
|
if( NUMBERFORMAT_TEXT != nNewFmt )
|
|
|
|
{
|
|
|
|
if( SFX_ITEM_SET == GetItemState(
|
2011-01-17 15:06:54 +01:00
|
|
|
RES_BOXATR_VALUE, sal_False ))
|
2007-02-28 14:50:39 +00:00
|
|
|
nOldFmt = NUMBERFORMAT_TEXT;
|
|
|
|
else
|
|
|
|
nNewFmt = NUMBERFORMAT_TEXT;
|
|
|
|
}
|
|
|
|
else if( NUMBERFORMAT_TEXT == nNewFmt )
|
|
|
|
nOldFmt = 0;
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// Logic:
|
|
|
|
// Value change: -> "simulate" a format change!
|
|
|
|
// Format change:
|
|
|
|
// Text -> !Text or format change:
|
|
|
|
// - align right for horizontal alignment, if LEFT or JUSTIFIED
|
|
|
|
// - align bottom for vertical alignment, if TOP is set, or default
|
|
|
|
// - replace text (color? negative numbers RED?)
|
2007-02-28 14:50:39 +00:00
|
|
|
// !Text -> Text:
|
2012-08-10 15:42:44 +02:00
|
|
|
// - align left for horizontal alignment, if RIGHT
|
|
|
|
// - align top for vertical alignment, if BOTTOM is set
|
2007-02-28 14:50:39 +00:00
|
|
|
SvNumberFormatter* pNumFmtr = GetDoc()->GetNumberFormatter();
|
2012-12-03 19:21:53 +09:00
|
|
|
bool bNewIsTxtFmt = pNumFmtr->IsTextFormat( nNewFmt ) ||
|
2007-02-28 14:50:39 +00:00
|
|
|
NUMBERFORMAT_TEXT == nNewFmt;
|
|
|
|
|
2010-09-30 18:34:49 +02:00
|
|
|
if( (!bNewIsTxtFmt && nOldFmt != nNewFmt) || pNewFml )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-12-03 19:21:53 +09:00
|
|
|
bool bChgTxt = true;
|
2007-02-28 14:50:39 +00:00
|
|
|
double fVal = 0;
|
|
|
|
if( !pNewVal && SFX_ITEM_SET != GetItemState(
|
2011-01-17 15:06:54 +01:00
|
|
|
RES_BOXATR_VALUE, sal_False, (const SfxPoolItem**)&pNewVal ))
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// so far, no value has been set, so try to evaluate the content
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNdPos = pBox->IsValidNumTxtNd( sal_True );
|
2007-02-28 14:50:39 +00:00
|
|
|
if( ULONG_MAX != nNdPos )
|
|
|
|
{
|
|
|
|
sal_uInt32 nTmpFmtIdx = nNewFmt;
|
2013-10-16 11:18:56 +02:00
|
|
|
OUString aTxt( GetDoc()->GetNodes()[ nNdPos ]
|
2007-02-28 14:50:39 +00:00
|
|
|
->GetTxtNode()->GetRedlineTxt());
|
2013-10-16 11:18:56 +02:00
|
|
|
if( aTxt.isEmpty() )
|
2012-12-03 19:21:53 +09:00
|
|
|
bChgTxt = false;
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// Keep Tabs
|
2007-02-28 14:50:39 +00:00
|
|
|
lcl_TabToBlankAtSttEnd( aTxt );
|
|
|
|
|
|
|
|
// JP 22.04.98: Bug 49659 -
|
2012-08-10 15:42:44 +02:00
|
|
|
// Special casing for percent
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bIsNumFmt = sal_False;
|
2007-02-28 14:50:39 +00:00
|
|
|
if( NUMBERFORMAT_PERCENT ==
|
|
|
|
pNumFmtr->GetType( nNewFmt ))
|
|
|
|
{
|
|
|
|
sal_uInt32 nTmpFmt = 0;
|
|
|
|
if( pNumFmtr->IsNumberFormat(
|
|
|
|
aTxt, nTmpFmt, fVal ))
|
|
|
|
{
|
|
|
|
if( NUMBERFORMAT_NUMBER ==
|
|
|
|
pNumFmtr->GetType( nTmpFmt ))
|
2013-10-16 11:18:56 +02:00
|
|
|
aTxt += "%";
|
2007-02-28 14:50:39 +00:00
|
|
|
|
|
|
|
bIsNumFmt = pNumFmtr->IsNumberFormat(
|
|
|
|
aTxt, nTmpFmtIdx, fVal );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bIsNumFmt = pNumFmtr->IsNumberFormat(
|
|
|
|
aTxt, nTmpFmtIdx, fVal );
|
|
|
|
|
|
|
|
if( bIsNumFmt )
|
|
|
|
{
|
2012-08-10 15:42:44 +02:00
|
|
|
// directly assign value - without Modify
|
2012-11-21 07:34:08 +09:00
|
|
|
bool bIsLockMod = IsModifyLocked();
|
2007-02-28 14:50:39 +00:00
|
|
|
LockModify();
|
2008-06-13 09:13:23 +00:00
|
|
|
SetFmtAttr( SwTblBoxValue( fVal ));
|
2007-02-28 14:50:39 +00:00
|
|
|
if( !bIsLockMod )
|
|
|
|
UnlockModify();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fVal = pNewVal->GetValue();
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// format contents with the new value assigned and write to paragraph
|
2007-02-28 14:50:39 +00:00
|
|
|
Color* pCol = 0;
|
2013-07-05 16:25:03 -05:00
|
|
|
OUString sNewTxt;
|
2007-02-28 14:50:39 +00:00
|
|
|
if( DBL_MAX == fVal )
|
2013-07-05 16:25:03 -05:00
|
|
|
{
|
2013-10-26 19:50:13 +02:00
|
|
|
sNewTxt = SwViewShell::GetShellRes()->aCalc_Error;
|
2013-07-05 16:25:03 -05:00
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pNumFmtr->GetOutputString( fVal, nNewFmt, sNewTxt, &pCol );
|
|
|
|
|
|
|
|
if( !bChgTxt )
|
2013-07-05 16:25:03 -05:00
|
|
|
{
|
|
|
|
sNewTxt = "";
|
|
|
|
}
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// across all boxes
|
2007-02-28 14:50:39 +00:00
|
|
|
ChgTextToNum( *pBox, sNewTxt, pCol,
|
|
|
|
GetDoc()->IsInsTblAlignNum() );
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( bNewIsTxtFmt && nOldFmt != nNewFmt )
|
|
|
|
{
|
|
|
|
ChgNumToText( *pBox, nNewFmt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-08-10 15:42:44 +02:00
|
|
|
// call base class
|
2007-02-28 14:50:39 +00:00
|
|
|
SwFrmFmt::Modify( pOld, pNew );
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwTableBox::HasNumCntnt( double& rNum, sal_uInt32& rFmtIndex,
|
|
|
|
sal_Bool& rIsEmptyTxtNd ) const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRet = sal_False;
|
|
|
|
sal_uLong nNdPos = IsValidNumTxtNd( sal_True );
|
2007-02-28 14:50:39 +00:00
|
|
|
if( ULONG_MAX != nNdPos )
|
|
|
|
{
|
2013-10-16 11:18:56 +02:00
|
|
|
OUString aTxt( pSttNd->GetNodes()[ nNdPos ]->GetTxtNode()->
|
2007-02-28 14:50:39 +00:00
|
|
|
GetRedlineTxt() );
|
2012-08-10 15:42:44 +02:00
|
|
|
// Keep Tabs
|
2007-02-28 14:50:39 +00:00
|
|
|
lcl_TabToBlankAtSttEnd( aTxt );
|
2013-10-16 11:18:56 +02:00
|
|
|
rIsEmptyTxtNd = aTxt.isEmpty();
|
2007-02-28 14:50:39 +00:00
|
|
|
SvNumberFormatter* pNumFmtr = GetFrmFmt()->GetDoc()->GetNumberFormatter();
|
|
|
|
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
if( SFX_ITEM_SET == GetFrmFmt()->GetItemState( RES_BOXATR_FORMAT,
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_False, &pItem ))
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
rFmtIndex = ((SwTblBoxNumFormat*)pItem)->GetValue();
|
2012-08-10 15:42:44 +02:00
|
|
|
// Special casing for percent
|
2007-02-28 14:50:39 +00:00
|
|
|
if( !rIsEmptyTxtNd &&
|
|
|
|
NUMBERFORMAT_PERCENT == pNumFmtr->GetType( rFmtIndex ))
|
|
|
|
{
|
|
|
|
sal_uInt32 nTmpFmt = 0;
|
|
|
|
if( pNumFmtr->IsNumberFormat( aTxt, nTmpFmt, rNum ) &&
|
|
|
|
NUMBERFORMAT_NUMBER == pNumFmtr->GetType( nTmpFmt ))
|
2013-10-16 11:18:56 +02:00
|
|
|
aTxt += "%";
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rFmtIndex = 0;
|
|
|
|
|
|
|
|
bRet = pNumFmtr->IsNumberFormat( aTxt, rFmtIndex, rNum );
|
|
|
|
}
|
|
|
|
else
|
2011-01-17 15:06:54 +01:00
|
|
|
rIsEmptyTxtNd = sal_False;
|
2007-02-28 14:50:39 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool SwTableBox::IsNumberChanged() const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_Bool bRet = sal_True;
|
2007-02-28 14:50:39 +00:00
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
if( SFX_ITEM_SET == GetFrmFmt()->GetItemState( RES_BOXATR_FORMULA, sal_False ))
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
const SwTblBoxNumFormat *pNumFmt;
|
|
|
|
const SwTblBoxValue *pValue;
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
if( SFX_ITEM_SET != GetFrmFmt()->GetItemState( RES_BOXATR_VALUE, sal_False,
|
2007-02-28 14:50:39 +00:00
|
|
|
(const SfxPoolItem**)&pValue ))
|
|
|
|
pValue = 0;
|
2011-01-17 15:06:54 +01:00
|
|
|
if( SFX_ITEM_SET != GetFrmFmt()->GetItemState( RES_BOXATR_FORMAT, sal_False,
|
2007-02-28 14:50:39 +00:00
|
|
|
(const SfxPoolItem**)&pNumFmt ))
|
|
|
|
pNumFmt = 0;
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nNdPos;
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pNumFmt && pValue &&
|
2011-01-17 15:06:54 +01:00
|
|
|
ULONG_MAX != ( nNdPos = IsValidNumTxtNd( sal_True ) ) )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2013-07-05 16:25:03 -05:00
|
|
|
OUString sNewTxt, sOldTxt( pSttNd->GetNodes()[ nNdPos ]->
|
2007-02-28 14:50:39 +00:00
|
|
|
GetTxtNode()->GetRedlineTxt() );
|
|
|
|
lcl_DelTabsAtSttEnd( sOldTxt );
|
|
|
|
|
|
|
|
Color* pCol = 0;
|
|
|
|
GetFrmFmt()->GetDoc()->GetNumberFormatter()->GetOutputString(
|
|
|
|
pValue->GetValue(), pNumFmt->GetValue(), sNewTxt, &pCol );
|
|
|
|
|
|
|
|
bRet = sNewTxt != sOldTxt ||
|
|
|
|
!( ( !pCol && !GetSaveNumFmtColor() ) ||
|
|
|
|
( pCol && GetSaveNumFmtColor() &&
|
|
|
|
*pCol == *GetSaveNumFmtColor() ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong SwTableBox::IsValidNumTxtNd( sal_Bool bCheckAttr ) const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nPos = ULONG_MAX;
|
2007-02-28 14:50:39 +00:00
|
|
|
if( pSttNd )
|
|
|
|
{
|
|
|
|
SwNodeIndex aIdx( *pSttNd );
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uLong nIndex = aIdx.GetIndex();
|
|
|
|
const sal_uLong nIndexEnd = pSttNd->GetNodes()[ nIndex ]->EndOfSectionIndex();
|
2007-07-18 13:28:19 +00:00
|
|
|
const SwTxtNode *pTextNode = 0;
|
|
|
|
while( ++nIndex < nIndexEnd )
|
|
|
|
{
|
|
|
|
const SwNode* pNode = pSttNd->GetNodes()[nIndex];
|
|
|
|
if( pNode->IsTableNode() )
|
2011-02-05 20:34:13 +01:00
|
|
|
{
|
2007-07-18 13:28:19 +00:00
|
|
|
pTextNode = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if( pNode->IsTxtNode() )
|
|
|
|
{
|
|
|
|
if( pTextNode )
|
2011-02-05 15:56:54 +01:00
|
|
|
{
|
2007-07-18 13:28:19 +00:00
|
|
|
pTextNode = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pTextNode = pNode->GetTxtNode();
|
|
|
|
nPos = nIndex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if( pTextNode )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
if( bCheckAttr )
|
|
|
|
{
|
2007-07-18 13:28:19 +00:00
|
|
|
const SwpHints* pHts = pTextNode->GetpSwpHints();
|
2012-08-10 15:42:44 +02:00
|
|
|
// do some tests if there's only text in the node!
|
|
|
|
// Flys/fields/...
|
2007-07-18 13:28:19 +00:00
|
|
|
if( pHts )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2013-12-16 23:39:58 +01:00
|
|
|
sal_Int32 nNextSetField = 0;
|
2011-01-17 15:06:54 +01:00
|
|
|
for( sal_uInt16 n = 0; n < pHts->Count(); ++n )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2007-07-18 13:28:19 +00:00
|
|
|
const SwTxtAttr* pAttr = (*pHts)[ n ];
|
2013-03-08 18:11:16 +01:00
|
|
|
if( RES_TXTATR_NOEND_BEGIN <= pAttr->Which() )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2013-12-19 18:50:58 +00:00
|
|
|
if ( (*pAttr->GetStart() == nNextSetField)
|
|
|
|
&& (pAttr->Which() == RES_TXTATR_FIELD))
|
2009-11-24 11:34:17 +01:00
|
|
|
{
|
2011-05-13 17:25:30 +02:00
|
|
|
// #i104949# hideous hack for report builder:
|
|
|
|
// it inserts hidden variable-set fields at
|
|
|
|
// the beginning of para in cell, but they
|
|
|
|
// should not turn cell into text cell
|
2013-09-24 15:03:38 +00:00
|
|
|
const SwField* pField = pAttr->GetFmtFld().GetField();
|
2011-05-13 17:25:30 +02:00
|
|
|
if (pField &&
|
|
|
|
(pField->GetTypeId() == TYP_SETFLD) &&
|
|
|
|
(0 != (static_cast<SwSetExpField const*>
|
|
|
|
(pField)->GetSubType() &
|
|
|
|
nsSwExtendedSubType::SUB_INVISIBLE)))
|
2009-11-24 11:34:17 +01:00
|
|
|
{
|
2011-05-13 17:25:30 +02:00
|
|
|
nNextSetField = *pAttr->GetStart() + 1;
|
2009-11-24 11:34:17 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2007-07-18 13:28:19 +00:00
|
|
|
nPos = ULONG_MAX;
|
|
|
|
break;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-07-18 13:28:19 +00:00
|
|
|
else
|
|
|
|
nPos = ULONG_MAX;
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
return nPos;
|
|
|
|
}
|
|
|
|
|
2012-08-10 15:42:44 +02:00
|
|
|
// is this a Formula box or one with numeric content (AutoSum)
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 SwTableBox::IsFormulaOrValueBox() const
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
sal_uInt16 nWhich = 0;
|
2007-02-28 14:50:39 +00:00
|
|
|
const SwTxtNode* pTNd;
|
|
|
|
SwFrmFmt* pFmt = GetFrmFmt();
|
2011-01-17 15:06:54 +01:00
|
|
|
if( SFX_ITEM_SET == pFmt->GetItemState( RES_BOXATR_FORMULA, sal_False ))
|
2007-02-28 14:50:39 +00:00
|
|
|
nWhich = RES_BOXATR_FORMULA;
|
2011-01-17 15:06:54 +01:00
|
|
|
else if( SFX_ITEM_SET == pFmt->GetItemState( RES_BOXATR_VALUE, sal_False ) &&
|
2007-02-28 14:50:39 +00:00
|
|
|
!pFmt->GetDoc()->GetNumberFormatter()->IsTextFormat(
|
|
|
|
pFmt->GetTblBoxNumFmt().GetValue() ))
|
|
|
|
nWhich = RES_BOXATR_VALUE;
|
|
|
|
else if( pSttNd && pSttNd->GetIndex() + 2 == pSttNd->EndOfSectionIndex()
|
|
|
|
&& 0 != ( pTNd = pSttNd->GetNodes()[ pSttNd->GetIndex() + 1 ]
|
2013-02-18 18:36:45 +01:00
|
|
|
->GetTxtNode() ) && pTNd->GetTxt().isEmpty())
|
2007-02-28 14:50:39 +00:00
|
|
|
nWhich = USHRT_MAX;
|
|
|
|
|
|
|
|
return nWhich;
|
|
|
|
}
|
|
|
|
|
2007-07-06 08:52:34 +00:00
|
|
|
void SwTableBox::ActualiseValueBox()
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
const SfxPoolItem *pFmtItem, *pValItem;
|
|
|
|
SwFrmFmt* pFmt = GetFrmFmt();
|
2011-01-17 15:06:54 +01:00
|
|
|
if( SFX_ITEM_SET == pFmt->GetItemState( RES_BOXATR_FORMAT, sal_True, &pFmtItem )
|
|
|
|
&& SFX_ITEM_SET == pFmt->GetItemState( RES_BOXATR_VALUE, sal_True, &pValItem ))
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
2011-01-17 15:06:54 +01:00
|
|
|
const sal_uLong nFmtId = ((SwTblBoxNumFormat*)pFmtItem)->GetValue();
|
|
|
|
sal_uLong nNdPos = ULONG_MAX;
|
2007-02-28 14:50:39 +00:00
|
|
|
SvNumberFormatter* pNumFmtr = pFmt->GetDoc()->GetNumberFormatter();
|
|
|
|
|
|
|
|
if( !pNumFmtr->IsTextFormat( nFmtId ) &&
|
2011-01-17 15:06:54 +01:00
|
|
|
ULONG_MAX != (nNdPos = IsValidNumTxtNd( sal_True )) )
|
2007-02-28 14:50:39 +00:00
|
|
|
{
|
|
|
|
double fVal = ((SwTblBoxValue*)pValItem)->GetValue();
|
|
|
|
Color* pCol = 0;
|
2013-07-05 16:25:03 -05:00
|
|
|
OUString sNewTxt;
|
2007-02-28 14:50:39 +00:00
|
|
|
pNumFmtr->GetOutputString( fVal, nFmtId, sNewTxt, &pCol );
|
|
|
|
|
2013-10-16 11:18:56 +02:00
|
|
|
const OUString& rTxt = pSttNd->GetNodes()[ nNdPos ]->GetTxtNode()->GetTxt();
|
2007-02-28 14:50:39 +00:00
|
|
|
if( rTxt != sNewTxt )
|
2011-01-17 15:06:54 +01:00
|
|
|
ChgTextToNum( *this, sNewTxt, pCol, sal_False ,nNdPos);
|
2007-02-28 14:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTableBox_Impl::SetNewCol( Color** ppCol, const Color* pNewCol )
|
|
|
|
{
|
|
|
|
if( *ppCol != pNewCol )
|
|
|
|
{
|
|
|
|
delete *ppCol;
|
|
|
|
if( pNewCol )
|
|
|
|
*ppCol = new Color( *pNewCol );
|
|
|
|
else
|
|
|
|
*ppCol = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-30 11:12:34 +02:00
|
|
|
struct SwTableCellInfo::Impl
|
|
|
|
{
|
|
|
|
const SwTable * m_pTable;
|
|
|
|
const SwCellFrm * m_pCellFrm;
|
|
|
|
const SwTabFrm * m_pTabFrm;
|
|
|
|
typedef ::std::set<const SwTableBox *> TableBoxes_t;
|
|
|
|
TableBoxes_t m_HandledTableBoxes;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Impl()
|
|
|
|
: m_pTable(NULL), m_pCellFrm(NULL), m_pTabFrm(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~Impl() {}
|
|
|
|
|
|
|
|
void setTable(const SwTable * pTable) {
|
|
|
|
m_pTable = pTable;
|
|
|
|
SwFrmFmt * pFrmFmt = m_pTable->GetFrmFmt();
|
2010-12-17 09:02:23 +01:00
|
|
|
m_pTabFrm = SwIterator<SwTabFrm,SwFmt>::FirstElement(*pFrmFmt);
|
2010-04-30 11:12:34 +02:00
|
|
|
if (m_pTabFrm->IsFollow())
|
|
|
|
m_pTabFrm = m_pTabFrm->FindMaster(true);
|
|
|
|
}
|
|
|
|
const SwTable * getTable() const { return m_pTable; }
|
|
|
|
|
|
|
|
const SwCellFrm * getCellFrm() const { return m_pCellFrm; }
|
|
|
|
|
|
|
|
const SwFrm * getNextFrmInTable(const SwFrm * pFrm);
|
|
|
|
const SwCellFrm * getNextCellFrm(const SwFrm * pFrm);
|
|
|
|
const SwCellFrm * getNextTableBoxsCellFrm(const SwFrm * pFrm);
|
|
|
|
bool getNext();
|
|
|
|
};
|
|
|
|
|
|
|
|
const SwFrm * SwTableCellInfo::Impl::getNextFrmInTable(const SwFrm * pFrm)
|
|
|
|
{
|
|
|
|
const SwFrm * pResult = NULL;
|
|
|
|
|
|
|
|
if (((! pFrm->IsTabFrm()) || pFrm == m_pTabFrm) && pFrm->GetLower())
|
|
|
|
pResult = pFrm->GetLower();
|
|
|
|
else if (pFrm->GetNext())
|
|
|
|
pResult = pFrm->GetNext();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (pFrm->GetUpper() != NULL)
|
|
|
|
{
|
|
|
|
pFrm = pFrm->GetUpper();
|
|
|
|
|
|
|
|
if (pFrm->IsTabFrm())
|
|
|
|
{
|
|
|
|
m_pTabFrm = static_cast<const SwTabFrm *>(pFrm)->GetFollow();
|
|
|
|
pResult = m_pTabFrm;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (pFrm->GetNext())
|
|
|
|
{
|
|
|
|
pResult = pFrm->GetNext();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwCellFrm * SwTableCellInfo::Impl::getNextCellFrm(const SwFrm * pFrm)
|
|
|
|
{
|
|
|
|
const SwCellFrm * pResult = NULL;
|
|
|
|
|
|
|
|
while ((pFrm = getNextFrmInTable(pFrm)) != NULL)
|
|
|
|
{
|
|
|
|
if (pFrm->IsCellFrm())
|
|
|
|
{
|
|
|
|
pResult = static_cast<const SwCellFrm *>(pFrm);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwCellFrm * SwTableCellInfo::Impl::getNextTableBoxsCellFrm(const SwFrm * pFrm)
|
|
|
|
{
|
|
|
|
const SwCellFrm * pResult = NULL;
|
|
|
|
|
|
|
|
while ((pFrm = getNextCellFrm(pFrm)) != NULL)
|
|
|
|
{
|
|
|
|
const SwCellFrm * pCellFrm = static_cast<const SwCellFrm *>(pFrm);
|
|
|
|
const SwTableBox * pTabBox = pCellFrm->GetTabBox();
|
|
|
|
TableBoxes_t::const_iterator aIt = m_HandledTableBoxes.find(pTabBox);
|
|
|
|
|
|
|
|
if (aIt == m_HandledTableBoxes.end())
|
|
|
|
{
|
|
|
|
pResult = pCellFrm;
|
|
|
|
m_HandledTableBoxes.insert(pTabBox);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwCellFrm * SwTableCellInfo::getCellFrm() const
|
|
|
|
{
|
|
|
|
return m_pImpl->getCellFrm();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SwTableCellInfo::Impl::getNext()
|
|
|
|
{
|
|
|
|
if (m_pCellFrm == NULL)
|
|
|
|
{
|
|
|
|
if (m_pTabFrm != NULL)
|
|
|
|
m_pCellFrm = Impl::getNextTableBoxsCellFrm(m_pTabFrm);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_pCellFrm = Impl::getNextTableBoxsCellFrm(m_pCellFrm);
|
|
|
|
|
|
|
|
return m_pCellFrm != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwTableCellInfo::SwTableCellInfo(const SwTable * pTable)
|
|
|
|
{
|
|
|
|
m_pImpl.reset(new Impl());
|
|
|
|
m_pImpl->setTable(pTable);
|
|
|
|
}
|
|
|
|
|
|
|
|
SwTableCellInfo::~SwTableCellInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SwTableCellInfo::getNext()
|
|
|
|
{
|
|
|
|
return m_pImpl->getNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
SwRect SwTableCellInfo::getRect() const
|
|
|
|
{
|
|
|
|
SwRect aRet;
|
|
|
|
|
|
|
|
if (getCellFrm() != NULL)
|
|
|
|
aRet = getCellFrm()->Frm();
|
|
|
|
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SwTableBox * SwTableCellInfo::getTableBox() const
|
|
|
|
{
|
|
|
|
const SwTableBox * pRet = NULL;
|
|
|
|
|
|
|
|
if (getCellFrm() != NULL)
|
|
|
|
pRet = getCellFrm()->GetTabBox();
|
|
|
|
|
|
|
|
return pRet;
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
void SwTable::RegisterToFormat( SwFmt& rFmt )
|
|
|
|
{
|
|
|
|
rFmt.Add( this );
|
|
|
|
}
|
|
|
|
|
2012-03-21 17:15:06 +01:00
|
|
|
bool SwTable::HasLayout() const
|
|
|
|
{
|
|
|
|
const SwFrmFmt* pFrmFmt = GetFrmFmt();
|
|
|
|
//a table in a clipboard document doesn't have any layout information
|
|
|
|
return pFrmFmt && SwIterator<SwTabFrm,SwFmt>::FirstElement(*pFrmFmt);
|
|
|
|
}
|
|
|
|
|
2010-12-17 09:02:23 +01:00
|
|
|
void SwTableLine::RegisterToFormat( SwFmt& rFmt )
|
|
|
|
{
|
|
|
|
rFmt.Add( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwTableBox::RegisterToFormat( SwFmt& rFmt )
|
|
|
|
{
|
|
|
|
rFmt.Add( this );
|
|
|
|
}
|
|
|
|
|
2012-06-18 18:04:44 +02:00
|
|
|
// free's any remaining child objects
|
|
|
|
SwTableLines::~SwTableLines()
|
|
|
|
{
|
|
|
|
for ( const_iterator it = begin(); it != end(); ++it )
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
|
2011-03-30 06:18:21 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|