summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-03-02 09:33:10 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-03-02 09:33:10 +0100
commitfa38d91786a5ec9504cf310748eda364c2427f88 (patch)
tree7e755bd334168078c877ca91a76cf1be9d27a3da
parentinitial work for stubbed sw (diff)
downloadcore-feature/stub_writer.tar.gz
core-feature/stub_writer.zip
some more work on stubbing SwDoc feature/stub_writer
it compiles and links but executing filters-test will crash due to a problem with a SfxPoolItem
-rw-r--r--sw/Library_sw.mk16
-rw-r--r--sw/Module_sw.mk2
-rw-r--r--sw/inc/doc.hxx14
-rw-r--r--sw/source/core/doc/doc.cxx392
-rw-r--r--sw/source/core/doc/docnew.cxx1033
-rw-r--r--sw/source/core/doc/docredln.cxx1906
-rw-r--r--sw/source/core/doc/docruby.cxx274
-rw-r--r--sw/source/core/doc/docsort.cxx306
-rw-r--r--sw/source/core/doc/doctxm.cxx575
-rw-r--r--sw/source/core/docnode/ndtbl.cxx1687
-rw-r--r--sw/source/core/docnode/ndtbl1.cxx1038
-rw-r--r--sw/source/core/undo/undraw.cxx24
12 files changed, 274 insertions, 6993 deletions
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 36b2cc9eb7c6..9d9944e73c0a 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -161,12 +161,28 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
sw/source/core/doc/acmplwrd \
sw/source/core/doc/dbgoutsw \
sw/source/core/doc/doc \
+ sw/source/core/doc/docruby \
+ sw/source/core/doc/docsort \
+ sw/source/core/doc/docnew \
+ sw/source/core/doc/extinput \
+ sw/source/core/doc/docstat \
+ sw/source/core/doc/doccorr \
+ sw/source/core/doc/docedt \
+ sw/source/core/doc/docchart \
+ sw/source/core/doc/docftn \
+ sw/source/core/doc/docfmt \
+ sw/source/core/doc/docfld \
+ sw/source/core/doc/poolfmt \
+ sw/source/core/doc/doctxm \
+ sw/source/core/doc/docbm \
sw/source/core/doc/docdraw \
+ sw/source/core/doc/docredln \
sw/source/core/doc/fmtcol \
sw/source/core/doc/ftnidx \
sw/source/core/doc/gctable \
sw/source/core/doc/htmltbl \
sw/source/core/doc/list \
+ sw/source/core/doc/lineinfo \
sw/source/core/doc/notxtfrm \
sw/source/core/doc/number \
sw/source/core/doc/sortopt \
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index d9477e951d91..28a6e369286e 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -49,8 +49,6 @@ endif
$(eval $(call gb_Module_add_check_targets,sw,\
CppunitTest_sw_filters_test \
- CppunitTest_sw_macros_test \
- CppunitTest_sw_swdoc_test \
))
$(eval $(call gb_Module_add_slowcheck_targets,sw,\
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index cbf30ad11264..00dde58a48e3 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -243,12 +243,15 @@ class SW_DLLPUBLIC SwDoc : public IInterface ,
public IDocumentExternalData {
private:
SwDoc(const SwDoc & arg1);
+ sal_Int32 mReferenceCount;
public:
SwDoc();
- ~SwDoc();
+ virtual ~SwDoc();
static SwAutoCompleteWord *pACmpltWords;
+ virtual bool InsertString(const SwPaM &rRg, const String&,
+ const enum InsertFlags nInsertMode = INS_EMPTYEXPAND );
virtual bool IsInDtor() const;
virtual SwNodes & GetNodes();
virtual SwNodes const & GetNodes() const;
@@ -350,7 +353,7 @@ public:
virtual bool IsNewFldLst() const;
virtual void SetNewFldLst(bool bFlag);
virtual void InsDelFldInFldLst(bool bIns, const SwTxtFld & rFld);
- virtual SwField * GetField(const SwPosition & rPos);
+ static SwField * GetField(const SwPosition & rPos);
static SwTxtFld * GetTxtFld(const SwPosition & rPos);
virtual bool CopyRange(SwPaM & arg1, SwPosition & arg2, const bool bCopyAll) const;
virtual void DeleteSection(SwNode * pNode);
@@ -843,8 +846,15 @@ public:
virtual SfxObjectShell * CreateCopy(bool bCallInitNew) const;
virtual void dumpAsXml(xmlTextWriterPtr writer= NULL);
virtual void SetDrawDefaults();
+
+ DECL_LINK( AddDrawUndo, SdrUndoAction * );
+ DECL_STATIC_LINK( SwDoc, BackgroundDone, SvxBrushItem *);
+ DECL_LINK(CalcFieldValueHdl, EditFieldInfo*);
};
+// This method is called in Dtor of SwDoc and deletes cache of ContourObjects.
+void ClrContourCache();
+
// namespace <docfunc> for functions and procedures working on a Writer document.
namespace docfunc
{
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 9f663e8d93d5..c0510daf3890 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1,8 +1,54 @@
#include <doc.hxx>
#include <iostream>
+#include "UndoManager.hxx"
+#include "fmtmeta.hxx"
+#include "printdata.hxx"
+#include "docary.hxx"
+#include "docfld.hxx"
+#include "lineinfo.hxx"
+#include "docstat.hxx"
+#include "ftninfo.hxx"
+#include "tox.hxx"
+#include "pagedesc.hxx"
+#include "frmfmt.hxx"
+#include "ftnidx.hxx"
+#include "unochart.hxx"
+#include "istyleaccess.hxx"
+#include "fmtcntnt.hxx"
+#include "swstylemanager.hxx"
+#include "fmtfld.hxx"
+#include "switerator.hxx"
+#include "fldbas.hxx"
+#include "txtfld.hxx"
+#include "ndtxt.hxx"
+#include "docufld.hxx"
+#include <editeng/forbiddencharacterstable.hxx>
+#include <sfx2/Metadatable.hxx>
+#include <sfx2/linkmgr.hxx>
+
+
+
+// Page descriptors
+SV_IMPL_PTRARR(SwPageDescs,SwPageDescPtr);
+// Table Of ...
+SV_IMPL_PTRARR( SwTOXTypes, SwTOXTypePtr )
+// Field types
+SV_IMPL_PTRARR( SwFldTypes, SwFldTypePtr)
+
+
using namespace std;
+SwDoc::SwDoc()
+{
+ cout << "Constructor" << std::endl;
+}
+
+SwDoc::~SwDoc()
+{
+
+}
+
bool SwDoc::IsInDtor() const{
bool out = false;
cout << "IsInDtor(";
@@ -22,7 +68,7 @@ SwNodes & SwDoc::GetNodes(){
}
SwNodes const & SwDoc::GetNodes() const{
- SwNodes const out(this);
+ SwNodes out(const_cast<SwDoc*>(this));
cout << "GetNodes(";
cout << ") -> ";
cout << "type: \"SwNodes\"";
@@ -31,21 +77,11 @@ SwNodes const & SwDoc::GetNodes() const{
}
sal_Int32 SwDoc::acquire(){
- sal_Int32 out = 0;
- cout << "acquire(";
- cout << ") -> ";
- cout << out;
- cout << "\n";
- return out;
+ return osl_incrementInterlockedCount(&mReferenceCount);
}
sal_Int32 SwDoc::release(){
- sal_Int32 out = 0;
- cout << "release(";
- cout << ") -> ";
- cout << out;
- cout << "\n";
- return out;
+ return osl_decrementInterlockedCount(&mReferenceCount);
}
sal_Int32 SwDoc::getReferenceCount() const{
@@ -258,13 +294,15 @@ void SwDoc::setVirtualDevice(VirtualDevice * pVd, bool bDeleteOld, bool bCallVir
}
OutputDevice * SwDoc::getReferenceDevice(bool bCreate) const{
- OutputDevice * out = 0;
- cout << "getReferenceDevice(";
- cout << bCreate;
- cout << ") -> ";
- cout << out;
- cout << "\n";
- return out;
+ VirtualDevice* pNewVir = new VirtualDevice( 1 );
+
+ pNewVir->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
+
+ MapMode aMapMode( pNewVir->GetMapMode() );
+ aMapMode.SetMapUnit( MAP_TWIP );
+ pNewVir->SetMapMode( aMapMode );
+
+ return pNewVir;
}
void SwDoc::setReferenceDeviceType(bool bNewVirtual, bool bNewHiRes){
@@ -584,7 +622,7 @@ sal_uInt16 SwDoc::GetRedlineAuthor(){
sal_uInt16 SwDoc::InsertRedlineAuthor(const String & rAuthor){
sal_uInt16 out = 0;
cout << "InsertRedlineAuthor(";
- cout << rAuthor.c_str();
+ cout << rAuthor.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -596,7 +634,7 @@ bool SwDoc::SetRedlineComment(const SwPaM & rPam, const String & rComment){
cout << "SetRedlineComment(";
cout << "rPam";
cout << ",";
- cout << rComment.c_str();
+ cout << rComment.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -622,7 +660,7 @@ void SwDoc::SetRedlinePassword(const ::com::sun::star::uno::Sequence<sal_Int8> &
}
IDocumentUndoRedo & SwDoc::GetIDocumentUndoRedo(){
- IDocumentUndoRedo out(::std::auto_ptr<SwNodes>(new SwNodes(this)),*this,*whis,*this);
+ sw::UndoManager out(::std::auto_ptr<SwNodes>(new SwNodes(this)),static_cast<IDocumentDrawModelAccess&>(*this),static_cast<IDocumentRedlineAccess&>(*this),static_cast<IDocumentState&>(*this));
cout << "GetIDocumentUndoRedo(";
cout << ") -> ";
cout << "type: \"IDocumentUndoRedo\"";
@@ -631,7 +669,7 @@ IDocumentUndoRedo & SwDoc::GetIDocumentUndoRedo(){
}
IDocumentUndoRedo const & SwDoc::GetIDocumentUndoRedo() const{
- IDocumentUndoRedo const out(::std::auto_ptr<SwNodes>(new SwNodes(this)),*this,*whis,*this);
+ sw::UndoManager out(::std::auto_ptr<SwNodes>(new SwNodes(const_cast<SwDoc*>(this))),static_cast<IDocumentDrawModelAccess&>(*const_cast<SwDoc*>(this)),static_cast<IDocumentRedlineAccess&>(*const_cast<SwDoc*>(this)),static_cast<IDocumentState&>(*const_cast<SwDoc*>(this)));
cout << "GetIDocumentUndoRedo(";
cout << ") -> ";
cout << "type: \"IDocumentUndoRedo\"";
@@ -658,7 +696,7 @@ void SwDoc::SetVisibleLinks(bool bFlag){
}
sfx2::LinkManager & SwDoc::GetLinkManager(){
- sfx2::LinkManager out;
+ sfx2::LinkManager out(NULL);
cout << "GetLinkManager(";
cout << ") -> ";
cout << "type: \"sfx2::LinkManager\"";
@@ -667,7 +705,7 @@ sfx2::LinkManager & SwDoc::GetLinkManager(){
}
const sfx2::LinkManager & SwDoc::GetLinkManager() const{
- sfx2::LinkManager out;
+ sfx2::LinkManager out(NULL);
cout << "GetLinkManager(";
cout << ") -> ";
cout << "type: \"sfx2::LinkManager\"";
@@ -689,7 +727,7 @@ bool SwDoc::GetData(const rtl::OUString & rItem, const String & rMimeType, ::com
cout << "GetData(";
cout << "rItem";
cout << ",";
- cout << rMimeType.c_str();
+ cout << rMimeType.GetBuffer();
cout << ",";
cout << "rValue";
cout << ") -> ";
@@ -703,7 +741,7 @@ bool SwDoc::SetData(const rtl::OUString & rItem, const String & rMimeType, const
cout << "SetData(";
cout << "rItem";
cout << ",";
- cout << rMimeType.c_str();
+ cout << rMimeType.GetBuffer();
cout << ",";
cout << "rValue";
cout << ") -> ";
@@ -783,7 +821,7 @@ SwFieldType * SwDoc::GetFldType(sal_uInt16 nResId, const String & rName, bool bD
cout << "GetFldType(";
cout << nResId;
cout << ",";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << bDbFieldMatching;
cout << ") -> ";
@@ -1144,7 +1182,7 @@ bool SwDoc::Overwrite(const SwPaM & rRg, const String & rStr){
cout << "Overwrite(";
cout << "rRg";
cout << ",";
- cout << rStr.c_str();
+ cout << rStr.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -1194,9 +1232,9 @@ SwFlyFrmFmt * SwDoc::Insert(const SwPaM & rRg, const String & rGrfName, const St
cout << "Insert(";
cout << "rRg";
cout << ",";
- cout << rGrfName.c_str();
+ cout << rGrfName.GetBuffer();
cout << ",";
- cout << rFltName.c_str();
+ cout << rFltName.GetBuffer();
cout << ",";
cout << pGraphic;
cout << ",";
@@ -1295,9 +1333,9 @@ void SwDoc::ReRead(SwPaM & arg1, const String & rGrfName, const String & rFltNam
cout << "ReRead(";
cout << "arg1";
cout << ",";
- cout << rGrfName.c_str();
+ cout << rGrfName.GetBuffer();
cout << ",";
- cout << rFltName.c_str();
+ cout << rFltName.GetBuffer();
cout << ",";
cout << pGraphic;
cout << ",";
@@ -1324,7 +1362,7 @@ SwFlyFrmFmt * SwDoc::InsertOLE(const SwPaM & rRg, const String & rObjName, sal_I
cout << "InsertOLE(";
cout << "rRg";
cout << ",";
- cout << rObjName.c_str();
+ cout << rObjName.GetBuffer();
cout << ",";
cout << nAspect;
cout << ",";
@@ -1375,7 +1413,7 @@ bool SwDoc::ReplaceRange(SwPaM & rPam, const String & rNewStr, const bool bRegEx
cout << "ReplaceRange(";
cout << "rPam";
cout << ",";
- cout << rNewStr.c_str();
+ cout << rNewStr.GetBuffer();
cout << ",";
cout << bRegExReplace;
cout << ") -> ";
@@ -1987,7 +2025,7 @@ String SwDoc::getListItemText(const SwNodeNum & rNodeNum, const bool bWithNumber
cout << ",";
cout << bWithSpacesForLevel;
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -2038,7 +2076,7 @@ String SwDoc::getOutlineText(const sal_Int32 nIdx, const bool bWithNumber, const
cout << ",";
cout << bWithSpacesForLevel;
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -2065,9 +2103,9 @@ void SwDoc::getOutlineNodes(IDocumentOutlineNodes::tSortedOutlineNodeList & orOu
SwList * SwDoc::createList(String sListId, const String sDefaultListStyleName){
SwList * out = 0;
cout << "createList(";
- cout << sListId.c_str();
+ cout << sListId.GetBuffer();
cout << ",";
- cout << sDefaultListStyleName.c_str();
+ cout << sDefaultListStyleName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -2076,7 +2114,7 @@ SwList * SwDoc::createList(String sListId, const String sDefaultListStyleName){
void SwDoc::deleteList(const String sListId){
cout << "deleteList(";
- cout << sListId.c_str();
+ cout << sListId.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -2086,7 +2124,7 @@ void SwDoc::deleteList(const String sListId){
SwList * SwDoc::getListByName(const String sListId) const{
SwList * out = 0;
cout << "getListByName(";
- cout << sListId.c_str();
+ cout << sListId.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -2096,7 +2134,7 @@ SwList * SwDoc::getListByName(const String sListId) const{
SwList * SwDoc::createListForListStyle(const String sListStyleName){
SwList * out = 0;
cout << "createListForListStyle(";
- cout << sListStyleName.c_str();
+ cout << sListStyleName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -2106,7 +2144,7 @@ SwList * SwDoc::createListForListStyle(const String sListStyleName){
SwList * SwDoc::getListForListStyle(const String sListStyleName) const{
SwList * out = 0;
cout << "getListForListStyle(";
- cout << sListStyleName.c_str();
+ cout << sListStyleName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -2115,7 +2153,7 @@ SwList * SwDoc::getListForListStyle(const String sListStyleName) const{
void SwDoc::deleteListForListStyle(const String sListStyleName){
cout << "deleteListForListStyle(";
- cout << sListStyleName.c_str();
+ cout << sListStyleName.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -2124,9 +2162,9 @@ void SwDoc::deleteListForListStyle(const String sListStyleName){
void SwDoc::trackChangeOfListStyleName(const String sListStyleName, const String sNewListStyleName){
cout << "trackChangeOfListStyleName(";
- cout << sListStyleName.c_str();
+ cout << sListStyleName.GetBuffer();
cout << ",";
- cout << sNewListStyleName.c_str();
+ cout << sNewListStyleName.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -2217,7 +2255,7 @@ void SwDoc::GetAllFlyFmts(SwPosFlyFrms & rPosFlyFmts, const SwPaM * arg1, sal_Bo
SwFlyFrmFmt * SwDoc::MakeFlyFrmFmt(const String & rFmtName, SwFrmFmt * pDerivedFrom){
SwFlyFrmFmt * out = 0;
cout << "MakeFlyFrmFmt(";
- cout << rFmtName.c_str();
+ cout << rFmtName.GetBuffer();
cout << ",";
cout << pDerivedFrom;
cout << ") -> ";
@@ -2229,7 +2267,7 @@ SwFlyFrmFmt * SwDoc::MakeFlyFrmFmt(const String & rFmtName, SwFrmFmt * pDerivedF
SwDrawFrmFmt * SwDoc::MakeDrawFrmFmt(const String & rFmtName, SwFrmFmt * pDerivedFrom){
SwDrawFrmFmt * out = 0;
cout << "MakeDrawFrmFmt(";
- cout << rFmtName.c_str();
+ cout << rFmtName.GetBuffer();
cout << ",";
cout << pDerivedFrom;
cout << ") -> ";
@@ -2323,7 +2361,7 @@ void SwDoc::SetFlyFrmTitle(SwFlyFrmFmt & rFlyFrmFmt, const String & sNewTitle){
cout << "SetFlyFrmTitle(";
cout << "rFlyFrmFmt";
cout << ",";
- cout << sNewTitle.c_str();
+ cout << sNewTitle.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -2334,7 +2372,7 @@ void SwDoc::SetFlyFrmDescription(SwFlyFrmFmt & rFlyFrmFmt, const String & sNewDe
cout << "SetFlyFrmDescription(";
cout << "rFlyFrmFmt";
cout << ",";
- cout << sNewDescription.c_str();
+ cout << sNewDescription.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -2400,7 +2438,7 @@ bool SwDoc::SetCurFtn(const SwPaM & rPam, const String & rNumStr, sal_uInt16 nNu
cout << "SetCurFtn(";
cout << "rPam";
cout << ",";
- cout << rNumStr.c_str();
+ cout << rNumStr.GetBuffer();
cout << ",";
cout << nNumber;
cout << ",";
@@ -2565,7 +2603,7 @@ void SwDoc::ChangeDBFields(const std::vector<String> & rOldNames, const String &
cout << "ChangeDBFields(";
cout << "rOldNames";
cout << ",";
- cout << rNewName.c_str();
+ cout << rNewName.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -2632,7 +2670,7 @@ String SwDoc::GetUniqueGrfName() const{
String out;
cout << "GetUniqueGrfName(";
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -2641,7 +2679,7 @@ String SwDoc::GetUniqueOLEName() const{
String out;
cout << "GetUniqueOLEName(";
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -2650,7 +2688,7 @@ String SwDoc::GetUniqueFrameName() const{
String out;
cout << "GetUniqueFrameName(";
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -2668,7 +2706,7 @@ void SwDoc::SetFlyName(SwFlyFrmFmt & rFmt, const String & rName){
cout << "SetFlyName(";
cout << "rFmt";
cout << ",";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -2678,7 +2716,7 @@ void SwDoc::SetFlyName(SwFlyFrmFmt & rFmt, const String & rName){
const SwFlyFrmFmt * SwDoc::FindFlyByName(const String & rName, sal_Int8 nNdTyp) const{
const SwFlyFrmFmt * out = 0;
cout << "FindFlyByName(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << nNdTyp;
cout << ") -> ";
@@ -2786,13 +2824,13 @@ void SwDoc::SetDefault(const SfxItemSet & arg1){
}
const SfxPoolItem & SwDoc::GetDefault(sal_uInt16 nFmtHint) const{
- const SfxPoolItem out(0);
+ const SfxPoolItem* pItem = new SwFmtCntnt();
cout << "GetDefault(";
cout << nFmtHint;
cout << ") -> ";
cout << "type: \"SfxPoolItem\"";
cout << "\n";
- return out;
+ return *pItem;
}
sal_Bool SwDoc::DontExpandFmt(const SwPosition & rPos, sal_Bool bFlag){
@@ -2925,12 +2963,12 @@ SwCharFmt * SwDoc::GetDfltCharFmt(){
}
IStyleAccess & SwDoc::GetIStyleAccess(){
- IStyleAccess out;
+ IStyleAccess* out = createStyleManager(NULL);
cout << "GetIStyleAccess(";
cout << ") -> ";
cout << "type: \"IStyleAccess\"";
cout << "\n";
- return out;
+ return *out;
}
void SwDoc::RemoveAllFmtLanguageDependencies(){
@@ -2944,7 +2982,7 @@ void SwDoc::RemoveAllFmtLanguageDependencies(){
SwFrmFmt * SwDoc::MakeFrmFmt(const String & rFmtName, SwFrmFmt * pDerivedFrom, sal_Bool bBroadcast, sal_Bool bAuto){
SwFrmFmt * out = 0;
cout << "MakeFrmFmt(";
- cout << rFmtName.c_str();
+ cout << rFmtName.GetBuffer();
cout << ",";
cout << pDerivedFrom;
cout << ",";
@@ -2971,7 +3009,7 @@ void SwDoc::DelFrmFmt(SwFrmFmt * pFmt, sal_Bool bBroadcast){
SwFrmFmt * SwDoc::FindFrmFmtByName(const String & rName) const{
SwFrmFmt * out = 0;
cout << "FindFrmFmtByName(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -2981,7 +3019,7 @@ SwFrmFmt * SwDoc::FindFrmFmtByName(const String & rName) const{
SwCharFmt * SwDoc::MakeCharFmt(const String & rFmtName, SwCharFmt * pDerivedFrom, sal_Bool bBroadcast, sal_Bool bAuto){
SwCharFmt * out = 0;
cout << "MakeCharFmt(";
- cout << rFmtName.c_str();
+ cout << rFmtName.GetBuffer();
cout << ",";
cout << pDerivedFrom;
cout << ",";
@@ -3019,7 +3057,7 @@ void SwDoc::DelCharFmt(SwCharFmt * pFmt, sal_Bool bBroadcast){
SwCharFmt * SwDoc::FindCharFmtByName(const String & rName) const{
SwCharFmt * out = 0;
cout << "FindCharFmtByName(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -3047,7 +3085,7 @@ const SwTxtFmtColls * SwDoc::GetTxtFmtColls() const{
SwTxtFmtColl * SwDoc::MakeTxtFmtColl(const String & rFmtName, SwTxtFmtColl * pDerivedFrom, sal_Bool bBroadcast, sal_Bool bAuto){
SwTxtFmtColl * out = 0;
cout << "MakeTxtFmtColl(";
- cout << rFmtName.c_str();
+ cout << rFmtName.GetBuffer();
cout << ",";
cout << pDerivedFrom;
cout << ",";
@@ -3063,7 +3101,7 @@ SwTxtFmtColl * SwDoc::MakeTxtFmtColl(const String & rFmtName, SwTxtFmtColl * pDe
SwConditionTxtFmtColl * SwDoc::MakeCondTxtFmtColl(const String & rFmtName, SwTxtFmtColl * pDerivedFrom, sal_Bool bBroadcast){
SwConditionTxtFmtColl * out = 0;
cout << "MakeCondTxtFmtColl(";
- cout << rFmtName.c_str();
+ cout << rFmtName.GetBuffer();
cout << ",";
cout << pDerivedFrom;
cout << ",";
@@ -3115,7 +3153,7 @@ sal_Bool SwDoc::SetTxtFmtColl(const SwPaM & rRg, SwTxtFmtColl * pFmt, bool bRese
SwTxtFmtColl * SwDoc::FindTxtFmtCollByName(const String & rName) const{
SwTxtFmtColl * out = 0;
cout << "FindTxtFmtCollByName(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -3151,7 +3189,7 @@ const SwGrfFmtColls * SwDoc::GetGrfFmtColls() const{
SwGrfFmtColl * SwDoc::MakeGrfFmtColl(const String & rFmtName, SwGrfFmtColl * pDerivedFrom){
SwGrfFmtColl * out = 0;
cout << "MakeGrfFmtColl(";
- cout << rFmtName.c_str();
+ cout << rFmtName.GetBuffer();
cout << ",";
cout << pDerivedFrom;
cout << ") -> ";
@@ -3163,7 +3201,7 @@ SwGrfFmtColl * SwDoc::MakeGrfFmtColl(const String & rFmtName, SwGrfFmtColl * pDe
SwGrfFmtColl * SwDoc::FindGrfFmtCollByName(const String & rName) const{
SwGrfFmtColl * out = 0;
cout << "FindGrfFmtCollByName(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -3199,7 +3237,8 @@ sal_uInt16 SwDoc::GetTblFrmFmtCount(sal_Bool bUsed) const{
}
SwFrmFmt & SwDoc::GetTblFrmFmt(sal_uInt16 nFmt, sal_Bool bUsed) const{
- SwFrmFmt out;
+ SwAttrPool* pPool = new SwAttrPool(const_cast<SwDoc*>(this));
+ SwFrmFmt out(*pPool, "test", NULL);
cout << "GetTblFrmFmt(";
cout << nFmt;
cout << ",";
@@ -3213,7 +3252,7 @@ SwFrmFmt & SwDoc::GetTblFrmFmt(sal_uInt16 nFmt, sal_Bool bUsed) const{
SwTableFmt * SwDoc::MakeTblFrmFmt(const String & rFmtName, SwFrmFmt * pDerivedFrom){
SwTableFmt * out = 0;
cout << "MakeTblFrmFmt(";
- cout << rFmtName.c_str();
+ cout << rFmtName.GetBuffer();
cout << ",";
cout << pDerivedFrom;
cout << ") -> ";
@@ -3234,7 +3273,7 @@ void SwDoc::DelTblFrmFmt(SwTableFmt * pFmt){
SwTableFmt * SwDoc::FindTblFmtByName(const String & rName, sal_Bool bAll) const{
SwTableFmt * out = 0;
cout << "FindTblFmtByName(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << bAll;
cout << ") -> ";
@@ -3355,7 +3394,7 @@ sal_Bool SwDoc::IsUsed(const SwNumRule & arg1) const{
sal_uInt16 SwDoc::SetDocPattern(const String & rPatternName){
sal_uInt16 out = 0;
cout << "SetDocPattern(";
- cout << rPatternName.c_str();
+ cout << rPatternName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -3394,7 +3433,7 @@ sal_Bool SwDoc::InsertGlossary(SwTextBlocks & rBlock, const String & rEntry, SwP
cout << "InsertGlossary(";
cout << "rBlock";
cout << ",";
- cout << rEntry.c_str();
+ cout << rEntry.GetBuffer();
cout << ",";
cout << "rPaM";
cout << ",";
@@ -3462,7 +3501,7 @@ sal_uInt16 SwDoc::GetPageDescCnt() const{
}
const SwPageDesc & SwDoc::GetPageDesc(const sal_uInt16 i) const{
- SwPageDesc out;
+ SwPageDesc out(String(), NULL, const_cast<SwDoc*>(this));
cout << "GetPageDesc(";
cout << i;
cout << ") -> ";
@@ -3474,7 +3513,7 @@ const SwPageDesc & SwDoc::GetPageDesc(const sal_uInt16 i) const{
SwPageDesc * SwDoc::FindPageDescByName(const String & rName, sal_uInt16 * pPos) const{
SwPageDesc * out = 0;
cout << "FindPageDescByName(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << pPos;
cout << ") -> ";
@@ -3521,7 +3560,7 @@ void SwDoc::CopyFooter(const SwFrmFmt & rSrcFmt, SwFrmFmt & rDestFmt){
SwPageDesc * SwDoc::GetPageDesc(const String & rName){
SwPageDesc * out = 0;
cout << "GetPageDesc(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -3529,7 +3568,7 @@ SwPageDesc * SwDoc::GetPageDesc(const String & rName){
}
SwPageDesc & SwDoc::_GetPageDesc(sal_uInt16 i) const{
- SwPageDesc out;
+ SwPageDesc out(String(), NULL, const_cast<SwDoc*>(this));
cout << "_GetPageDesc(";
cout << i;
cout << ") -> ";
@@ -3540,7 +3579,7 @@ SwPageDesc & SwDoc::_GetPageDesc(sal_uInt16 i) const{
void SwDoc::ChgPageDesc(const String & rName, const SwPageDesc & arg1){
cout << "ChgPageDesc(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << "arg1";
cout << ") -> ";
@@ -3563,7 +3602,7 @@ void SwDoc::ChgPageDesc(sal_uInt16 i, const SwPageDesc & arg1){
sal_Bool SwDoc::FindPageDesc(const String & rName, sal_uInt16 * pFound){
sal_Bool out = false;
cout << "FindPageDesc(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << pFound;
cout << ") -> ";
@@ -3574,7 +3613,7 @@ sal_Bool SwDoc::FindPageDesc(const String & rName, sal_uInt16 * pFound){
void SwDoc::DelPageDesc(const String & rName, sal_Bool bBroadcast){
cout << "DelPageDesc(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << bBroadcast;
cout << ") -> ";
@@ -3606,7 +3645,7 @@ void SwDoc::PreDelPageDesc(SwPageDesc * pDel){
sal_uInt16 SwDoc::MakePageDesc(const String & rName, const SwPageDesc * pCpy, sal_Bool bRegardLanguage, sal_Bool bBroadcast){
sal_uInt16 out = 0;
cout << "MakePageDesc(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << pCpy;
cout << ",";
@@ -3621,7 +3660,7 @@ sal_uInt16 SwDoc::MakePageDesc(const String & rName, const SwPageDesc * pCpy, sa
void SwDoc::BroadcastStyleOperation(String rName, SfxStyleFamily eFamily, sal_uInt16 nOp){
cout << "BroadcastStyleOperation(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << "eFamily";
cout << ",";
@@ -3662,7 +3701,7 @@ void SwDoc::DeleteTOXMark(const SwTOXMark * pTOXMark){
}
const SwTOXMark & SwDoc::GotoTOXMark(const SwTOXMark & rCurTOXMark, SwTOXSearch eDir, sal_Bool bInReadOnly){
- const SwTOXMark out;
+ const SwTOXMark out(NULL);
cout << "GotoTOXMark(";
cout << "rCurTOXMark";
cout << ",";
@@ -3718,13 +3757,14 @@ const SwTOXBase * SwDoc::GetCurTOX(const SwPosition & rPos) const{
}
const SwAttrSet & SwDoc::GetTOXBaseAttrSet(const SwTOXBase & rTOX) const{
- SwAttrSet out;
+ SwAttrPool* pPool = new SwAttrPool(const_cast<SwDoc*>(this));
+ SwAttrSet* pSet = new SwAttrSet(*pPool, 0, 0);
cout << "GetTOXBaseAttrSet(";
cout << "rTOX";
cout << ") -> ";
cout << "type: \"SwAttrSet\"";
cout << "\n";
- return out;
+ return *pSet;
}
sal_Bool SwDoc::DeleteTOX(const SwTOXBase & rTOXBase, sal_Bool bDelNodes){
@@ -3746,7 +3786,7 @@ String SwDoc::GetUniqueTOXBaseName(const SwTOXType & rType, const String * pChkS
cout << ",";
cout << pChkStr;
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -3756,7 +3796,7 @@ sal_Bool SwDoc::SetTOXBaseName(const SwTOXBase & rTOXBase, const String & rName)
cout << "SetTOXBaseName(";
cout << "rTOXBase";
cout << ",";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -3796,14 +3836,14 @@ const String & SwDoc::GetTOIAutoMarkURL() const{
const String out;
cout << "GetTOIAutoMarkURL(";
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
void SwDoc::SetTOIAutoMarkURL(const String & rSet){
cout << "SetTOIAutoMarkURL(";
- cout << rSet.c_str();
+ cout << rSet.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -4113,7 +4153,7 @@ sal_Bool SwDoc::GotoOutline(SwPosition & rPos, const String & rName) const{
cout << "GotoOutline(";
cout << "rPos";
cout << ",";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -4128,7 +4168,7 @@ void SwDoc::SetNumRule(const SwPaM & arg1, const SwNumRule & arg2, const bool bC
cout << ",";
cout << bCreateNewList;
cout << ",";
- cout << sContinuedListId.c_str();
+ cout << sContinuedListId.GetBuffer();
cout << ",";
cout << bSetItem;
cout << ",";
@@ -4212,7 +4252,7 @@ void SwDoc::AddNumRule(SwNumRule * pRule){
sal_uInt16 SwDoc::MakeNumRule(const String & rName, const SwNumRule * pCpy, sal_Bool bBroadcast, const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode){
sal_uInt16 out = 0;
cout << "MakeNumRule(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << pCpy;
cout << ",";
@@ -4228,7 +4268,7 @@ sal_uInt16 SwDoc::MakeNumRule(const String & rName, const SwNumRule * pCpy, sal_
sal_uInt16 SwDoc::FindNumRule(const String & rName) const{
sal_uInt16 out = 0;
cout << "FindNumRule(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -4238,7 +4278,7 @@ sal_uInt16 SwDoc::FindNumRule(const String & rName) const{
SwNumRule * SwDoc::FindNumRulePtr(const String & rName) const{
SwNumRule * out = 0;
cout << "FindNumRulePtr(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -4248,9 +4288,9 @@ SwNumRule * SwDoc::FindNumRulePtr(const String & rName) const{
sal_Bool SwDoc::RenameNumRule(const String & aOldName, const String & aNewName, sal_Bool bBroadcast){
sal_Bool out = false;
cout << "RenameNumRule(";
- cout << aOldName.c_str();
+ cout << aOldName.GetBuffer();
cout << ",";
- cout << aNewName.c_str();
+ cout << aNewName.GetBuffer();
cout << ",";
cout << bBroadcast;
cout << ") -> ";
@@ -4262,7 +4302,7 @@ sal_Bool SwDoc::RenameNumRule(const String & aOldName, const String & aNewName,
sal_Bool SwDoc::DelNumRule(const String & rName, sal_Bool bBroadCast){
sal_Bool out = false;
cout << "DelNumRule(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ",";
cout << bBroadCast;
cout << ") -> ";
@@ -4278,7 +4318,7 @@ String SwDoc::GetUniqueNumRuleName(const String * pChkStr, sal_Bool bAutoNum) co
cout << ",";
cout << bAutoNum;
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -4307,9 +4347,9 @@ sal_Bool SwDoc::ReplaceNumRule(const SwPosition & rPos, const String & rOldRule,
cout << "ReplaceNumRule(";
cout << "rPos";
cout << ",";
- cout << rOldRule.c_str();
+ cout << rOldRule.GetBuffer();
cout << ",";
- cout << rNewRule.c_str();
+ cout << rNewRule.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -4361,7 +4401,7 @@ const SwNumRule * SwDoc::SearchNumRule(const SwPosition & rPos, const bool bForw
cout << ",";
cout << nNonEmptyAllowed;
cout << ",";
- cout << sListId.c_str();
+ cout << sListId.GetBuffer();
cout << ",";
cout << bInvestigateStartNode;
cout << ") -> ";
@@ -4648,7 +4688,7 @@ String SwDoc::GetUniqueTblName() const{
String out;
cout << "GetUniqueTblName(";
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -4894,7 +4934,7 @@ sal_Bool SwDoc::InsCopyOfTbl(SwPosition & rInsPos, const SwSelBoxes & rBoxes, co
sal_Bool SwDoc::UnProtectCells(const String & rTblName){
sal_Bool out = false;
cout << "UnProtectCells(";
- cout << rTblName.c_str();
+ cout << rTblName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -4965,7 +5005,7 @@ sal_Bool SwDoc::MergeTable(const SwPosition & rPos, sal_Bool bWithPrev, sal_uInt
void SwDoc::UpdateCharts(const String & rName) const{
cout << "UpdateCharts(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -4984,7 +5024,7 @@ void SwDoc::SetTableName(SwFrmFmt & rTblFmt, const String & rNewName){
cout << "SetTableName(";
cout << "rTblFmt";
cout << ",";
- cout << rNewName.c_str();
+ cout << rNewName.GetBuffer();
cout << ") -> ";
cout << "type: \"void\"";
cout << "\n";
@@ -4994,7 +5034,7 @@ void SwDoc::SetTableName(SwFrmFmt & rTblFmt, const String & rNewName){
const SwFmtRefMark * SwDoc::GetRefMark(const String & rName) const{
const SwFmtRefMark * out = 0;
cout << "GetRefMark(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -5026,11 +5066,11 @@ SwFlyFrmFmt * SwDoc::InsertLabel(const SwLabelType eType, const String & rTxt, c
cout << "InsertLabel(";
cout << "eType";
cout << ",";
- cout << rTxt.c_str();
+ cout << rTxt.GetBuffer();
cout << ",";
- cout << rSeparator.c_str();
+ cout << rSeparator.GetBuffer();
cout << ",";
- cout << rNumberingSeparator.c_str();
+ cout << rNumberingSeparator.GetBuffer();
cout << ",";
cout << bBefore;
cout << ",";
@@ -5038,7 +5078,7 @@ SwFlyFrmFmt * SwDoc::InsertLabel(const SwLabelType eType, const String & rTxt, c
cout << ",";
cout << nIdx;
cout << ",";
- cout << rCharacterStyle.c_str();
+ cout << rCharacterStyle.GetBuffer();
cout << ",";
cout << bCpyBrd;
cout << ") -> ";
@@ -5050,15 +5090,15 @@ SwFlyFrmFmt * SwDoc::InsertLabel(const SwLabelType eType, const String & rTxt, c
SwFlyFrmFmt * SwDoc::InsertDrawLabel(const String & rTxt, const String & rSeparator, const String & rNumberSeparator, const sal_uInt16 nId, const String & rCharacterStyle, SdrObject & rObj){
SwFlyFrmFmt * out = 0;
cout << "InsertDrawLabel(";
- cout << rTxt.c_str();
+ cout << rTxt.GetBuffer();
cout << ",";
- cout << rSeparator.c_str();
+ cout << rSeparator.GetBuffer();
cout << ",";
- cout << rNumberSeparator.c_str();
+ cout << rNumberSeparator.GetBuffer();
cout << ",";
cout << nId;
cout << ",";
- cout << rCharacterStyle.c_str();
+ cout << rCharacterStyle.GetBuffer();
cout << ",";
cout << "rObj";
cout << ") -> ";
@@ -5068,21 +5108,21 @@ SwFlyFrmFmt * SwDoc::InsertDrawLabel(const String & rTxt, const String & rSepara
}
const SwAttrPool & SwDoc::GetAttrPool() const{
- const SwAttrPool out(this);
+ SwAttrPool* out = new SwAttrPool(const_cast<SwDoc*>(this));
cout << "GetAttrPool(";
cout << ") -> ";
cout << "type: \"SwAttrPool\"";
cout << "\n";
- return out;
+ return *out;
}
SwAttrPool & SwDoc::GetAttrPool(){
- SwAttrPool out(this);
+ SwAttrPool* out = new SwAttrPool(this);
cout << "GetAttrPool(";
cout << ") -> ";
cout << "type: \"SwAttrPool\"";
cout << "\n";
- return out;
+ return *out;
}
SwEditShell * SwDoc::GetEditShell(ViewShell * * ppSh) const{
@@ -5221,7 +5261,7 @@ String SwDoc::GetUniqueSectionName(const String * pChkStr) const{
cout << "GetUniqueSectionName(";
cout << pChkStr;
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -5310,7 +5350,7 @@ void SwDoc::SetInLoadAsynchron(bool bFlag){
sal_Bool SwDoc::SelectServerObj(const String & rStr, SwPaM * & rpPam, SwNodeRange * & rpRange) const{
sal_Bool out = false;
cout << "SelectServerObj(";
- cout << rStr.c_str();
+ cout << rStr.GetBuffer();
cout << ",";
cout << rpPam;
cout << ",";
@@ -5401,7 +5441,7 @@ void SwDoc::SetCalcFieldValueHdl(Outliner * pOutliner){
sal_Bool SwDoc::IsVisitedURL(const String & rURL) const{
sal_Bool out = false;
cout << "IsVisitedURL(";
- cout << rURL.c_str();
+ cout << rURL.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -5429,7 +5469,7 @@ SwAutoCorrExceptWord * SwDoc::GetAutoCorrExceptWord(){
const SwFmtINetFmt * SwDoc::FindINetAttr(const String & rName) const{
const SwFmtINetFmt * out = 0;
cout << "FindINetAttr(";
- cout << rName.c_str();
+ cout << rName.GetBuffer();
cout << ") -> ";
cout << out;
cout << "\n";
@@ -5540,7 +5580,7 @@ sal_Bool SwDoc::ConvertFieldsToText(){
sal_Bool SwDoc::GenerateGlobalDoc(const String & rPath, const SwTxtFmtColl * pSplitColl){
sal_Bool out = false;
cout << "GenerateGlobalDoc(";
- cout << rPath.c_str();
+ cout << rPath.GetBuffer();
cout << ",";
cout << pSplitColl;
cout << ") -> ";
@@ -5552,7 +5592,7 @@ sal_Bool SwDoc::GenerateGlobalDoc(const String & rPath, const SwTxtFmtColl * pSp
sal_Bool SwDoc::GenerateGlobalDoc(const String & rPath, int nOutlineLevel){
sal_Bool out = false;
cout << "GenerateGlobalDoc(";
- cout << rPath.c_str();
+ cout << rPath.GetBuffer();
cout << ",";
cout << nOutlineLevel;
cout << ") -> ";
@@ -5564,7 +5604,7 @@ sal_Bool SwDoc::GenerateGlobalDoc(const String & rPath, int nOutlineLevel){
sal_Bool SwDoc::GenerateHTMLDoc(const String & rPath, const SwTxtFmtColl * pSplitColl){
sal_Bool out = false;
cout << "GenerateHTMLDoc(";
- cout << rPath.c_str();
+ cout << rPath.GetBuffer();
cout << ",";
cout << pSplitColl;
cout << ") -> ";
@@ -5576,7 +5616,7 @@ sal_Bool SwDoc::GenerateHTMLDoc(const String & rPath, const SwTxtFmtColl * pSpli
sal_Bool SwDoc::GenerateHTMLDoc(const String & rPath, int nOutlineLevel){
sal_Bool out = false;
cout << "GenerateHTMLDoc(";
- cout << rPath.c_str();
+ cout << rPath.GetBuffer();
cout << ",";
cout << nOutlineLevel;
cout << ") -> ";
@@ -5987,15 +6027,6 @@ SwExtTextInput * SwDoc::GetExtTextInput() const{
return out;
}
-SwAutoCompleteWord & SwDoc::GetAutoCompleteWords(){
- SwAutoCompleteWord out;
- cout << "GetAutoCompleteWords(";
- cout << ") -> ";
- cout << "type: \"SwAutoCompleteWord\"";
- cout << "\n";
- return out;
-}
-
bool SwDoc::ContainsMSVBasic() const{
bool out = false;
cout << "ContainsMSVBasic(";
@@ -6098,7 +6129,7 @@ IGrammarContact * SwDoc::getGrammarContact() const{
void SwDoc::MarkListLevel(const String & sListId, const int nListLevel, const sal_Bool bValue){
cout << "MarkListLevel(";
- cout << sListId.c_str();
+ cout << sListId.GetBuffer();
cout << ",";
cout << nListLevel;
cout << ",";
@@ -6137,7 +6168,7 @@ void SwDoc::RenameFmt(SwFmt & rFmt, const String & sNewName, sal_Bool bBroadcast
cout << "RenameFmt(";
cout << "rFmt";
cout << ",";
- cout << sNewName.c_str();
+ cout << sNewName.GetBuffer();
cout << ",";
cout << bBroadcast;
cout << ") -> ";
@@ -6162,7 +6193,7 @@ String SwDoc::GetPaMDescr(const SwPaM & rPaM) const{
cout << "GetPaMDescr(";
cout << "rPaM";
cout << ") -> ";
- cout << out.c_str();
+ cout << out.GetBuffer();
cout << "\n";
return out;
}
@@ -6313,12 +6344,12 @@ com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> SwDoc:
}
::sfx2::IXmlIdRegistry & SwDoc::GetXmlIdRegistry(){
- ::sfx2::IXmlIdRegistry out;
- cout << "GetXmlIdRegistry(";
+ sfx2::IXmlIdRegistry* out = sfx2::createXmlIdRegistry(false);
+ cout << "GetXmlIdRegistry(";
cout << ") -> ";
cout << "type: \"::sfx2::IXmlIdRegistry\"";
cout << "\n";
- return out;
+ return *out;
}
::sw::MetaFieldManager & SwDoc::GetMetaFieldManager(){
@@ -6331,7 +6362,7 @@ com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> SwDoc:
}
::sw::UndoManager & SwDoc::GetUndoManager(){
- ::sw::UndoManager out;
+ sw::UndoManager out(::std::auto_ptr<SwNodes>(new SwNodes(this)),static_cast<IDocumentDrawModelAccess&>(*this),static_cast<IDocumentRedlineAccess&>(*this),static_cast<IDocumentState&>(*this));
cout << "GetUndoManager(";
cout << ") -> ";
cout << "type: \"::sw::UndoManager\"";
@@ -6340,7 +6371,7 @@ com::sun::star::uno::Reference<com::sun::star::container::XNameContainer> SwDoc:
}
::sw::UndoManager const & SwDoc::GetUndoManager() const{
- ::sw::UndoManager out;
+ sw::UndoManager out(::std::auto_ptr<SwNodes>(new SwNodes(const_cast<SwDoc*>(this))),static_cast<IDocumentDrawModelAccess&>(*const_cast<SwDoc*>(this)),static_cast<IDocumentRedlineAccess&>(*const_cast<SwDoc*>(this)),static_cast<IDocumentState&>(*const_cast<SwDoc*>(this)));
cout << "GetUndoManager(";
cout << ") -> ";
cout << "type: \"::sw::UndoManager\"";
@@ -6375,3 +6406,72 @@ void SwDoc::SetDrawDefaults(){
return;
}
+bool SwDoc::InsertString(const SwPaM&, const String&, IDocumentContentOperations::InsertFlags)
+{
+ return false;
+}
+
+IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo*, pInfo)
+{
+ return 0;
+}
+
+IMPL_STATIC_LINK( SwDoc, BackgroundDone, SvxBrushItem*, EMPTYARG )
+{
+ return 0;
+}
+
+IMPL_LINK( SwDoc, AddDrawUndo, SdrUndoAction *, pUndo )
+{
+ return 0;
+}
+
+struct _PostItFld : public _SetGetExpFld
+{
+ _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld, const SwIndex* pIdx = 0 )
+ : _SetGetExpFld( rNdIdx, pFld, pIdx ) {}
+
+ sal_uInt16 GetPageNo( const StringRangeEnumerator &rRangeEnum,
+ const std::set< sal_Int32 > &rPossiblePages,
+ sal_uInt16& rVirtPgNo, sal_uInt16& rLineNo );
+
+ SwPostItField* GetPostIt() const
+ {
+ return (SwPostItField*) GetFld()->GetFld().GetFld();
+ }
+};
+
+bool lcl_GetPostIts(
+ IDocumentFieldsAccess* pIDFA,
+ _SetGetExpFlds * pSrtLst )
+{
+ bool bHasPostIts = false;
+
+ SwFieldType* pFldType = pIDFA->GetSysFldType( RES_POSTITFLD );
+ OSL_ENSURE( pFldType, "kein PostItType ? ");
+
+ if( pFldType->GetDepends() )
+ {
+ // Found modify object; insert all fields into the array
+ SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
+ const SwTxtFld* pTxtFld;
+ for( SwFmtFld* pFld = aIter.First(); pFld; pFld = aIter.Next() )
+ {
+ if( 0 != ( pTxtFld = pFld->GetTxtFld() ) &&
+ pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
+ {
+ bHasPostIts = true;
+ if (pSrtLst)
+ {
+ SwNodeIndex aIdx( pTxtFld->GetTxtNode() );
+ _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld );
+ pSrtLst->Insert( pNew );
+ }
+ else
+ break; // we just wanted to check for the existence of postits ...
+ }
+ }
+ }
+
+ return bHasPostIts;
+}
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index d3e1ad526c61..349a90452c40 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -133,28 +133,6 @@ SV_IMPL_PTRARR( SwGrfFmtColls, SwGrfFmtCollPtr)
/*
* global functions...
*/
- uno::Reference< linguistic2::XProofreadingIterator > SwDoc::GetGCIterator() const
-{
- if (!m_xGCIterator.is() && SvtLinguConfig().HasGrammarChecker())
- {
- uno::Reference< lang::XMultiServiceFactory > xMgr( comphelper::getProcessServiceFactory() );
- if (xMgr.is())
- {
- try
- {
- rtl::OUString aServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.linguistic2.ProofreadingIterator"));
- m_xGCIterator = uno::Reference< linguistic2::XProofreadingIterator >
- ( xMgr->createInstance( aServiceName ), uno::UNO_QUERY_THROW );
- }
- catch (uno::Exception &)
- {
- OSL_FAIL( "No GCIterator" );
- }
- }
- }
-
- return m_xGCIterator;
-}
void StartGrammarChecking( SwDoc &rDoc )
{
@@ -202,704 +180,6 @@ sal_Bool lcl_DelFmtIndizes( const SwFrmFmtPtr& rpFmt, void* )
return sal_True;
}
-/*
- * exported methods
- */
-SwDoc::SwDoc()
- : m_pNodes( new SwNodes(this) )
- ,
- mpAttrPool(new SwAttrPool(this)),
- pMarkManager(new ::sw::mark::MarkManager(*this)),
- m_pMetaFieldManager(new ::sw::MetaFieldManager()),
- m_pUndoManager(new ::sw::UndoManager(
- ::std::auto_ptr<SwNodes>(new SwNodes(this)), *this, *this, *this)),
- pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
- pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ),
- pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ),
- pDfltCharFmt( new SwCharFmt( GetAttrPool(), sCharFmtStr, 0 ) ),
- pDfltTxtFmtColl( new SwTxtFmtColl( GetAttrPool(), sTxtCollStr ) ),
- pDfltGrfFmtColl( new SwGrfFmtColl( GetAttrPool(), sGrfCollStr ) ),
- pFrmFmtTbl( new SwFrmFmts() ),
- pCharFmtTbl( new SwCharFmts() ),
- pSpzFrmFmtTbl( new SwSpzFrmFmts() ),
- pSectionFmtTbl( new SwSectionFmts() ),
- pTblFrmFmtTbl( new SwFrmFmts() ),
- pTxtFmtCollTbl( new SwTxtFmtColls() ),
- pGrfFmtCollTbl( new SwGrfFmtColls() ),
- pTOXTypes( new SwTOXTypes() ),
- pDefTOXBases( new SwDefTOXBase_Impl() ),
- pCurrentView( 0 ), //swmod 071225
- pDrawModel( 0 ),
- pUpdtFlds( new SwDocUpdtFld() ),
- pFldTypes( new SwFldTypes() ),
- pVirDev( 0 ),
- pPrt( 0 ),
- pPrtData( 0 ),
- pGlossaryDoc( 0 ),
- pOutlineRule( 0 ),
- pFtnInfo( new SwFtnInfo ),
- pEndNoteInfo( new SwEndNoteInfo ),
- pLineNumberInfo( new SwLineNumberInfo ),
- pFtnIdxs( new SwFtnIdxs ),
- pDocStat( new SwDocStat ),
- pDocShell( 0 ),
- pLinkMgr( new sfx2::LinkManager( 0 ) ),
- pACEWord( 0 ),
- pURLStateChgd( 0 ),
- pNumberFormatter( 0 ),
- pNumRuleTbl( new SwNumRuleTbl ),
- maLists(),
- maListStyleLists(),
- pRedlineTbl( new SwRedlineTbl ),
- pAutoFmtRedlnComment( 0 ),
- pUnoCrsrTbl( new SwUnoCrsrTbl( 0 ) ),
- pPgPViewPrtData( 0 ),
- pExtInputRing( 0 ),
- pLayouter( 0 ),
- pStyleAccess( 0 ),
- pLayoutCache( 0 ),
- pUnoCallBack(new SwModify(0)),
- mpGrammarContact( 0 ),
- aChartDataProviderImplRef(),
- pChartControllerHelper( 0 ),
- mpListItemsList( new tImplSortedNodeNumList() ), // #i83479#
- m_pXmlIdRegistry(),
- nAutoFmtRedlnCommentNo( 0 ),
- nLinkUpdMode( GLOBALSETTING ),
- eFldUpdMode( AUTOUPD_GLOBALSETTING ),
- eRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
- eChrCmprType( CHARCOMPRESS_NONE ),
- mReferenceCount(0),
- mIdleBlockCount(0),
- nLockExpFld( 0 ),
- mbReadlineChecked(false),
- mbLinksUpdated( sal_False ), //#i38810#
- mbClipBoard( false ),
- mbColumnSelection( false ),
- mbProtectForm(false), // i#78591#
- mbLastBrowseMode( false ),
- n32DummyCompatabilityOptions1(0),
- n32DummyCompatabilityOptions2(0),
- mbStartIdleTimer(sal_False),
- mbSetDrawDefaults(false)
-{
- RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722", "SwDoc::SwDoc" );
-
- mbGlossDoc =
- mbModified =
- mbDtor =
- mbPageNums =
- mbLoaded =
- mbUpdateExpFld =
- mbNewDoc =
- mbCopyIsMove =
- mbInReading =
- mbInXMLImport =
- mbUpdateTOX =
- mbInLoadAsynchron =
- mbHTMLMode =
- mbInCallModified =
- mbIsGlobalDoc =
- mbGlblDocSaveLinks =
- mbIsLabelDoc =
- mbIsAutoFmtRedline =
- mbOLEPrtNotifyPending =
- mbAllOLENotify =
- mbIsRedlineMove =
- mbInsOnlyTxtGlssry =
- mbContains_MSVBasic =
- mbKernAsianPunctuation =
-#ifdef DBG_UTIL
- mbXMLExport =
-#endif
- mbApplyWorkaroundForB6375613 =
- false;
-
- mbNewFldLst =
- mbVisibleLinks =
- mbPurgeOLE =
- true;
-
- //
- // COMPATIBILITY FLAGS START
- //
-
- // Note: Any non-hidden compatibility flag should obtain its default
- // by asking SvtCompatibilityOptions, see below.
- //
- const SvtCompatibilityOptions aOptions;
- mbParaSpaceMax = aOptions.IsAddSpacing();
- mbParaSpaceMaxAtPages = aOptions.IsAddSpacingAtPages();
- mbTabCompat = !aOptions.IsUseOurTabStops();
- mbUseVirtualDevice = !aOptions.IsUsePrtDevice();
- mbAddExternalLeading = !aOptions.IsNoExtLeading();
- mbOldLineSpacing = aOptions.IsUseLineSpacing();
- mbAddParaSpacingToTableCells = aOptions.IsAddTableSpacing();
- mbUseFormerObjectPos = aOptions.IsUseObjectPositioning();
- mbUseFormerTextWrapping = aOptions.IsUseOurTextWrapping();
- mbConsiderWrapOnObjPos = aOptions.IsConsiderWrappingStyle();
- mbMathBaselineAlignment = false; // default for *old* documents is 'off'
- mbAddFlyOffsets = false; // hidden
- mbOldNumbering = false; // hidden
- mbUseHiResolutionVirtualDevice = true; // hidden
- mbIgnoreFirstLineIndentInNumbering = false; // hidden
- mbDoNotJustifyLinesWithManualBreak = !aOptions.IsExpandWordSpace();
- mbDoNotResetParaAttrsForNumFont = false; // hidden
- mbOutlineLevelYieldsOutlineRule = false; // hidden
- mbTableRowKeep = false; // hidden
- mbIgnoreTabsAndBlanksForLineCalculation = false; // hidden
- mbDoNotCaptureDrawObjsOnPage = false; // hidden
- mbClipAsCharacterAnchoredWriterFlyFrames= false; // hidden
- mbUnixForceZeroExtLeading = false; // hidden
- mbOldPrinterMetrics = false; // hidden
- mbTabRelativeToIndent = true; // hidden
- mbTabAtLeftIndentForParagraphsInList = false; // hidden #i89181#
- mbInvertBorderSpacing = false; // hidden
- mbCollapseEmptyCellPara = true; // hidden
- mbSmallCapsPercentage66 = false; // hidden
- mbTabOverflow = true;
- mbUnbreakableNumberings = false;
-
- //
- // COMPATIBILITY FLAGS END
- //
-
- pMacroTable = new SvxMacroTableDtor;
-
- mpGrammarContact = ::createGrammarContact();
-
- /*
- * DefaultFormats and DefaultFormatCollections (FmtColl)
- * are inserted at position 0 at the respective array.
- * The formats in the FmtColls are derived from the
- * DefaultFormats and are also in the list.
- */
- /* Formats */
- pFrmFmtTbl->Insert(pDfltFrmFmt, 0 );
- pCharFmtTbl->Insert(pDfltCharFmt, 0 );
-
- /* FmtColls */
- // TXT
- pTxtFmtCollTbl->Insert(pDfltTxtFmtColl, 0 );
- // GRF
- pGrfFmtCollTbl->Insert(pDfltGrfFmtColl, 0 );
-
- // Create PageDesc, EmptyPageFmt and ColumnFmt
- if ( !aPageDescs.Count() )
- GetPageDescFromPool( RES_POOLPAGE_STANDARD );
-
- // Set to "Empty Page"
- pEmptyPageFmt->SetFmtAttr( SwFmtFrmSize( ATT_FIX_SIZE ) );
- // Set BodyFmt for columns
- pColumnContFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) );
-
- _InitFieldTypes();
-
- // Create a default OutlineNumRule (for Filters)
- pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ),
- // #i89178#
- numfunc::GetDefaultPositionAndSpaceMode(),
- OUTLINE_RULE );
- AddNumRule(pOutlineRule);
- // Counting of phantoms depends on <IsOldNumbering()>
- pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) );
-
- new SwTxtNode(
- SwNodeIndex(GetUndoManager().GetUndoNodes().GetEndOfContent()),
- pDfltTxtFmtColl );
- new SwTxtNode( SwNodeIndex( GetNodes().GetEndOfContent() ),
- GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
-
- // set the own IdleTimer
- aIdleTimer.SetTimeout( 600 );
- aIdleTimer.SetTimeoutHdl( LINK(this, SwDoc, DoIdleJobs) );
-
- aOLEModifiedTimer.SetTimeout( 1000 );
- aOLEModifiedTimer.SetTimeoutHdl( LINK( this, SwDoc, DoUpdateModifiedOLE ));
-
- // Create DBMgr
- pNewDBMgr = new SwNewDBMgr;
-
- // create TOXTypes
- InitTOXTypes();
-
- // pass empty item set containing the paragraph's list attributes
- // as ignorable items to the stype manager.
- {
- SfxItemSet aIgnorableParagraphItems( GetAttrPool(),
- RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
- 0 );
- pStyleAccess = createStyleManager( &aIgnorableParagraphItems );
- }
-
- // Initialize the session id of the current document to a random number
- // smaller than 2^21.
- static rtlRandomPool aPool = rtl_random_createPool();
- rtl_random_getBytes( aPool, &nRsid, sizeof ( nRsid ) );
- nRsid &= ( 1<<21 ) - 1;
- nRsid++;
- nRsidRoot = nRsid;
-
- ResetModified();
-}
-
-/*
- * Speciality: a member of the class SwDoc is located at
- * position 0 in the array of the Format and GDI objects.
- * This MUST not be destroyed using 'delete' in any case!
- */
-SwDoc::~SwDoc()
-{
- // nothing here should create Undo actions!
- GetIDocumentUndoRedo().DoUndo(false);
-
- if (pDocShell)
- {
- pDocShell->SetUndoManager(0);
- }
-
-
- // #i83479#
- delete mpListItemsList;
- mpListItemsList = 0;
-
- // clean up chart related structures...
- // Note: the chart data provider gets already diposed in ~SwDocShell
- // since all UNO API related functionality requires an existing SwDocShell
- // this assures that dipose gets called if there is need for it.
- aChartDataProviderImplRef.reset();
- delete pChartControllerHelper;
-
- delete mpGrammarContact;
- mpGrammarContact = 0;
-
- //!! needs to be done to destroy a possible SwFmtDrop format that may
- //!! be connected to a char format which may not otherwise be removed
- //!! and thus would leave a unremoved SwFmt object. (TL)
- //!! (this is case is not possible via UI but via API...)
- SwFmtDrop aDrop;
- SetDefault(aDrop);
- //!! same for SwFmtCharFmt
- SwFmtCharFmt aCharFmt(NULL);
- SetDefault(aCharFmt);
-
- StopIdling(); // stop idle timer
-
- delete pUnoCallBack, pUnoCallBack = 0;
- delete pURLStateChgd;
-
- delete pLayouter;
- pLayouter = 0L;
-
- // Deactivate Undo notification from the Draw
- if( pDrawModel )
- {
- DrawNotifyUndoHdl();
- ClrContourCache();
- }
-
- delete pPgPViewPrtData;
-
- mbDtor = sal_True;
-
- delete pRedlineTbl;
- delete pUnoCrsrTbl;
- delete pAutoFmtRedlnComment;
- delete pUpdtFlds;
- delete pACEWord;
-
- // Release the BaseLinks
- {
- for( sal_uInt16 n = pLinkMgr->GetServers().Count(); n; )
- pLinkMgr->GetServers()[ --n ]->Closed();
-
- if( pLinkMgr->GetLinks().Count() )
- pLinkMgr->Remove( 0, pLinkMgr->GetLinks().Count() );
- }
-
- // The ChapterNumbers/Numbers need to be deleted before the Templates
- // or we update all the time!
- m_pNodes->pOutlineNds->Remove(sal_uInt16(0), m_pNodes->pOutlineNds->Count());
- SwNodes & rUndoNodes( GetUndoManager().GetUndoNodes() );
- rUndoNodes.pOutlineNds->Remove(sal_uInt16(0), rUndoNodes.pOutlineNds->Count());
-
- pFtnIdxs->Remove( sal_uInt16(0), pFtnIdxs->Count() );
-
- // indices could be registered in attributes
- m_pUndoManager->DelAllUndoObj();
-
- // The BookMarks contain indices to the Content. These must be deleted
- // before deleting the Nodes.
- pMarkManager->clearAllMarks();
- DELETEZ( pMacroTable );
-
- if( pExtInputRing )
- {
- Ring* pTmp = pExtInputRing;
- pExtInputRing = 0;
- while( pTmp->GetNext() != pTmp )
- delete pTmp->GetNext();
- delete pTmp;
- }
-
- // Old - deletion without a Flag is expensive, because we send a Modify
- // aTOXTypes.DeleteAndDestroy( 0, aTOXTypes.Count() );
- {
- for( sal_uInt16 n = pTOXTypes->Count(); n; )
- {
- (*pTOXTypes)[ --n ]->SetInDocDTOR();
- delete (*pTOXTypes)[ n ];
- }
- pTOXTypes->Remove( 0, pTOXTypes->Count() );
- }
- delete pDefTOXBases;
-
- // Any of the FrmFormats can still have indices registered.
- // These need to be destroyed now at the latest.
- pFrmFmtTbl->ForEach( &lcl_DelFmtIndizes, this );
- pSpzFrmFmtTbl->ForEach( &lcl_DelFmtIndizes, this );
- ((SwFrmFmts&)*pSectionFmtTbl).ForEach( &lcl_DelFmtIndizes, this );
-
- // The formattings that come hereafter depend on the default formattings.
- // [Destroy] these only after destroying the FmtIndices, because the content
- // of headers/footers has to be deleted as well. If in the headers/footers
- // there are still Flys registered at that point, we have a problem.
- // (This comment might have been translated incorrectly. Blame the bad
- // German original)
- aPageDescs.DeleteAndDestroy( 0, aPageDescs.Count() );
-
- // Delete content selections.
- // Don't wait for the SwNodes dtor to destroy them; so that Formats
- // do not have any dependencies anymore.
- m_pNodes->DelNodes( SwNodeIndex(*m_pNodes), m_pNodes->Count() );
- rUndoNodes.DelNodes( SwNodeIndex( rUndoNodes ), rUndoNodes.Count() );
-
- // Delete Formats, make it permanent some time in the future
-
- // Delete for Collections
- // So that we get rid of the dependencies
- pFtnInfo->ReleaseCollection();
- pEndNoteInfo->ReleaseCollection();
-
- OSL_ENSURE( pDfltTxtFmtColl == (*pTxtFmtCollTbl)[0],
- "Default-Text-Collection must always be at the start" );
-
- // Optimization: Based on the fact that Standard is always 2nd in the
- // array, we should delete it as the last. With this we avoid
- // remangling the Formats all the time!
- if( 2 < pTxtFmtCollTbl->Count() )
- pTxtFmtCollTbl->DeleteAndDestroy( 2, pTxtFmtCollTbl->Count()-2 );
- pTxtFmtCollTbl->DeleteAndDestroy( 1, pTxtFmtCollTbl->Count()-1 );
- delete pTxtFmtCollTbl;
-
- OSL_ENSURE( pDfltGrfFmtColl == (*pGrfFmtCollTbl)[0],
- "DefaultGrfCollection must always be at the start" );
-
- pGrfFmtCollTbl->DeleteAndDestroy( 1, pGrfFmtCollTbl->Count()-1 );
- // Is the result anyway - no _DEL array!
- // pGrfFmtCollTbl->Remove( 0, n );
- delete pGrfFmtCollTbl;
-
- /*
- * DefaultFormats and DefaultFormatCollections (FmtColl)
- * are at position 0 of their respective arrays.
- * In order to not be deleted by the array's dtor, we remove them
- * now.
- */
- pFrmFmtTbl->Remove( 0 );
- pCharFmtTbl->Remove( 0 );
-
- // Delete for pPrt
- DELETEZ( pPrt );
- DELETEZ( pNewDBMgr );
-
- // All Flys need to be destroyed before the Drawing Model,
- // because Flys can still contain DrawContacts, when no
- // Layout could be constructed due to a read error.
- pSpzFrmFmtTbl->DeleteAndDestroy( 0, pSpzFrmFmtTbl->Count() );
-
- // Only now destroy the Model, the drawing objects - which are also
- // contained in the Undo - need to remove their attributes from the
- // Model. Also, DrawContacts could exist before that.
- ReleaseDrawModel();
- // Destroy DrawModel before the LinkManager, because it's always set
- // in the DrawModel.
- DELETEZ( pLinkMgr );
-
- // Clear the Tables before deleting them, or we crash due to
- // definition dependencies.
- // We also convert the arrays (due to includes) to pointers.
- delete pFrmFmtTbl;
- delete pSpzFrmFmtTbl;
-
- delete pStyleAccess;
-
- delete pCharFmtTbl;
- delete pSectionFmtTbl;
- delete pTblFrmFmtTbl;
- delete pDfltTxtFmtColl;
- delete pDfltGrfFmtColl;
- delete pNumRuleTbl;
-
- {
- for ( boost::unordered_map< String, SwList*, StringHash >::iterator
- aListIter = maLists.begin();
- aListIter != maLists.end();
- ++aListIter )
- {
- delete (*aListIter).second;
- }
- maLists.clear();
- }
- maListStyleLists.clear();
-
- delete pPrtData;
- delete pNumberFormatter;
- delete pFtnInfo;
- delete pEndNoteInfo;
- delete pLineNumberInfo;
- delete pFtnIdxs;
- delete pFldTypes;
- delete pTOXTypes;
- delete pDocStat;
- delete pEmptyPageFmt;
- delete pColumnContFmt;
- delete pDfltCharFmt;
- delete pDfltFrmFmt;
- delete pLayoutCache;
- delete pVirDev;
-
- SfxItemPool::Free(mpAttrPool);
-}
-
-VirtualDevice& SwDoc::CreateVirtualDevice_() const
-{
- VirtualDevice* pNewVir = new VirtualDevice( 1 );
-
- pNewVir->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
-
- // #i60945# External leading compatibility for unix systems.
- if ( get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING ) )
- pNewVir->Compat_ZeroExtleadBug();
-
- MapMode aMapMode( pNewVir->GetMapMode() );
- aMapMode.SetMapUnit( MAP_TWIP );
- pNewVir->SetMapMode( aMapMode );
-
- const_cast<SwDoc*>(this)->setVirtualDevice( pNewVir, true, true );
- return *pVirDev;
-}
-
-SfxPrinter& SwDoc::CreatePrinter_() const
-{
- OSL_ENSURE( ! pPrt, "Do not call CreatePrinter_(), call getPrinter() instead" );
-
-#if OSL_DEBUG_LEVEL > 1
- OSL_FAIL( "Printer will be created!" );
-#endif
-
- // We create a default SfxPrinter.
- // The ItemSet is deleted by Sfx!
- SfxItemSet *pSet = new SfxItemSet( ((SwDoc*)this)->GetAttrPool(),
- FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
- SID_HTML_MODE, SID_HTML_MODE,
- SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
- SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
- 0 );
-
- SfxPrinter* pNewPrt = new SfxPrinter( pSet );
- const_cast<SwDoc*>(this)->setPrinter( pNewPrt, true, true );
- return *pPrt;
-}
-
-void SwDoc::SetDocShell( SwDocShell* pDSh )
-{
- if( pDocShell != pDSh )
- {
- if (pDocShell)
- {
- pDocShell->SetUndoManager(0);
- }
- pDocShell = pDSh;
- if (pDocShell)
- {
- pDocShell->SetUndoManager(& GetUndoManager());
- }
-
- pLinkMgr->SetPersist( pDocShell );
- if( pDrawModel )
- {
- ((SwDrawDocument*)pDrawModel)->SetObjectShell( pDocShell );
- pDrawModel->SetPersist( pDocShell );
- OSL_ENSURE( pDrawModel->GetPersist() == GetPersist(),
- "draw model's persist is out of sync" );
- }
- }
-}
-
-// Convenience method; to avoid excessive includes from docsh.hxx
-uno::Reference < embed::XStorage > SwDoc::GetDocStorage()
-{
- if( pDocShell )
- return pDocShell->GetStorage();
- if( pLinkMgr->GetPersist() )
- return pLinkMgr->GetPersist()->GetStorage();
- return NULL;
-}
-
-SfxObjectShell* SwDoc::GetPersist() const
-{
- return pDocShell ? pDocShell : pLinkMgr->GetPersist();
-}
-
-void SwDoc::ClearDoc()
-{
- GetIDocumentUndoRedo().DelAllUndoObj();
- ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
-
- // Deactivate Undo notification from the Draw
- if( pDrawModel )
- {
- DrawNotifyUndoHdl();
- ClrContourCache();
- }
-
- // if there are still FlyFrames dangling around, delete them too
- sal_uInt16 n;
- while ( 0 != (n = GetSpzFrmFmts()->Count()) )
- DelLayoutFmt((*pSpzFrmFmtTbl)[n-1]);
- OSL_ENSURE( !pDrawModel || !pDrawModel->GetPage(0)->GetObjCount(),
- "not all DrawObjects removed from the page" );
-
- pRedlineTbl->DeleteAndDestroy( 0, pRedlineTbl->Count() );
-
- delete pACEWord;
-
- // The BookMarks contain indices to the Content. These must be deleted
- // before deleting the Nodes.
- pMarkManager->clearAllMarks();
- InitTOXTypes();
-
- // create a dummy pagedesc for the layout
- sal_uInt16 nDummyPgDsc = MakePageDesc( String::CreateFromAscii( "?DUMMY?" ));
- SwPageDesc* pDummyPgDsc = aPageDescs[ nDummyPgDsc ];
-
- SwNodeIndex aSttIdx( *GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
- // create the first one over and over again (without Attribute/Templates etc.
- SwTxtNode* pFirstNd = GetNodes().MakeTxtNode( aSttIdx, pDfltTxtFmtColl );
-
- if( pCurrentView ) //swmod 071029//swmod 071225
- {
- // set the layout to the dummy pagedesc
- pFirstNd->SetAttr( SwFmtPageDesc( pDummyPgDsc ));
-
- SwPosition aPos( *pFirstNd, SwIndex( pFirstNd ));
- SwPaM const tmpPaM(aSttIdx, SwNodeIndex(GetNodes().GetEndOfContent()));
- ::PaMCorrAbs(tmpPaM, aPos);
- }
-
- GetNodes().Delete( aSttIdx,
- GetNodes().GetEndOfContent().GetIndex() - aSttIdx.GetIndex() );
-
- // #i62440#
- // destruction of numbering rules and creation of new outline rule
- // *after* the document nodes are deleted.
- pOutlineRule = NULL;
- pNumRuleTbl->DeleteAndDestroy( 0, pNumRuleTbl->Count() );
- // creation of new outline numbering rule
- pOutlineRule = new SwNumRule( String::CreateFromAscii( SwNumRule::GetOutlineRuleName() ),
- // #i89178#
- numfunc::GetDefaultPositionAndSpaceMode(),
- OUTLINE_RULE );
- AddNumRule(pOutlineRule);
- // Counting of phantoms depends on <IsOldNumbering()>
- pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) );
-
- // remove the dummy pagedec from the array and delete all the old ones
- aPageDescs.Remove( nDummyPgDsc );
- aPageDescs.DeleteAndDestroy( 0, aPageDescs.Count() );
-
- // Delete for Collections
- // So that we get rid of the dependencies
- pFtnInfo->ReleaseCollection();
- pEndNoteInfo->ReleaseCollection();
-
- // Optimization: Based on the fact that Standard is always 2nd in the
- // array, we should delete it as the last. With this we avoid
- // remangling the Formats all the time!
- if( 2 < pTxtFmtCollTbl->Count() )
- pTxtFmtCollTbl->DeleteAndDestroy( 2, pTxtFmtCollTbl->Count()-2 );
- pTxtFmtCollTbl->DeleteAndDestroy( 1, pTxtFmtCollTbl->Count()-1 );
- pGrfFmtCollTbl->DeleteAndDestroy( 1, pGrfFmtCollTbl->Count()-1 );
- pCharFmtTbl->DeleteAndDestroy( 1, pCharFmtTbl->Count()-1 );
-
- if( pCurrentView )
- {
- // search the FrameFormat of the root frm. This is not allowed to delete
- pFrmFmtTbl->Remove( pFrmFmtTbl->GetPos( pCurrentView->GetLayout()->GetFmt() ) );
- pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 );
- pFrmFmtTbl->Insert( pCurrentView->GetLayout()->GetFmt(), pFrmFmtTbl->Count() );
- }
- else //swmod 071029//swmod 071225
- pFrmFmtTbl->DeleteAndDestroy( 1, pFrmFmtTbl->Count()-1 );
-
- xForbiddenCharsTable.clear();
-
- pFldTypes->DeleteAndDestroy( INIT_FLDTYPES,
- pFldTypes->Count() - INIT_FLDTYPES );
-
- delete pNumberFormatter, pNumberFormatter = 0;
-
- GetPageDescFromPool( RES_POOLPAGE_STANDARD );
- pFirstNd->ChgFmtColl( GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
- nDummyPgDsc = aPageDescs.Count();
- aPageDescs.Insert( pDummyPgDsc, nDummyPgDsc );
- // set the layout back to the new standard pagedesc
- pFirstNd->ResetAllAttr();
- // delete now the dummy pagedesc
- DelPageDesc( nDummyPgDsc );
-}
-
-void SwDoc::SetPreViewPrtData( const SwPagePreViewPrtData* pNew )
-{
- if( pNew )
- {
- if( pPgPViewPrtData )
- *pPgPViewPrtData = *pNew;
- else
- pPgPViewPrtData = new SwPagePreViewPrtData( *pNew );
- }
- else if( pPgPViewPrtData )
- DELETEZ( pPgPViewPrtData );
- SetModified();
-}
-
-SwModify* SwDoc::GetUnoCallBack() const
-{
- return pUnoCallBack;
-}
-
-
-/** SwDoc:
- * Reading and writing of the layout cache.
- *--------------------------------------------------*/
-void SwDoc::ReadLayoutCache( SvStream& rStream )
-{
- if( !pLayoutCache )
- pLayoutCache = new SwLayoutCache();
- if( !pLayoutCache->IsLocked() )
- {
- pLayoutCache->GetLockCount() |= 0x8000;
- pLayoutCache->Read( rStream );
- pLayoutCache->GetLockCount() &= 0x7fff;
- }
-}
-
-void SwDoc::WriteLayoutCache( SvStream& rStream )
-{
- pLayoutCache->Write( rStream, *this );
-}
-
IGrammarContact* getGrammarContact( const SwTxtNode& rTxtNode )
{
const SwDoc* pDoc = rTxtNode.GetDoc();
@@ -910,318 +190,5 @@ IGrammarContact* getGrammarContact( const SwTxtNode& rTxtNode )
// #i42634# Moved common code of SwReader::Read() and SwDocShell::UpdateLinks()
// to new SwDoc::UpdateLinks():
-void SwDoc::UpdateLinks( sal_Bool bUI )
-{
- SfxObjectCreateMode eMode;
- sal_uInt16 nLinkMode = getLinkUpdateMode( true );
- if ( GetDocShell()) {
- sal_uInt16 nUpdateDocMode = GetDocShell()->GetUpdateDocMode();
- if( (nLinkMode != NEVER || document::UpdateDocMode::FULL_UPDATE == nUpdateDocMode) &&
- GetLinkManager().GetLinks().Count() &&
- SFX_CREATE_MODE_INTERNAL !=
- ( eMode = GetDocShell()->GetCreateMode()) &&
- SFX_CREATE_MODE_ORGANIZER != eMode &&
- SFX_CREATE_MODE_PREVIEW != eMode &&
- !GetDocShell()->IsPreview() )
- {
- ViewShell* pVSh = 0;
- sal_Bool bAskUpdate = nLinkMode == MANUAL;
- sal_Bool bUpdate = sal_True;
- switch(nUpdateDocMode)
- {
- case document::UpdateDocMode::NO_UPDATE: bUpdate = sal_False;break;
- case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = sal_False; break;
- case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = sal_True; break;
- }
- if( bUpdate && (bUI || !bAskUpdate) )
- {
- SfxMedium* pMedium = GetDocShell()->GetMedium();
- SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
- Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0;
- if( GetCurrentViewShell() && !GetEditShell( &pVSh ) && !pVSh ) //swmod 071108//swmod 071225
- {
- ViewShell aVSh( *this, 0, 0 );
-
- SET_CURR_SHELL( &aVSh );
- GetLinkManager().UpdateAllLinks( bAskUpdate , sal_True, sal_False, pDlgParent );
- }
- else
- GetLinkManager().UpdateAllLinks( bAskUpdate, sal_True, sal_False, pDlgParent );
- }
- }
- }
-
-}
-
-void SwDoc::SetApplyWorkaroundForB6375613( bool p_bApplyWorkaroundForB6375613 )
-{
- if ( mbApplyWorkaroundForB6375613 != p_bApplyWorkaroundForB6375613 )
- {
- mbApplyWorkaroundForB6375613 = p_bApplyWorkaroundForB6375613;
-
- uno::Reference< document::XDocumentInfoSupplier > xDoc(
- GetDocShell()->GetBaseModel(),
- uno::UNO_QUERY);
- if ( xDoc.is() )
- {
- uno::Reference< beans::XPropertyContainer > xDocInfo(
- xDoc->getDocumentInfo(),
- uno::UNO_QUERY );
- if ( xDocInfo.is() )
- {
- try
- {
- if ( mbApplyWorkaroundForB6375613 )
- {
- xDocInfo->addProperty(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WorkaroundForB6375613Applied")),
- beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::REMOVABLE,
- uno::makeAny( false ) );
- }
- else
- {
- xDocInfo->removeProperty( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WorkaroundForB6375613Applied")) );
- }
- }
- catch( uno::Exception& )
- {
- }
- }
- }
- }
-}
-
-::sfx2::IXmlIdRegistry&
-SwDoc::GetXmlIdRegistry()
-{
- // UGLY: this relies on SetClipBoard being called before GetXmlIdRegistry!
- if (!m_pXmlIdRegistry.get())
- {
- m_pXmlIdRegistry.reset( ::sfx2::createXmlIdRegistry( IsClipBoard() ) );
- }
- return *m_pXmlIdRegistry;
-}
-
-::sw::MetaFieldManager &
-SwDoc::GetMetaFieldManager()
-{
- return *m_pMetaFieldManager;
-}
-
-::sw::UndoManager &
-SwDoc::GetUndoManager()
-{
- return *m_pUndoManager;
-}
-
-::sw::UndoManager const&
-SwDoc::GetUndoManager() const
-{
- return *m_pUndoManager;
-}
-
-IDocumentUndoRedo &
-SwDoc::GetIDocumentUndoRedo()
-{
- return *m_pUndoManager;
-}
-
-IDocumentUndoRedo const&
-SwDoc::GetIDocumentUndoRedo() const
-{
- return *m_pUndoManager;
-}
-
-void SwDoc::InitTOXTypes()
-{
- ShellResource* pShellRes = ViewShell::GetShellRes();
- SwTOXType * pNew = new SwTOXType(TOX_CONTENT, pShellRes->aTOXContentName );
- pTOXTypes->Insert( pNew, pTOXTypes->Count() );
- pNew = new SwTOXType(TOX_INDEX, pShellRes->aTOXIndexName );
- pTOXTypes->Insert( pNew, pTOXTypes->Count() );
- pNew = new SwTOXType(TOX_USER, pShellRes->aTOXUserName );
- pTOXTypes->Insert( pNew, pTOXTypes->Count() );
- pNew = new SwTOXType(TOX_ILLUSTRATIONS, pShellRes->aTOXIllustrationsName );
- pTOXTypes->Insert( pNew, pTOXTypes->Count() );
- pNew = new SwTOXType(TOX_OBJECTS, pShellRes->aTOXObjectsName );
- pTOXTypes->Insert( pNew, pTOXTypes->Count() );
- pNew = new SwTOXType(TOX_TABLES, pShellRes->aTOXTablesName );
- pTOXTypes->Insert( pNew, pTOXTypes->Count() );
- pNew = new SwTOXType(TOX_AUTHORITIES, pShellRes->aTOXAuthoritiesName );
- pTOXTypes->Insert( pNew, pTOXTypes->Count() );
-}
-
-void SwDoc::ReplaceDefaults(const SwDoc& rSource)
-{
- // copy property defaults
- const sal_uInt16 aRangeOfDefaults[] =
- {
- RES_FRMATR_BEGIN, RES_FRMATR_END-1,
- RES_CHRATR_BEGIN, RES_CHRATR_END-1,
- RES_PARATR_BEGIN, RES_PARATR_END-1,
- RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
- RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
- 0
- };
-
- SfxItemSet aNewDefaults(GetAttrPool(), aRangeOfDefaults);
-
- sal_uInt16 nRange = 0;
- while (aRangeOfDefaults[nRange] != 0)
- {
- for (sal_uInt16 nWhich = aRangeOfDefaults[nRange];
- nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich)
- {
- const SfxPoolItem& rSourceAttr =
- rSource.mpAttrPool->GetDefaultItem(nWhich);
- if (rSourceAttr != mpAttrPool->GetDefaultItem(nWhich))
- aNewDefaults.Put(rSourceAttr);
- }
- nRange += 2;
- }
-
- if (aNewDefaults.Count())
- SetDefault(aNewDefaults);
-}
-
-void SwDoc::ReplaceCompatabilityOptions(const SwDoc& rSource)
-{
- n32DummyCompatabilityOptions1 = rSource.n32DummyCompatabilityOptions1;
- n32DummyCompatabilityOptions2 = rSource.n32DummyCompatabilityOptions2;
- mbParaSpaceMax = rSource.mbParaSpaceMax;
- mbParaSpaceMaxAtPages = rSource.mbParaSpaceMaxAtPages;
- mbTabCompat = rSource.mbTabCompat;
- mbUseVirtualDevice = rSource.mbUseVirtualDevice;
- mbAddExternalLeading = rSource.mbAddExternalLeading;
- mbOldLineSpacing = rSource.mbOldLineSpacing;
- mbAddParaSpacingToTableCells = rSource.mbAddParaSpacingToTableCells;
- mbUseFormerObjectPos = rSource.mbUseFormerObjectPos;
- mbUseFormerTextWrapping = rSource.mbUseFormerTextWrapping;
- mbConsiderWrapOnObjPos = rSource.mbConsiderWrapOnObjPos;
- mbAddFlyOffsets = rSource.mbAddFlyOffsets;
- mbOldNumbering = rSource.mbOldNumbering;
- mbUseHiResolutionVirtualDevice = rSource.mbUseHiResolutionVirtualDevice;
- mbIgnoreFirstLineIndentInNumbering = rSource.mbIgnoreFirstLineIndentInNumbering;
- mbDoNotJustifyLinesWithManualBreak = rSource.mbDoNotJustifyLinesWithManualBreak;
- mbDoNotResetParaAttrsForNumFont = rSource.mbDoNotResetParaAttrsForNumFont;
- mbOutlineLevelYieldsOutlineRule = rSource.mbOutlineLevelYieldsOutlineRule;
- mbTableRowKeep = rSource.mbTableRowKeep;
- mbIgnoreTabsAndBlanksForLineCalculation = rSource.mbIgnoreTabsAndBlanksForLineCalculation;
- mbDoNotCaptureDrawObjsOnPage = rSource.mbDoNotCaptureDrawObjsOnPage;
- mbClipAsCharacterAnchoredWriterFlyFrames = rSource.mbClipAsCharacterAnchoredWriterFlyFrames;
- mbUnixForceZeroExtLeading = rSource.mbUnixForceZeroExtLeading;
- mbOldPrinterMetrics = rSource.mbOldPrinterMetrics;
- mbTabRelativeToIndent = rSource.mbTabRelativeToIndent;
- mbTabAtLeftIndentForParagraphsInList = rSource.mbTabAtLeftIndentForParagraphsInList;
-}
-
-SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
-{
- SwDoc* pRet = new SwDoc;
-
- // we have to use pointer here, since the callee has to decide whether
- // SfxObjectShellLock or SfxObjectShellRef should be used sometimes the
- // object will be returned with refcount set to 0 ( if no DoInitNew is done )
- SfxObjectShell* pRetShell = new SwDocShell( pRet, SFX_CREATE_MODE_STANDARD );
- if( bCallInitNew )
- {
- // it could happen that DoInitNew creates model, that increases the refcount of the object
- pRetShell->DoInitNew();
- }
-
- pRet->acquire();
-
- pRet->ReplaceDefaults(*this);
-
- pRet->ReplaceCompatabilityOptions(*this);
-
- pRet->ReplaceStyles(*this);
-
- // copy content
- pRet->Paste( *this );
-
- // remove the temporary shell if it is there as it was done before
- pRet->SetTmpDocShell( (SfxObjectShell*)NULL );
-
- pRet->release();
-
- return pRetShell;
-}
-
-/*-------------------------------------------------------------------------
- copy document content - code from SwFEShell::Paste( SwDoc* , sal_Bool )
- -----------------------------------------------------------------------*/
-void SwDoc::Paste( const SwDoc& rSource )
-{
- // this has to be empty const sal_uInt16 nStartPageNumber = GetPhyPageNum();
- // until the end of the NodesArray
- SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 2 );
- SwPaM aCpyPam( aSourceIdx ); //DocStart
- SwNodeIndex aTargetIdx( GetNodes().GetEndOfExtras(), 2 );
- SwPaM aInsertPam( aTargetIdx ); //replaces PCURCRSR from SwFEShell::Paste()
-
-
- aCpyPam.SetMark();
- aCpyPam.Move( fnMoveForward, fnGoDoc );
-
- this->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL );
- this->LockExpFlds();
-
- {
- SwPosition& rInsPos = *aInsertPam.GetPoint();
- //find out if the clipboard document starts with a table
- bool bStartWithTable = 0 != aCpyPam.Start()->nNode.GetNode().FindTableNode();
- SwPosition aInsertPosition( rInsPos );
-
- {
- SwNodeIndex aIndexBefore(rInsPos.nNode);
-
- aIndexBefore--;
-
- rSource.CopyRange( aCpyPam, rInsPos, true );
-
- {
- aIndexBefore++;
- SwPaM aPaM(SwPosition(aIndexBefore),
- SwPosition(rInsPos.nNode));
-
- MakeUniqueNumRules(aPaM);
- }
- }
-
- //TODO: Is this necessary here? SaveTblBoxCntnt( &rInsPos );
- if(/*bIncludingPageFrames && */bStartWithTable)
- {
- //remove the paragraph in front of the table
- SwPaM aPara(aInsertPosition);
- this->DelFullPara(aPara);
- }
- //additionally copy page bound frames
- if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->Count() )
- {
- for ( sal_uInt16 i = 0; i < rSource.GetSpzFrmFmts()->Count(); ++i )
- {
- sal_Bool bInsWithFmt = sal_True;
- const SwFrmFmt& rCpyFmt = *(*rSource.GetSpzFrmFmts())[i];
- if( bInsWithFmt )
- {
- SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
- if (FLY_AT_PAGE == aAnchor.GetAnchorId())
- {
- aAnchor.SetPageNum( aAnchor.GetPageNum() /*+ nStartPageNumber - */);
- }
- else
- continue;
- this->CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
- }
- }
- }
- }
-
- this->GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL );
-
- UnlockExpFlds();
- UpdateFlds(NULL, false);
-}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index ae671ba0e066..03e937283607 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -158,90 +158,6 @@ TYPEINIT1(SwRedlineHint, SfxHint);
SV_IMPL_OP_PTRARR_SORT( _SwRedlineTbl, SwRedlinePtr )
-RedlineMode_t SwDoc::GetRedlineMode() const
-{
- return eRedlineMode;
-}
-
-void SwDoc::SetRedlineMode( RedlineMode_t eMode )
-{
- if( eRedlineMode != eMode )
- {
- if( (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) != (nsRedlineMode_t::REDLINE_SHOW_MASK & eMode)
- || 0 == (nsRedlineMode_t::REDLINE_SHOW_MASK & eMode) )
- {
- bool bSaveInXMLImportFlag = IsInXMLImport();
- SetInXMLImport( false );
- // and then hide/display everything
- void (SwRedline::*pFnc)( sal_uInt16 ) = 0;
-
- switch( nsRedlineMode_t::REDLINE_SHOW_MASK & eMode )
- {
- case nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE :
- pFnc = &SwRedline::Show;
- break;
- case nsRedlineMode_t::REDLINE_SHOW_INSERT:
- pFnc = &SwRedline::Hide;
- break;
- case nsRedlineMode_t::REDLINE_SHOW_DELETE:
- pFnc = &SwRedline::ShowOriginal;
- break;
-
- default:
- pFnc = &SwRedline::Hide;
- eMode = (RedlineMode_t)(eMode | nsRedlineMode_t::REDLINE_SHOW_INSERT);
- break;
- }
-
- _CHECK_REDLINE( this )
-
- if( pFnc )
- for( sal_uInt16 nLoop = 1; nLoop <= 2; ++nLoop )
- for( sal_uInt16 i = 0; i < pRedlineTbl->Count(); ++i )
- ((*pRedlineTbl)[ i ]->*pFnc)( nLoop );
- _CHECK_REDLINE( this )
- SetInXMLImport( bSaveInXMLImportFlag );
- }
- eRedlineMode = eMode;
- SetModified();
- }
-}
-
-bool SwDoc::IsRedlineOn() const
-{
- return IDocumentRedlineAccess::IsRedlineOn(eRedlineMode);
-}
-
-bool SwDoc::IsIgnoreRedline() const
-{
- return (nsRedlineMode_t::REDLINE_IGNORE & eRedlineMode);
-}
-
-void SwDoc::SetRedlineMode_intern(RedlineMode_t eMode)
-{
- eRedlineMode = eMode;
-}
-
-const SwRedlineTbl& SwDoc::GetRedlineTbl() const
-{
- return *pRedlineTbl;
-}
-
-bool SwDoc::IsRedlineMove() const
-{
- return mbIsRedlineMove;
-}
-
-void SwDoc::SetRedlineMove(bool bFlag)
-{
- mbIsRedlineMove = bFlag;
-}
-
-const uno::Sequence <sal_Int8>& SwDoc::GetRedlinePassword() const
-{
- return aRedlinePasswd;
-}
-
inline bool IsPrevPos( const SwPosition rPos1, const SwPosition rPos2 )
{
const SwCntntNode* pCNd;
@@ -305,1281 +221,6 @@ Behaviour of Delete-Redline:
the Delete
*/
-bool SwDoc::AppendRedline( SwRedline* pNewRedl, bool bCallDelete )
-{
- bool bError = true;
- _CHECK_REDLINE( this )
-
- if( IsRedlineOn() && !IsShowOriginal( eRedlineMode ) &&
- pNewRedl->GetAuthorString().Len() )
- {
- pNewRedl->InvalidateRange();
-
- if( mbIsAutoFmtRedline )
- {
- pNewRedl->SetAutoFmtFlag();
- if( pAutoFmtRedlnComment && pAutoFmtRedlnComment->Len() )
- {
- pNewRedl->SetComment( *pAutoFmtRedlnComment );
- pNewRedl->SetSeqNo( nAutoFmtRedlnCommentNo );
- }
- }
-
- SwPosition* pStt = pNewRedl->Start(),
- * pEnd = pStt == pNewRedl->GetPoint() ? pNewRedl->GetMark()
- : pNewRedl->GetPoint();
- {
- SwTxtNode* pTxtNode = pStt->nNode.GetNode().GetTxtNode();
- if( pTxtNode == NULL )
- {
- if( pStt->nContent > 0 )
- {
- OSL_ENSURE( false, "Redline start: non-text-node with content" );
- pStt->nContent = 0;
- }
- }
- else
- {
- if( pStt->nContent > pTxtNode->Len() )
- {
- OSL_ENSURE( false, "Redline start: index behind text" );
- pStt->nContent = pTxtNode->Len();
- }
- }
- pTxtNode = pEnd->nNode.GetNode().GetTxtNode();
- if( pTxtNode == NULL )
- {
- if( pEnd->nContent > 0 )
- {
- OSL_ENSURE( false, "Redline end: non-text-node with content" );
- pEnd->nContent = 0;
- }
- }
- else
- {
- if( pEnd->nContent > pTxtNode->Len() )
- {
- OSL_ENSURE( false, "Redline end: index behind text" );
- pEnd->nContent = pTxtNode->Len();
- }
- }
- }
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- { // Do not insert empty redlines
- delete pNewRedl;
- return sal_False;
- }
- sal_Bool bCompress = sal_False;
- sal_uInt16 n = 0;
- // look up the first Redline for the starting position
- if( !GetRedline( *pStt, &n ) && n )
- --n;
- bool bDec = false;
-
- for( ; pNewRedl && n < pRedlineTbl->Count(); bDec ? n : ++n )
- {
- bDec = false;
-
- SwRedline* pRedl = (*pRedlineTbl)[ n ];
- SwPosition* pRStt = pRedl->Start(),
- * pREnd = pRStt == pRedl->GetPoint() ? pRedl->GetMark()
- : pRedl->GetPoint();
-
- // #i8518# remove empty redlines while we're at it
- if( ( *pRStt == *pREnd ) &&
- ( pRedl->GetContentIdx() == NULL ) )
- {
- pRedlineTbl->DeleteAndDestroy(n);
- continue;
- }
-
- SwComparePosition eCmpPos = ComparePosition( *pStt, *pEnd, *pRStt, *pREnd );
-
- switch( pNewRedl->GetType() )
- {
- case nsRedlineType_t::REDLINE_INSERT:
- switch( pRedl->GetType() )
- {
- case nsRedlineType_t::REDLINE_INSERT:
- if( pRedl->IsOwnRedline( *pNewRedl ) )
- {
- bool bDelete = false;
-
- // Merge if applicable?
- if( (( POS_BEHIND == eCmpPos &&
- IsPrevPos( *pREnd, *pStt ) ) ||
- ( POS_COLLIDE_START == eCmpPos ) ||
- ( POS_OVERLAP_BEHIND == eCmpPos ) ) &&
- pRedl->CanCombine( *pNewRedl ) &&
- ( n+1 >= pRedlineTbl->Count() ||
- ( *(*pRedlineTbl)[ n+1 ]->Start() >= *pEnd &&
- *(*pRedlineTbl)[ n+1 ]->Start() != *pREnd ) ) )
- {
- pRedl->SetEnd( *pEnd, pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- }
-
- bError = false;
- bDelete = true;
- }
- else if( (( POS_BEFORE == eCmpPos &&
- IsPrevPos( *pEnd, *pRStt ) ) ||
- ( POS_COLLIDE_END == eCmpPos ) ||
- ( POS_OVERLAP_BEFORE == eCmpPos ) ) &&
- pRedl->CanCombine( *pNewRedl ) &&
- ( !n ||
- *(*pRedlineTbl)[ n-1 ]->End() != *pRStt ))
- {
- pRedl->SetStart( *pStt, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
-
- bError = false;
- bDelete = true;
- }
- else if ( POS_OUTSIDE == eCmpPos )
- {
- // own insert-over-insert redlines:
- // just scrap the inside ones
- pRedlineTbl->Remove( n );
- bDec = true;
- }
- else if( POS_OVERLAP_BEHIND == eCmpPos )
- {
- *pStt = *pREnd;
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- bDelete = true;
- }
- else if( POS_OVERLAP_BEFORE == eCmpPos )
- {
- *pEnd = *pRStt;
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- bDelete = true;
- }
- else if( POS_INSIDE == eCmpPos || POS_EQUAL == eCmpPos)
- bDelete = true;
-
- if( bDelete )
- {
- delete pNewRedl, pNewRedl = 0;
- bCompress = sal_True;
- }
- }
- else if( POS_INSIDE == eCmpPos )
- {
- // split up
- if( *pEnd != *pREnd )
- {
- SwRedline* pCpy = new SwRedline( *pRedl );
- pCpy->SetStart( *pEnd );
- pRedlineTbl->Insert( pCpy );
- }
- pRedl->SetEnd( *pStt, pREnd );
- if( ( *pStt == *pRStt ) &&
- ( pRedl->GetContentIdx() == NULL ) )
- {
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- }
- }
- else if ( POS_OUTSIDE == eCmpPos )
- {
- // handle overlapping redlines in broken documents
-
- // split up the new redline, since it covers the
- // existing redline. Insert the first part, and
- // progress with the remainder as usual
- SwRedline* pSplit = new SwRedline( *pNewRedl );
- pSplit->SetEnd( *pRStt );
- pNewRedl->SetStart( *pREnd );
- pRedlineTbl->Insert( pSplit );
- if( *pStt == *pEnd && pNewRedl->GetContentIdx() == NULL )
- {
- delete pNewRedl;
- pNewRedl = 0;
- bCompress = true;
- }
- }
- else if ( POS_OVERLAP_BEHIND == eCmpPos )
- {
- // handle overlapping redlines in broken documents
- pNewRedl->SetStart( *pREnd );
- }
- else if ( POS_OVERLAP_BEFORE == eCmpPos )
- {
- // handle overlapping redlines in broken documents
- *pEnd = *pRStt;
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- {
- delete pNewRedl;
- pNewRedl = 0;
- bCompress = true;
- }
- }
- break;
- case nsRedlineType_t::REDLINE_DELETE:
- if( POS_INSIDE == eCmpPos )
- {
- // split up
- if( *pEnd != *pREnd )
- {
- SwRedline* pCpy = new SwRedline( *pRedl );
- pCpy->SetStart( *pEnd );
- pRedlineTbl->Insert( pCpy );
- }
- pRedl->SetEnd( *pStt, pREnd );
- if( ( *pStt == *pRStt ) &&
- ( pRedl->GetContentIdx() == NULL ) )
- {
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- }
- }
- else if ( POS_OUTSIDE == eCmpPos )
- {
- // handle overlapping redlines in broken documents
-
- // split up the new redline, since it covers the
- // existing redline. Insert the first part, and
- // progress with the remainder as usual
- SwRedline* pSplit = new SwRedline( *pNewRedl );
- pSplit->SetEnd( *pRStt );
- pNewRedl->SetStart( *pREnd );
- pRedlineTbl->Insert( pSplit );
- if( *pStt == *pEnd && pNewRedl->GetContentIdx() == NULL )
- {
- delete pNewRedl;
- pNewRedl = 0;
- bCompress = true;
- }
- }
- else if ( POS_EQUAL == eCmpPos )
- {
- // handle identical redlines in broken documents
- // delete old (delete) redline
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else if ( POS_OVERLAP_BEHIND == eCmpPos )
- { // Another workaround for broken redlines
- pNewRedl->SetStart( *pREnd );
- }
- break;
- case nsRedlineType_t::REDLINE_FORMAT:
- switch( eCmpPos )
- {
- case POS_OVERLAP_BEFORE:
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- bDec = true;
- break;
-
- case POS_OVERLAP_BEHIND:
- pRedl->SetEnd( *pStt, pREnd );
- if( *pStt == *pRStt && pRedl->GetContentIdx() == NULL )
- {
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- break;
-
- case POS_EQUAL:
- case POS_OUTSIDE:
- // Overlaps the current one completely or has the
- // same dimension, delete the old one
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- break;
-
- case POS_INSIDE:
- // Overlaps the current one completely,
- // split or shorten the new one
- if( *pEnd != *pREnd )
- {
- if( *pEnd != *pRStt )
- {
- SwRedline* pNew = new SwRedline( *pRedl );
- pNew->SetStart( *pEnd );
- pRedl->SetEnd( *pStt, pREnd );
- if( *pStt == *pRStt && pRedl->GetContentIdx() == NULL )
- pRedlineTbl->DeleteAndDestroy( n );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- }
- else
- pRedl->SetEnd( *pStt, pREnd );
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- break;
-
- case nsRedlineType_t::REDLINE_DELETE:
- switch( pRedl->GetType() )
- {
- case nsRedlineType_t::REDLINE_DELETE:
- switch( eCmpPos )
- {
- case POS_OUTSIDE:
- {
- // Overlaps the current one completely,
- // split the new one
- if( *pEnd != *pREnd )
- {
- SwRedline* pNew = new SwRedline( *pNewRedl );
- pNew->SetStart( *pREnd );
- pNewRedl->SetEnd( *pRStt, pEnd );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- else
- pNewRedl->SetEnd( *pRStt, pEnd );
- }
- break;
-
- case POS_INSIDE:
- case POS_EQUAL:
- delete pNewRedl, pNewRedl = 0;
- bCompress = sal_True;
- break;
-
- case POS_OVERLAP_BEFORE:
- case POS_OVERLAP_BEHIND:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
-// 1 == pRedl->GetStackCount() &&
- pRedl->CanCombine( *pNewRedl ))
- {
- // If that's the case we can merge it, meaning
- // the new one covers this well
- if( POS_OVERLAP_BEHIND == eCmpPos )
- pNewRedl->SetStart( *pRStt, pStt );
- else
- pNewRedl->SetEnd( *pREnd, pEnd );
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else if( POS_OVERLAP_BEHIND == eCmpPos )
- pNewRedl->SetStart( *pREnd, pStt );
- else
- pNewRedl->SetEnd( *pRStt, pEnd );
- break;
-
- case POS_COLLIDE_START:
- case POS_COLLIDE_END:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ) )
- {
- if( IsHideChanges( eRedlineMode ))
- {
- // Before we can merge, we make it visible!
- // We insert temporarily so that pNew is
- // also dealt with when moving the indices.
- pRedlineTbl->SavePtrInArr( pNewRedl );
- pRedl->Show();
- pRedlineTbl->Remove( pRedlineTbl->GetPos(pNewRedl ));
- pRStt = pRedl->Start();
- pREnd = pRedl->End();
- }
-
- // If that's the case we can merge it, meaning
- // the new one covers this well
- if( POS_COLLIDE_START == eCmpPos )
- pNewRedl->SetStart( *pRStt, pStt );
- else
- pNewRedl->SetEnd( *pREnd, pEnd );
-
- // delete current (below), and restart process with
- // previous
- sal_uInt16 nToBeDeleted = n;
- bDec = true;
-
- if( *(pNewRedl->Start()) <= *pREnd )
- {
- // Whoooah, we just extended the new 'redline'
- // beyond previous redlines, so better start
- // again. Of course this is not supposed to
- // happen, and in an ideal world it doesn't,
- // but unfortunately this code is buggy and
- // totally rotten so it does happen and we
- // better fix it.
- n = 0;
- bDec = true;
- }
-
- pRedlineTbl->DeleteAndDestroy( nToBeDeleted );
- }
- break;
- default:
- break;
- }
- break;
-
- case nsRedlineType_t::REDLINE_INSERT:
- {
- // b62341295: Do not throw away redlines
- // even if they are not allowed to be combined
- RedlineMode_t eOld = eRedlineMode;
- if( !( eOld & nsRedlineMode_t::REDLINE_DONTCOMBINE_REDLINES ) &&
- pRedl->IsOwnRedline( *pNewRedl ) )
- {
-
- // Set to NONE, so that the Delete::Redo merges the Redline data correctly!
- // The ShowMode needs to be retained!
- eRedlineMode = (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE));
- switch( eCmpPos )
- {
- case POS_EQUAL:
- bCompress = sal_True;
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- // no break!
-
- case POS_INSIDE:
- if( bCallDelete )
- {
- eRedlineMode = (RedlineMode_t)(eRedlineMode | nsRedlineMode_t::REDLINE_IGNOREDELETE_REDLINES);
-
- // DeleteAndJoin does not yield the
- // desired result if there is no paragraph to
- // join with, i.e. at the end of the document.
- // For this case, we completely delete the
- // paragraphs (if, of course, we also start on
- // a paragraph boundary).
- if( (pStt->nContent == 0) &&
- pEnd->nNode.GetNode().IsEndNode() )
- {
- pEnd->nNode--;
- pEnd->nContent.Assign(
- pEnd->nNode.GetNode().GetTxtNode(), 0);
- DelFullPara( *pNewRedl );
- }
- else
- DeleteAndJoin( *pNewRedl );
-
- bCompress = sal_True;
- }
- delete pNewRedl, pNewRedl = 0;
- break;
-
- case POS_OUTSIDE:
- {
- pRedlineTbl->Remove( n );
- bDec = true;
- // We insert temporarily so that pNew is
- // also dealt with when moving the indices.
- if( bCallDelete )
- {
- pRedlineTbl->SavePtrInArr( pNewRedl );
- DeleteAndJoin( *pRedl );
- sal_uInt16 nFnd = pRedlineTbl->GetPos(pNewRedl );
- if( USHRT_MAX != nFnd )
- pRedlineTbl->Remove( nFnd );
- else
- pNewRedl = 0;
- }
- delete pRedl;
- }
- break;
-
- case POS_OVERLAP_BEFORE:
- {
- SwPaM aPam( *pRStt, *pEnd );
-
- if( *pEnd == *pREnd )
- pRedlineTbl->DeleteAndDestroy( n );
- else
- {
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- }
-
- if( bCallDelete )
- {
- // We insert temporarily so that pNew is
- // also dealt with when moving the indices.
- pRedlineTbl->SavePtrInArr( pNewRedl );
- DeleteAndJoin( aPam );
- sal_uInt16 nFnd = pRedlineTbl->GetPos(pNewRedl );
- if( USHRT_MAX != nFnd )
- pRedlineTbl->Remove( nFnd );
- else
- pNewRedl = 0;
- n = 0; // re-initialize
- }
- bDec = true;
- }
- break;
-
- case POS_OVERLAP_BEHIND:
- {
- SwPaM aPam( *pStt, *pREnd );
-
- if( *pStt == *pRStt )
- {
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- else
- pRedl->SetEnd( *pStt, pREnd );
-
- if( bCallDelete )
- {
- // We insert temporarily so that pNew is
- // also dealt with when moving the indices.
- pRedlineTbl->SavePtrInArr( pNewRedl );
- DeleteAndJoin( aPam );
- sal_uInt16 nFnd = pRedlineTbl->GetPos(pNewRedl );
- if( USHRT_MAX != nFnd )
- pRedlineTbl->Remove( nFnd );
- else
- pNewRedl = 0;
- n = 0; // re-initialize
- bDec = true;
- }
- }
- break;
- default:
- break;
- }
-
- eRedlineMode = eOld;
- }
- else
- {
- // it may be necessary to split the existing redline in
- // two. In this case, pRedl will be changed to cover
- // only part of it's former range, and pNew will cover
- // the remainder.
- SwRedline* pNew = 0;
-
- switch( eCmpPos )
- {
- case POS_EQUAL:
- {
- pRedl->PushData( *pNewRedl );
- delete pNewRedl, pNewRedl = 0;
- if( IsHideChanges( eRedlineMode ))
- pRedl->Hide();
- bCompress = sal_True;
- }
- break;
-
- case POS_INSIDE:
- {
- if( *pRStt == *pStt )
- {
- // #i97421#
- // redline w/out extent loops
- if (*pStt != *pEnd)
- {
- pNewRedl->PushData( *pRedl, sal_False );
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- bDec = true;
- }
- }
- else
- {
- pNewRedl->PushData( *pRedl, sal_False );
- if( *pREnd != *pEnd )
- {
- pNew = new SwRedline( *pRedl );
- pNew->SetStart( *pEnd );
- }
- pRedl->SetEnd( *pStt, pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- }
- }
- }
- break;
-
- case POS_OUTSIDE:
- {
- pRedl->PushData( *pNewRedl );
- if( *pEnd == *pREnd )
- pNewRedl->SetEnd( *pRStt, pEnd );
- else
- {
- pNew = new SwRedline( *pNewRedl );
- pNew->SetEnd( *pRStt );
- pNewRedl->SetStart( *pREnd, pStt );
- }
- bCompress = sal_True;
- }
- break;
-
- case POS_OVERLAP_BEFORE:
- {
- if( *pEnd == *pREnd )
- {
- pRedl->PushData( *pNewRedl );
- pNewRedl->SetEnd( *pRStt, pEnd );
- if( IsHideChanges( eRedlineMode ))
- {
- pRedlineTbl->SavePtrInArr( pNewRedl );
- pRedl->Hide();
- pRedlineTbl->Remove(
- pRedlineTbl->GetPos(pNewRedl ));
- }
- }
- else
- {
- pNew = new SwRedline( *pRedl );
- pNew->PushData( *pNewRedl );
- pNew->SetEnd( *pEnd );
- pNewRedl->SetEnd( *pRStt, pEnd );
- pRedl->SetStart( *pNew->End(), pRStt ) ;
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- bDec = true;
- }
- }
- break;
-
- case POS_OVERLAP_BEHIND:
- {
- if( *pStt == *pRStt )
- {
- pRedl->PushData( *pNewRedl );
- pNewRedl->SetStart( *pREnd, pStt );
- if( IsHideChanges( eRedlineMode ))
- {
- pRedlineTbl->SavePtrInArr( pNewRedl );
- pRedl->Hide();
- pRedlineTbl->Remove(
- pRedlineTbl->GetPos(pNewRedl ));
- }
- }
- else
- {
- pNew = new SwRedline( *pRedl );
- pNew->PushData( *pNewRedl );
- pNew->SetStart( *pStt );
- pNewRedl->SetStart( *pREnd, pStt );
- pRedl->SetEnd( *pNew->Start(), pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- }
- }
- }
- break;
- default:
- break;
- }
-
- // insert the pNew part (if it exists)
- if( pNew )
- {
- pRedlineTbl->Insert( pNew );
-
- // pNew must be deleted if Insert() wasn't
- // successful. But that can't happen, since pNew is
- // part of the original pRedl redline.
- // OSL_ENSURE( bRet, "Can't insert existing redline?" );
-
- // restart (now with pRedl being split up)
- n = 0;
- bDec = true;
- }
- }
- }
- break;
-
- case nsRedlineType_t::REDLINE_FORMAT:
- switch( eCmpPos )
- {
- case POS_OVERLAP_BEFORE:
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- bDec = true;
- break;
-
- case POS_OVERLAP_BEHIND:
- pRedl->SetEnd( *pStt, pREnd );
- break;
-
- case POS_EQUAL:
- case POS_OUTSIDE:
- // Overlaps the current one completely or has the
- // same dimension, delete the old one
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- break;
-
- case POS_INSIDE:
- // Overlaps the current one completely,
- // split or shorten the new one
- if( *pEnd != *pREnd )
- {
- if( *pEnd != *pRStt )
- {
- SwRedline* pNew = new SwRedline( *pRedl );
- pNew->SetStart( *pEnd );
- pRedl->SetEnd( *pStt, pREnd );
- if( ( *pStt == *pRStt ) &&
- ( pRedl->GetContentIdx() == NULL ) )
- pRedlineTbl->DeleteAndDestroy( n );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- }
- else
- pRedl->SetEnd( *pStt, pREnd );
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- break;
-
- case nsRedlineType_t::REDLINE_FORMAT:
- switch( pRedl->GetType() )
- {
- case nsRedlineType_t::REDLINE_INSERT:
- case nsRedlineType_t::REDLINE_DELETE:
- switch( eCmpPos )
- {
- case POS_OVERLAP_BEFORE:
- pNewRedl->SetEnd( *pRStt, pEnd );
- break;
-
- case POS_OVERLAP_BEHIND:
- pNewRedl->SetStart( *pREnd, pStt );
- break;
-
- case POS_EQUAL:
- case POS_INSIDE:
- delete pNewRedl, pNewRedl = 0;
- break;
-
- case POS_OUTSIDE:
- // Overlaps the current one completely,
- // split or shorten the new one
- if( *pEnd != *pREnd )
- {
- if( *pEnd != *pRStt )
- {
- SwRedline* pNew = new SwRedline( *pNewRedl );
- pNew->SetStart( *pREnd );
- pNewRedl->SetEnd( *pRStt, pEnd );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- }
- else
- pNewRedl->SetEnd( *pRStt, pEnd );
- break;
- default:
- break;
- }
- break;
- case nsRedlineType_t::REDLINE_FORMAT:
- switch( eCmpPos )
- {
- case POS_OUTSIDE:
- case POS_EQUAL:
- {
- // Overlaps the current one completely or has the
- // same dimension, delete the old one
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- break;
-
- case POS_INSIDE:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ))
- // own one can be ignored completely
- delete pNewRedl, pNewRedl = 0;
-
- else if( *pREnd == *pEnd )
- // or else only shorten the current one
- pRedl->SetEnd( *pStt, pREnd );
- else if( *pRStt == *pStt )
- {
- // or else only shorten the current one
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl, n );
- bDec = true;
- }
- else
- {
- // If it lies completely within the current one
- // we need to split it
- SwRedline* pNew = new SwRedline( *pRedl );
- pNew->SetStart( *pEnd );
- pRedl->SetEnd( *pStt, pREnd );
- AppendRedline( pNew, bCallDelete );
- n = 0; // re-initialize
- bDec = true;
- }
- break;
-
- case POS_OVERLAP_BEFORE:
- case POS_OVERLAP_BEHIND:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ))
- {
- // If that's the case we can merge it, meaning
- // the new one covers this well
- if( POS_OVERLAP_BEHIND == eCmpPos )
- pNewRedl->SetStart( *pRStt, pStt );
- else
- pNewRedl->SetEnd( *pREnd, pEnd );
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = 0;
- }
- else if( POS_OVERLAP_BEHIND == eCmpPos )
- pNewRedl->SetStart( *pREnd, pStt );
- else
- pNewRedl->SetEnd( *pRStt, pEnd );
- break;
-
- case POS_COLLIDE_END:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ) && n &&
- *(*pRedlineTbl)[ n-1 ]->End() < *pStt )
- {
- // If that's the case we can merge it, meaning
- // the new one covers this well
- pNewRedl->SetEnd( *pREnd, pEnd );
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- break;
- case POS_COLLIDE_START:
- if( pRedl->IsOwnRedline( *pNewRedl ) &&
- pRedl->CanCombine( *pNewRedl ) &&
- n+1 < pRedlineTbl->Count() &&
- *(*pRedlineTbl)[ n+1 ]->Start() < *pEnd )
- {
- // If that's the case we can merge it, meaning
- // the new one covers this well
- pNewRedl->SetStart( *pRStt, pStt );
- pRedlineTbl->DeleteAndDestroy( n );
- bDec = true;
- }
- break;
- default:
- break;
- }
- break;
- default:
- break;
- }
- break;
-
-
- case nsRedlineType_t::REDLINE_FMTCOLL:
- // How should we behave here?
- // insert as is
- break;
- default:
- break;
- }
- }
-
- if( pNewRedl )
- {
- if( ( *pStt == *pEnd ) &&
- ( pNewRedl->GetContentIdx() == NULL ) )
- { // Do not insert empty redlines
- delete pNewRedl;
- pNewRedl = 0;
- }
- else
- pRedlineTbl->Insert( pNewRedl );
- }
-
- if( bCompress )
- CompressRedlines();
- }
- else
- {
- if( bCallDelete && nsRedlineType_t::REDLINE_DELETE == pNewRedl->GetType() )
- {
- RedlineMode_t eOld = eRedlineMode;
- // Set to NONE, so that the Delete::Redo merges the Redline data correctly!
- // The ShowMode needs to be retained!
- eRedlineMode = (RedlineMode_t)(eOld & ~(nsRedlineMode_t::REDLINE_ON | nsRedlineMode_t::REDLINE_IGNORE));
- DeleteAndJoin( *pNewRedl );
- eRedlineMode = eOld;
- }
- delete pNewRedl, pNewRedl = 0;
- }
- _CHECK_REDLINE( this )
-
- return ( 0 != pNewRedl ) || !bError;
-}
-
-void SwDoc::CompressRedlines()
-{
- _CHECK_REDLINE( this )
-
- void (SwRedline::*pFnc)(sal_uInt16) = 0;
- switch( nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode )
- {
- case nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE:
- pFnc = &SwRedline::Show;
- break;
- case nsRedlineMode_t::REDLINE_SHOW_INSERT:
- pFnc = &SwRedline::Hide;
- break;
- }
-
- // Try to merge identical ones
- for( sal_uInt16 n = 1; n < pRedlineTbl->Count(); ++n )
- {
- SwRedline* pPrev = (*pRedlineTbl)[ n-1 ],
- * pCur = (*pRedlineTbl)[ n ];
- const SwPosition* pPrevStt = pPrev->Start(),
- * pPrevEnd = pPrevStt == pPrev->GetPoint()
- ? pPrev->GetMark() : pPrev->GetPoint();
- const SwPosition* pCurStt = pCur->Start(),
- * pCurEnd = pCurStt == pCur->GetPoint()
- ? pCur->GetMark() : pCur->GetPoint();
- if( *pPrevEnd == *pCurStt && pPrev->CanCombine( *pCur ) &&
- pPrevStt->nNode.GetNode().StartOfSectionNode() ==
- pCurEnd->nNode.GetNode().StartOfSectionNode() &&
- !pCurEnd->nNode.GetNode().StartOfSectionNode()->IsTableNode() )
- {
- // we then can merge them
- pPrev->Show();
- pCur->Show();
-
- pPrev->SetEnd( *pCur->End() );
- pRedlineTbl->DeleteAndDestroy( n );
- --n;
- if( pFnc )
- (pPrev->*pFnc)(0);
- }
- }
- _CHECK_REDLINE( this )
-}
-
-bool SwDoc::SplitRedline( const SwPaM& rRange )
-{
- sal_Bool bChg = sal_False;
- sal_uInt16 n = 0;
- const SwPosition* pStt = rRange.Start(),
- * pEnd = pStt == rRange.GetPoint() ? rRange.GetMark()
- : rRange.GetPoint();
- GetRedline( *pStt, &n );
- for( ; n < pRedlineTbl->Count() ; ++n )
- {
- SwRedline* pTmp = (*pRedlineTbl)[ n ];
- SwPosition* pTStt = pTmp->Start(),
- * pTEnd = pTStt == pTmp->GetPoint() ? pTmp->GetMark()
- : pTmp->GetPoint();
- if( *pTStt <= *pStt && *pStt <= *pTEnd &&
- *pTStt <= *pEnd && *pEnd <= *pTEnd )
- {
- bChg = sal_True;
- int nn = 0;
- if( *pStt == *pTStt )
- nn += 1;
- if( *pEnd == *pTEnd )
- nn += 2;
-
- SwRedline* pNew = 0;
- switch( nn )
- {
- case 0:
- pNew = new SwRedline( *pTmp );
- pTmp->SetEnd( *pStt, pTEnd );
- pNew->SetStart( *pEnd );
- break;
-
- case 1:
- *pTStt = *pEnd;
- break;
-
- case 2:
- *pTEnd = *pStt;
- break;
-
- case 3:
- pTmp->InvalidateRange();
- pRedlineTbl->DeleteAndDestroy( n-- );
- pTmp = 0;
- break;
- }
- if( pTmp && !pTmp->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pTmp, n );
- }
- if( pNew )
- pRedlineTbl->Insert( pNew, n );
- }
- else if( *pEnd < *pTStt )
- break;
- }
- return bChg;
-}
-
-bool SwDoc::DeleteRedline( const SwPaM& rRange, bool bSaveInUndo,
- sal_uInt16 nDelType )
-{
- if( nsRedlineMode_t::REDLINE_IGNOREDELETE_REDLINES & eRedlineMode ||
- !rRange.HasMark() || *rRange.GetMark() == *rRange.GetPoint() )
- return sal_False;
-
- sal_Bool bChg = sal_False;
-
- if (bSaveInUndo && GetIDocumentUndoRedo().DoesUndo())
- {
- SwUndoRedline* pUndo = new SwUndoRedline( UNDO_REDLINE, rRange );
- if( pUndo->GetRedlSaveCount() )
- {
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
- else
- delete pUndo;
- }
-
- const SwPosition* pStt = rRange.Start(),
- * pEnd = pStt == rRange.GetPoint() ? rRange.GetMark()
- : rRange.GetPoint();
- sal_uInt16 n = 0;
- GetRedline( *pStt, &n );
- for( ; n < pRedlineTbl->Count() ; ++n )
- {
- SwRedline* pRedl = (*pRedlineTbl)[ n ];
- if( USHRT_MAX != nDelType && nDelType != pRedl->GetType() )
- continue;
-
- SwPosition* pRStt = pRedl->Start(),
- * pREnd = pRStt == pRedl->GetPoint() ? pRedl->GetMark()
- : pRedl->GetPoint();
- switch( ComparePosition( *pStt, *pEnd, *pRStt, *pREnd ) )
- {
- case POS_EQUAL:
- case POS_OUTSIDE:
- pRedl->InvalidateRange();
- pRedlineTbl->DeleteAndDestroy( n-- );
- bChg = sal_True;
- break;
-
- case POS_OVERLAP_BEFORE:
- pRedl->InvalidateRange();
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- --n;
- break;
-
- case POS_OVERLAP_BEHIND:
- pRedl->InvalidateRange();
- pRedl->SetEnd( *pStt, pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- --n;
- }
- break;
-
- case POS_INSIDE:
- {
- // this one needs to be splitted
- pRedl->InvalidateRange();
- if( *pRStt == *pStt )
- {
- pRedl->SetStart( *pEnd, pRStt );
- // re-insert
- pRedlineTbl->Remove( n );
- pRedlineTbl->Insert( pRedl );
- --n;
- }
- else
- {
- SwRedline* pCpy;
- if( *pREnd != *pEnd )
- {
- pCpy = new SwRedline( *pRedl );
- pCpy->SetStart( *pEnd );
- }
- else
- pCpy = 0;
- pRedl->SetEnd( *pStt, pREnd );
- if( !pRedl->HasValidRange() )
- {
- // re-insert
- pRedlineTbl->Remove( pRedlineTbl->GetPos( pRedl ));
- pRedlineTbl->Insert( pRedl );
- --n;
- }
- if( pCpy )
- pRedlineTbl->Insert( pCpy );
- }
- }
- break;
-
- case POS_COLLIDE_END:
- case POS_BEFORE:
- n = pRedlineTbl->Count();
- break;
- default:
- break;
- }
- }
-
- if( bChg )
- SetModified();
-
- return bChg;
-}
-
-bool SwDoc::DeleteRedline( const SwStartNode& rNode, bool bSaveInUndo,
- sal_uInt16 nDelType )
-{
- SwPaM aTemp(*rNode.EndOfSectionNode(), rNode);
- return DeleteRedline(aTemp, bSaveInUndo, nDelType);
-}
-
-sal_uInt16 SwDoc::GetRedlinePos( const SwNode& rNd, sal_uInt16 nType ) const
-{
- const sal_uLong nNdIdx = rNd.GetIndex();
- for( sal_uInt16 n = 0; n < pRedlineTbl->Count() ; ++n )
- {
- const SwRedline* pTmp = (*pRedlineTbl)[ n ];
- sal_uLong nPt = pTmp->GetPoint()->nNode.GetIndex(),
- nMk = pTmp->GetMark()->nNode.GetIndex();
- if( nPt < nMk ) { long nTmp = nMk; nMk = nPt; nPt = nTmp; }
-
- if( ( USHRT_MAX == nType || nType == pTmp->GetType()) &&
- nMk <= nNdIdx && nNdIdx <= nPt )
- return n;
-
- if( nMk > nNdIdx )
- break;
- }
- return USHRT_MAX;
-}
-
-const SwRedline* SwDoc::GetRedline( const SwPosition& rPos,
- sal_uInt16* pFndPos ) const
-{
- sal_uInt16 nO = pRedlineTbl->Count(), nM, nU = 0;
- if( nO > 0 )
- {
- nO--;
- while( nU <= nO )
- {
- nM = nU + ( nO - nU ) / 2;
- const SwRedline* pRedl = (*pRedlineTbl)[ nM ];
- const SwPosition* pStt = pRedl->Start();
- const SwPosition* pEnd = pStt == pRedl->GetPoint()
- ? pRedl->GetMark()
- : pRedl->GetPoint();
- if( pEnd == pStt
- ? *pStt == rPos
- : ( *pStt <= rPos && rPos < *pEnd ) )
- {
- while( nM && rPos == *(*pRedlineTbl)[ nM - 1 ]->End() &&
- rPos == *(*pRedlineTbl)[ nM - 1 ]->Start() )
- {
- --nM;
- pRedl = (*pRedlineTbl)[ nM ];
- }
- // if there are format and insert changes in the same position
- // show insert change first.
- // since the redlines are sorted by position, only check the redline
- // before and after the current redline
- if( nsRedlineType_t::REDLINE_FORMAT == pRedl->GetType() )
- {
- if( nM && rPos >= *(*pRedlineTbl)[ nM - 1 ]->Start() &&
- rPos <= *(*pRedlineTbl)[ nM - 1 ]->End() &&
- ( nsRedlineType_t::REDLINE_INSERT == (*pRedlineTbl)[ nM - 1 ]->GetType() ) )
- {
- --nM;
- pRedl = (*pRedlineTbl)[ nM ];
- }
- else if( ( nM + 1 ) <= nO && rPos >= *(*pRedlineTbl)[ nM + 1 ]->Start() &&
- rPos <= *(*pRedlineTbl)[ nM + 1 ]->End() &&
- ( nsRedlineType_t::REDLINE_INSERT == (*pRedlineTbl)[ nM + 1 ]->GetType() ) )
- {
- ++nM;
- pRedl = (*pRedlineTbl)[ nM ];
- }
- }
-
- if( pFndPos )
- *pFndPos = nM;
- return pRedl;
- }
- else if( *pEnd <= rPos )
- nU = nM + 1;
- else if( nM == 0 )
- {
- if( pFndPos )
- *pFndPos = nU;
- return 0;
- }
- else
- nO = nM - 1;
- }
- }
- if( pFndPos )
- *pFndPos = nU;
- return 0;
-}
-
typedef sal_Bool (*Fn_AcceptReject)( SwRedlineTbl& rArr, sal_uInt16& rPos,
sal_Bool bCallDelete,
const SwPosition* pSttRng,
@@ -2060,542 +701,6 @@ void lcl_AdjustRedlineRange( SwPaM& rPam )
}
-bool SwDoc::AcceptRedline( sal_uInt16 nPos, bool bCallDelete )
-{
- sal_Bool bRet = sal_False;
-
- // Switch to visible in any case
- if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
- (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
- SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
-
- SwRedline* pTmp = (*pRedlineTbl)[ nPos ];
- if( pTmp->HasMark() && pTmp->IsVisible() )
- {
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwRewriter aRewriter;
-
- aRewriter.AddRule(UNDO_ARG1, pTmp->GetDescr());
- GetIDocumentUndoRedo().StartUndo(UNDO_ACCEPT_REDLINE, &aRewriter);
- }
-
- int nLoopCnt = 2;
- sal_uInt16 nSeqNo = pTmp->GetSeqNo();
-
- do {
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwUndo *const pUndo( new SwUndoAcceptRedline(*pTmp) );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
-
- bRet |= lcl_AcceptRedline( *pRedlineTbl, nPos, bCallDelete );
-
- if( nSeqNo )
- {
- if( USHRT_MAX == nPos )
- nPos = 0;
- sal_uInt16 nFndPos = 2 == nLoopCnt
- ? pRedlineTbl->FindNextSeqNo( nSeqNo, nPos )
- : pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos );
- if( USHRT_MAX != nFndPos || ( 0 != ( --nLoopCnt ) &&
- USHRT_MAX != ( nFndPos =
- pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos ))) )
- pTmp = (*pRedlineTbl)[ nPos = nFndPos ];
- else
- nLoopCnt = 0;
- }
- else
- nLoopCnt = 0;
-
- } while( nLoopCnt );
-
- if( bRet )
- {
- CompressRedlines();
- SetModified();
- }
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
- }
- }
- return bRet;
-}
-
-bool SwDoc::AcceptRedline( const SwPaM& rPam, bool bCallDelete )
-{
- // Switch to visible in any case
- if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
- (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
- SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
-
- // The Selection is only in the ContentSection. If there are Redlines
- // to Non-ContentNodes before or after that, then the Selections
- // expand to them.
- SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
- lcl_AdjustRedlineRange( aPam );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().StartUndo( UNDO_ACCEPT_REDLINE, NULL );
- GetIDocumentUndoRedo().AppendUndo( new SwUndoAcceptRedline( aPam ));
- }
-
- int nRet = lcl_AcceptRejectRedl( lcl_AcceptRedline, *pRedlineTbl,
- bCallDelete, aPam );
- if( nRet > 0 )
- {
- CompressRedlines();
- SetModified();
- }
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- String aTmpStr;
-
- {
- SwRewriter aRewriter;
- aRewriter.AddRule(UNDO_ARG1, String::CreateFromInt32(nRet));
- aTmpStr = aRewriter.Apply(String(SW_RES(STR_N_REDLINES)));
- }
-
- SwRewriter aRewriter;
- aRewriter.AddRule(UNDO_ARG1, aTmpStr);
-
- GetIDocumentUndoRedo().EndUndo( UNDO_ACCEPT_REDLINE, &aRewriter );
- }
- return nRet != 0;
-}
-
-bool SwDoc::RejectRedline( sal_uInt16 nPos, bool bCallDelete )
-{
- sal_Bool bRet = sal_False;
-
- // Switch to visible in any case
- if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
- (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
- SetRedlineMode( (RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
-
- SwRedline* pTmp = (*pRedlineTbl)[ nPos ];
- if( pTmp->HasMark() && pTmp->IsVisible() )
- {
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwRewriter aRewriter;
-
- aRewriter.AddRule(UNDO_ARG1, pTmp->GetDescr());
- GetIDocumentUndoRedo().StartUndo(UNDO_REJECT_REDLINE, &aRewriter);
- }
-
- int nLoopCnt = 2;
- sal_uInt16 nSeqNo = pTmp->GetSeqNo();
-
- do {
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- SwUndo *const pUndo( new SwUndoRejectRedline( *pTmp ) );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- }
-
- bRet |= lcl_RejectRedline( *pRedlineTbl, nPos, bCallDelete );
-
- if( nSeqNo )
- {
- if( USHRT_MAX == nPos )
- nPos = 0;
- sal_uInt16 nFndPos = 2 == nLoopCnt
- ? pRedlineTbl->FindNextSeqNo( nSeqNo, nPos )
- : pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos );
- if( USHRT_MAX != nFndPos || ( 0 != ( --nLoopCnt ) &&
- USHRT_MAX != ( nFndPos =
- pRedlineTbl->FindPrevSeqNo( nSeqNo, nPos ))) )
- pTmp = (*pRedlineTbl)[ nPos = nFndPos ];
- else
- nLoopCnt = 0;
- }
- else
- nLoopCnt = 0;
-
- } while( nLoopCnt );
-
- if( bRet )
- {
- CompressRedlines();
- SetModified();
- }
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().EndUndo(UNDO_END, 0);
- }
- }
- return bRet;
-}
-
-bool SwDoc::RejectRedline( const SwPaM& rPam, bool bCallDelete )
-{
- // Switch to visible in any case
- if( (nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE) !=
- (nsRedlineMode_t::REDLINE_SHOW_MASK & eRedlineMode) )
- SetRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE | eRedlineMode));
-
- // The Selection is only in the ContentSection. If there are Redlines
- // to Non-ContentNodes before or after that, then the Selections
- // expand to them.
- SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
- lcl_AdjustRedlineRange( aPam );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().StartUndo( UNDO_REJECT_REDLINE, NULL );
- GetIDocumentUndoRedo().AppendUndo( new SwUndoRejectRedline(aPam) );
- }
-
- int nRet = lcl_AcceptRejectRedl( lcl_RejectRedline, *pRedlineTbl,
- bCallDelete, aPam );
- if( nRet > 0 )
- {
- CompressRedlines();
- SetModified();
- }
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- String aTmpStr;
-
- {
- SwRewriter aRewriter;
- aRewriter.AddRule(UNDO_ARG1, String::CreateFromInt32(nRet));
- aTmpStr = aRewriter.Apply(String(SW_RES(STR_N_REDLINES)));
- }
-
- SwRewriter aRewriter;
- aRewriter.AddRule(UNDO_ARG1, aTmpStr);
-
- GetIDocumentUndoRedo().EndUndo( UNDO_REJECT_REDLINE, &aRewriter );
- }
-
- return nRet != 0;
-}
-
-const SwRedline* SwDoc::SelNextRedline( SwPaM& rPam ) const
-{
- rPam.DeleteMark();
- rPam.SetMark();
-
- SwPosition& rSttPos = *rPam.GetPoint();
- SwPosition aSavePos( rSttPos );
- sal_Bool bRestart;
-
- // If the starting positon points to the last valid ContentNode,
- // we take the next Redline in any case.
- sal_uInt16 n = 0;
- const SwRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, sal_True );
- if( pFnd )
- {
- const SwPosition* pEnd = pFnd->End();
- if( !pEnd->nNode.GetNode().IsCntntNode() )
- {
- SwNodeIndex aTmp( pEnd->nNode );
- SwCntntNode* pCNd = GetNodes().GoPrevSection( &aTmp );
- if( !pCNd || ( aTmp == rSttPos.nNode &&
- pCNd->Len() == rSttPos.nContent.GetIndex() ))
- pFnd = 0;
- }
- if( pFnd )
- rSttPos = *pFnd->End();
- }
-
- do {
- bRestart = sal_False;
-
- for( ; !pFnd && n < pRedlineTbl->Count(); ++n )
- {
- pFnd = (*pRedlineTbl)[ n ];
- if( pFnd->HasMark() && pFnd->IsVisible() )
- {
- *rPam.GetMark() = *pFnd->Start();
- rSttPos = *pFnd->End();
- break;
- }
- else
- pFnd = 0;
- }
-
- if( pFnd )
- {
- // Merge all of the same type and author that are
- // consecutive into one Selection.
- const SwPosition* pPrevEnd = pFnd->End();
- while( ++n < pRedlineTbl->Count() )
- {
- const SwRedline* pTmp = (*pRedlineTbl)[ n ];
- if( pTmp->HasMark() && pTmp->IsVisible() )
- {
- const SwPosition *pRStt;
- if( pFnd->GetType() == pTmp->GetType() &&
- pFnd->GetAuthor() == pTmp->GetAuthor() &&
- ( *pPrevEnd == *( pRStt = pTmp->Start() ) ||
- IsPrevPos( *pPrevEnd, *pRStt )) )
- {
- pPrevEnd = pTmp->End();
- rSttPos = *pPrevEnd;
- }
- else
- break;
- }
- }
- }
-
- if( pFnd )
- {
- const SwRedline* pSaveFnd = pFnd;
-
- SwCntntNode* pCNd;
- SwNodeIndex* pIdx = &rPam.GetMark()->nNode;
- if( !pIdx->GetNode().IsCntntNode() &&
- 0 != ( pCNd = GetNodes().GoNextSection( pIdx )) )
- {
- if( *pIdx <= rPam.GetPoint()->nNode )
- rPam.GetMark()->nContent.Assign( pCNd, 0 );
- else
- pFnd = 0;
- }
-
- if( pFnd )
- {
- pIdx = &rPam.GetPoint()->nNode;
- if( !pIdx->GetNode().IsCntntNode() &&
- 0 != ( pCNd = GetNodes().GoPrevSection( pIdx )) )
- {
- if( *pIdx >= rPam.GetMark()->nNode )
- rPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
- else
- pFnd = 0;
- }
- }
-
- if( !pFnd || *rPam.GetMark() == *rPam.GetPoint() )
- {
- if( n < pRedlineTbl->Count() )
- {
- bRestart = sal_True;
- *rPam.GetPoint() = *pSaveFnd->End();
- }
- else
- {
- rPam.DeleteMark();
- *rPam.GetPoint() = aSavePos;
- }
- pFnd = 0;
- }
- }
- } while( bRestart );
-
- return pFnd;
-}
-
-const SwRedline* SwDoc::SelPrevRedline( SwPaM& rPam ) const
-{
- rPam.DeleteMark();
- rPam.SetMark();
-
- SwPosition& rSttPos = *rPam.GetPoint();
- SwPosition aSavePos( rSttPos );
- sal_Bool bRestart;
-
- // If the starting positon points to the last valid ContentNode,
- // we take the previous Redline in any case.
- sal_uInt16 n = 0;
- const SwRedline* pFnd = lcl_FindCurrRedline( rSttPos, n, sal_False );
- if( pFnd )
- {
- const SwPosition* pStt = pFnd->Start();
- if( !pStt->nNode.GetNode().IsCntntNode() )
- {
- SwNodeIndex aTmp( pStt->nNode );
- SwCntntNode* pCNd = GetNodes().GoNextSection( &aTmp );
- if( !pCNd || ( aTmp == rSttPos.nNode &&
- !rSttPos.nContent.GetIndex() ))
- pFnd = 0;
- }
- if( pFnd )
- rSttPos = *pFnd->Start();
- }
-
- do {
- bRestart = sal_False;
-
- while( !pFnd && 0 < n )
- {
- pFnd = (*pRedlineTbl)[ --n ];
- if( pFnd->HasMark() && pFnd->IsVisible() )
- {
- *rPam.GetMark() = *pFnd->End();
- rSttPos = *pFnd->Start();
- }
- else
- pFnd = 0;
- }
-
- if( pFnd )
- {
- // Merge all of the same type and author that are
- // consecutive into one Selection.
- const SwPosition* pNextStt = pFnd->Start();
- while( 0 < n )
- {
- const SwRedline* pTmp = (*pRedlineTbl)[ --n ];
- if( pTmp->HasMark() && pTmp->IsVisible() )
- {
- const SwPosition *pREnd;
- if( pFnd->GetType() == pTmp->GetType() &&
- pFnd->GetAuthor() == pTmp->GetAuthor() &&
- ( *pNextStt == *( pREnd = pTmp->End() ) ||
- IsPrevPos( *pREnd, *pNextStt )) )
- {
- pNextStt = pTmp->Start();
- rSttPos = *pNextStt;
- }
- else
- {
- ++n;
- break;
- }
- }
- }
- }
-
- if( pFnd )
- {
- const SwRedline* pSaveFnd = pFnd;
-
- SwCntntNode* pCNd;
- SwNodeIndex* pIdx = &rPam.GetMark()->nNode;
- if( !pIdx->GetNode().IsCntntNode() &&
- 0 != ( pCNd = GetNodes().GoPrevSection( pIdx )) )
- {
- if( *pIdx >= rPam.GetPoint()->nNode )
- rPam.GetMark()->nContent.Assign( pCNd, pCNd->Len() );
- else
- pFnd = 0;
- }
-
- if( pFnd )
- {
- pIdx = &rPam.GetPoint()->nNode;
- if( !pIdx->GetNode().IsCntntNode() &&
- 0 != ( pCNd = GetNodes().GoNextSection( pIdx )) )
- {
- if( *pIdx <= rPam.GetMark()->nNode )
- rPam.GetPoint()->nContent.Assign( pCNd, 0 );
- else
- pFnd = 0;
- }
- }
-
- if( !pFnd || *rPam.GetMark() == *rPam.GetPoint() )
- {
- if( n )
- {
- bRestart = sal_True;
- *rPam.GetPoint() = *pSaveFnd->Start();
- }
- else
- {
- rPam.DeleteMark();
- *rPam.GetPoint() = aSavePos;
- }
- pFnd = 0;
- }
- }
- } while( bRestart );
-
- return pFnd;
-}
-
-// Set comment at the Redline
-bool SwDoc::SetRedlineComment( const SwPaM& rPaM, const String& rS )
-{
- sal_Bool bRet = sal_False;
- const SwPosition* pStt = rPaM.Start(),
- * pEnd = pStt == rPaM.GetPoint() ? rPaM.GetMark()
- : rPaM.GetPoint();
- sal_uInt16 n = 0;
- if( lcl_FindCurrRedline( *pStt, n, sal_True ) )
- {
- for( ; n < pRedlineTbl->Count(); ++n )
- {
- bRet = sal_True;
- SwRedline* pTmp = (*pRedlineTbl)[ n ];
- if( pStt != pEnd && *pTmp->Start() > *pEnd )
- break;
-
- pTmp->SetComment( rS );
- if( *pTmp->End() >= *pEnd )
- break;
- }
- }
- if( bRet )
- SetModified();
-
- return bRet;
-}
-
-// Create a new author if necessary
-sal_uInt16 SwDoc::GetRedlineAuthor()
-{
- return SW_MOD()->GetRedlineAuthor();
-}
-
-// Insert new author into the Table for the Readers etc.
-sal_uInt16 SwDoc::InsertRedlineAuthor( const String& rNew )
-{
- return SW_MOD()->InsertRedlineAuthor(rNew);
-}
-
-void SwDoc::UpdateRedlineAttr()
-{
- const SwRedlineTbl& rTbl = GetRedlineTbl();
- for( sal_uInt16 n = 0; n < rTbl.Count(); ++n )
- {
- SwRedline* pRedl = rTbl[ n ];
- if( pRedl->IsVisible() )
- pRedl->InvalidateRange();
- }
-}
-
-// Set comment text for the Redline, which is inserted later on via
-// AppendRedline. Is used by Autoformat.
-// A null pointer resets the mode. The pointer is not copied, so it
-// needs to stay valid!
-void SwDoc::SetAutoFmtRedlineComment( const String* pTxt, sal_uInt16 nSeqNo )
-{
- mbIsAutoFmtRedline = 0 != pTxt;
- if( pTxt )
- {
- if( !pAutoFmtRedlnComment )
- pAutoFmtRedlnComment = new String( *pTxt );
- else
- *pAutoFmtRedlnComment = *pTxt;
- }
- else
- delete pAutoFmtRedlnComment, pAutoFmtRedlnComment = 0;
-
- nAutoFmtRedlnCommentNo = nSeqNo;
-}
-
-void SwDoc::SetRedlinePassword(
- /*[in]*/const uno::Sequence <sal_Int8>& rNewPassword)
-{
- aRedlinePasswd = rNewPassword;
- SetModified();
-}
-
-
sal_Bool SwRedlineTbl::Insert( SwRedlinePtr& p, sal_Bool bIns )
{
sal_Bool bRet = sal_False;
@@ -3819,15 +1924,4 @@ String SwRedline::GetDescr(sal_uInt16 nPos)
return aResult;
}
-
-bool SwDoc::IsInRedlines(const SwNode & rNode) const
-{
- SwPosition aPos(rNode);
- SwNode & rEndOfRedlines = GetNodes().GetEndOfRedlines();
- SwPaM aPam(SwPosition(*rEndOfRedlines.StartOfSectionNode()),
- SwPosition(rEndOfRedlines));
-
- return aPam.ContainsPosition(aPos) ? true : false;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx
index baea7a78ee6d..2337af2d2c6e 100644
--- a/sw/source/core/doc/docruby.cxx
+++ b/sw/source/core/doc/docruby.cxx
@@ -59,280 +59,6 @@ using namespace ::com::sun::star::i18n;
*
*
*/
-sal_uInt16 SwDoc::FillRubyList( const SwPaM& rPam, SwRubyList& rList,
- sal_uInt16 nMode )
-{
- const SwPaM *_pStartCrsr = (SwPaM*)rPam.GetNext(),
- *__pStartCrsr = _pStartCrsr;
- sal_Bool bCheckEmpty = &rPam != _pStartCrsr;
- do {
- const SwPosition* pStt = _pStartCrsr->Start(),
- * pEnd = pStt == _pStartCrsr->GetPoint()
- ? _pStartCrsr->GetMark()
- : _pStartCrsr->GetPoint();
- if( !bCheckEmpty || ( pStt != pEnd && *pStt != *pEnd ))
- {
- SwPaM aPam( *pStt );
- do {
- SwRubyListEntry* pNew = new SwRubyListEntry;
- if( pEnd != pStt )
- {
- aPam.SetMark();
- *aPam.GetMark() = *pEnd;
- }
- if( _SelectNextRubyChars( aPam, *pNew, nMode ))
- {
- rList.Insert( pNew, rList.Count() );
- aPam.DeleteMark();
- }
- else
- {
- delete pNew;
- if( *aPam.GetPoint() < *pEnd )
- {
- // goto next paragraph
- aPam.DeleteMark();
- aPam.Move( fnMoveForward, fnGoNode );
- }
- else
- break;
- }
- } while( 30 > rList.Count() && *aPam.GetPoint() < *pEnd );
- }
- } while( 30 > rList.Count() &&
- (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr );
-
- return rList.Count();
-}
-
-sal_uInt16 SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList,
- sal_uInt16 nMode )
-{
- GetIDocumentUndoRedo().StartUndo( UNDO_SETRUBYATTR, NULL );
- std::set<sal_uInt16> aDelArr;
- aDelArr.insert( RES_TXTATR_CJK_RUBY );
-
- sal_uInt16 nListEntry = 0;
-
- const SwPaM *_pStartCrsr = (SwPaM*)rPam.GetNext(),
- *__pStartCrsr = _pStartCrsr;
- sal_Bool bCheckEmpty = &rPam != _pStartCrsr;
- do {
- const SwPosition* pStt = _pStartCrsr->Start(),
- * pEnd = pStt == _pStartCrsr->GetPoint()
- ? _pStartCrsr->GetMark()
- : _pStartCrsr->GetPoint();
- if( !bCheckEmpty || ( pStt != pEnd && *pStt != *pEnd ))
- {
-
- SwPaM aPam( *pStt );
- do {
- SwRubyListEntry aCheckEntry;
- if( pEnd != pStt )
- {
- aPam.SetMark();
- *aPam.GetMark() = *pEnd;
- }
- if( _SelectNextRubyChars( aPam, aCheckEntry, nMode ))
- {
- const SwRubyListEntry* pEntry = rList[ nListEntry++ ];
- if( aCheckEntry.GetRubyAttr() != pEntry->GetRubyAttr() )
- {
- // set/reset the attribut
- if( pEntry->GetRubyAttr().GetText().Len() )
- {
- InsertPoolItem( aPam, pEntry->GetRubyAttr(), 0 );
- }
- else
- {
- ResetAttrs( aPam, sal_True, aDelArr );
- }
- }
-
- if( aCheckEntry.GetText() != pEntry->GetText() &&
- pEntry->GetText().Len() )
- {
- // text is changed, so replace the original
- ReplaceRange( aPam, pEntry->GetText(), false );
- }
- aPam.DeleteMark();
- }
- else
- {
- if( *aPam.GetPoint() < *pEnd )
- {
- // goto next paragraph
- aPam.DeleteMark();
- aPam.Move( fnMoveForward, fnGoNode );
- }
- else
- {
- const SwRubyListEntry* pEntry = rList[ nListEntry++ ];
-
- // set/reset the attribut
- if( pEntry->GetRubyAttr().GetText().Len() &&
- pEntry->GetText().Len() )
- {
- InsertString( aPam, pEntry->GetText() );
- aPam.SetMark();
- aPam.GetMark()->nContent -= pEntry->GetText().Len();
- InsertPoolItem( aPam, pEntry->GetRubyAttr(),
- nsSetAttrMode::SETATTR_DONTEXPAND );
- }
- else
- break;
- aPam.DeleteMark();
- }
- }
- } while( nListEntry < rList.Count() && *aPam.GetPoint() < *pEnd );
- }
- } while( 30 > rList.Count() &&
- (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr );
-
- GetIDocumentUndoRedo().EndUndo( UNDO_SETRUBYATTR, NULL );
-
- return nListEntry;
-}
-
-sal_Bool SwDoc::_SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rEntry, sal_uInt16 )
-{
- // Point must be the startposition, Mark is optional the end position
- SwPosition* pPos = rPam.GetPoint();
- const SwTxtNode* pTNd = pPos->nNode.GetNode().GetTxtNode();
- const String* pTxt = &pTNd->GetTxt();
- xub_StrLen nStart = pPos->nContent.GetIndex(), nEnd = pTxt->Len();
-
- sal_Bool bHasMark = rPam.HasMark();
- if( bHasMark )
- {
- // in the same node?
- if( rPam.GetMark()->nNode == pPos->nNode )
- {
- // then use that end
- xub_StrLen nTEnd = rPam.GetMark()->nContent.GetIndex();
- if( nTEnd < nEnd )
- nEnd = nTEnd;
- }
- rPam.DeleteMark();
- }
-
- // ----- search the start
- // --- look where a ruby attribut starts
- sal_uInt16 nHtIdx = USHRT_MAX;
- const SwpHints* pHts = pTNd->GetpSwpHints();
- const SwTxtAttr* pAttr = 0;
- if( pHts )
- {
- const SwTxtAttr* pHt;
- for( nHtIdx = 0; nHtIdx < pHts->Count(); ++nHtIdx )
- if( RES_TXTATR_CJK_RUBY == ( pHt = (*pHts)[ nHtIdx ])->Which() &&
- *pHt->GetAnyEnd() > nStart )
- {
- if( *pHt->GetStart() < nEnd )
- {
- pAttr = pHt;
- if( !bHasMark && nStart > *pAttr->GetStart() )
- {
- nStart = *pAttr->GetStart();
- pPos->nContent = nStart;
- }
- }
- break;
- }
- }
-
- if( !bHasMark && nStart && ( !pAttr || nStart != *pAttr->GetStart()) )
- {
- // skip to the word begin!
- long nWordStt = pBreakIt->GetBreakIter()->getWordBoundary(
- *pTxt, nStart,
- pBreakIt->GetLocale( pTNd->GetLang( nStart )),
- WordType::ANYWORD_IGNOREWHITESPACES,
- sal_True ).startPos;
- if( nWordStt < nStart && -1 != nWordStt )
- {
- nStart = (xub_StrLen)nWordStt;
- pPos->nContent = nStart;
- }
- }
-
- sal_Bool bAlphaNum = sal_False;
- long nWordEnd = nEnd;
- CharClass& rCC = GetAppCharClass();
- while( nStart < nEnd )
- {
- if( pAttr && nStart == *pAttr->GetStart() )
- {
- pPos->nContent = nStart;
- if( !rPam.HasMark() )
- {
- rPam.SetMark();
- pPos->nContent = *pAttr->GetAnyEnd();
- if( pPos->nContent.GetIndex() > nEnd )
- pPos->nContent = nEnd;
- rEntry.SetRubyAttr( pAttr->GetRuby() );
- }
- break;
- }
-
- sal_Int32 nChType = rCC.getType( *pTxt, nStart );
- sal_Bool bIgnoreChar = sal_False, bIsAlphaNum = sal_False, bChkNxtWrd = sal_False;
- switch( nChType )
- {
- case UnicodeType::UPPERCASE_LETTER:
- case UnicodeType::LOWERCASE_LETTER:
- case UnicodeType::TITLECASE_LETTER:
- case UnicodeType::DECIMAL_DIGIT_NUMBER:
- bChkNxtWrd = bIsAlphaNum = sal_True;
- break;
-
- case UnicodeType::SPACE_SEPARATOR:
- case UnicodeType::CONTROL:
-/*??*/ case UnicodeType::PRIVATE_USE:
- case UnicodeType::START_PUNCTUATION:
- case UnicodeType::END_PUNCTUATION:
- bIgnoreChar = sal_True;
- break;
-
-
- case UnicodeType::OTHER_LETTER:
- bChkNxtWrd = sal_True;
-
- default:
- bIsAlphaNum = sal_False;
- break;
- }
-
- if( rPam.HasMark() )
- {
- if( bIgnoreChar || bIsAlphaNum != bAlphaNum || nStart >= nWordEnd )
- break;
- }
- else if( !bIgnoreChar )
- {
- rPam.SetMark();
- bAlphaNum = bIsAlphaNum;
- if( bChkNxtWrd && pBreakIt->GetBreakIter().is() )
- {
- // search the end of this word
- nWordEnd = pBreakIt->GetBreakIter()->getWordBoundary(
- *pTxt, nStart,
- pBreakIt->GetLocale( pTNd->GetLang( nStart )),
- WordType::ANYWORD_IGNOREWHITESPACES,
- sal_True ).endPos;
- if( 0 > nWordEnd || nWordEnd > nEnd || nWordEnd == nStart )
- nWordEnd = nEnd;
- }
- }
- pTNd->GoNext( &pPos->nContent, CRSR_SKIP_CHARS );
- nStart = pPos->nContent.GetIndex();
- }
-
- nStart = rPam.GetMark()->nContent.GetIndex();
- rEntry.SetText( pTxt->Copy( nStart,
- rPam.GetPoint()->nContent.GetIndex() - nStart ));
- return rPam.HasMark();
-}
SwRubyListEntry::~SwRubyListEntry()
{
diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index 69eaedd17619..c7cfe756d5c6 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -306,312 +306,6 @@ double SwSortBoxElement::GetValue( sal_uInt16 nKey ) const
/*--------------------------------------------------------------------
Description: Sort Text in the Document
--------------------------------------------------------------------*/
-sal_Bool SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt)
-{
- // Check if Frame is in the Text
- const SwPosition *pStart = rPaM.Start(), *pEnd = rPaM.End();
-
- // Set index to the Selection's start
- for ( sal_uInt16 n = 0; n < GetSpzFrmFmts()->Count(); ++n )
- {
- SwFrmFmt *const pFmt = static_cast<SwFrmFmt*>((*GetSpzFrmFmts())[n]);
- SwFmtAnchor const*const pAnchor = &pFmt->GetAnchor();
- SwPosition const*const pAPos = pAnchor->GetCntntAnchor();
-
- if (pAPos && (FLY_AT_PARA == pAnchor->GetAnchorId()) &&
- pStart->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode )
- return sal_False;
- }
-
- // Check if only TextNodes are within the Selection
- {
- sal_uLong nStart = pStart->nNode.GetIndex(),
- nEnd = pEnd->nNode.GetIndex();
- while( nStart <= nEnd )
- // Iterate over a selected Area
- if( !GetNodes()[ nStart++ ]->IsTxtNode() )
- return sal_False;
- }
-
- bool const bUndo = GetIDocumentUndoRedo().DoesUndo();
- if( bUndo )
- {
- GetIDocumentUndoRedo().StartUndo( UNDO_START, NULL );
- }
-
- SwPaM* pRedlPam = 0;
- SwUndoRedlineSort* pRedlUndo = 0;
- SwUndoSort* pUndoSort = 0;
-
- if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() ))
- {
- pRedlPam = new SwPaM( pStart->nNode, pEnd->nNode, -1, 1 );
- SwCntntNode* pCNd = pRedlPam->GetCntntNode( sal_False );
- if( pCNd )
- pRedlPam->GetMark()->nContent = pCNd->Len();
-
- if( IsRedlineOn() && !IsShowOriginal( GetRedlineMode() ) )
- {
- if( bUndo )
- {
- pRedlUndo = new SwUndoRedlineSort( *pRedlPam,rOpt );
- GetIDocumentUndoRedo().DoUndo(false);
- }
- // First copy the area
- SwNodeIndex aEndIdx( pEnd->nNode, 1 );
- SwNodeRange aRg( pStart->nNode, aEndIdx );
- GetNodes()._Copy( aRg, aEndIdx );
-
- // Area is new from pEnd->nNode+1 to aEndIdx
- DeleteRedline( *pRedlPam, true, USHRT_MAX );
-
- pRedlPam->GetMark()->nNode.Assign( pEnd->nNode.GetNode(), 1 );
- pCNd = pRedlPam->GetCntntNode( sal_False );
- pRedlPam->GetMark()->nContent.Assign( pCNd, 0 );
-
- pRedlPam->GetPoint()->nNode.Assign( aEndIdx.GetNode() );
- pCNd = pRedlPam->GetCntntNode( sal_True );
- xub_StrLen nCLen = 0;
- if( !pCNd &&
- 0 != (pCNd = GetNodes()[ aEndIdx.GetIndex()-1 ]->GetCntntNode()))
- {
- nCLen = pCNd->Len();
- pRedlPam->GetPoint()->nNode.Assign( *pCNd );
- }
- pRedlPam->GetPoint()->nContent.Assign( pCNd, nCLen );
-
- if( pRedlUndo )
- pRedlUndo->SetValues( rPaM );
- }
- else
- {
- DeleteRedline( *pRedlPam, true, USHRT_MAX );
- delete pRedlPam, pRedlPam = 0;
- }
- }
-
- SwNodeIndex aStart(pStart->nNode);
- SwSortElement::Init( this, rOpt );
- SwSortElements aSortArr;
- while( aStart <= pEnd->nNode )
- {
- // Iterate over a selected Area
- SwSortTxtElement* pSE = new SwSortTxtElement( aStart );
- aSortArr.Insert(pSE);
- aStart++;
- }
-
- // Now comes the tricky part: Move Nodes (and always keep Undo in mind)
- sal_uLong nBeg = pStart->nNode.GetIndex();
- SwNodeRange aRg( aStart, aStart );
-
- if( bUndo && !pRedlUndo )
- {
- pUndoSort = new SwUndoSort(rPaM, rOpt);
- GetIDocumentUndoRedo().AppendUndo(pUndoSort);
- }
-
- GetIDocumentUndoRedo().DoUndo(false);
-
- for ( sal_uInt16 n = 0; n < aSortArr.Count(); ++n )
- {
- SwSortTxtElement* pBox = (SwSortTxtElement*)aSortArr[n];
- aStart = nBeg + n;
- aRg.aStart = pBox->aPos.GetIndex();
- aRg.aEnd = aRg.aStart.GetIndex() + 1;
-
- // Move Nodes
- MoveNodeRange( aRg, aStart,
- IDocumentContentOperations::DOC_MOVEDEFAULT );
-
- // Insert Move in Undo
- if(pUndoSort)
- pUndoSort->Insert(pBox->nOrg, nBeg + n);
- }
- // Delete all elements from the SortArray
- aSortArr.DeleteAndDestroy(0, aSortArr.Count());
- SwSortElement::Finit();
-
- if( pRedlPam )
- {
- if( pRedlUndo )
- {
- pRedlUndo->SetSaveRange( *pRedlPam );
- // UGLY: temp. enable Undo
- GetIDocumentUndoRedo().DoUndo(true);
- GetIDocumentUndoRedo().AppendUndo( pRedlUndo );
- GetIDocumentUndoRedo().DoUndo(false);
- }
-
- // nBeg is start of sorted range
- SwNodeIndex aSttIdx( GetNodes(), nBeg );
-
- // the copied range is deleted
- SwRedline *const pDeleteRedline(
- new SwRedline( nsRedlineType_t::REDLINE_DELETE, *pRedlPam ));
-
- // pRedlPam points to nodes that may be deleted (hidden) by
- // AppendRedline, so adjust it beforehand to prevent ASSERT
- pRedlPam->GetPoint()->nNode = aSttIdx;
- SwCntntNode* pCNd = aSttIdx.GetNode().GetCntntNode();
- pRedlPam->GetPoint()->nContent.Assign( pCNd, 0 );
-
- AppendRedline(pDeleteRedline, true);
-
- // the sorted range is inserted
- AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, *pRedlPam ), true);
-
- if( pRedlUndo )
- {
- SwNodeIndex aInsEndIdx( pRedlPam->GetMark()->nNode, -1 );
- pRedlPam->GetMark()->nNode = aInsEndIdx;
- SwCntntNode *const pPrevNode =
- pRedlPam->GetMark()->nNode.GetNode().GetCntntNode();
- pRedlPam->GetMark()->nContent.Assign( pPrevNode, pPrevNode->Len() );
-
- pRedlUndo->SetValues( *pRedlPam );
- }
-
- if( pRedlUndo )
- pRedlUndo->SetOffset( aSttIdx );
-
- delete pRedlPam, pRedlPam = 0;
- }
- GetIDocumentUndoRedo().DoUndo( bUndo );
- if( bUndo )
- {
- GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL );
- }
-
- return sal_True;
-}
-
-/*--------------------------------------------------------------------
- Description: Sort Table in the Document
- --------------------------------------------------------------------*/
-sal_Bool SwDoc::SortTbl(const SwSelBoxes& rBoxes, const SwSortOptions& rOpt)
-{
- // Via SwDoc for Undo!
- OSL_ENSURE( !rBoxes.empty(), "no valid Box list" );
- SwTableNode* pTblNd = const_cast<SwTableNode*>( rBoxes.begin()->second->GetSttNd()->FindTableNode() );
- if( !pTblNd )
- return sal_False;
-
- // We begin sorting
- // Find all Boxes/Lines
- _FndBox aFndBox( 0, 0 );
- {
- _FndPara aPara( rBoxes, &aFndBox );
- pTblNd->GetTable().GetTabLines().ForEach( &_FndLineCopyCol, &aPara );;
- }
-
- if(!aFndBox.GetLines().Count())
- return sal_False;
-
- if( !IsIgnoreRedline() && GetRedlineTbl().Count() )
- DeleteRedline( *pTblNd, true, USHRT_MAX );
-
- sal_uInt16 nStart = 0;
- if( pTblNd->GetTable().GetRowsToRepeat() > 0 && rOpt.eDirection == SRT_ROWS )
- {
- // Uppermost selected Cell
- _FndLines& rLines = aFndBox.GetLines();
-
- while( nStart < rLines.Count() )
- {
- // Respect Split Merge nesting,
- // extract the upper most
- SwTableLine* pLine = rLines[nStart]->GetLine();
- while ( pLine->GetUpper() )
- pLine = pLine->GetUpper()->GetUpper();
-
- if( pTblNd->GetTable().IsHeadline( *pLine ) )
- nStart++;
- else
- break;
- }
- // Are all selected in the HeaderLine? -> no Offset
- if( nStart == rLines.Count() )
- nStart = 0;
- }
-
- // Switch to relative Formulas
- SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
- aMsgHnt.eFlags = TBL_RELBOXNAME;
- UpdateTblFlds( &aMsgHnt );
-
- // Table as a flat array structure
- FlatFndBox aFlatBox(this, aFndBox);
-
- if(!aFlatBox.IsSymmetric())
- return sal_False;
-
- // Delete HTML layout
- pTblNd->GetTable().SetHTMLTableLayout( 0 );
-
- // #i37739# A simple 'MakeFrms' after the node sorting
- // does not work if the table is inside a frame and has no prev/next.
- SwNode2Layout aNode2Layout( *pTblNd );
-
- // Delete the Table's Frames
- pTblNd->DelFrms();
- // ? TL_CHART2: ?
-
- SwUndoSort* pUndoSort = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- pUndoSort = new SwUndoSort( rBoxes.begin()->second->GetSttIdx(),
- rBoxes.rbegin()->second->GetSttIdx(),
- *pTblNd, rOpt, aFlatBox.HasItemSets() );
- GetIDocumentUndoRedo().AppendUndo(pUndoSort);
- }
- ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
-
- // Insert KeyElements
- sal_uInt16 nCount = (rOpt.eDirection == SRT_ROWS) ?
- aFlatBox.GetRows() : aFlatBox.GetCols();
-
- // Sort SortList by Key
- SwSortElement::Init( this, rOpt, &aFlatBox );
- SwSortElements aSortList;
-
- // When sorting, do not include the first row if the HeaderLine is repeated
- sal_uInt16 i;
-
- for( i = nStart; i < nCount; ++i)
- {
- SwSortBoxElement* pEle = new SwSortBoxElement( i );
- aSortList.Insert(pEle);
- }
-
- // Move after Sorting
- SwMovedBoxes aMovedList;
- for(i=0; i < aSortList.Count(); ++i)
- {
- SwSortBoxElement* pBox = (SwSortBoxElement*)aSortList[i];
- if(rOpt.eDirection == SRT_ROWS)
- MoveRow(this, aFlatBox, pBox->nRow, i + nStart, aMovedList, pUndoSort);
- else
- MoveCol(this, aFlatBox, pBox->nRow, i + nStart, aMovedList, pUndoSort);
- }
-
- // Restore table frames:
- // #i37739# A simple 'MakeFrms' after the node sorting
- // does not work if the table is inside a frame and has no prev/next.
- const sal_uLong nIdx = pTblNd->GetIndex();
- aNode2Layout.RestoreUpperFrms( GetNodes(), nIdx, nIdx + 1 );
-
- // TL_CHART2: need to inform chart of probably changed cell names
- UpdateCharts( pTblNd->GetTable().GetFrmFmt()->GetName() );
-
- // Delete all Elements in the SortArray
- aSortList.DeleteAndDestroy( 0, aSortList.Count() );
- SwSortElement::Finit();
-
- SetModified();
- return sal_True;
-}
-
/*--------------------------------------------------------------------
Description: Move a row
--------------------------------------------------------------------*/
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index b1c91998e651..e7a2f50647f2 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -97,109 +97,6 @@ struct LinkStruct
typedef std::vector<LinkStruct*> LinkStructArr;
-sal_uInt16 SwDoc::GetTOIKeys( SwTOIKeyType eTyp, std::vector<String>& rArr ) const
-{
- rArr.clear();
-
- // Look up all Primary and Secondary via the Pool
- const SwTxtTOXMark* pMark;
- const SfxPoolItem* pItem;
- const SwTOXType* pTOXType;
- sal_uInt32 i, nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_TOXMARK );
- for( i = 0; i < nMaxItems; ++i )
- if( 0 != (pItem = GetAttrPool().GetItem2( RES_TXTATR_TOXMARK, i ) ) &&
- 0!= ( pTOXType = ((SwTOXMark*)pItem)->GetTOXType()) &&
- TOX_INDEX == pTOXType->GetType() &&
- 0 != ( pMark = ((SwTOXMark*)pItem)->GetTxtTOXMark() ) &&
- pMark->GetpTxtNd() &&
- pMark->GetpTxtNd()->GetNodes().IsDocNodes() )
- {
- const String* pStr;
- if( TOI_PRIMARY == eTyp )
- pStr = &((SwTOXMark*)pItem)->GetPrimaryKey();
- else
- pStr = &((SwTOXMark*)pItem)->GetSecondaryKey();
-
- if( pStr->Len() )
- rArr.push_back( *pStr );
- }
-
- return rArr.size();
-}
-
-/*--------------------------------------------------------------------
- Description: Get current table of contents Mark.
- --------------------------------------------------------------------*/
-sal_uInt16 SwDoc::GetCurTOXMark( const SwPosition& rPos,
- SwTOXMarks& rArr ) const
-{
- // search on Position rPos for all SwTOXMarks
- SwTxtNode *const pTxtNd = rPos.nNode.GetNode().GetTxtNode();
- if( !pTxtNd || !pTxtNd->GetpSwpHints() )
- return 0;
-
- const SwpHints & rHts = *pTxtNd->GetpSwpHints();
- const SwTxtAttr* pHt;
- xub_StrLen nSttIdx;
- const xub_StrLen *pEndIdx;
-
- xub_StrLen nAktPos = rPos.nContent.GetIndex();
-
- for( sal_uInt16 n = 0; n < rHts.Count(); ++n )
- {
- if( RES_TXTATR_TOXMARK != (pHt = rHts[n])->Which() )
- continue;
- if( ( nSttIdx = *pHt->GetStart() ) < nAktPos )
- {
- // also check the end
- if( 0 == ( pEndIdx = pHt->GetEnd() ) ||
- *pEndIdx <= nAktPos )
- continue; // keep searching
- }
- else if( nSttIdx > nAktPos )
- // If Hint's Start is greater than rPos, break, because
- // the attributes are sorted by Start!
- break;
-
- const SwTOXMark* pTMark = &pHt->GetTOXMark();
- rArr.Insert( pTMark, rArr.Count() );
- }
- return rArr.Count();
-}
-
-/*--------------------------------------------------------------------
- Description: Delete table of contents Mark
- --------------------------------------------------------------------*/
-void SwDoc::DeleteTOXMark( const SwTOXMark* pTOXMark )
-{
- // hole den TextNode und
- const SwTxtTOXMark* pTxtTOXMark = pTOXMark->GetTxtTOXMark();
- OSL_ENSURE( pTxtTOXMark, "No TxtTOXMark, cannot be deleted" );
-
- SwTxtNode& rTxtNd = const_cast<SwTxtNode&>(pTxtTOXMark->GetTxtNode());
- OSL_ENSURE( rTxtNd.GetpSwpHints(), "cannot be deleted" );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- // save attributes for Undo
- SwUndoResetAttr* pUndo = new SwUndoResetAttr(
- SwPosition( rTxtNd, SwIndex( &rTxtNd, *pTxtTOXMark->GetStart() ) ),
- RES_TXTATR_TOXMARK );
- GetIDocumentUndoRedo().AppendUndo( pUndo );
-
- SwRegHistory aRHst( rTxtNd, &pUndo->GetHistory() );
- rTxtNd.GetpSwpHints()->Register( &aRHst );
- }
-
- rTxtNd.DeleteAttribute( const_cast<SwTxtTOXMark*>(pTxtTOXMark) );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- if( rTxtNd.GetpSwpHints() )
- rTxtNd.GetpSwpHints()->DeRegister();
- }
- SetModified();
-}
/*--------------------------------------------------------------------
Description: Travel between table of content Marks
@@ -230,478 +127,6 @@ public:
( nNode == rCmp.nNode && nCntnt >= rCmp.nCntnt); }
};
-const SwTOXMark& SwDoc::GotoTOXMark( const SwTOXMark& rCurTOXMark,
- SwTOXSearch eDir, sal_Bool bInReadOnly )
-{
- const SwTxtTOXMark* pMark = rCurTOXMark.GetTxtTOXMark();
- OSL_ENSURE(pMark, "pMark==0 invalid TxtTOXMark");
-
- const SwTxtNode *pTOXSrc = pMark->GetpTxtNd();
-
- CompareNodeCntnt aAbsIdx( pTOXSrc->GetIndex(), *pMark->GetStart() );
- CompareNodeCntnt aPrevPos( 0, 0 );
- CompareNodeCntnt aNextPos( ULONG_MAX, STRING_NOTFOUND );
- CompareNodeCntnt aMax( 0, 0 );
- CompareNodeCntnt aMin( ULONG_MAX, STRING_NOTFOUND );
-
- const SwTOXMark* pNew = 0;
- const SwTOXMark* pMax = &rCurTOXMark;
- const SwTOXMark* pMin = &rCurTOXMark;
-
- const SwTOXType* pType = rCurTOXMark.GetTOXType();
- SwTOXMarks aMarks;
- SwTOXMark::InsertTOXMarks( aMarks, *pType );
-
- const SwTOXMark* pTOXMark;
- const SwCntntFrm* pCFrm;
- Point aPt;
- for( sal_Int32 nMark=0; nMark<aMarks.Count(); nMark++ )
- {
- pTOXMark = aMarks[nMark];
- if( pTOXMark != &rCurTOXMark &&
- 0 != ( pMark = pTOXMark->GetTxtTOXMark()) &&
- 0 != ( pTOXSrc = pMark->GetpTxtNd() ) &&
- 0 != ( pCFrm = pTOXSrc->getLayoutFrm( GetCurrentLayout(), &aPt, 0, sal_False )) &&
- ( bInReadOnly || !pCFrm->IsProtected() ))
- {
- CompareNodeCntnt aAbsNew( pTOXSrc->GetIndex(), *pMark->GetStart() );
- switch( eDir )
- {
- // The following (a bit more complicated) statements make it
- // possible to also travel across Entries on the same (!)
- // position. If someone has time, please feel free to optimize.
- case TOX_SAME_PRV:
- if( pTOXMark->GetText() != rCurTOXMark.GetText() )
- break;
- /* no break here */
- case TOX_PRV:
- if ( (aAbsNew < aAbsIdx && aAbsNew > aPrevPos &&
- aPrevPos != aAbsIdx && aAbsNew != aAbsIdx ) ||
- (aAbsIdx == aAbsNew &&
- (sal_uLong(&rCurTOXMark) > sal_uLong(pTOXMark) &&
- (!pNew ||
- (pNew && (aPrevPos < aAbsIdx ||
- sal_uLong(pNew) < sal_uLong(pTOXMark)))))) ||
- (aPrevPos == aAbsNew && aAbsIdx != aAbsNew &&
- sal_uLong(pTOXMark) > sal_uLong(pNew)) )
- {
- pNew = pTOXMark;
- aPrevPos = aAbsNew;
- if ( aAbsNew >= aMax )
- {
- aMax = aAbsNew;
- pMax = pTOXMark;
- }
- }
- break;
-
- case TOX_SAME_NXT:
- if( pTOXMark->GetText() != rCurTOXMark.GetText() )
- break;
- /* no break here */
- case TOX_NXT:
- if ( (aAbsNew > aAbsIdx && aAbsNew < aNextPos &&
- aNextPos != aAbsIdx && aAbsNew != aAbsIdx ) ||
- (aAbsIdx == aAbsNew &&
- (sal_uLong(&rCurTOXMark) < sal_uLong(pTOXMark) &&
- (!pNew ||
- (pNew && (aNextPos > aAbsIdx ||
- sal_uLong(pNew) > sal_uLong(pTOXMark)))))) ||
- (aNextPos == aAbsNew && aAbsIdx != aAbsNew &&
- sal_uLong(pTOXMark) < sal_uLong(pNew)) )
- {
- pNew = pTOXMark;
- aNextPos = aAbsNew;
- if ( aAbsNew <= aMin )
- {
- aMin = aAbsNew;
- pMin = pTOXMark;
- }
- }
- break;
- }
- }
- }
-
-
- // We couldn't find a successor
- // Use minimum or maximum
- if(!pNew)
- {
- switch(eDir)
- {
- case TOX_PRV:
- case TOX_SAME_PRV:
- pNew = pMax;
- break;
- case TOX_NXT:
- case TOX_SAME_NXT:
- pNew = pMin;
- break;
- default:
- pNew = &rCurTOXMark;
- }
- }
- return *pNew;
-}
-
-const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos,
- const SwTOXBase& rTOX,
- const SfxItemSet* pSet,
- sal_Bool bExpand )
-{
- GetIDocumentUndoRedo().StartUndo( UNDO_INSTOX, NULL );
-
- String sSectNm( rTOX.GetTOXName() );
- sSectNm = GetUniqueTOXBaseName( *rTOX.GetTOXType(), &sSectNm );
- SwPaM aPam( rPos );
- SwSectionData aSectionData( TOX_CONTENT_SECTION, sSectNm );
- SwTOXBaseSection *const pNewSection = dynamic_cast<SwTOXBaseSection *>(
- InsertSwSection( aPam, aSectionData, & rTOX, pSet, false ));
- if (pNewSection)
- {
- SwSectionNode *const pSectNd = pNewSection->GetFmt()->GetSectionNode();
- pNewSection->SetTOXName(sSectNm); // rTOX may have had no name...
-
- if( bExpand )
- {
- // add value for 2nd parameter = true to
- // indicate, that a creation of a new table of content has to be performed.
- // Value of 1st parameter = default value.
- pNewSection->Update( 0, true );
- }
- else if( 1 == rTOX.GetTitle().Len() && IsInReading() )
- // insert title of TOX
- {
- // then insert the headline section
- SwNodeIndex aIdx( *pSectNd, +1 );
-
- SwTxtNode* pHeadNd = GetNodes().MakeTxtNode( aIdx,
- GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
-
- String sNm( pNewSection->GetTOXName() );
- // ??Resource
- sNm.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "_Head" ));
-
- SwSectionData headerData( TOX_HEADER_SECTION, sNm );
-
- SwNodeIndex aStt( *pHeadNd ); aIdx--;
- SwSectionFmt* pSectFmt = MakeSectionFmt( 0 );
- GetNodes().InsertTextSection(
- aStt, *pSectFmt, headerData, 0, &aIdx, true, false);
- }
- }
-
- GetIDocumentUndoRedo().EndUndo( UNDO_INSTOX, NULL );
-
- return pNewSection;
-}
-
-const SwTOXBaseSection* SwDoc::InsertTableOf( sal_uLong nSttNd, sal_uLong nEndNd,
- const SwTOXBase& rTOX,
- const SfxItemSet* pSet )
-{
- // check for recursiv TOX
- SwNode* pNd = GetNodes()[ nSttNd ];
- SwSectionNode* pSectNd = pNd->FindSectionNode();
- while( pSectNd )
- {
- SectionType eT = pSectNd->GetSection().GetType();
- if( TOX_HEADER_SECTION == eT || TOX_CONTENT_SECTION == eT )
- return 0;
- pSectNd = pSectNd->StartOfSectionNode()->FindSectionNode();
- }
-
- String sSectNm( rTOX.GetTOXName() );
- sSectNm = GetUniqueTOXBaseName(*rTOX.GetTOXType(), &sSectNm);
-
- SwSectionData aSectionData( TOX_CONTENT_SECTION, sSectNm );
-
- SwNodeIndex aStt( GetNodes(), nSttNd ), aEnd( GetNodes(), nEndNd );
- SwSectionFmt* pFmt = MakeSectionFmt( 0 );
- if(pSet)
- pFmt->SetFmtAttr(*pSet);
-
- // --aEnd; // End is inclusive in InsertSection
-
- SwSectionNode *const pNewSectionNode =
- GetNodes().InsertTextSection(aStt, *pFmt, aSectionData, &rTOX, &aEnd);
- if (!pNewSectionNode)
- {
- DelSectionFmt( pFmt );
- return 0;
- }
-
- SwTOXBaseSection *const pNewSection(
- dynamic_cast<SwTOXBaseSection*>(& pNewSectionNode->GetSection()));
- pNewSection->SetTOXName(sSectNm); // rTOX may have had no name...
- return pNewSection;
-}
-
-/*--------------------------------------------------------------------
- Description: Get current table of contents
- --------------------------------------------------------------------*/
-const SwTOXBase* SwDoc::GetCurTOX( const SwPosition& rPos ) const
-{
- const SwNode& rNd = rPos.nNode.GetNode();
- const SwSectionNode* pSectNd = rNd.FindSectionNode();
- while( pSectNd )
- {
- SectionType eT = pSectNd->GetSection().GetType();
- if( TOX_CONTENT_SECTION == eT )
- {
- OSL_ENSURE( pSectNd->GetSection().ISA( SwTOXBaseSection ),
- "no TOXBaseSection!" );
- SwTOXBaseSection& rTOXSect = (SwTOXBaseSection&)
- pSectNd->GetSection();
- return &rTOXSect;
- }
- pSectNd = pSectNd->StartOfSectionNode()->FindSectionNode();
- }
- return 0;
-}
-
-const SwAttrSet& SwDoc::GetTOXBaseAttrSet(const SwTOXBase& rTOXBase) const
-{
- OSL_ENSURE( rTOXBase.ISA( SwTOXBaseSection ), "no TOXBaseSection!" );
- const SwTOXBaseSection& rTOXSect = (const SwTOXBaseSection&)rTOXBase;
- SwSectionFmt* pFmt = rTOXSect.GetFmt();
- OSL_ENSURE( pFmt, "invalid TOXBaseSection!" );
- return pFmt->GetAttrSet();
-}
-
-const SwTOXBase* SwDoc::GetDefaultTOXBase( TOXTypes eTyp, sal_Bool bCreate )
-{
- SwTOXBase** prBase = 0;
- switch(eTyp)
- {
- case TOX_CONTENT: prBase = &pDefTOXBases->pContBase; break;
- case TOX_INDEX: prBase = &pDefTOXBases->pIdxBase; break;
- case TOX_USER: prBase = &pDefTOXBases->pUserBase; break;
- case TOX_TABLES: prBase = &pDefTOXBases->pTblBase; break;
- case TOX_OBJECTS: prBase = &pDefTOXBases->pObjBase; break;
- case TOX_ILLUSTRATIONS: prBase = &pDefTOXBases->pIllBase; break;
- case TOX_AUTHORITIES: prBase = &pDefTOXBases->pAuthBase; break;
- }
- if(!(*prBase) && bCreate)
- {
- SwForm aForm(eTyp);
- const SwTOXType* pType = GetTOXType(eTyp, 0);
- (*prBase) = new SwTOXBase(pType, aForm, 0, pType->GetTypeName());
- }
- return (*prBase);
-}
-
-void SwDoc::SetDefaultTOXBase(const SwTOXBase& rBase)
-{
- SwTOXBase** prBase = 0;
- switch(rBase.GetType())
- {
- case TOX_CONTENT: prBase = &pDefTOXBases->pContBase; break;
- case TOX_INDEX: prBase = &pDefTOXBases->pIdxBase; break;
- case TOX_USER: prBase = &pDefTOXBases->pUserBase; break;
- case TOX_TABLES: prBase = &pDefTOXBases->pTblBase; break;
- case TOX_OBJECTS: prBase = &pDefTOXBases->pObjBase; break;
- case TOX_ILLUSTRATIONS: prBase = &pDefTOXBases->pIllBase; break;
- case TOX_AUTHORITIES: prBase = &pDefTOXBases->pAuthBase; break;
- }
- if(*prBase)
- delete (*prBase);
- (*prBase) = new SwTOXBase(rBase);
-}
-
-/*--------------------------------------------------------------------
- Description: Delete table of contents
- --------------------------------------------------------------------*/
-sal_Bool SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, sal_Bool bDelNodes )
-{
- // We only delete the TOX, not the Nodes
- sal_Bool bRet = sal_False;
- OSL_ENSURE( rTOXBase.ISA( SwTOXBaseSection ), "no TOXBaseSection!" );
-
- const SwTOXBaseSection& rTOXSect = (const SwTOXBaseSection&)rTOXBase;
- SwSectionFmt* pFmt = rTOXSect.GetFmt();
- if( pFmt )
- {
- GetIDocumentUndoRedo().StartUndo( UNDO_CLEARTOXRANGE, NULL );
-
- /* Save the start node of the TOX' section. */
- SwSectionNode * pMyNode = pFmt->GetSectionNode();
- /* Save start node of section's surrounding. */
- SwNode * pStartNd = pMyNode->StartOfSectionNode();
-
- /* Look for the point where to move the cursors in the area to
- delete to. This is done by first searching forward from the
- end of the TOX' section. If no content node is found behind
- the TOX one is searched before it. If this is not
- successfull, too, insert new text node behind the end of
- the TOX' section. The cursors from the TOX' section will be
- moved to the content node found or the new text node. */
-
- /* Set PaM to end of TOX' section and search following content node.
- aSearchPam will contain the point where to move the cursors
- to. */
- SwPaM aSearchPam(*pMyNode->EndOfSectionNode());
- SwPosition aEndPos(*pStartNd->EndOfSectionNode());
- if (! aSearchPam.Move() /* no content node found */
- || *aSearchPam.GetPoint() >= aEndPos /* content node found
- outside surrounding */
- )
- {
- /* Set PaM to beginning of TOX' section and search previous
- content node */
- SwPaM aTmpPam(*pMyNode);
- aSearchPam = aTmpPam;
- SwPosition aStartPos(*pStartNd);
-
- if ( ! aSearchPam.Move(fnMoveBackward) /* no content node found */
- || *aSearchPam.GetPoint() <= aStartPos /* content node
- found outside
- surrounding */
- )
- {
- /* There is no content node in the surrounding of
- TOX'. Append text node behind TOX' section. */
-
- SwPosition aInsPos(*pMyNode->EndOfSectionNode());
- AppendTxtNode(aInsPos);
-
- SwPaM aTmpPam1(aInsPos);
- aSearchPam = aTmpPam1;
- }
- }
-
-
- /* PaM containing the TOX. */
- SwPaM aPam(*pMyNode->EndOfSectionNode(), *pMyNode);
-
- /* Move cursors contained in TOX to the above calculated point. */
- PaMCorrAbs(aPam, *aSearchPam.GetPoint());
-
- if( !bDelNodes )
- {
- SwSections aArr( 0 );
- sal_uInt16 nCnt = pFmt->GetChildSections( aArr, SORTSECT_NOT, sal_False );
- for( sal_uInt16 n = 0; n < nCnt; ++n )
- {
- SwSection* pSect = aArr[ n ];
- if( TOX_HEADER_SECTION == pSect->GetType() )
- {
- DelSectionFmt( pSect->GetFmt(), bDelNodes );
- }
- }
- }
-
- DelSectionFmt( pFmt, bDelNodes );
-
- GetIDocumentUndoRedo().EndUndo( UNDO_CLEARTOXRANGE, NULL );
- bRet = sal_True;
- }
-
- return bRet;
-}
-
-/*--------------------------------------------------------------------
- Description: Manage table of content types
- --------------------------------------------------------------------*/
-sal_uInt16 SwDoc::GetTOXTypeCount(TOXTypes eTyp) const
-{
- const SwTOXTypePtr * ppTTypes = pTOXTypes->GetData();
- sal_uInt16 nCnt = 0;
- for( sal_uInt16 n = 0; n < pTOXTypes->Count(); ++n, ++ppTTypes )
- if( eTyp == (*ppTTypes)->GetType() )
- ++nCnt;
- return nCnt;
-}
-
-const SwTOXType* SwDoc::GetTOXType( TOXTypes eTyp, sal_uInt16 nId ) const
-{
- const SwTOXTypePtr * ppTTypes = pTOXTypes->GetData();
- sal_uInt16 nCnt = 0;
- for( sal_uInt16 n = 0; n < pTOXTypes->Count(); ++n, ++ppTTypes )
- if( eTyp == (*ppTTypes)->GetType() && nCnt++ == nId )
- return (*ppTTypes);
- return 0;
-}
-
-const SwTOXType* SwDoc::InsertTOXType( const SwTOXType& rTyp )
-{
- SwTOXType * pNew = new SwTOXType( rTyp );
- pTOXTypes->Insert( pNew, pTOXTypes->Count() );
- return pNew;
-}
-
-String SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType,
- const String* pChkStr ) const
-{
- sal_uInt16 n;
- const SwSectionNode* pSectNd;
- const SwSection* pSect;
-
- if(pChkStr && !pChkStr->Len())
- pChkStr = 0;
- String aName( rType.GetTypeName() );
- xub_StrLen nNmLen = aName.Len();
-
- sal_uInt16 nNum = 0;
- sal_uInt16 nTmp = 0;
- sal_uInt16 nFlagSize = ( pSectionFmtTbl->Count() / 8 ) +2;
- sal_uInt8* pSetFlags = new sal_uInt8[ nFlagSize ];
- memset( pSetFlags, 0, nFlagSize );
-
- for( n = 0; n < pSectionFmtTbl->Count(); ++n )
- if( 0 != ( pSectNd = (*pSectionFmtTbl)[ n ]->GetSectionNode( sal_False ) )&&
- TOX_CONTENT_SECTION == (pSect = &pSectNd->GetSection())->GetType())
- {
- const String& rNm = pSect->GetSectionName();
- if( rNm.Match( aName ) == nNmLen )
- {
- // Calculate number and set the Flag
- nNum = (sal_uInt16)rNm.Copy( nNmLen ).ToInt32();
- if( nNum-- && nNum < pSectionFmtTbl->Count() )
- pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
- }
- if( pChkStr && pChkStr->Equals( rNm ) )
- pChkStr = 0;
- }
-
- if( !pChkStr )
- {
- // All Numbers have been flagged accordingly, so get the right Number
- nNum = pSectionFmtTbl->Count();
- for( n = 0; n < nFlagSize; ++n )
- if( 0xff != ( nTmp = pSetFlags[ n ] ))
- {
- // so get the Number
- nNum = n * 8;
- while( nTmp & 1 )
- ++nNum, nTmp >>= 1;
- break;
- }
- }
- delete [] pSetFlags;
- if( pChkStr )
- return *pChkStr;
- return aName += String::CreateFromInt32( ++nNum );
-}
-
-sal_Bool SwDoc::SetTOXBaseName(const SwTOXBase& rTOXBase, const String& rName)
-{
- OSL_ENSURE( rTOXBase.ISA( SwTOXBaseSection ),
- "no TOXBaseSection!" );
- SwTOXBaseSection* pTOX = (SwTOXBaseSection*)&rTOXBase;
-
- String sTmp = GetUniqueTOXBaseName(*rTOXBase.GetTOXType(), &rName);
- sal_Bool bRet = sTmp == rName;
- if(bRet)
- {
- pTOX->SetTOXName(rName);
- pTOX->SetSectionName(rName);
- SetModified();
- }
- return bRet;
-}
-
const SwTxtNode* lcl_FindChapterNode( const SwNode& rNd, sal_uInt8 nLvl = 0 )
{
const SwNode* pNd = &rNd;
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 8c3b37393532..59ab2e403575 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -382,258 +382,6 @@ SwTableNode* SwNodes::InsertTable( const SwNodeIndex& rNdIdx,
//---------------- Text -> Tabelle -----------------------
-const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTblOpts,
- const SwPaM& rRange, sal_Unicode cCh,
- sal_Int16 eAdjust,
- const SwTableAutoFmt* pTAFmt )
-{
- // pruefe ob in der Selection eine Tabelle liegt
- const SwPosition *pStt = rRange.Start(), *pEnd = rRange.End();
- {
- sal_uLong nCnt = pStt->nNode.GetIndex();
- for( ; nCnt <= pEnd->nNode.GetIndex(); ++nCnt )
- if( !GetNodes()[ nCnt ]->IsTxtNode() )
- return 0;
- }
-
- /* Save first node in the selection if it is a context node. */
- SwCntntNode * pSttCntntNd = pStt->nNode.GetNode().GetCntntNode();
-
- SwPaM aOriginal( *pStt, *pEnd );
- pStt = aOriginal.GetMark();
- pEnd = aOriginal.GetPoint();
-
- SwUndoTxtToTbl* pUndo = 0;
- if( GetIDocumentUndoRedo().DoesUndo() )
- {
- GetIDocumentUndoRedo().StartUndo( UNDO_TEXTTOTABLE, NULL );
- pUndo = new SwUndoTxtToTbl( aOriginal, rInsTblOpts, cCh,
- static_cast<sal_uInt16>(eAdjust), pTAFmt );
- GetIDocumentUndoRedo().AppendUndo( pUndo );
-
- // das Splitten vom TextNode nicht in die Undohistory aufnehmen
- GetIDocumentUndoRedo().DoUndo( false );
- }
-
- ::PaMCorrAbs( aOriginal, *pEnd );
-
- // sorge dafuer, das der Bereich auf Node-Grenzen liegt
- SwNodeRange aRg( pStt->nNode, pEnd->nNode );
- if( pStt->nContent.GetIndex() )
- SplitNode( *pStt, false );
-
- sal_Bool bEndCntnt = 0 != pEnd->nContent.GetIndex();
- // nicht splitten am Ende der Zeile (aber am Ende vom Doc!!)
- if( bEndCntnt )
- {
- if( pEnd->nNode.GetNode().GetCntntNode()->Len() != pEnd->nContent.GetIndex()
- || pEnd->nNode.GetIndex() >= GetNodes().GetEndOfContent().GetIndex()-1 )
- {
- SplitNode( *pEnd, false );
- ((SwNodeIndex&)pEnd->nNode)--;
- ((SwIndex&)pEnd->nContent).Assign(
- pEnd->nNode.GetNode().GetCntntNode(), 0 );
- // ein Node und am Ende ??
- if( pStt->nNode.GetIndex() >= pEnd->nNode.GetIndex() )
- aRg.aStart--;
- }
- else
- aRg.aEnd++;
- }
-
-
- if( aRg.aEnd.GetIndex() == aRg.aStart.GetIndex() )
- {
- OSL_FAIL( "Kein Bereich" );
- aRg.aEnd++;
- }
-
- // Wir gehen jetzt immer ueber die Upper, um die Tabelle einzufuegen:
- SwNode2Layout aNode2Layout( aRg.aStart.GetNode() );
-
- GetIDocumentUndoRedo().DoUndo( 0 != pUndo );
-
- // dann erstelle die Box/Line/Table-Struktur
- SwTableBoxFmt* pBoxFmt = MakeTableBoxFmt();
- SwTableLineFmt* pLineFmt = MakeTableLineFmt();
- SwTableFmt* pTableFmt = MakeTblFrmFmt( GetUniqueTblName(), GetDfltFrmFmt() );
-
- // alle Zeilen haben die Fill-Order von links nach rechts !
- pLineFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ));
- // die Tabelle bekommt USHRT_MAX als default SSize
- pTableFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX ));
- if( !(rInsTblOpts.mnInsMode & tabopts::SPLIT_LAYOUT) )
- pTableFmt->SetFmtAttr( SwFmtLayoutSplit( sal_False ));
-
- /* If the first node in the selection is a context node and if it
- has an item FRAMEDIR set (no default) propagate the item to the
- replacing table. */
- if (pSttCntntNd)
- {
- const SwAttrSet & aNdSet = pSttCntntNd->GetSwAttrSet();
- const SfxPoolItem *pItem = NULL;
-
- if (SFX_ITEM_SET == aNdSet.GetItemState( RES_FRAMEDIR, sal_True, &pItem )
- && pItem != NULL)
- {
- pTableFmt->SetFmtAttr( *pItem );
- }
- }
-
- SwTableNode* pTblNd = GetNodes().TextToTable(
- aRg, cCh, pTableFmt, pLineFmt, pBoxFmt,
- GetTxtCollFromPool( RES_POOLCOLL_STANDARD ), pUndo );
-
- SwTable * pNdTbl = &pTblNd->GetTable();
- OSL_ENSURE( pNdTbl, "kein Tabellen-Node angelegt." );
-
- const sal_uInt16 nRowsToRepeat =
- tabopts::HEADLINE == (rInsTblOpts.mnInsMode & tabopts::HEADLINE) ?
- rInsTblOpts.mnRowsToRepeat :
- 0;
- pNdTbl->SetRowsToRepeat( nRowsToRepeat );
-
- sal_Bool bUseBoxFmt = sal_False;
- if( !pBoxFmt->GetDepends() )
- {
- // die Formate an den Boxen haben schon die richtige Size, es darf
- // also nur noch die richtige Umrandung/AutoFmt gesetzt werden.
- bUseBoxFmt = sal_True;
- pTableFmt->SetFmtAttr( pBoxFmt->GetFrmSize() );
- delete pBoxFmt;
- eAdjust = text::HoriOrientation::NONE;
- }
-
- //Orientation am Fmt der Table setzen
- pTableFmt->SetFmtAttr( SwFmtHoriOrient( 0, eAdjust ) );
- pNdTbl->RegisterToFormat( *pTableFmt );
-
- if( pTAFmt || ( rInsTblOpts.mnInsMode & tabopts::DEFAULT_BORDER) )
- {
- sal_uInt8 nBoxArrLen = pTAFmt ? 16 : 4;
- SvPtrarr aBoxFmtArr( nBoxArrLen );
- {
- for( sal_uInt8 i = 0; i < nBoxArrLen; ++i )
- aBoxFmtArr.Insert( (void*)0, i );
- }
-
- SfxItemSet aCharSet( GetAttrPool(), RES_CHRATR_BEGIN, RES_PARATR_LIST_END-1 );
-
- SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0;
-
- SwTableBoxFmt *pBoxF = 0;
- SwTableLines& rLines = pNdTbl->GetTabLines();
- sal_uInt16 nRows = rLines.Count();
- for( sal_uInt16 n = 0; n < nRows; ++n )
- {
- SwTableBoxes& rBoxes = rLines[ n ]->GetTabBoxes();
- sal_uInt16 nCols = rBoxes.Count();
- for( sal_uInt16 i = 0; i < nCols; ++i )
- {
- SwTableBox* pBox = rBoxes[ i ];
- sal_Bool bChgSz = sal_False;
-
- if( pTAFmt )
- {
- sal_uInt8 nId = static_cast<sal_uInt8>(!n ? 0 : (( n+1 == nRows )
- ? 12 : (4 * (1 + ((n-1) & 1 )))));
- nId = nId + static_cast<sal_uInt8>(!i ? 0 :
- ( i+1 == nCols ? 3 : (1 + ((i-1) & 1))));
- if( bUseBoxFmt )
- ::lcl_SetDfltBoxAttr( *pBox, aBoxFmtArr, nId, pTAFmt );
- else
- {
- bChgSz = 0 == aBoxFmtArr[ nId ];
- pBoxF = ::lcl_CreateAFmtBoxFmt( *this, aBoxFmtArr,
- *pTAFmt, USHRT_MAX, nId );
- }
-
- // ggfs. noch die Absatz/ZeichenAttribute setzen
- if( pTAFmt->IsFont() || pTAFmt->IsJustify() )
- {
- aCharSet.ClearItem();
- pTAFmt->UpdateToSet( nId, aCharSet,
- SwTableAutoFmt::UPDATE_CHAR, 0 );
- if( aCharSet.Count() )
- {
- sal_uLong nSttNd = pBox->GetSttIdx()+1;
- sal_uLong nEndNd = pBox->GetSttNd()->EndOfSectionIndex();
- for( ; nSttNd < nEndNd; ++nSttNd )
- {
- SwCntntNode* pNd = GetNodes()[ nSttNd ]->GetCntntNode();
- if( pNd )
- {
- if( pHistory )
- {
- SwRegHistory aReg( pNd, *pNd, pHistory );
- pNd->SetAttr( aCharSet );
- }
- else
- pNd->SetAttr( aCharSet );
- }
- }
- }
- }
- }
- else
- {
- sal_uInt8 nId = (i < nCols - 1 ? 0 : 1) + (n ? 2 : 0 );
- if( bUseBoxFmt )
- ::lcl_SetDfltBoxAttr( *pBox, aBoxFmtArr, nId );
- else
- {
- bChgSz = 0 == aBoxFmtArr[ nId ];
- pBoxF = ::lcl_CreateDfltBoxFmt( *this, aBoxFmtArr,
- USHRT_MAX, nId );
- }
- }
-
- if( !bUseBoxFmt )
- {
- if( bChgSz )
- pBoxF->SetFmtAttr( pBox->GetFrmFmt()->GetFrmSize() );
- pBox->ChgFrmFmt( pBoxF );
- }
- }
- }
-
- if( bUseBoxFmt )
- {
- for( sal_uInt8 i = 0; i < nBoxArrLen; ++i )
- {
- SvPtrarr* pArr = (SvPtrarr*)aBoxFmtArr[ i ];
- delete pArr;
- }
- }
- }
-
- // JP 03.04.97: Inhalt der Boxen auf Zahlen abpruefen
- if( IsInsTblFormatNum() )
- {
- for( sal_uInt16 nBoxes = pNdTbl->GetTabSortBoxes().Count(); nBoxes; )
- ChkBoxNumFmt( *pNdTbl->GetTabSortBoxes()[ --nBoxes ], sal_False );
- }
-
- sal_uLong nIdx = pTblNd->GetIndex();
- aNode2Layout.RestoreUpperFrms( GetNodes(), nIdx, nIdx + 1 );
-
- {
- SwPaM& rTmp = (SwPaM&)rRange; // Point immer an den Anfang
- rTmp.DeleteMark();
- rTmp.GetPoint()->nNode = *pTblNd;
- SwCntntNode* pCNd = GetNodes().GoNext( &rTmp.GetPoint()->nNode );
- rTmp.GetPoint()->nContent.Assign( pCNd, 0 );
- }
-
- if( pUndo )
- {
- GetIDocumentUndoRedo().EndUndo( UNDO_TEXTTOTABLE, NULL );
- }
-
- SetModified();
- SetFieldsDirty(true, NULL, 0);
- return pNdTbl;
-}
SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
SwTableFmt* pTblFmt,
@@ -829,120 +577,6 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh,
return pTblNd;
}
-const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> >& rTableNodes )
-{
- /* Save first node in the selection if it is a content node. */
- SwCntntNode * pSttCntntNd = rTableNodes.begin()->begin()->aStart.GetNode().GetCntntNode();
-
- /**debug**/
-#if OSL_DEBUG_LEVEL > 1
- const SwNodeRange& rStartRange = *rTableNodes.begin()->begin();
- const SwNodeRange& rEndRange = *rTableNodes.rbegin()->rbegin();
- (void) rStartRange;
- (void) rEndRange;
-#endif
- /**debug**/
-
- //!!! not necessarily TextNodes !!!
- SwPaM aOriginal( rTableNodes.begin()->begin()->aStart, rTableNodes.rbegin()->rbegin()->aEnd );
- const SwPosition *pStt = aOriginal.GetMark();
- const SwPosition *pEnd = aOriginal.GetPoint();
-
-// SwUndoTxtToTbl* pUndo = 0;
- bool const bUndo(GetIDocumentUndoRedo().DoesUndo());
- if (bUndo)
- {
- // das Splitten vom TextNode nicht in die Undohistory aufnehmen
- GetIDocumentUndoRedo().DoUndo(false);
- }
-
- ::PaMCorrAbs( aOriginal, *pEnd );
-
- // sorge dafuer, das der Bereich auf Node-Grenzen liegt
- SwNodeRange aRg( pStt->nNode, pEnd->nNode );
- if( pStt->nContent.GetIndex() )
- SplitNode( *pStt, false );
-
- sal_Bool bEndCntnt = 0 != pEnd->nContent.GetIndex();
- // nicht splitten am Ende der Zeile (aber am Ende vom Doc!!)
- if( bEndCntnt )
- {
- if( pEnd->nNode.GetNode().GetCntntNode()->Len() != pEnd->nContent.GetIndex()
- || pEnd->nNode.GetIndex() >= GetNodes().GetEndOfContent().GetIndex()-1 )
- {
- SplitNode( *pEnd, false );
- ((SwNodeIndex&)pEnd->nNode)--;
- ((SwIndex&)pEnd->nContent).Assign(
- pEnd->nNode.GetNode().GetCntntNode(), 0 );
- // ein Node und am Ende ??
- if( pStt->nNode.GetIndex() >= pEnd->nNode.GetIndex() )
- aRg.aStart--;
- }
- else
- aRg.aEnd++;
- }
-
-
- if( aRg.aEnd.GetIndex() == aRg.aStart.GetIndex() )
- {
- OSL_FAIL( "Kein Bereich" );
- aRg.aEnd++;
- }
-
- // Wir gehen jetzt immer ueber die Upper, um die Tabelle einzufuegen:
- SwNode2Layout aNode2Layout( aRg.aStart.GetNode() );
-
- GetIDocumentUndoRedo().DoUndo(bUndo);
-
- // dann erstelle die Box/Line/Table-Struktur
- SwTableBoxFmt* pBoxFmt = MakeTableBoxFmt();
- SwTableLineFmt* pLineFmt = MakeTableLineFmt();
- SwTableFmt* pTableFmt = MakeTblFrmFmt( GetUniqueTblName(), GetDfltFrmFmt() );
-
- // alle Zeilen haben die Fill-Order von links nach rechts !
- pLineFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ));
- // die Tabelle bekommt USHRT_MAX als default SSize
- pTableFmt->SetFmtAttr( SwFmtFrmSize( ATT_VAR_SIZE, USHRT_MAX ));
-
- /* If the first node in the selection is a context node and if it
- has an item FRAMEDIR set (no default) propagate the item to the
- replacing table. */
- if (pSttCntntNd)
- {
- const SwAttrSet & aNdSet = pSttCntntNd->GetSwAttrSet();
- const SfxPoolItem *pItem = NULL;
-
- if (SFX_ITEM_SET == aNdSet.GetItemState( RES_FRAMEDIR, sal_True, &pItem )
- && pItem != NULL)
- {
- pTableFmt->SetFmtAttr( *pItem );
- }
- }
-
- SwTableNode* pTblNd = GetNodes().TextToTable(
- rTableNodes, pTableFmt, pLineFmt, pBoxFmt,
- GetTxtCollFromPool( RES_POOLCOLL_STANDARD )/*, pUndo*/ );
-
- SwTable * pNdTbl = &pTblNd->GetTable();
- OSL_ENSURE( pNdTbl, "kein Tabellen-Node angelegt." );
- pNdTbl->RegisterToFormat( *pTableFmt );
-
- if( !pBoxFmt->GetDepends() )
- {
- // die Formate an den Boxen haben schon die richtige Size, es darf
- // also nur noch die richtige Umrandung/AutoFmt gesetzt werden.
- pTableFmt->SetFmtAttr( pBoxFmt->GetFrmSize() );
- delete pBoxFmt;
- }
-
- sal_uLong nIdx = pTblNd->GetIndex();
- aNode2Layout.RestoreUpperFrms( GetNodes(), nIdx, nIdx + 1 );
-
- SetModified();
- SetFieldsDirty( true, NULL, 0 );
- return pNdTbl;
-}
-
SwNodeRange * SwNodes::ExpandRangeForTableBox(const SwNodeRange & rRange)
{
SwNodeRange * pResult = NULL;
@@ -1152,48 +786,6 @@ SwTableNode* SwNodes::TextToTable( const SwNodes::TableRanges_t & rTableNodes,
//---------------- Tabelle -> Text -----------------------
-sal_Bool SwDoc::TableToText( const SwTableNode* pTblNd, sal_Unicode cCh )
-{
- if( !pTblNd )
- return sal_False;
-
- // #i34471#
- // If this is trigged by SwUndoTblToTxt::Repeat() nobody ever deleted
- // the table cursor.
- SwEditShell* pESh = GetEditShell();
- if( pESh && pESh->IsTableMode() )
- pESh->ClearMark();
-
- SwNodeRange aRg( *pTblNd, 0, *pTblNd->EndOfSectionNode() );
- SwUndoTblToTxt* pUndo = 0;
- SwNodeRange* pUndoRg = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().ClearRedo();
- pUndoRg = new SwNodeRange( aRg.aStart, -1, aRg.aEnd, +1 );
- pUndo = new SwUndoTblToTxt( pTblNd->GetTable(), cCh );
- }
-
- SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
- aMsgHnt.eFlags = TBL_BOXNAME;
- UpdateTblFlds( &aMsgHnt );
-
- sal_Bool bRet = GetNodes().TableToText( aRg, cCh, pUndo );
- if( pUndoRg )
- {
- pUndoRg->aStart++;
- pUndoRg->aEnd--;
- pUndo->SetRange( *pUndoRg );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- delete pUndoRg;
- }
-
- if( bRet )
- SetModified();
-
- return bRet;
-}
-
// -- benutze die ForEach Methode vom PtrArray um aus einer Tabelle wieder
// Text zuerzeugen. (Die Boxen koennen auch noch Lines enthalten !!)
struct _DelTabPara
@@ -1404,661 +996,6 @@ sal_Bool SwNodes::TableToText( const SwNodeRange& rRange, sal_Unicode cCh,
}
-// ----- einfuegen von Spalten/Zeilen ------------------------
-
-sal_Bool SwDoc::InsertCol( const SwCursor& rCursor, sal_uInt16 nCnt, sal_Bool bBehind )
-{
- if( !::CheckSplitCells( rCursor, nCnt + 1, nsSwTblSearchType::TBLSEARCH_COL ) )
- return sal_False;
-
- // lasse ueber das Layout die Boxen suchen
- SwSelBoxes aBoxes;
- ::GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
-
- sal_Bool bRet = sal_False;
- if( !aBoxes.empty() )
- bRet = InsertCol( aBoxes, nCnt, bBehind );
- return bRet;
-}
-
-sal_Bool SwDoc::InsertCol( const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bBehind )
-{
- // uebers SwDoc fuer Undo !!
- OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" );
- SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode());
- if( !pTblNd )
- return sal_False;
-
- SwTable& rTbl = pTblNd->GetTable();
- if( rTbl.ISA( SwDDETable ))
- return sal_False;
-
- SwTableSortBoxes aTmpLst( 0 );
- SwUndoTblNdsChg* pUndo = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo = new SwUndoTblNdsChg( UNDO_TABLE_INSCOL, rBoxes, *pTblNd,
- 0, 0, nCnt, bBehind, sal_False );
- aTmpLst.Insert( &rTbl.GetTabSortBoxes(), 0, rTbl.GetTabSortBoxes().Count() );
- }
-
- bool bRet(false);
- {
- ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
-
- SwTableFmlUpdate aMsgHnt( &rTbl );
- aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
-
- bRet = rTbl.InsertCol( this, rBoxes, nCnt, bBehind );
- if (bRet)
- {
- SetModified();
- ::ClearFEShellTabCols();
- SetFieldsDirty( true, NULL, 0 );
- }
- }
-
- if( pUndo )
- {
- if( bRet )
- {
- pUndo->SaveNewBoxes( *pTblNd, aTmpLst );
- GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
- else
- delete pUndo;
- }
- return bRet;
-}
-
-sal_Bool SwDoc::InsertRow( const SwCursor& rCursor, sal_uInt16 nCnt, sal_Bool bBehind )
-{
- // lasse ueber das Layout die Boxen suchen
- SwSelBoxes aBoxes;
- GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
-
- sal_Bool bRet = sal_False;
- if( !aBoxes.empty() )
- bRet = InsertRow( aBoxes, nCnt, bBehind );
- return bRet;
-}
-
-sal_Bool SwDoc::InsertRow( const SwSelBoxes& rBoxes, sal_uInt16 nCnt, sal_Bool bBehind )
-{
- // uebers SwDoc fuer Undo !!
- OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" );
- SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode());
- if( !pTblNd )
- return sal_False;
-
- SwTable& rTbl = pTblNd->GetTable();
- if( rTbl.ISA( SwDDETable ))
- return sal_False;
-
- SwTableSortBoxes aTmpLst( 0 );
- SwUndoTblNdsChg* pUndo = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo = new SwUndoTblNdsChg( UNDO_TABLE_INSROW,rBoxes, *pTblNd,
- 0, 0, nCnt, bBehind, sal_False );
- aTmpLst.Insert( &rTbl.GetTabSortBoxes(), 0, rTbl.GetTabSortBoxes().Count() );
- }
-
- bool bRet(false);
- {
- ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
-
- SwTableFmlUpdate aMsgHnt( &rTbl );
- aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
-
- bRet = rTbl.InsertRow( this, rBoxes, nCnt, bBehind );
- if (bRet)
- {
- SetModified();
- ::ClearFEShellTabCols();
- SetFieldsDirty( true, NULL, 0 );
- }
- }
-
- if( pUndo )
- {
- if( bRet )
- {
- pUndo->SaveNewBoxes( *pTblNd, aTmpLst );
- GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
- else
- delete pUndo;
- }
- return bRet;
-
-}
-
-// ----- loeschen von Spalten/Zeilen ------------------------
-
-sal_Bool SwDoc::DeleteRow( const SwCursor& rCursor )
-{
- // lasse ueber das Layout die Boxen suchen
- SwSelBoxes aBoxes;
- GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
- if( ::HasProtectedCells( aBoxes ))
- return sal_False;
-
- // die Crsr aus dem Loeschbereich entfernen.
- // Der Cursor steht danach:
- // - es folgt noch eine Zeile, in dieser
- // - vorher steht noch eine Zeile, in dieser
- // - sonst immer dahinter
- {
- SwTableNode* pTblNd = rCursor.GetNode()->FindTableNode();
-
- if( pTblNd->GetTable().ISA( SwDDETable ))
- return sal_False;
-
- // suche alle Boxen / Lines
- _FndBox aFndBox( 0, 0 );
- {
- _FndPara aPara( aBoxes, &aFndBox );
- pTblNd->GetTable().GetTabLines().ForEach( &_FndLineCopyCol, &aPara );
- }
-
- if( !aFndBox.GetLines().Count() )
- return sal_False;
-
- SwEditShell* pESh = GetEditShell();
- if( pESh )
- {
- pESh->KillPams();
- // JP: eigentlich sollte man ueber alle Shells iterieren!!
- }
-
- _FndBox* pFndBox = &aFndBox;
- while( 1 == pFndBox->GetLines().Count() &&
- 1 == pFndBox->GetLines()[0]->GetBoxes().Count() )
- {
- _FndBox* pTmp = pFndBox->GetLines()[0]->GetBoxes()[0];
- if( pTmp->GetBox()->GetSttNd() )
- break; // das ist sonst zu weit
- pFndBox = pTmp;
- }
-
- SwTableLine* pDelLine = pFndBox->GetLines()[
- pFndBox->GetLines().Count()-1 ]->GetLine();
- SwTableBox* pDelBox = pDelLine->GetTabBoxes()[
- pDelLine->GetTabBoxes().Count() - 1 ];
- while( !pDelBox->GetSttNd() )
- {
- SwTableLine* pLn = pDelBox->GetTabLines()[
- pDelBox->GetTabLines().Count()-1 ];
- pDelBox = pLn->GetTabBoxes()[ pLn->GetTabBoxes().Count() - 1 ];
- }
- SwTableBox* pNextBox = pDelLine->FindNextBox( pTblNd->GetTable(),
- pDelBox, sal_True );
- while( pNextBox &&
- pNextBox->GetFrmFmt()->GetProtect().IsCntntProtected() )
- pNextBox = pNextBox->FindNextBox( pTblNd->GetTable(), pNextBox );
-
- if( !pNextBox ) // keine nachfolgende? dann die vorhergehende
- {
- pDelLine = pFndBox->GetLines()[ 0 ]->GetLine();
- pDelBox = pDelLine->GetTabBoxes()[ 0 ];
- while( !pDelBox->GetSttNd() )
- pDelBox = pDelBox->GetTabLines()[0]->GetTabBoxes()[0];
- pNextBox = pDelLine->FindPreviousBox( pTblNd->GetTable(),
- pDelBox, sal_True );
- while( pNextBox &&
- pNextBox->GetFrmFmt()->GetProtect().IsCntntProtected() )
- pNextBox = pNextBox->FindPreviousBox( pTblNd->GetTable(), pNextBox );
- }
-
- sal_uLong nIdx;
- if( pNextBox ) // dann den Cursor hier hinein
- nIdx = pNextBox->GetSttIdx() + 1;
- else // ansonsten hinter die Tabelle
- nIdx = pTblNd->EndOfSectionIndex() + 1;
-
- SwNodeIndex aIdx( GetNodes(), nIdx );
- SwCntntNode* pCNd = aIdx.GetNode().GetCntntNode();
- if( !pCNd )
- pCNd = GetNodes().GoNext( &aIdx );
-
- if( pCNd )
- {
- // die Cursor von der Shell oder den uebergebenen Cursor aendern?
- SwPaM* pPam = (SwPaM*)&rCursor;
- pPam->GetPoint()->nNode = aIdx;
- pPam->GetPoint()->nContent.Assign( pCNd, 0 );
- pPam->SetMark(); // beide wollen etwas davon haben
- pPam->DeleteMark();
- }
- }
-
- // dann loesche doch die Zeilen
-
- GetIDocumentUndoRedo().StartUndo(UNDO_ROW_DELETE, NULL);
- sal_Bool bResult = DeleteRowCol( aBoxes );
- GetIDocumentUndoRedo().EndUndo(UNDO_ROW_DELETE, NULL);
-
- return bResult;
-}
-
-sal_Bool SwDoc::DeleteCol( const SwCursor& rCursor )
-{
- // lasse ueber das Layout die Boxen suchen
- SwSelBoxes aBoxes;
- GetTblSel( rCursor, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
- if( ::HasProtectedCells( aBoxes ))
- return sal_False;
-
- // die Crsr muessen noch aus dem Loesch Bereich entfernt
- // werden. Setze sie immer hinter/auf die Tabelle; ueber die
- // Dokument-Position werden sie dann immer an die alte Position gesetzt.
- SwEditShell* pESh = GetEditShell();
- if( pESh )
- {
- const SwNode* pNd = rCursor.GetNode()->FindTableBoxStartNode();
- pESh->ParkCrsr( SwNodeIndex( *pNd ) );
- }
-
- // dann loesche doch die Spalten
- GetIDocumentUndoRedo().StartUndo(UNDO_COL_DELETE, NULL);
- sal_Bool bResult = DeleteRowCol( aBoxes, true );
- GetIDocumentUndoRedo().EndUndo(UNDO_COL_DELETE, NULL);
-
- return bResult;
-}
-
-sal_Bool SwDoc::DeleteRowCol( const SwSelBoxes& rBoxes, bool bColumn )
-{
- if( ::HasProtectedCells( rBoxes ))
- return sal_False;
-
- // uebers SwDoc fuer Undo !!
- OSL_ENSURE( !rBoxes.empty(), "keine gueltige Box-Liste" );
- SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode());
- if( !pTblNd )
- return sal_False;
-
- if( pTblNd->GetTable().ISA( SwDDETable ))
- return sal_False;
-
- ::ClearFEShellTabCols();
- SwSelBoxes aSelBoxes( rBoxes );
- SwTable &rTable = pTblNd->GetTable();
- long nMin = 0;
- long nMax = 0;
- if( rTable.IsNewModel() )
- {
- if( bColumn )
- rTable.ExpandColumnSelection( aSelBoxes, nMin, nMax );
- else
- rTable.FindSuperfluousRows( aSelBoxes );
- }
-
- // soll die gesamte Tabelle geloescht werden ??
- const sal_uLong nTmpIdx1 = pTblNd->GetIndex();
- const sal_uLong nTmpIdx2 = aSelBoxes.rbegin()->second->GetSttNd()->
- EndOfSectionIndex()+1;
- if( pTblNd->GetTable().GetTabSortBoxes().Count() == aSelBoxes.size() &&
- aSelBoxes.begin()->second->GetSttIdx()-1 == nTmpIdx1 &&
- nTmpIdx2 == pTblNd->EndOfSectionIndex() )
- {
- sal_Bool bNewTxtNd = sal_False;
- // steht diese auch noch alleine in einem FlyFrame ?
- SwNodeIndex aIdx( *pTblNd, -1 );
- const SwStartNode* pSttNd = aIdx.GetNode().GetStartNode();
- if( pSttNd )
- {
- const sal_uLong nTblEnd = pTblNd->EndOfSectionIndex() + 1;
- const sal_uLong nSectEnd = pSttNd->EndOfSectionIndex();
- if( nTblEnd == nSectEnd )
- {
- if( SwFlyStartNode == pSttNd->GetStartNodeType() )
- {
- SwFrmFmt* pFmt = pSttNd->GetFlyFmt();
- if( pFmt )
- {
- // Ok, das ist das gesuchte FlyFormat
- DelLayoutFmt( pFmt );
- return sal_True;
- }
- }
- // kein Fly ?? also Kopf- oder Fusszeile: dann immer einen
- // TextNode ueberig lassen.
- // Undo koennen wir dann vergessen !!
- bNewTxtNd = sal_True;
- }
- }
-
- // kein Fly ?? also Kopf- oder Fusszeile: dann immer einen
- // TextNode ueberig lassen.
- aIdx++;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().ClearRedo();
- SwPaM aPaM( *pTblNd->EndOfSectionNode(), aIdx.GetNode() );
-
- if( bNewTxtNd )
- {
- const SwNodeIndex aTmpIdx( *pTblNd->EndOfSectionNode(), 1 );
- GetNodes().MakeTxtNode( aTmpIdx,
- GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
- }
-
- // save the cursors (UNO and otherwise)
- SwPaM aSavePaM( SwNodeIndex( *pTblNd->EndOfSectionNode() ) );
- if( ! aSavePaM.Move( fnMoveForward, fnGoNode ) )
- {
- *aSavePaM.GetMark() = SwPosition( *pTblNd );
- aSavePaM.Move( fnMoveBackward, fnGoNode );
- }
- {
- SwPaM const tmpPaM(*pTblNd, *pTblNd->EndOfSectionNode());
- ::PaMCorrAbs(tmpPaM, *aSavePaM.GetMark());
- }
-
- // harte SeitenUmbrueche am nachfolgenden Node verschieben
- sal_Bool bSavePageBreak = sal_False, bSavePageDesc = sal_False;
- sal_uLong nNextNd = pTblNd->EndOfSectionIndex()+1;
- SwCntntNode* pNextNd = GetNodes()[ nNextNd ]->GetCntntNode();
- if( pNextNd )
- {
- {
- SwFrmFmt* pTableFmt = pTblNd->GetTable().GetFrmFmt();
- const SfxPoolItem *pItem;
- if( SFX_ITEM_SET == pTableFmt->GetItemState( RES_PAGEDESC,
- sal_False, &pItem ) )
- {
- pNextNd->SetAttr( *pItem );
- bSavePageDesc = sal_True;
- }
-
- if( SFX_ITEM_SET == pTableFmt->GetItemState( RES_BREAK,
- sal_False, &pItem ) )
- {
- pNextNd->SetAttr( *pItem );
- bSavePageBreak = sal_True;
- }
- }
- }
- SwUndoDelete* pUndo = new SwUndoDelete( aPaM );
- if( bNewTxtNd )
- pUndo->SetTblDelLastNd();
- pUndo->SetPgBrkFlags( bSavePageBreak, bSavePageDesc );
- pUndo->SetTableName(pTblNd->GetTable().GetFrmFmt()->GetName());
- GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
- else
- {
- if( bNewTxtNd )
- {
- const SwNodeIndex aTmpIdx( *pTblNd->EndOfSectionNode(), 1 );
- GetNodes().MakeTxtNode( aTmpIdx,
- GetTxtCollFromPool( RES_POOLCOLL_STANDARD ) );
- }
-
- // save the cursors (UNO and otherwise)
- SwPaM aSavePaM( SwNodeIndex( *pTblNd->EndOfSectionNode() ) );
- if( ! aSavePaM.Move( fnMoveForward, fnGoNode ) )
- {
- *aSavePaM.GetMark() = SwPosition( *pTblNd );
- aSavePaM.Move( fnMoveBackward, fnGoNode );
- }
- {
- SwPaM const tmpPaM(*pTblNd, *pTblNd->EndOfSectionNode());
- ::PaMCorrAbs(tmpPaM, *aSavePaM.GetMark());
- }
-
- // harte SeitenUmbrueche am nachfolgenden Node verschieben
- SwCntntNode* pNextNd = GetNodes()[ pTblNd->EndOfSectionIndex()+1 ]->GetCntntNode();
- if( pNextNd )
- {
- SwFrmFmt* pTableFmt = pTblNd->GetTable().GetFrmFmt();
- const SfxPoolItem *pItem;
- if( SFX_ITEM_SET == pTableFmt->GetItemState( RES_PAGEDESC,
- sal_False, &pItem ) )
- pNextNd->SetAttr( *pItem );
-
- if( SFX_ITEM_SET == pTableFmt->GetItemState( RES_BREAK,
- sal_False, &pItem ) )
- pNextNd->SetAttr( *pItem );
- }
-
- pTblNd->DelFrms();
- DeleteSection( pTblNd );
- }
- SetModified();
- SetFieldsDirty( true, NULL, 0 );
- return sal_True;
- }
-
- SwUndoTblNdsChg* pUndo = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo = new SwUndoTblNdsChg( UNDO_TABLE_DELBOX, aSelBoxes, *pTblNd,
- nMin, nMax, 0, sal_False, sal_False );
- }
-
- bool bRet(false);
- {
- ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
-
- SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
- aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
-
- if (rTable.IsNewModel())
- {
- if (bColumn)
- rTable.PrepareDeleteCol( nMin, nMax );
- rTable.FindSuperfluousRows( aSelBoxes );
- if (pUndo)
- pUndo->ReNewBoxes( aSelBoxes );
- }
- bRet = rTable.DeleteSel( this, aSelBoxes, 0, pUndo, sal_True, sal_True );
- if (bRet)
- {
- SetModified();
- SetFieldsDirty( true, NULL, 0 );
- }
- }
-
- if( pUndo )
- {
- if( bRet )
- {
- GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
- else
- delete pUndo;
- }
-
- return bRet;
-}
-
-
-// ---------- teilen / zusammenfassen von Boxen in der Tabelle --------
-
-sal_Bool SwDoc::SplitTbl( const SwSelBoxes& rBoxes, sal_Bool bVert, sal_uInt16 nCnt,
- sal_Bool bSameHeight )
-{
- // uebers SwDoc fuer Undo !!
- OSL_ENSURE( !rBoxes.empty() && nCnt, "keine gueltige Box-Liste" );
- SwTableNode* pTblNd = const_cast<SwTableNode*>(rBoxes.begin()->second->GetSttNd()->FindTableNode());
- if( !pTblNd )
- return sal_False;
-
- SwTable& rTbl = pTblNd->GetTable();
- if( rTbl.ISA( SwDDETable ))
- return sal_False;
-
- std::vector<sal_uLong> aNdsCnts;
- SwTableSortBoxes aTmpLst( 0 );
- SwUndoTblNdsChg* pUndo = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo = new SwUndoTblNdsChg( UNDO_TABLE_SPLIT, rBoxes, *pTblNd, 0, 0,
- nCnt, bVert, bSameHeight );
-
- aTmpLst.Insert( &rTbl.GetTabSortBoxes(), 0, rTbl.GetTabSortBoxes().Count() );
- if( !bVert )
- {
- for( SwSelBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it)
- {
- const SwStartNode* pSttNd = it->second->GetSttNd();
- aNdsCnts.push_back( pSttNd->EndOfSectionIndex() -
- pSttNd->GetIndex() );
- }
- }
- }
-
- bool bRet(false);
- {
- ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
-
- SwTableFmlUpdate aMsgHnt( &rTbl );
- aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
-
- if (bVert)
- bRet = rTbl.SplitCol( this, rBoxes, nCnt );
- else
- bRet = rTbl.SplitRow( this, rBoxes, nCnt, bSameHeight );
-
- if (bRet)
- {
- SetModified();
- SetFieldsDirty( true, NULL, 0 );
- }
- }
-
- if( pUndo )
- {
- if( bRet )
- {
- if( bVert )
- pUndo->SaveNewBoxes( *pTblNd, aTmpLst );
- else
- pUndo->SaveNewBoxes( *pTblNd, aTmpLst, rBoxes, aNdsCnts );
- GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
- else
- delete pUndo;
- }
-
- return bRet;
-}
-
-
-sal_uInt16 SwDoc::MergeTbl( SwPaM& rPam )
-{
- // pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
- SwTableNode* pTblNd = rPam.GetNode()->FindTableNode();
- if( !pTblNd )
- return TBLMERGE_NOSELECTION;
- SwTable& rTable = pTblNd->GetTable();
- if( rTable.ISA(SwDDETable) )
- return TBLMERGE_NOSELECTION;
- sal_uInt16 nRet = TBLMERGE_NOSELECTION;
- if( !rTable.IsNewModel() )
- {
- nRet =::CheckMergeSel( rPam );
- if( TBLMERGE_OK != nRet )
- return nRet;
- nRet = TBLMERGE_NOSELECTION;
- }
-
- // #i33394#
- GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_MERGE, NULL );
-
- RedlineMode_t eOld = GetRedlineMode();
- SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE));
-
- SwUndoTblMerge *const pUndo( (GetIDocumentUndoRedo().DoesUndo())
- ? new SwUndoTblMerge( rPam )
- : 0 );
-
- // lasse ueber das Layout die Boxen suchen
- SwSelBoxes aBoxes;
- SwSelBoxes aMerged;
- SwTableBox* pMergeBox;
-
- if( !rTable.PrepareMerge( rPam, aBoxes, aMerged, &pMergeBox, pUndo ) )
- { // no cells found to merge
- SetRedlineMode_intern( eOld );
- if( pUndo )
- {
- delete pUndo;
- SwUndoId nLastUndoId(UNDO_EMPTY);
- if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId)
- && (UNDO_REDLINE == nLastUndoId))
- {
- // FIXME: why is this horrible cleanup necessary?
- SwUndoRedline *const pU = dynamic_cast<SwUndoRedline*>(
- GetUndoManager().RemoveLastUndo());
- if( pU->GetRedlSaveCount() )
- {
- SwEditShell *const pEditShell(GetEditShell(0));
- OSL_ASSERT(pEditShell);
- ::sw::UndoRedoContext context(*this, *pEditShell);
- static_cast<SfxUndoAction *>(pU)->UndoWithContext(context);
- }
- delete pU;
- }
- }
- }
- else
- {
- // die PaMs muessen noch aus dem Loesch Bereich entfernt
- // werden. Setze sie immer hinter/auf die Tabelle; ueber die
- // Dokument-Position werden sie dann immer an die alte Position gesetzt.
- // Erstmal einen Index auf die Parkposition merken, denn nach GetMergeSel
- // komme ich nicht mehr dran.
- {
- rPam.DeleteMark();
- rPam.GetPoint()->nNode = *pMergeBox->GetSttNd();
- rPam.GetPoint()->nContent.Assign( 0, 0 );
- rPam.SetMark();
- rPam.DeleteMark();
-
- SwPaM* pTmp = &rPam;
- while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ))
- for( int i = 0; i < 2; ++i )
- pTmp->GetBound( (sal_Bool)i ) = *rPam.GetPoint();
- }
-
- // dann fuege sie zusammen
- SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
- aMsgHnt.eFlags = TBL_BOXPTR;
- UpdateTblFlds( &aMsgHnt );
-
- if( pTblNd->GetTable().Merge( this, aBoxes, aMerged, pMergeBox, pUndo ))
- {
- nRet = TBLMERGE_OK;
- SetModified();
- SetFieldsDirty( true, NULL, 0 );
- if( pUndo )
- {
- GetIDocumentUndoRedo().AppendUndo( pUndo );
- }
- }
- else
- delete pUndo;
-
- rPam.GetPoint()->nNode = *pMergeBox->GetSttNd();
- rPam.Move();
-
- ::ClearFEShellTabCols();
- SetRedlineMode_intern( eOld );
- }
- GetIDocumentUndoRedo().EndUndo( UNDO_TABLE_MERGE, NULL );
- return nRet;
-}
-
-
-
// -------------------------------------------------------
//---------
@@ -2210,62 +1147,6 @@ void SwTableNode::SetNewTable( SwTable* pNewTable, sal_Bool bNewFrames )
}
}
-void SwDoc::GetTabCols( SwTabCols &rFill, const SwCursor* pCrsr,
- const SwCellFrm* pBoxFrm ) const
-{
- const SwTableBox* pBox = 0;
- SwTabFrm *pTab = 0;
-
- if( pBoxFrm )
- {
- pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
- pBox = pBoxFrm->GetTabBox();
- }
- else if( pCrsr )
- {
- const SwCntntNode* pCNd = pCrsr->GetCntntNode();
- if( !pCNd )
- return ;
-
- Point aPt;
- const SwShellCrsr *pShCrsr = dynamic_cast<const SwShellCrsr*>(pCrsr);
- if( pShCrsr )
- aPt = pShCrsr->GetPtPos();
-
- const SwFrm* pTmpFrm = pCNd->getLayoutFrm( pCNd->GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False );
- do {
- pTmpFrm = pTmpFrm->GetUpper();
- } while ( !pTmpFrm->IsCellFrm() );
-
- pBoxFrm = (SwCellFrm*)pTmpFrm;
- pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
- pBox = pBoxFrm->GetTabBox();
- }
- else if( !pCrsr && !pBoxFrm )
- {
- OSL_ENSURE( !this, "einer von beiden muss angegeben werden!" );
- return ;
- }
-
- //Fix-Punkte setzen, LeftMin in Dokumentkoordinaten die anderen relativ.
- SWRECTFN( pTab )
- const SwPageFrm* pPage = pTab->FindPageFrm();
- const sal_uLong nLeftMin = (pTab->Frm().*fnRect->fnGetLeft)() -
- (pPage->Frm().*fnRect->fnGetLeft)();
- const sal_uLong nRightMax = (pTab->Frm().*fnRect->fnGetRight)() -
- (pPage->Frm().*fnRect->fnGetLeft)();
-
- rFill.SetLeftMin ( nLeftMin );
- rFill.SetLeft ( (pTab->Prt().*fnRect->fnGetLeft)() );
- rFill.SetRight ( (pTab->Prt().*fnRect->fnGetRight)());
- rFill.SetRightMax( nRightMax - nLeftMin );
-
- pTab->GetTable()->GetTabCols( rFill, pBox );
-}
-
-//
-// Here are some little helpers used in SwDoc::GetTabRows
-//
#define ROWFUZZY 25
@@ -2284,384 +1165,6 @@ bool lcl_IsFrmInColumn( const SwCellFrm& rFrm, SwSelBoxes& rBoxes )
return 0 != rBoxes.count(rFrm.GetTabBox());
}
-//
-// SwDoc::GetTabRows()
-//
-
-void SwDoc::GetTabRows( SwTabCols &rFill, const SwCursor* ,
- const SwCellFrm* pBoxFrm ) const
-{
- OSL_ENSURE( pBoxFrm, "GetTabRows called without pBoxFrm" );
-
- // Make code robust:
- if ( !pBoxFrm )
- return;
-
- // #i39552# Collection of the boxes of the current
- // column has to be done at the beginning of this function, because
- // the table may be formatted in ::GetTblSel.
- SwDeletionChecker aDelCheck( pBoxFrm );
-
- SwSelBoxes aBoxes;
- const SwCntntFrm* pCntnt = ::GetCellCntnt( *pBoxFrm );
- if ( pCntnt && pCntnt->IsTxtFrm() )
- {
- const SwPosition aPos( *((SwTxtFrm*)pCntnt)->GetTxtNode() );
- const SwCursor aTmpCrsr( aPos, 0, false );
- ::GetTblSel( aTmpCrsr, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
- }
-
- // Make code robust:
- if ( aDelCheck.HasBeenDeleted() )
- {
- OSL_FAIL( "Current box has been deleted during GetTabRows()" );
- return;
- }
-
- // Make code robust:
- const SwTabFrm* pTab = pBoxFrm->FindTabFrm();
- OSL_ENSURE( pTab, "GetTabRows called without a table" );
- if ( !pTab )
- return;
-
- const SwFrm* pFrm = pTab->GetNextLayoutLeaf();
-
- //Fix-Punkte setzen, LeftMin in Dokumentkoordinaten die anderen relativ.
- SWRECTFN( pTab )
- const SwPageFrm* pPage = pTab->FindPageFrm();
- const long nLeftMin = ( bVert ?
- pTab->GetPrtLeft() - pPage->Frm().Left() :
- pTab->GetPrtTop() - pPage->Frm().Top() );
- const long nLeft = bVert ? LONG_MAX : 0;
- const long nRight = (pTab->Prt().*fnRect->fnGetHeight)();
- const long nRightMax = bVert ? nRight : LONG_MAX;
-
- rFill.SetLeftMin( nLeftMin );
- rFill.SetLeft( nLeft );
- rFill.SetRight( nRight );
- rFill.SetRightMax( nRightMax );
-
- typedef std::map< long, std::pair< long, long >, FuzzyCompare > BoundaryMap;
- BoundaryMap aBoundaries;
- BoundaryMap::iterator aIter;
- std::pair< long, long > aPair;
-
- typedef std::map< long, bool > HiddenMap;
- HiddenMap aHidden;
- HiddenMap::iterator aHiddenIter;
-
- while ( pFrm && pTab->IsAnLower( pFrm ) )
- {
- if ( pFrm->IsCellFrm() && pFrm->FindTabFrm() == pTab )
- {
- // upper and lower borders of current cell frame:
- long nUpperBorder = (pFrm->Frm().*fnRect->fnGetTop)();
- long nLowerBorder = (pFrm->Frm().*fnRect->fnGetBottom)();
-
- // get boundaries for nUpperBorder:
- aIter = aBoundaries.find( nUpperBorder );
- if ( aIter == aBoundaries.end() )
- {
- aPair.first = nUpperBorder; aPair.second = LONG_MAX;
- aBoundaries[ nUpperBorder ] = aPair;
- }
-
- // get boundaries for nLowerBorder:
- aIter = aBoundaries.find( nLowerBorder );
- if ( aIter == aBoundaries.end() )
- {
- aPair.first = nUpperBorder; aPair.second = LONG_MAX;
- }
- else
- {
- nLowerBorder = (*aIter).first;
- long nNewLowerBorderUpperBoundary = Max( (*aIter).second.first, nUpperBorder );
- aPair.first = nNewLowerBorderUpperBoundary; aPair.second = LONG_MAX;
- }
- aBoundaries[ nLowerBorder ] = aPair;
-
- // calculate hidden flags for entry nUpperBorder/nLowerBorder:
- long nTmpVal = nUpperBorder;
- for ( sal_uInt8 i = 0; i < 2; ++i )
- {
- aHiddenIter = aHidden.find( nTmpVal );
- if ( aHiddenIter == aHidden.end() )
- aHidden[ nTmpVal ] = !lcl_IsFrmInColumn( *((SwCellFrm*)pFrm), aBoxes );
- else
- {
- if ( aHidden[ nTmpVal ] &&
- lcl_IsFrmInColumn( *((SwCellFrm*)pFrm), aBoxes ) )
- aHidden[ nTmpVal ] = false;
- }
- nTmpVal = nLowerBorder;
- }
- }
-
- pFrm = pFrm->GetNextLayoutLeaf();
- }
-
- // transfer calculated values from BoundaryMap and HiddenMap into rFill:
- sal_uInt16 nIdx = 0;
- for ( aIter = aBoundaries.begin(); aIter != aBoundaries.end(); ++aIter )
- {
- const long nTabTop = (pTab->*fnRect->fnGetPrtTop)();
- const long nKey = (*fnRect->fnYDiff)( (*aIter).first, nTabTop );
- const std::pair< long, long > aTmpPair = (*aIter).second;
- const long nFirst = (*fnRect->fnYDiff)( aTmpPair.first, nTabTop );
- const long nSecond = aTmpPair.second;
-
- aHiddenIter = aHidden.find( (*aIter).first );
- const bool bHidden = aHiddenIter != aHidden.end() && (*aHiddenIter).second;
- rFill.Insert( nKey, nFirst, nSecond, bHidden, nIdx++ );
- }
-
- // delete first and last entry
- OSL_ENSURE( rFill.Count(), "Deleting from empty vector. Fasten your seatbelts!" );
- // #i60818# There may be only one entry in rFill. Make
- // code robust by checking count of rFill.
- if ( rFill.Count() ) rFill.Remove( 0, 1 );
- if ( rFill.Count() ) rFill.Remove( rFill.Count() - 1 , 1 );
- rFill.SetLastRowAllowedToChange( !pTab->HasFollowFlowLine() );
-}
-
-void SwDoc::SetTabCols( const SwTabCols &rNew, sal_Bool bCurRowOnly,
- const SwCursor* pCrsr, const SwCellFrm* pBoxFrm )
-{
- const SwTableBox* pBox = 0;
- SwTabFrm *pTab = 0;
-
- if( pBoxFrm )
- {
- pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
- pBox = pBoxFrm->GetTabBox();
- }
- else if( pCrsr )
- {
- const SwCntntNode* pCNd = pCrsr->GetCntntNode();
- if( !pCNd )
- return ;
-
- Point aPt;
- const SwShellCrsr *pShCrsr = dynamic_cast<const SwShellCrsr*>(pCrsr);
- if( pShCrsr )
- aPt = pShCrsr->GetPtPos();
-
- const SwFrm* pTmpFrm = pCNd->getLayoutFrm( pCNd->GetDoc()->GetCurrentLayout(), &aPt, 0, sal_False );
- do {
- pTmpFrm = pTmpFrm->GetUpper();
- } while ( !pTmpFrm->IsCellFrm() );
-
- pBoxFrm = (SwCellFrm*)pTmpFrm;
- pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
- pBox = pBoxFrm->GetTabBox();
- }
- else if( !pCrsr && !pBoxFrm )
- {
- OSL_ENSURE( !this, "einer von beiden muss angegeben werden!" );
- return ;
- }
-
- // sollte die Tabelle noch auf relativen Werten (USHRT_MAX) stehen
- // dann muss es jetzt auf absolute umgerechnet werden.
- SwTable& rTab = *pTab->GetTable();
- const SwFmtFrmSize& rTblFrmSz = rTab.GetFrmFmt()->GetFrmSize();
- SWRECTFN( pTab )
- // #i17174# - With fix for #i9040# the shadow size is taken
- // from the table width. Thus, add its left and right size to current table
- // printing area width in order to get the correct table size attribute.
- SwTwips nPrtWidth = (pTab->Prt().*fnRect->fnGetWidth)();
- {
- SvxShadowItem aShadow( rTab.GetFrmFmt()->GetShadow() );
- nPrtWidth += aShadow.CalcShadowSpace( SHADOW_LEFT ) +
- aShadow.CalcShadowSpace( SHADOW_RIGHT );
- }
- if( nPrtWidth != rTblFrmSz.GetWidth() )
- {
- SwFmtFrmSize aSz( rTblFrmSz );
- aSz.SetWidth( nPrtWidth );
- rTab.GetFrmFmt()->SetFmtAttr( aSz );
- }
-
- SwTabCols aOld( rNew.Count() );
-
- const SwPageFrm* pPage = pTab->FindPageFrm();
- const sal_uLong nLeftMin = (pTab->Frm().*fnRect->fnGetLeft)() -
- (pPage->Frm().*fnRect->fnGetLeft)();
- const sal_uLong nRightMax = (pTab->Frm().*fnRect->fnGetRight)() -
- (pPage->Frm().*fnRect->fnGetLeft)();
-
- //Fix-Punkte setzen, LeftMin in Dokumentkoordinaten die anderen relativ.
- aOld.SetLeftMin ( nLeftMin );
- aOld.SetLeft ( (pTab->Prt().*fnRect->fnGetLeft)() );
- aOld.SetRight ( (pTab->Prt().*fnRect->fnGetRight)());
- aOld.SetRightMax( nRightMax - nLeftMin );
-
- rTab.GetTabCols( aOld, pBox );
- SetTabCols(rTab, rNew, aOld, pBox, bCurRowOnly );
-}
-
-void SwDoc::SetTabRows( const SwTabCols &rNew, sal_Bool bCurColOnly, const SwCursor*,
- const SwCellFrm* pBoxFrm )
-{
- const SwTableBox* pBox;
- SwTabFrm *pTab;
-
- OSL_ENSURE( pBoxFrm, "SetTabRows called without pBoxFrm" );
-
- pTab = ((SwFrm*)pBoxFrm)->ImplFindTabFrm();
- pBox = pBoxFrm->GetTabBox();
-
- // sollte die Tabelle noch auf relativen Werten (USHRT_MAX) stehen
- // dann muss es jetzt auf absolute umgerechnet werden.
- SWRECTFN( pTab )
- SwTabCols aOld( rNew.Count() );
-
- //Fix-Punkte setzen, LeftMin in Dokumentkoordinaten die anderen relativ.
- const SwPageFrm* pPage = pTab->FindPageFrm();
-
- aOld.SetRight( (pTab->Prt().*fnRect->fnGetHeight)() );
- long nLeftMin;
- if ( bVert )
- {
- nLeftMin = pTab->GetPrtLeft() - pPage->Frm().Left();
- aOld.SetLeft ( LONG_MAX );
- aOld.SetRightMax( aOld.GetRight() );
-
- }
- else
- {
- nLeftMin = pTab->GetPrtTop() - pPage->Frm().Top();
- aOld.SetLeft ( 0 );
- aOld.SetRightMax( LONG_MAX );
- }
- aOld.SetLeftMin ( nLeftMin );
-
- GetTabRows( aOld, 0, pBoxFrm );
-
- GetIDocumentUndoRedo().StartUndo( UNDO_TABLE_ATTR, NULL );
-
- // check for differences between aOld and rNew:
- const sal_uInt16 nCount = rNew.Count();
- const SwTable* pTable = pTab->GetTable();
- OSL_ENSURE( pTable, "My colleague told me, this couldn't happen" );
-
- for ( sal_uInt16 i = 0; i <= nCount; ++i )
- {
- const sal_uInt16 nIdxStt = bVert ? nCount - i : i - 1;
- const sal_uInt16 nIdxEnd = bVert ? nCount - i - 1 : i;
-
- const long nOldRowStart = i == 0 ? 0 : aOld[ nIdxStt ];
- const long nOldRowEnd = i == nCount ? aOld.GetRight() : aOld[ nIdxEnd ];
- const long nOldRowHeight = nOldRowEnd - nOldRowStart;
-
- const long nNewRowStart = i == 0 ? 0 : rNew[ nIdxStt ];
- const long nNewRowEnd = i == nCount ? rNew.GetRight() : rNew[ nIdxEnd ];
- const long nNewRowHeight = nNewRowEnd - nNewRowStart;
-
- const long nDiff = nNewRowHeight - nOldRowHeight;
- if ( abs( nDiff ) >= ROWFUZZY )
- {
- // For the old table model pTxtFrm and pLine will be set for every box.
- // For the new table model pTxtFrm will be set if the box is not covered,
- // but the pLine will be set if the box is not an overlapping box
- // In the new table model the row height can be adjusted,
- // when both variables are set.
- SwTxtFrm* pTxtFrm = 0;
- const SwTableLine* pLine = 0;
-
- // Iterate over all SwCellFrms with Bottom = nOldPos
- const SwFrm* pFrm = pTab->GetNextLayoutLeaf();
- while ( pFrm && pTab->IsAnLower( pFrm ) )
- {
- if ( pFrm->IsCellFrm() && pFrm->FindTabFrm() == pTab )
- {
- const long nLowerBorder = (pFrm->Frm().*fnRect->fnGetBottom)();
- const sal_uLong nTabTop = (pTab->*fnRect->fnGetPrtTop)();
- if ( abs( (*fnRect->fnYInc)( nTabTop, nOldRowEnd ) - nLowerBorder ) <= ROWFUZZY )
- {
- if ( !bCurColOnly || pFrm == pBoxFrm )
- {
- const SwFrm* pCntnt = ::GetCellCntnt( static_cast<const SwCellFrm&>(*pFrm) );
-
- if ( pCntnt && pCntnt->IsTxtFrm() )
- {
- pBox = ((SwCellFrm*)pFrm)->GetTabBox();
- const long nRowSpan = pBox->getRowSpan();
- if( nRowSpan > 0 ) // Not overlapped
- pTxtFrm = (SwTxtFrm*)pCntnt;
- if( nRowSpan < 2 ) // Not overlapping for row height
- pLine = pBox->GetUpper();
- if( pLine && pTxtFrm ) // always for old table model
- {
- // The new row height must not to be calculated from a overlapping box
- SwFmtFrmSize aNew( pLine->GetFrmFmt()->GetFrmSize() );
- const long nNewSize = (pFrm->Frm().*fnRect->fnGetHeight)() + nDiff;
- if( nNewSize != aNew.GetHeight() )
- {
- aNew.SetHeight( nNewSize );
- if ( ATT_VAR_SIZE == aNew.GetHeightSizeType() )
- aNew.SetHeightSizeType( ATT_MIN_SIZE );
- // This position must not be in an overlapped box
- const SwPosition aPos( *((SwTxtFrm*)pCntnt)->GetTxtNode() );
- const SwCursor aTmpCrsr( aPos, 0, false );
- SetRowHeight( aTmpCrsr, aNew );
- // For the new table model we're done, for the old one
- // there might be another (sub)row to adjust...
- if( pTable->IsNewModel() )
- break;
- }
- pLine = 0;
- }
- }
- }
- }
- }
- pFrm = pFrm->GetNextLayoutLeaf();
- }
- }
- }
-
- GetIDocumentUndoRedo().EndUndo( UNDO_TABLE_ATTR, NULL );
-
- ::ClearFEShellTabCols();
-}
-
-/* --------------------------------------------------
- * Direktzugriff fuer UNO
- * --------------------------------------------------*/
-void SwDoc::SetTabCols(SwTable& rTab, const SwTabCols &rNew, const SwTabCols &rOld,
- const SwTableBox *pStart, sal_Bool bCurRowOnly )
-{
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(
- new SwUndoAttrTbl( *rTab.GetTableNode(), sal_True ));
- }
- rTab.SetTabCols( rNew, rOld, pStart, bCurRowOnly );
- ::ClearFEShellTabCols();
- SetModified();
-}
-
-void SwDoc::SetRowsToRepeat( SwTable &rTable, sal_uInt16 nSet )
-{
- if( nSet == rTable.GetRowsToRepeat() )
- return;
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(
- new SwUndoTblHeadline(rTable, rTable.GetRowsToRepeat(), nSet) );
- }
-
- SwMsgPoolItem aChg( RES_TBLHEADLINECHG );
- rTable.SetRowsToRepeat( nSet );
- rTable.GetFrmFmt()->ModifyNotification( &aChg, &aChg );
- SetModified();
-}
-
-
-
-
// Splittet eine Tabelle in der Grund-Zeile, in der der Index steht.
// Alle GrundZeilen dahinter wandern in eine neue Tabelle/-Node.
// Ist das Flag bCalcNewSize auf sal_True, wird fuer beide neuen Tabellen
@@ -2842,140 +1345,6 @@ sal_uInt16 aTableSplitBoxSetRange[] = {
}
-sal_Bool SwDoc::SplitTable( const SwPosition& rPos, sal_uInt16 eHdlnMode,
- sal_Bool bCalcNewSize )
-{
- SwNode* pNd = &rPos.nNode.GetNode();
- SwTableNode* pTNd = pNd->FindTableNode();
- if( !pTNd || pNd->IsTableNode() )
- return 0;
-
- if( pTNd->GetTable().ISA( SwDDETable ))
- return sal_False;
-
- SwTable& rTbl = pTNd->GetTable();
- rTbl.SetHTMLTableLayout( 0 ); // MIB 9.7.97: HTML-Layout loeschen
-
- SwTableFmlUpdate aMsgHnt( &rTbl );
-
- SwHistory aHistory;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- aMsgHnt.pHistory = &aHistory;
- }
-
- {
- sal_uLong nSttIdx = pNd->FindTableBoxStartNode()->GetIndex();
-
- // Suche die Grund-Line dieser Box:
- SwTableBox* pBox = rTbl.GetTblBox( nSttIdx );
- if( pBox )
- {
- SwTableLine* pLine = pBox->GetUpper();
- while( pLine->GetUpper() )
- pLine = pLine->GetUpper()->GetUpper();
-
- // in pLine steht jetzt die GrundLine.
- aMsgHnt.nSplitLine = rTbl.GetTabLines().C40_GETPOS( SwTableLine, pLine );
- }
-
- String sNewTblNm( GetUniqueTblName() );
- aMsgHnt.DATA.pNewTblNm = &sNewTblNm;
- aMsgHnt.eFlags = TBL_SPLITTBL;
- UpdateTblFlds( &aMsgHnt );
- }
-
- //Lines fuer das Layout-Update heraussuchen.
- _FndBox aFndBox( 0, 0 );
- aFndBox.SetTableLines( rTbl );
- aFndBox.DelFrms( rTbl );
-
- SwTableNode* pNew = GetNodes().SplitTable( rPos.nNode, sal_False, bCalcNewSize );
-
- if( pNew )
- {
- SwSaveRowSpan* pSaveRowSp = pNew->GetTable().CleanUpTopRowSpan( rTbl.GetTabLines().Count() );
- SwUndoSplitTbl* pUndo = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo = new SwUndoSplitTbl(
- *pNew, pSaveRowSp, eHdlnMode, bCalcNewSize);
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- if( aHistory.Count() )
- pUndo->SaveFormula( aHistory );
- }
-
- switch( eHdlnMode )
- {
- // setze die untere Border der vorherige Line,
- // an der aktuellen als obere
- case HEADLINE_BORDERCOPY:
- {
- SwCollectTblLineBoxes aPara( sal_False, eHdlnMode );
- SwTableLine* pLn = rTbl.GetTabLines()[
- rTbl.GetTabLines().Count() - 1 ];
- pLn->GetTabBoxes().ForEach( &lcl_Box_CollectBox, &aPara );
-
- aPara.SetValues( sal_True );
- pLn = pNew->GetTable().GetTabLines()[ 0 ];
- pLn->GetTabBoxes().ForEach( &lcl_BoxSetSplitBoxFmts, &aPara );
-
- // Kopfzeile wiederholen abschalten
- pNew->GetTable().SetRowsToRepeat( 0 );
- }
- break;
-
- // setze die Attributierung der ersten Line an der neuen ersten
- case HEADLINE_BOXATTRCOPY:
- case HEADLINE_BOXATRCOLLCOPY:
- {
- SwHistory* pHst = 0;
- if( HEADLINE_BOXATRCOLLCOPY == eHdlnMode && pUndo )
- pHst = pUndo->GetHistory();
-
- SwCollectTblLineBoxes aPara( sal_True, eHdlnMode, pHst );
- SwTableLine* pLn = rTbl.GetTabLines()[ 0 ];
- pLn->GetTabBoxes().ForEach( &lcl_Box_CollectBox, &aPara );
-
- aPara.SetValues( sal_True );
- pLn = pNew->GetTable().GetTabLines()[ 0 ];
- pLn->GetTabBoxes().ForEach( &lcl_BoxSetSplitBoxFmts, &aPara );
- }
- break;
-
- case HEADLINE_CNTNTCOPY:
- rTbl.CopyHeadlineIntoTable( *pNew );
- if( pUndo )
- pUndo->SetTblNodeOffset( pNew->GetIndex() );
- break;
-
- case HEADLINE_NONE:
- // Kopfzeile wiederholen abschalten
- pNew->GetTable().SetRowsToRepeat( 0 );
- break;
- }
-
- // und Frms einfuegen.
- SwNodeIndex aNdIdx( *pNew->EndOfSectionNode() );
- GetNodes().GoNext( &aNdIdx ); // zum naechsten ContentNode
- pNew->MakeFrms( &aNdIdx );
-
- //Zwischen die Tabellen wird ein Absatz geschoben
- GetNodes().MakeTxtNode( SwNodeIndex( *pNew ),
- GetTxtCollFromPool( RES_POOLCOLL_TEXT ) );
- }
-
- //Layout updaten
- aFndBox.MakeFrms( rTbl );
-
- // TL_CHART2: need to inform chart of probably changed cell names
- UpdateCharts( rTbl.GetFrmFmt()->GetName() );
-
- SetFieldsDirty( true, NULL, 0 );
-
- return 0 != pNew;
-}
-
sal_Bool lcl_ChgTblSize( SwTable& rTbl )
{
// das Attribut darf nicht ueber das Modify an der
@@ -3197,62 +1566,6 @@ SwTableNode* SwNodes::SplitTable( const SwNodeIndex& rPos, sal_Bool bAfter,
// und die Umkehrung davon. rPos muss in der Tabelle stehen, die bestehen
// bleibt. Das Flag besagt ob die aktuelle mit der davor oder dahinter
// stehenden vereint wird.
-sal_Bool SwDoc::MergeTable( const SwPosition& rPos, sal_Bool bWithPrev, sal_uInt16 nMode )
-{
- SwTableNode* pTblNd = rPos.nNode.GetNode().FindTableNode(), *pDelTblNd;
- if( !pTblNd )
- return sal_False;
-
- SwNodes& rNds = GetNodes();
- if( bWithPrev )
- pDelTblNd = rNds[ pTblNd->GetIndex() - 1 ]->FindTableNode();
- else
- pDelTblNd = rNds[ pTblNd->EndOfSectionIndex() + 1 ]->GetTableNode();
- if( !pDelTblNd )
- return sal_False;
-
- if( pTblNd->GetTable().ISA( SwDDETable ) ||
- pDelTblNd->GetTable().ISA( SwDDETable ))
- return sal_False;
-
- // MIB 9.7.97: HTML-Layout loeschen
- pTblNd->GetTable().SetHTMLTableLayout( 0 );
- pDelTblNd->GetTable().SetHTMLTableLayout( 0 );
-
- // beide Tabellen vorhanden, also kanns losgehen
- SwUndoMergeTbl* pUndo = 0;
- SwHistory* pHistory = 0;
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- pUndo = new SwUndoMergeTbl( *pTblNd, *pDelTblNd, bWithPrev, nMode );
- GetIDocumentUndoRedo().AppendUndo(pUndo);
- pHistory = new SwHistory;
- }
-
- // alle "Tabellenformeln" anpassen
- SwTableFmlUpdate aMsgHnt( &pTblNd->GetTable() );
- aMsgHnt.DATA.pDelTbl = &pDelTblNd->GetTable();
- aMsgHnt.eFlags = TBL_MERGETBL;
- aMsgHnt.pHistory = pHistory;
- UpdateTblFlds( &aMsgHnt );
-
- // das eigentliche Mergen
- SwNodeIndex aIdx( bWithPrev ? *pTblNd : *pDelTblNd );
- sal_Bool bRet = rNds.MergeTable( aIdx, !bWithPrev, nMode, pHistory );
-
- if( pHistory )
- {
- if( pHistory->Count() )
- pUndo->SaveFormula( *pHistory );
- delete pHistory;
- }
- if( bRet )
- {
- SetModified();
- SetFieldsDirty( true, NULL, 0 );
- }
- return bRet;
-}
sal_Bool SwNodes::MergeTable( const SwNodeIndex& rPos, sal_Bool bWithPrev,
sal_uInt16 nMode, SwHistory* )
diff --git a/sw/source/core/docnode/ndtbl1.cxx b/sw/source/core/docnode/ndtbl1.cxx
index 9e8ea04e1108..2c38b005e270 100644
--- a/sw/source/core/docnode/ndtbl1.cxx
+++ b/sw/source/core/docnode/ndtbl1.cxx
@@ -317,231 +317,6 @@ void lcl_ProcessBoxSize( SvPtrarr &rFmtCmp, SwTableBox *pBox, const SwFmtFrmSize
::lcl_ProcessRowSize( rFmtCmp, rLines[i], aSz );
}
}
-
-//-----------------------------------------------------------------------------
-
-/******************************************************************************
- * void SwDoc::SetRowSplit()
- ******************************************************************************/
-void SwDoc::SetRowSplit( const SwCursor& rCursor, const SwFmtRowSplit &rNew )
-{
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- if( pTblNd )
- {
- SvPtrarr aRowArr( 25 ); //Zum sammeln Lines.
- ::lcl_CollectLines( aRowArr, rCursor, false );
-
- if( aRowArr.Count() )
- {
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(new SwUndoAttrTbl(*pTblNd));
- }
-
- SvPtrarr aFmtCmp( Max( sal_uInt8(255), sal_uInt8(aRowArr.Count()) ) );
-
- for( sal_uInt16 i = 0; i < aRowArr.Count(); ++i )
- ::lcl_ProcessRowAttr( aFmtCmp, (SwTableLine*)aRowArr[i], rNew );
-
- SwTblFmtCmp::Delete( aFmtCmp );
- SetModified();
- }
- }
-}
-
-
-/******************************************************************************
- * SwTwips SwDoc::GetRowSplit() const
- ******************************************************************************/
-void SwDoc::GetRowSplit( const SwCursor& rCursor, SwFmtRowSplit *& rpSz ) const
-{
- rpSz = 0;
-
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- if( pTblNd )
- {
- SvPtrarr aRowArr( 25 ); //Zum sammeln der Lines.
- ::lcl_CollectLines( aRowArr, rCursor, false );
-
- if( aRowArr.Count() )
- {
- rpSz = &(SwFmtRowSplit&)((SwTableLine*)aRowArr[0])->
- GetFrmFmt()->GetRowSplit();
-
- for ( sal_uInt16 i = 1; i < aRowArr.Count() && rpSz; ++i )
- {
- if ( (*rpSz).GetValue() != ((SwTableLine*)aRowArr[i])->GetFrmFmt()->GetRowSplit().GetValue() )
- rpSz = 0;
- }
- if ( rpSz )
- rpSz = new SwFmtRowSplit( *rpSz );
- }
- }
-}
-
-
-/******************************************************************************
- * void SwDoc::SetRowHeight( SwTwips nNew )
- ******************************************************************************/
-void SwDoc::SetRowHeight( const SwCursor& rCursor, const SwFmtFrmSize &rNew )
-{
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- if( pTblNd )
- {
- SvPtrarr aRowArr( 25 ); //Zum sammeln Lines.
- ::lcl_CollectLines( aRowArr, rCursor, true );
-
- if( aRowArr.Count() )
- {
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(new SwUndoAttrTbl(*pTblNd));
- }
-
- SvPtrarr aFmtCmp( Max( sal_uInt8(255), sal_uInt8(aRowArr.Count()) ) );
- for ( sal_uInt16 i = 0; i < aRowArr.Count(); ++i )
- ::lcl_ProcessRowSize( aFmtCmp, (SwTableLine*)aRowArr[i], rNew );
- SwTblFmtCmp::Delete( aFmtCmp );
-
- SetModified();
- }
- }
-}
-
-
-/******************************************************************************
- * SwTwips SwDoc::GetRowHeight() const
- ******************************************************************************/
-void SwDoc::GetRowHeight( const SwCursor& rCursor, SwFmtFrmSize *& rpSz ) const
-{
- rpSz = 0;
-
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- if( pTblNd )
- {
- SvPtrarr aRowArr( 25 ); //Zum sammeln der Lines.
- ::lcl_CollectLines( aRowArr, rCursor, true );
-
- if( aRowArr.Count() )
- {
- rpSz = &(SwFmtFrmSize&)((SwTableLine*)aRowArr[0])->
- GetFrmFmt()->GetFrmSize();
-
- for ( sal_uInt16 i = 1; i < aRowArr.Count() && rpSz; ++i )
- {
- if ( *rpSz != ((SwTableLine*)aRowArr[i])->GetFrmFmt()->GetFrmSize() )
- rpSz = 0;
- }
- if ( rpSz )
- rpSz = new SwFmtFrmSize( *rpSz );
- }
- }
-}
-
-sal_Bool SwDoc::BalanceRowHeight( const SwCursor& rCursor, sal_Bool bTstOnly )
-{
- sal_Bool bRet = sal_False;
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- if( pTblNd )
- {
- SvPtrarr aRowArr( 25 ); //Zum sammeln der Lines.
- ::lcl_CollectLines( aRowArr, rCursor, true );
-
- if( 1 < aRowArr.Count() )
- {
- if( !bTstOnly )
- {
- long nHeight = 0;
- sal_uInt16 i;
-
- for ( i = 0; i < aRowArr.Count(); ++i )
- {
- SwIterator<SwFrm,SwFmt> aIter( *((SwTableLine*)aRowArr[i])->GetFrmFmt() );
- SwFrm* pFrm = aIter.First();
- while ( pFrm )
- {
- nHeight = Max( nHeight, pFrm->Frm().Height() );
- pFrm = aIter.Next();
- }
- }
- SwFmtFrmSize aNew( ATT_MIN_SIZE, 0, nHeight );
-
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(
- new SwUndoAttrTbl(*pTblNd));
- }
-
- SvPtrarr aFmtCmp( Max( sal_uInt8(255), sal_uInt8(aRowArr.Count()) ) );
- for( i = 0; i < aRowArr.Count(); ++i )
- ::lcl_ProcessRowSize( aFmtCmp, (SwTableLine*)aRowArr[i], aNew );
- SwTblFmtCmp::Delete( aFmtCmp );
-
- SetModified();
- }
- bRet = sal_True;
- }
- }
- return bRet;
-}
-
-/******************************************************************************
- * void SwDoc::SetRowBackground()
- ******************************************************************************/
-void SwDoc::SetRowBackground( const SwCursor& rCursor, const SvxBrushItem &rNew )
-{
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- if( pTblNd )
- {
- SvPtrarr aRowArr( 25 ); //Zum sammeln Lines.
- ::lcl_CollectLines( aRowArr, rCursor, true );
-
- if( aRowArr.Count() )
- {
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(new SwUndoAttrTbl(*pTblNd));
- }
-
- SvPtrarr aFmtCmp( Max( sal_uInt8(255), sal_uInt8(aRowArr.Count()) ) );
-
- for( sal_uInt16 i = 0; i < aRowArr.Count(); ++i )
- ::lcl_ProcessRowAttr( aFmtCmp, (SwTableLine*)aRowArr[i], rNew );
-
- SwTblFmtCmp::Delete( aFmtCmp );
- SetModified();
- }
- }
-}
-
-/******************************************************************************
- * SwTwips SwDoc::GetRowBackground() const
- ******************************************************************************/
-sal_Bool SwDoc::GetRowBackground( const SwCursor& rCursor, SvxBrushItem &rToFill ) const
-{
- sal_Bool bRet = sal_False;
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- if( pTblNd )
- {
- SvPtrarr aRowArr( 25 ); //Zum sammeln Lines.
- ::lcl_CollectLines( aRowArr, rCursor, true );
-
- if( aRowArr.Count() )
- {
- rToFill = ((SwTableLine*)aRowArr[0])->GetFrmFmt()->GetBackground();
-
- bRet = sal_True;
- for ( sal_uInt16 i = 1; i < aRowArr.Count(); ++i )
- if ( rToFill != ((SwTableLine*)aRowArr[i])->GetFrmFmt()->GetBackground() )
- {
- bRet = sal_False;
- break;
- }
- }
- }
- return bRet;
-}
-
/***********************************************************************
#* Class : SwDoc
#* Methoden : SetTabBorders(), GetTabBorders()
@@ -575,233 +350,6 @@ void lcl_CollectCells( SvPtrarr &rArr, const SwRect &rUnion,
} while( pCell && pTab->IsAnLower( pCell ) );
}
-void SwDoc::SetTabBorders( const SwCursor& rCursor, const SfxItemSet& rSet )
-{
- SwCntntNode* pCntNd = rCursor.GetPoint()->nNode.GetNode().GetCntntNode();
- SwTableNode* pTblNd = pCntNd ? pCntNd->FindTableNode() : 0;
- if( !pTblNd )
- return ;
-
- SwLayoutFrm *pStart, *pEnd;
- ::lcl_GetStartEndCell( rCursor, pStart, pEnd );
-
- SwSelUnions aUnions;
- ::MakeSelUnions( aUnions, pStart, pEnd );
-
- if( aUnions.Count() )
- {
- SwTable& rTable = pTblNd->GetTable();
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo( new SwUndoAttrTbl(*pTblNd) );
- }
-
- SvPtrarr aFmtCmp( 255 );
- const SvxBoxItem* pSetBox;
- const SvxBoxInfoItem *pSetBoxInfo;
-
- const SvxBorderLine* pLeft = 0;
- const SvxBorderLine* pRight = 0;
- const SvxBorderLine* pTop = 0;
- const SvxBorderLine* pBottom = 0;
- const SvxBorderLine* pHori = 0;
- const SvxBorderLine* pVert = 0;
- sal_Bool bHoriValid = sal_True, bVertValid = sal_True,
- bTopValid = sal_True, bBottomValid = sal_True,
- bLeftValid = sal_True, bRightValid = sal_True;
-
- // JP 21.07.95: die Flags im BoxInfo-Item entscheiden, wann eine
- // BorderLine gueltig ist!!
- if( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER, sal_False,
- (const SfxPoolItem**)&pSetBoxInfo) )
- {
- pHori = pSetBoxInfo->GetHori();
- pVert = pSetBoxInfo->GetVert();
-
- bHoriValid = pSetBoxInfo->IsValid(VALID_HORI);
- bVertValid = pSetBoxInfo->IsValid(VALID_VERT);
-
- // wollen wir die auswerten ??
- bTopValid = pSetBoxInfo->IsValid(VALID_TOP);
- bBottomValid = pSetBoxInfo->IsValid(VALID_BOTTOM);
- bLeftValid = pSetBoxInfo->IsValid(VALID_LEFT);
- bRightValid = pSetBoxInfo->IsValid(VALID_RIGHT);
- }
-
- if( SFX_ITEM_SET == rSet.GetItemState( RES_BOX, sal_False,
- (const SfxPoolItem**)&pSetBox) )
- {
- pLeft = pSetBox->GetLeft();
- pRight = pSetBox->GetRight();
- pTop = pSetBox->GetTop();
- pBottom = pSetBox->GetBottom();
- }
- else
- {
- // nicht gesetzt, also keine gueltigen Werte
- bTopValid = bBottomValid = bLeftValid = bRightValid = sal_False;
- pSetBox = 0;
- }
-
- sal_Bool bFirst = sal_True;
- for ( sal_uInt16 i = 0; i < aUnions.Count(); ++i )
- {
- SwSelUnion *pUnion = aUnions[i];
- SwTabFrm *pTab = pUnion->GetTable();
- const SwRect &rUnion = pUnion->GetUnion();
- const sal_Bool bLast = i == aUnions.Count() - 1 ? sal_True : sal_False;
-
- SvPtrarr aCellArr( 255 );
- ::lcl_CollectCells( aCellArr, pUnion->GetUnion(), pTab );
-
- //Alle Zellenkanten, die mit dem UnionRect uebereinstimmen oder
- //darueber hinausragen sind Aussenkanten. Alle anderen sind
- //Innenkanten.
- //neu: Die Aussenkanten koennen abhaengig davon, ob es sich um eine
- //Start/Mittlere/Folge -Tabelle (bei Selektionen ueber FollowTabs)
- //handelt doch keine Aussenkanten sein.
- //Aussenkanten werden links, rechts, oben und unten gesetzt.
- //Innenkanten werden nur oben und links gesetzt.
- for ( sal_uInt16 j = 0; j < aCellArr.Count(); ++j )
- {
- SwCellFrm *pCell = (SwCellFrm*)aCellArr[j];
- const sal_Bool bVert = pTab->IsVertical();
- const sal_Bool bRTL = pTab->IsRightToLeft();
- sal_Bool bTopOver, bLeftOver, bRightOver, bBottomOver;
- if ( bVert )
- {
- bTopOver = pCell->Frm().Right() >= rUnion.Right();
- bLeftOver = pCell->Frm().Top() <= rUnion.Top();
- bRightOver = pCell->Frm().Bottom() >= rUnion.Bottom();
- bBottomOver = pCell->Frm().Left() <= rUnion.Left();
- }
- else
- {
- bTopOver = pCell->Frm().Top() <= rUnion.Top();
- bLeftOver = pCell->Frm().Left() <= rUnion.Left();
- bRightOver = pCell->Frm().Right() >= rUnion.Right();
- bBottomOver = pCell->Frm().Bottom() >= rUnion.Bottom();
- }
-
- if ( bRTL )
- {
- sal_Bool bTmp = bRightOver;
- bRightOver = bLeftOver;
- bLeftOver = bTmp;
- }
-
- //Grundsaetzlich nichts setzen in HeadlineRepeats.
- if ( pTab->IsFollow() &&
- ( pTab->IsInHeadline( *pCell ) ||
- // Same holds for follow flow rows.
- pCell->IsInFollowFlowRow() ) )
- continue;
-
- SvxBoxItem aBox( pCell->GetFmt()->GetBox() );
-
- sal_Int16 nType = 0;
-
- //Obere Kante
- if( bTopValid )
- {
- if ( bFirst && bTopOver )
- {
- aBox.SetLine( pTop, BOX_LINE_TOP );
- nType |= 0x0001;
- }
- else if ( bHoriValid )
- {
- aBox.SetLine( 0, BOX_LINE_TOP );
- nType |= 0x0002;
- }
- }
-
- //Linke Kante
- if ( bLeftOver )
- {
- if( bLeftValid )
- {
- aBox.SetLine( pLeft, BOX_LINE_LEFT );
- nType |= 0x0004;
- }
- }
- else if( bVertValid )
- {
- aBox.SetLine( pVert, BOX_LINE_LEFT );
- nType |= 0x0008;
- }
-
- //Rechte Kante
- if( bRightValid )
- {
- if ( bRightOver )
- {
- aBox.SetLine( pRight, BOX_LINE_RIGHT );
- nType |= 0x0010;
- }
- else if ( bVertValid )
- {
- aBox.SetLine( 0, BOX_LINE_RIGHT );
- nType |= 0x0020;
- }
- }
-
- //Untere Kante
- if ( bLast && bBottomOver )
- {
- if( bBottomValid )
- {
- aBox.SetLine( pBottom, BOX_LINE_BOTTOM );
- nType |= 0x0040;
- }
- }
- else if( bHoriValid )
- {
- aBox.SetLine( pHori, BOX_LINE_BOTTOM );
- nType |= 0x0080;
- }
-
- if( pSetBox )
- {
- static sal_uInt16 const aBorders[] = {
- BOX_LINE_BOTTOM, BOX_LINE_TOP,
- BOX_LINE_RIGHT, BOX_LINE_LEFT };
- const sal_uInt16* pBrd = aBorders;
- for( int k = 0; k < 4; ++k, ++pBrd )
- aBox.SetDistance( pSetBox->GetDistance( *pBrd ), *pBrd );
- }
-
- SwTableBox *pBox = (SwTableBox*)pCell->GetTabBox();
- SwFrmFmt *pNewFmt;
- if ( 0 != (pNewFmt = SwTblFmtCmp::FindNewFmt( aFmtCmp, pBox->GetFrmFmt(), nType )))
- pBox->ChgFrmFmt( (SwTableBoxFmt*)pNewFmt );
- else
- {
- SwFrmFmt *pOld = pBox->GetFrmFmt();
- SwFrmFmt *pNew = pBox->ClaimFrmFmt();
- pNew->SetFmtAttr( aBox );
- aFmtCmp.Insert( new SwTblFmtCmp( pOld, pNew, nType ), aFmtCmp.Count());
- }
- }
-
- bFirst = sal_False;
- }
-
- SwHTMLTableLayout *pTableLayout = rTable.GetHTMLTableLayout();
- if( pTableLayout )
- {
- SwCntntFrm* pFrm = rCursor.GetCntntNode()->getLayoutFrm( rCursor.GetCntntNode()->GetDoc()->GetCurrentLayout() );
- SwTabFrm* pTabFrm = pFrm->ImplFindTabFrm();
-
- pTableLayout->BordersChanged(
- pTableLayout->GetBrowseWidthByTabFrm( *pTabFrm ), sal_True );
- }
- SwTblFmtCmp::Delete( aFmtCmp );
- ::ClearFEShellTabCols();
- SetModified();
- }
-}
-
void lcl_SetLineStyle( SvxBorderLine *pToSet,
const Color *pColor, const SvxBorderLine *pBorderLine)
{
@@ -820,442 +368,6 @@ void lcl_SetLineStyle( SvxBorderLine *pToSet,
pToSet->SetColor( *pColor );
}
-void SwDoc::SetTabLineStyle( const SwCursor& rCursor,
- const Color* pColor, sal_Bool bSetLine,
- const SvxBorderLine* pBorderLine )
-{
- SwCntntNode* pCntNd = rCursor.GetPoint()->nNode.GetNode().GetCntntNode();
- SwTableNode* pTblNd = pCntNd ? pCntNd->FindTableNode() : 0;
- if( !pTblNd )
- return ;
-
- SwLayoutFrm *pStart, *pEnd;
- ::lcl_GetStartEndCell( rCursor, pStart, pEnd );
-
- SwSelUnions aUnions;
- ::MakeSelUnions( aUnions, pStart, pEnd );
-
- if( aUnions.Count() )
- {
- SwTable& rTable = pTblNd->GetTable();
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo(new SwUndoAttrTbl(*pTblNd));
- }
-
- for( sal_uInt16 i = 0; i < aUnions.Count(); ++i )
- {
- SwSelUnion *pUnion = aUnions[i];
- SwTabFrm *pTab = pUnion->GetTable();
- SvPtrarr aCellArr( 255 );
- ::lcl_CollectCells( aCellArr, pUnion->GetUnion(), pTab );
-
- for ( sal_uInt16 j = 0; j < aCellArr.Count(); ++j )
- {
- SwCellFrm *pCell = ( SwCellFrm* )aCellArr[j];
-
- //Grundsaetzlich nichts setzen in HeadlineRepeats.
- if ( pTab->IsFollow() && pTab->IsInHeadline( *pCell ) )
- continue;
-
- ((SwTableBox*)pCell->GetTabBox())->ClaimFrmFmt();
- SwFrmFmt *pFmt = pCell->GetFmt();
- SvxBoxItem aBox( pFmt->GetBox() );
-
- if ( !pBorderLine && bSetLine )
- aBox = *(SvxBoxItem*)::GetDfltAttr( RES_BOX );
- else
- {
- if ( aBox.GetTop() )
- ::lcl_SetLineStyle( (SvxBorderLine*)aBox.GetTop(),
- pColor, pBorderLine );
- if ( aBox.GetBottom() )
- ::lcl_SetLineStyle( (SvxBorderLine*)aBox.GetBottom(),
- pColor, pBorderLine );
- if ( aBox.GetLeft() )
- ::lcl_SetLineStyle( (SvxBorderLine*)aBox.GetLeft(),
- pColor, pBorderLine );
- if ( aBox.GetRight() )
- ::lcl_SetLineStyle( (SvxBorderLine*)aBox.GetRight(),
- pColor, pBorderLine );
- }
- pFmt->SetFmtAttr( aBox );
- }
- }
-
- SwHTMLTableLayout *pTableLayout = rTable.GetHTMLTableLayout();
- if( pTableLayout )
- {
- SwCntntFrm* pFrm = rCursor.GetCntntNode()->getLayoutFrm( rCursor.GetCntntNode()->GetDoc()->GetCurrentLayout() );
- SwTabFrm* pTabFrm = pFrm->ImplFindTabFrm();
-
- pTableLayout->BordersChanged(
- pTableLayout->GetBrowseWidthByTabFrm( *pTabFrm ), sal_True );
- }
- ::ClearFEShellTabCols();
- SetModified();
- }
-}
-
-void SwDoc::GetTabBorders( const SwCursor& rCursor, SfxItemSet& rSet ) const
-{
- SwCntntNode* pCntNd = rCursor.GetPoint()->nNode.GetNode().GetCntntNode();
- SwTableNode* pTblNd = pCntNd ? pCntNd->FindTableNode() : 0;
- if( !pTblNd )
- return ;
-
- SwLayoutFrm *pStart, *pEnd;
- ::lcl_GetStartEndCell( rCursor, pStart, pEnd );
-
- SwSelUnions aUnions;
- ::MakeSelUnions( aUnions, pStart, pEnd );
-
- if( aUnions.Count() )
- {
- SvxBoxItem aSetBox ((const SvxBoxItem &) rSet.Get(RES_BOX ));
- SvxBoxInfoItem aSetBoxInfo((const SvxBoxInfoItem&) rSet.Get(SID_ATTR_BORDER_INNER));
-
- sal_Bool bTopSet = sal_False,
- bBottomSet = sal_False,
- bLeftSet = sal_False,
- bRightSet = sal_False,
- bHoriSet = sal_False,
- bVertSet = sal_False,
- bDistanceSet = sal_False;
-
- aSetBoxInfo.ResetFlags();
-
- for ( sal_uInt16 i = 0; i < aUnions.Count(); ++i )
- {
- SwSelUnion *pUnion = aUnions[i];
- const SwTabFrm *pTab = pUnion->GetTable();
- const SwRect &rUnion = pUnion->GetUnion();
- const sal_Bool bFirst = i == 0 ? sal_True : sal_False;
- const sal_Bool bLast = i == aUnions.Count() - 1 ? sal_True : sal_False;
-
- SvPtrarr aCellArr( 255 );
- ::lcl_CollectCells( aCellArr, rUnion, (SwTabFrm*)pTab );
-
- for ( sal_uInt16 j = 0; j < aCellArr.Count(); ++j )
- {
- const SwCellFrm *pCell = (const SwCellFrm*)aCellArr[j];
- const sal_Bool bVert = pTab->IsVertical();
- const sal_Bool bRTL = pTab->IsRightToLeft();
- sal_Bool bTopOver, bLeftOver, bRightOver, bBottomOver;
- if ( bVert )
- {
- bTopOver = pCell->Frm().Right() >= rUnion.Right();
- bLeftOver = pCell->Frm().Top() <= rUnion.Top();
- bRightOver = pCell->Frm().Bottom() >= rUnion.Bottom();
- bBottomOver = pCell->Frm().Left() <= rUnion.Left();
- }
- else
- {
- bTopOver = pCell->Frm().Top() <= rUnion.Top();
- bLeftOver = pCell->Frm().Left() <= rUnion.Left();
- bRightOver = pCell->Frm().Right() >= rUnion.Right();
- bBottomOver = pCell->Frm().Bottom() >= rUnion.Bottom();
- }
-
- if ( bRTL )
- {
- sal_Bool bTmp = bRightOver;
- bRightOver = bLeftOver;
- bLeftOver = bTmp;
- }
-
- const SwFrmFmt *pFmt = pCell->GetFmt();
- const SvxBoxItem &rBox = pFmt->GetBox();
-
- //Obere Kante
- if ( bFirst && bTopOver )
- {
- if (aSetBoxInfo.IsValid(VALID_TOP))
- {
- if ( !bTopSet )
- { bTopSet = sal_True;
- aSetBox.SetLine( rBox.GetTop(), BOX_LINE_TOP );
- }
- else if ((aSetBox.GetTop() && rBox.GetTop() &&
- !(*aSetBox.GetTop() == *rBox.GetTop())) ||
- ((!aSetBox.GetTop()) ^ (!rBox.GetTop()))) // XOR-Ausdruck ist sal_True, wenn genau einer der beiden Pointer 0 ist
- {
- aSetBoxInfo.SetValid(VALID_TOP, sal_False );
- aSetBox.SetLine( 0, BOX_LINE_TOP );
- }
- }
- }
-
- //Linke Kante
- if ( bLeftOver )
- {
- if (aSetBoxInfo.IsValid(VALID_LEFT))
- {
- if ( !bLeftSet )
- { bLeftSet = sal_True;
- aSetBox.SetLine( rBox.GetLeft(), BOX_LINE_LEFT );
- }
- else if ((aSetBox.GetLeft() && rBox.GetLeft() &&
- !(*aSetBox.GetLeft() == *rBox.GetLeft())) ||
- ((!aSetBox.GetLeft()) ^ (!rBox.GetLeft())))
- {
- aSetBoxInfo.SetValid(VALID_LEFT, sal_False );
- aSetBox.SetLine( 0, BOX_LINE_LEFT );
- }
- }
- }
- else
- {
- if (aSetBoxInfo.IsValid(VALID_VERT))
- {
- if ( !bVertSet )
- { bVertSet = sal_True;
- aSetBoxInfo.SetLine( rBox.GetLeft(), BOXINFO_LINE_VERT );
- }
- else if ((aSetBoxInfo.GetVert() && rBox.GetLeft() &&
- !(*aSetBoxInfo.GetVert() == *rBox.GetLeft())) ||
- ((!aSetBoxInfo.GetVert()) ^ (!rBox.GetLeft())))
- { aSetBoxInfo.SetValid( VALID_VERT, sal_False );
- aSetBoxInfo.SetLine( 0, BOXINFO_LINE_VERT );
- }
- }
- }
-
- //Rechte Kante
- if ( aSetBoxInfo.IsValid(VALID_RIGHT) && bRightOver )
- {
- if ( !bRightSet )
- { bRightSet = sal_True;
- aSetBox.SetLine( rBox.GetRight(), BOX_LINE_RIGHT );
- }
- else if ((aSetBox.GetRight() && rBox.GetRight() &&
- !(*aSetBox.GetRight() == *rBox.GetRight())) ||
- (!aSetBox.GetRight() ^ !rBox.GetRight()))
- { aSetBoxInfo.SetValid( VALID_RIGHT, sal_False );
- aSetBox.SetLine( 0, BOX_LINE_RIGHT );
- }
- }
-
- //Untere Kante
- if ( bLast && bBottomOver )
- {
- if ( aSetBoxInfo.IsValid(VALID_BOTTOM) )
- {
- if ( !bBottomSet )
- { bBottomSet = sal_True;
- aSetBox.SetLine( rBox.GetBottom(), BOX_LINE_BOTTOM );
- }
- else if ((aSetBox.GetBottom() && rBox.GetBottom() &&
- !(*aSetBox.GetBottom() == *rBox.GetBottom())) ||
- (!aSetBox.GetBottom() ^ !rBox.GetBottom()))
- { aSetBoxInfo.SetValid( VALID_BOTTOM, sal_False );
- aSetBox.SetLine( 0, BOX_LINE_BOTTOM );
- }
- }
- }
- //in allen Zeilen ausser der letzten werden die
- // horiz. Linien aus der Bottom-Linie entnommen
- else
- {
- if (aSetBoxInfo.IsValid(VALID_HORI))
- {
- if ( !bHoriSet )
- { bHoriSet = sal_True;
- aSetBoxInfo.SetLine( rBox.GetBottom(), BOXINFO_LINE_HORI );
- }
- else if ((aSetBoxInfo.GetHori() && rBox.GetBottom() &&
- !(*aSetBoxInfo.GetHori() == *rBox.GetBottom())) ||
- ((!aSetBoxInfo.GetHori()) ^ (!rBox.GetBottom())))
- {
- aSetBoxInfo.SetValid( VALID_HORI, sal_False );
- aSetBoxInfo.SetLine( 0, BOXINFO_LINE_HORI );
- }
- }
- }
-
- // Abstand zum Text
- if (aSetBoxInfo.IsValid(VALID_DISTANCE))
- {
- static sal_uInt16 const aBorders[] = {
- BOX_LINE_BOTTOM, BOX_LINE_TOP,
- BOX_LINE_RIGHT, BOX_LINE_LEFT };
- const sal_uInt16* pBrd = aBorders;
-
- if( !bDistanceSet ) // bei 1. Durchlauf erstmal setzen
- {
- bDistanceSet = sal_True;
- for( int k = 0; k < 4; ++k, ++pBrd )
- aSetBox.SetDistance( rBox.GetDistance( *pBrd ),
- *pBrd );
- }
- else
- {
- for( int k = 0; k < 4; ++k, ++pBrd )
- if( aSetBox.GetDistance( *pBrd ) !=
- rBox.GetDistance( *pBrd ) )
- {
- aSetBoxInfo.SetValid( VALID_DISTANCE, sal_False );
- aSetBox.SetDistance( (sal_uInt16) 0 );
- break;
- }
- }
- }
- }
- }
- rSet.Put( aSetBox );
- rSet.Put( aSetBoxInfo );
- }
-}
-
-/***********************************************************************
-#* Class : SwDoc
-#* Methoden : SetBoxAttr
-#***********************************************************************/
-void SwDoc::SetBoxAttr( const SwCursor& rCursor, const SfxPoolItem &rNew )
-{
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- SwSelBoxes aBoxes;
- if( pTblNd && ::lcl_GetBoxSel( rCursor, aBoxes, sal_True ) )
- {
- SwTable& rTable = pTblNd->GetTable();
- if (GetIDocumentUndoRedo().DoesUndo())
- {
- GetIDocumentUndoRedo().AppendUndo( new SwUndoAttrTbl(*pTblNd) );
- }
-
- SvPtrarr aFmtCmp( Max( sal_uInt8(255), sal_uInt8(aBoxes.size()) ) );
- for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it )
- {
- SwTableBox *pBox = it->second;
-
- SwFrmFmt *pNewFmt;
- if ( 0 != (pNewFmt = SwTblFmtCmp::FindNewFmt( aFmtCmp, pBox->GetFrmFmt(), 0 )))
- pBox->ChgFrmFmt( (SwTableBoxFmt*)pNewFmt );
- else
- {
- SwFrmFmt *pOld = pBox->GetFrmFmt();
- SwFrmFmt *pNew = pBox->ClaimFrmFmt();
- pNew->SetFmtAttr( rNew );
- aFmtCmp.Insert( new SwTblFmtCmp( pOld, pNew, 0 ), aFmtCmp.Count());
- }
- }
-
- SwHTMLTableLayout *pTableLayout = rTable.GetHTMLTableLayout();
- if( pTableLayout )
- {
- SwCntntFrm* pFrm = rCursor.GetCntntNode()->getLayoutFrm( rCursor.GetCntntNode()->GetDoc()->GetCurrentLayout() );
- SwTabFrm* pTabFrm = pFrm->ImplFindTabFrm();
-
- pTableLayout->Resize(
- pTableLayout->GetBrowseWidthByTabFrm( *pTabFrm ), sal_True );
- }
- SwTblFmtCmp::Delete( aFmtCmp );
- SetModified();
- }
-}
-
-/***********************************************************************
-#* Class : SwDoc
-#* Methoden : GetBoxAttr()
-#***********************************************************************/
-
-sal_Bool SwDoc::GetBoxAttr( const SwCursor& rCursor, SfxPoolItem& rToFill ) const
-{
- sal_Bool bRet = sal_False;
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- SwSelBoxes aBoxes;
- if( pTblNd && lcl_GetBoxSel( rCursor, aBoxes ))
- {
- bRet = sal_True;
- sal_Bool bOneFound = sal_False;
- const sal_uInt16 nWhich = rToFill.Which();
- for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it )
- {
- SwTableBox* pBox = it->second;
- switch ( nWhich )
- {
- case RES_BACKGROUND:
- {
- const SvxBrushItem &rBack =
- pBox->GetFrmFmt()->GetBackground();
- if( !bOneFound )
- {
- (SvxBrushItem&)rToFill = rBack;
- bOneFound = sal_True;
- }
- else if( rToFill != rBack )
- bRet = sal_False;
- }
- break;
-
- case RES_FRAMEDIR:
- {
- const SvxFrameDirectionItem& rDir =
- pBox->GetFrmFmt()->GetFrmDir();
- if( !bOneFound )
- {
- (SvxFrameDirectionItem&)rToFill = rDir;
- bOneFound = sal_True;
- }
- else if( rToFill != rDir )
- bRet = sal_False;
- }
- case RES_VERT_ORIENT:
- {
- const SwFmtVertOrient& rOrient =
- pBox->GetFrmFmt()->GetVertOrient();
- if( !bOneFound )
- {
- (SwFmtVertOrient&)rToFill = rOrient;
- bOneFound = sal_True;
- }
- else if( rToFill != rOrient )
- bRet = sal_False;
- }
- }
-
- if ( sal_False == bRet )
- break;
- }
- }
- return bRet;
-}
-
-/***********************************************************************
-#* Class : SwDoc
-#* Methoden : SetBoxAlign, SetBoxAlign
-#***********************************************************************/
-void SwDoc::SetBoxAlign( const SwCursor& rCursor, sal_uInt16 nAlign )
-{
- OSL_ENSURE( nAlign == text::VertOrientation::NONE ||
- nAlign == text::VertOrientation::CENTER ||
- nAlign == text::VertOrientation::BOTTOM, "wrong alignment" );
- SwFmtVertOrient aVertOri( 0, nAlign );
- SetBoxAttr( rCursor, aVertOri );
-}
-
-sal_uInt16 SwDoc::GetBoxAlign( const SwCursor& rCursor ) const
-{
- sal_uInt16 nAlign = USHRT_MAX;
- SwTableNode* pTblNd = rCursor.GetPoint()->nNode.GetNode().FindTableNode();
- SwSelBoxes aBoxes;
- if( pTblNd && ::lcl_GetBoxSel( rCursor, aBoxes ))
- for( SwSelBoxes::const_iterator it = aBoxes.begin(); it != aBoxes.end(); ++it )
- {
- const SwFmtVertOrient &rOri =
- it->second->GetFrmFmt()->GetVertOrient();
- if( USHRT_MAX == nAlign )
- nAlign = static_cast<sal_uInt16>(rOri.GetVertOrient());
- else if( rOri.GetVertOrient() != nAlign )
- {
- nAlign = USHRT_MAX;
- break;
- }
- }
- return nAlign;
-}
-
-
/***********************************************************************
#* Class : SwDoc
#* Methoden : AdjustCellWidth()
@@ -1444,154 +556,4 @@ void lcl_CalcColValues( std::vector<sal_uInt16> &rToFill, const SwTabCols &rCols
}
-void SwDoc::AdjustCellWidth( const SwCursor& rCursor, sal_Bool bBalance )
-{
- // pruefe ob vom aktuellen Crsr der Point/Mark in einer Tabelle stehen
- SwCntntNode* pCntNd = rCursor.GetPoint()->nNode.GetNode().GetCntntNode();
- SwTableNode* pTblNd = pCntNd ? pCntNd->FindTableNode() : 0;
- if( !pTblNd )
- return ;
-
- SwLayoutFrm *pStart, *pEnd;
- ::lcl_GetStartEndCell( rCursor, pStart, pEnd );
-
- //TabCols besorgen, den ueber diese stellen wir die Tabelle neu ein.
- SwFrm* pBoxFrm = pStart;
- while( pBoxFrm && !pBoxFrm->IsCellFrm() )
- pBoxFrm = pBoxFrm->GetUpper();
-
- if ( !pBoxFrm )
- return; // robust
-
- SwTabCols aTabCols;
- GetTabCols( aTabCols, 0, (SwCellFrm*)pBoxFrm );
-
- if ( ! aTabCols.Count() )
- return;
-
- const sal_uInt8 nTmp = (sal_uInt8)Max( sal_uInt16(255), sal_uInt16(aTabCols.Count() + 1) );
- std::vector<sal_uInt16> aWish( nTmp, nTmp ),
- aMins( nTmp, nTmp );
- sal_uInt16 i;
-
- for ( i = 0; i <= aTabCols.Count(); ++i )
- {
- aWish.push_back( 0 );
- aMins.push_back( 0 );
- }
- ::lcl_CalcColValues( aWish, aTabCols, pStart, pEnd, sal_True );
-
- //Es ist Robuster wenn wir die Min-Werte fuer die ganze Tabelle berechnen.
- const SwTabFrm *pTab = pStart->ImplFindTabFrm();
- pStart = (SwLayoutFrm*)pTab->FirstCell();
- pEnd = (SwLayoutFrm*)pTab->FindLastCntnt()->GetUpper();
- while( !pEnd->IsCellFrm() )
- pEnd = pEnd->GetUpper();
- ::lcl_CalcColValues( aMins, aTabCols, pStart, pEnd, sal_False );
-
- if( bBalance )
- {
- //Alle Spalten, die makiert sind haben jetzt einen Wunschwert
- //eingtragen. Wir addieren die aktuellen Werte, teilen das Ergebnis
- //durch die Anzahl und haben eine Wunschwert fuer den ausgleich.
- sal_uInt16 nWish = 0, nCnt = 0;
- for ( i = 0; i <= aTabCols.Count(); ++i )
- {
- int nDiff = aWish[i];
- if ( nDiff )
- {
- if ( i == 0 )
- nWish = static_cast<sal_uInt16>( nWish + aTabCols[i] - aTabCols.GetLeft() );
- else if ( i == aTabCols.Count() )
- nWish = static_cast<sal_uInt16>(nWish + aTabCols.GetRight() - aTabCols[i-1] );
- else
- nWish = static_cast<sal_uInt16>(nWish + aTabCols[i] - aTabCols[i-1] );
- ++nCnt;
- }
- }
- nWish = nWish / nCnt;
- for ( i = 0; i < aWish.size(); ++i )
- if ( aWish[i] )
- aWish[i] = nWish;
- }
-
- const sal_uInt16 nOldRight = static_cast<sal_uInt16>(aTabCols.GetRight());
-
- //Um die Impl. einfach zu gestalten, aber trotzdem in den meissten Faellen
- //den Platz richtig auszunutzen laufen wir zweimal.
- //Problem: Erste Spalte wird breiter, die anderen aber erst danach
- //schmaler. Die Wunschbreite der ersten Spalte wuerde abgelehnt, weil
- //mit ihr die max. Breite der Tabelle ueberschritten wuerde.
- for ( sal_uInt16 k= 0; k < 2; ++k )
- {
- for ( i = 0; i <= aTabCols.Count(); ++i )
- {
- int nDiff = aWish[i];
- if ( nDiff )
- {
- int nMin = aMins[i];
- if ( nMin > nDiff )
- nDiff = nMin;
-
- if ( i == 0 )
- {
- if( aTabCols.Count() )
- nDiff -= aTabCols[0] - aTabCols.GetLeft();
- else
- nDiff -= aTabCols.GetRight() - aTabCols.GetLeft();
- }
- else if ( i == aTabCols.Count() )
- nDiff -= aTabCols.GetRight() - aTabCols[i-1];
- else
- nDiff -= aTabCols[i] - aTabCols[i-1];
-
- long nTabRight = aTabCols.GetRight() + nDiff;
-
- //Wenn die Tabelle zu breit wuerde begrenzen wir die Anpassung
- //auf das erlaubte Maximum.
- if ( !bBalance && nTabRight > aTabCols.GetRightMax() )
- {
- const long nTmpD = nTabRight - aTabCols.GetRightMax();
- nDiff -= nTmpD;
- nTabRight -= nTmpD;
- }
- for ( sal_uInt16 i2 = i; i2 < aTabCols.Count(); ++i2 )
- aTabCols[i2] += nDiff;
- aTabCols.SetRight( nTabRight );
- }
- }
- }
-
- const sal_uInt16 nNewRight = static_cast<sal_uInt16>(aTabCols.GetRight());
-
- SwFrmFmt *pFmt = pTblNd->GetTable().GetFrmFmt();
- const sal_Int16 nOriHori = pFmt->GetHoriOrient().GetHoriOrient();
-
- //So, die richtige Arbeit koennen wir jetzt der SwTable ueberlassen.
- SetTabCols( aTabCols, sal_False, 0, (SwCellFrm*)pBoxFrm );
-
- // i54248: lijian/fme
- // alignment might have been changed in SetTabCols, restore old value:
- const SwFmtHoriOrient &rHori = pFmt->GetHoriOrient();
- SwFmtHoriOrient aHori( rHori );
- if ( aHori.GetHoriOrient() != nOriHori )
- {
- aHori.SetHoriOrient( nOriHori );
- pFmt->SetFmtAttr( aHori );
- }
-
- //Bei Automatischer Breite wird auf Linksbuendig umgeschaltet.
- //Bei Randattributen wird der Rechte Rand angepasst.
- if( !bBalance && nNewRight < nOldRight )
- {
- if( aHori.GetHoriOrient() == text::HoriOrientation::FULL )
- {
- aHori.SetHoriOrient( text::HoriOrientation::LEFT );
- pFmt->SetFmtAttr( aHori );
- }
- }
-
- SetModified();
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx
index 0e5bf3189e55..1027dce0e529 100644
--- a/sw/source/core/undo/undraw.cxx
+++ b/sw/source/core/undo/undraw.cxx
@@ -66,30 +66,6 @@ struct SwUndoGroupObjImpl
};
-// Draw-Objecte
-
-IMPL_LINK( SwDoc, AddDrawUndo, SdrUndoAction *, pUndo )
-{
-#if OSL_DEBUG_LEVEL > 1
- sal_uInt16 nId = pUndo->GetId();
- (void)nId;
- String sComment( pUndo->GetComment() );
-#endif
-
- if (GetIDocumentUndoRedo().DoesUndo() &&
- GetIDocumentUndoRedo().DoesDrawUndo())
- {
- const SdrMarkList* pMarkList = 0;
- ViewShell* pSh = GetCurrentViewShell();
- if( pSh && pSh->HasDrawView() )
- pMarkList = &pSh->GetDrawView()->GetMarkedObjectList();
-
- GetIDocumentUndoRedo().AppendUndo( new SwSdrUndo(pUndo, pMarkList) );
- }
- else
- delete pUndo;
- return 0;
-}
SwSdrUndo::SwSdrUndo( SdrUndoAction* pUndo, const SdrMarkList* pMrkLst )
: SwUndo( UNDO_DRAWUNDO ), pSdrUndo( pUndo )