summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorFlorian Reuter <freuter@novell.com>2010-09-14 14:40:15 +0200
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2010-09-14 14:40:15 +0200
commit56b2cf0c10d9caa01ebae1d80465e342d046a85c (patch)
tree616bfd5abdceeb821d589a926fb39d44d537db83 /sw
parentde0866b507e259f1726d1015293aad8fcadd763a (diff)
sw-collapse-empty-table-par-like-html.diff:
n#376690
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/IDocumentSettingAccess.hxx1
-rw-r--r--sw/inc/doc.hxx1
-rw-r--r--sw/inc/ndtxt.hxx2
-rw-r--r--sw/source/core/crsr/callnk.cxx50
-rw-r--r--sw/source/core/doc/doc.cxx4
-rw-r--r--sw/source/core/doc/docnew.cxx1
-rw-r--r--sw/source/core/inc/frame.hxx4
-rw-r--r--sw/source/core/layout/calcmove.cxx43
-rw-r--r--sw/source/core/layout/findfrm.cxx9
-rw-r--r--sw/source/core/text/frmpaint.cxx34
-rw-r--r--sw/source/core/text/porrst.cxx16
-rw-r--r--sw/source/filter/ww8/ww8par.cxx1
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx14
-rw-r--r--sw/source/ui/uno/SwXDocumentSettings.cxx16
14 files changed, 166 insertions, 30 deletions
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 32e6551a8f76..3bd68f869097 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -82,6 +82,7 @@ namespace com { namespace sun { namespace star { namespace i18n { struct Forbidd
TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST,
// <--
INVERT_BORDER_SPACING,
+ COLLAPSE_EMPTY_CELL_PARA,
// COMPATIBILITY FLAGS END
BROWSE_MODE,
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index bc4bc86ef12b..d8d4199d9092 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -604,6 +604,7 @@ private:
bool mbTabRelativeToIndent : 1; // #i24363# tab stops relative to indent
bool mbProtectForm : 1;
bool mbInvertBorderSpacing : 1;
+ bool mbCollapseEmptyCellPara : 1;
bool mbTabAtLeftIndentForParagraphsInList; // OD 2008-06-05 #i89181# - see above
// #i78591#
diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 53168d5a9cb4..811e445e7d0f 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -856,6 +856,8 @@ public:
virtual ::com::sun::star::uno::Reference<
::com::sun::star::rdf::XMetadatable > MakeUnoObject();
+ bool IsCollapse() const;
+
DECL_FIXEDMEMPOOL_NEWDEL(SwTxtNode)
};
diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx
index bf06a19d83b0..276b8779e01a 100644
--- a/sw/source/core/crsr/callnk.cxx
+++ b/sw/source/core/crsr/callnk.cxx
@@ -43,10 +43,15 @@
#include <doc.hxx>
#include <frmfmt.hxx>
#include <txtfrm.hxx>
+#include <tabfrm.hxx>
+#include <rowfrm.hxx>
+#include <fmtfsize.hxx>
#include <ndtxt.hxx>
#include <flyfrm.hxx>
#include <breakit.hxx>
+#include<vcl/window.hxx>
+
SwCallLink::SwCallLink( SwCrsrShell & rSh, ULONG nAktNode, xub_StrLen nAktCntnt,
BYTE nAktNdTyp, long nLRPos, bool bAktSelection )
@@ -97,6 +102,51 @@ SwCallLink::~SwCallLink()
if( !pCNd )
return;
+ bool bUpdatedTable = false;
+ SwFrm *myFrm=pCNd->GetFrm();
+ if (myFrm!=NULL)
+ {
+ // We need to emulated a change of the row height in order
+ // to have the complete row redrawn
+ SwRowFrm* pRow = myFrm->FindRowFrm( );
+ if ( pRow )
+ {
+ const SwTableLine* pLine = pRow->GetTabLine( );
+ SwFmtFrmSize pSize = pLine->GetFrmFmt( )->GetFrmSize( );
+ pRow->Modify( NULL, &pSize );
+
+ bUpdatedTable = true;
+ }
+ }
+
+ const SwDoc *pDoc=rShell.GetDoc();
+ const SwCntntNode *pNode = NULL;
+ if ( ( pDoc != NULL && nNode < pDoc->GetNodes( ).Count( ) ) )
+ {
+ pNode = pDoc->GetNodes()[nNode]->GetCntntNode();
+ }
+ if ( pNode != NULL )
+ {
+ SwFrm *myFrm2=pNode->GetFrm();
+ if (myFrm2!=NULL)
+ {
+ // We need to emulated a change of the row height in order
+ // to have the complete row redrawn
+ SwRowFrm* pRow = myFrm2->FindRowFrm();
+ if ( pRow )
+ {
+ const SwTableLine* pLine = pRow->GetTabLine( );
+ SwFmtFrmSize pSize = pLine->GetFrmFmt( )->GetFrmSize( );
+ pRow->Modify( NULL, &pSize );
+
+ bUpdatedTable = true;
+ }
+ }
+ }
+
+ if ( bUpdatedTable )
+ rShell.GetWin( )->Invalidate( 0 );
+
xub_StrLen nCmp, nAktCntnt = pCurCrsr->GetPoint()->nContent.GetIndex();
USHORT nNdWhich = pCNd->GetNodeType();
ULONG nAktNode = pCurCrsr->GetPoint()->nNode.GetIndex();
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 64c73c59d7b9..934909ebfd8a 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -198,6 +198,7 @@ bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: return mbTabAtLeftIndentForParagraphsInList;
// <--
case INVERT_BORDER_SPACING: return mbInvertBorderSpacing;
+ case COLLAPSE_EMPTY_CELL_PARA: return mbCollapseEmptyCellPara;
// COMPATIBILITY FLAGS END
case BROWSE_MODE: return mbBrowseMode;
@@ -324,6 +325,9 @@ void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
case INVERT_BORDER_SPACING:
mbInvertBorderSpacing = value;
break;
+ case COLLAPSE_EMPTY_CELL_PARA:
+ mbCollapseEmptyCellPara = value;
+ break;
// COMPATIBILITY FLAGS END
case BROWSE_MODE:
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 8e3a2f5d4fdc..78ee26f4c3b1 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -384,6 +384,7 @@ SwDoc::SwDoc() :
mbTabAtLeftIndentForParagraphsInList = false; // hidden
// <--
mbInvertBorderSpacing = false; // hidden
+ mbCollapseEmptyCellPara = true; // hidden
//
// COMPATIBILITY FLAGS END
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index e1560a230d7a..1cb7666ea850 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -624,6 +624,7 @@ public:
SwRootFrm *FindRootFrm();
SwPageFrm *FindPageFrm();
SwFrm *FindColFrm();
+ SwRowFrm *FindRowFrm();
SwFtnBossFrm *FindFtnBossFrm( BOOL bFootnotes = FALSE );
SwTabFrm *ImplFindTabFrm();
SwFtnFrm *ImplFindFtnFrm();
@@ -910,6 +911,9 @@ public:
// FME 2007-08-30 #i81146# new loop control
void ValidateThisAndAllLowers( const USHORT nStage );
+
+public:
+ bool IsCollapse() const;
};
inline BOOL SwFrm::IsInDocBody() const
diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx
index 28287c957ad1..377c58f329f4 100644
--- a/sw/source/core/layout/calcmove.cxx
+++ b/sw/source/core/layout/calcmove.cxx
@@ -63,6 +63,8 @@
#include <flyfrms.hxx>
// <--
+#include <ndtxt.hxx>
+
//------------------------------------------------------------------------
// Move-Methoden
//------------------------------------------------------------------------
@@ -952,6 +954,42 @@ void SwLayoutFrm::MakeAll()
|* Letzte Aenderung MA 03. Mar. 96
|*
|*************************************************************************/
+bool SwTxtNode::IsCollapse() const
+{
+ if ( GetDoc()->get( IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA ) && GetTxt().Len()==0 ) {
+ ULONG nIdx=GetIndex();
+ const SwEndNode *pNdBefore=GetNodes()[nIdx-1]->GetEndNode();
+ const SwEndNode *pNdAfter=GetNodes()[nIdx+1]->GetEndNode();
+
+ // The paragraph is collapsed only if the NdAfter is the end of a cell
+ bool bInTable = this->FindTableNode( ) != NULL;
+
+ SwSortedObjs* pObjs = this->GetFrm()->GetDrawObjs( );
+ sal_uInt32 nObjs = ( pObjs != NULL ) ? pObjs->Count( ) : 0;
+
+ if ( pNdBefore!=NULL && pNdAfter!=NULL && nObjs == 0 && bInTable ) {
+ return true;
+ } else {
+ return false;
+ }
+ } else
+ return false;
+}
+
+bool SwFrm::IsCollapse() const
+{
+ if (IsTxtFrm()) {
+ const SwTxtFrm *pTxtFrm=(SwTxtFrm*)this;
+ const SwTxtNode *pTxtNode=pTxtFrm->GetTxtNode();
+ if (pTxtNode && pTxtNode->IsCollapse()) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+}
BOOL SwCntntFrm::MakePrtArea( const SwBorderAttrs &rAttrs )
{
@@ -1054,6 +1092,11 @@ BOOL SwCntntFrm::MakePrtArea( const SwBorderAttrs &rAttrs )
// OD 2004-03-02 #106629# - use new method <CalcLowerSpace(..)>
SwTwips nLower = CalcLowerSpace( &rAttrs );
+ if (IsCollapse()) {
+ ViewShell *pSh = GetShell();
+ nUpper=0;
+ nLower=0;
+ }
// // in balanced columned section frames we do not want the
// // common border
// sal_Bool bCommonBorder = sal_True;
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index 8a1e8fe9ea7a..a41d48bf1000 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -596,6 +596,15 @@ SwFrm *SwFrm::FindColFrm()
return pFrm;
}
+SwRowFrm *SwFrm::FindRowFrm()
+{
+ SwFrm *pFrm = this;
+ do
+ { pFrm = pFrm->GetUpper();
+ } while ( pFrm && !pFrm->IsRowFrm() );
+ return dynamic_cast< SwRowFrm* >( pFrm );
+}
+
SwFrm* SwFrm::FindFooterOrHeader()
{
SwFrm* pRet = this;
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index 443900e1942c..bbb2f28ad173 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -566,21 +566,25 @@ sal_Bool SwTxtFrm::PaintEmpty( const SwRect &rRect, sal_Bool bCheck ) const
}
}
- const XubString aTmp( CH_PAR );
- SwDrawTextInfo aDrawInf( pSh, *pSh->GetOut(), 0, aTmp, 0, 1 );
- aDrawInf.SetLeft( rRect.Left() );
- aDrawInf.SetRight( rRect.Right() );
- aDrawInf.SetPos( aPos );
- aDrawInf.SetSpace( 0 );
- aDrawInf.SetKanaComp( 0 );
- aDrawInf.SetWrong( NULL );
- aDrawInf.SetGrammarCheck( NULL );
- aDrawInf.SetSmartTags( NULL ); // SMARTTAGS
- aDrawInf.SetFrm( this );
- aDrawInf.SetFont( pFnt );
- aDrawInf.SetSnapToGrid( sal_False );
-
- pFnt->_DrawText( aDrawInf );
+ // Don't show the paragraph mark for collapsed paragraphs, when they are hidden
+ if ( EmptyHeight( ) > 1 )
+ {
+ const XubString aTmp( CH_PAR );
+ SwDrawTextInfo aDrawInf( pSh, *pSh->GetOut(), 0, aTmp, 0, 1 );
+ aDrawInf.SetLeft( rRect.Left() );
+ aDrawInf.SetRight( rRect.Right() );
+ aDrawInf.SetPos( aPos );
+ aDrawInf.SetSpace( 0 );
+ aDrawInf.SetKanaComp( 0 );
+ aDrawInf.SetWrong( NULL );
+ aDrawInf.SetGrammarCheck( NULL );
+ aDrawInf.SetSmartTags( NULL ); // SMARTTAGS
+ aDrawInf.SetFrm( this );
+ aDrawInf.SetFont( pFnt );
+ aDrawInf.SetSnapToGrid( sal_False );
+
+ pFnt->_DrawText( aDrawInf );
+ }
delete pClip;
}
delete pFnt;
diff --git a/sw/source/core/text/porrst.cxx b/sw/source/core/text/porrst.cxx
index 3bc8e566b335..be85b282eb5d 100644
--- a/sw/source/core/text/porrst.cxx
+++ b/sw/source/core/text/porrst.cxx
@@ -58,6 +58,8 @@
#include <IDocumentSettingAccess.hxx>
#include <IDocumentDeviceAccess.hxx>
+#include <crsrsh.hxx>
+
/*************************************************************************
* class SwTmpEndPortion
*************************************************************************/
@@ -228,6 +230,20 @@ SwLinePortion *SwArrowPortion::Compress() { return this; }
SwTwips SwTxtFrm::EmptyHeight() const
{
+ if (IsCollapse()) {
+ ViewShell *pSh = GetShell();
+ if ( pSh->IsA( TYPE(SwCrsrShell) ) ) {
+ SwCrsrShell *pCrSh=(SwCrsrShell*)pSh;
+ SwCntntFrm *pCurrFrm=pCrSh->GetCurrFrm();
+ if (pCurrFrm==(SwCntntFrm*)this) {
+ // do nothing
+ } else {
+ return 1;
+ }
+ } else {
+ return 1;
+ }
+ }
ASSERT( ! IsVertical() || ! IsSwapped(),"SwTxtFrm::EmptyHeight with swapped frame" );
SwFont *pFnt;
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index a8099b970aa9..c8f64fb32701 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1395,6 +1395,7 @@ void SwWW8ImplReader::ImportDop()
// <--
rDoc.set(IDocumentSettingAccess::INVERT_BORDER_SPACING, true);
+ rDoc.set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, true);
//
// COMPATIBILITY FLAGS END
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index f24d29f2269d..6596e64acd68 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -3639,22 +3639,8 @@ bool lcl_PamContainsFly(SwPaM & rPam)
void SwWW8ImplReader::TabCellEnd()
{
if (nInTable && pTableDesc)
- {
pTableDesc->TableCellEnd();
- if (bReadTable
- && pWFlyPara == NULL
- && mpTableEndPaM.get() != NULL
- && (! SwPaM::Overlap(*pPaM, *mpTableEndPaM))
- && SwPaM::LessThan(*mpTableEndPaM, *pPaM)
- && mpTableEndPaM->GetPoint()->nNode.GetNode().IsTxtNode()
- && !lcl_PamContainsFly(*mpTableEndPaM)
- )
- {
- rDoc.DelFullPara(*mpTableEndPaM);
- }
- }
-
bFirstPara = true; // We have come to the end of a cell so FirstPara flag
bReadTable = false;
mpTableEndPaM.reset();
diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx
index 2804a122384a..a58090aaf7ab 100644
--- a/sw/source/ui/uno/SwXDocumentSettings.cxx
+++ b/sw/source/ui/uno/SwXDocumentSettings.cxx
@@ -125,7 +125,8 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST,
// <--
HANDLE_MODIFYPASSWORDINFO,
- HANDLE_INVERT_BORDER_SPACING
+ HANDLE_INVERT_BORDER_SPACING,
+ HANDLE_COLLAPSE_EMPTY_CELL_PARA
};
MasterPropertySetInfo * lcl_createSettingsInfo()
@@ -181,6 +182,7 @@ MasterPropertySetInfo * lcl_createSettingsInfo()
{ RTL_CONSTASCII_STRINGPARAM("TabAtLeftIndentForParagraphsInList"), HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, CPPUTYPE_BOOLEAN, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("ModifyPasswordInfo"), HANDLE_MODIFYPASSWORDINFO, CPPUTYPE_PROPERTYVALUE, 0, 0},
{ RTL_CONSTASCII_STRINGPARAM("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, CPPUTYPE_BOOLEAN, 0, 0},
/*
* As OS said, we don't have a view when we need to set this, so I have to
* find another solution before adding them to this property set - MTG
@@ -695,6 +697,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
mpDoc->set(IDocumentSettingAccess::INVERT_BORDER_SPACING, bTmp);
}
break;
+ case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, bTmp);
+ }
+ break;
default:
throw UnknownPropertyException();
}
@@ -1033,6 +1041,12 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
rValue.setValue( &bTmp, ::getBooleanCppuType() );
}
break;
+ case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
default:
throw UnknownPropertyException();
}