diff options
author | Philipp Lohmann <Philipp.Lohmann@Sun.COM> | 2009-10-09 15:11:54 +0200 |
---|---|---|
committer | Philipp Lohmann <Philipp.Lohmann@Sun.COM> | 2009-10-09 15:11:54 +0200 |
commit | eb5cdebdf7e3ff4c8d9c4f26682892c861b0a2d2 (patch) | |
tree | d3f14fb42f9c896b4de8698913ef90595bf97fae | |
parent | 73c391c15da3961be45133e152e8417f4407cd37 (diff) | |
parent | b4fca3befd4ada3c6288c6f5c3826fefd3e3b7cf (diff) |
merge with m61
408 files changed, 26720 insertions, 11443 deletions
diff --git a/starmath/inc/edit.hxx b/starmath/inc/edit.hxx index 87b7ecef36..c6e3121ced 100644 --- a/starmath/inc/edit.hxx +++ b/starmath/inc/edit.hxx @@ -99,6 +99,7 @@ class SmEditWindow : public Window, public DropTargetHelper Rectangle AdjustScrollBars(); void SetScrollBarRanges(); void InitScrollBars(); + void InvalidateSlots(); public: SmEditWindow( SmCmdBoxWindow &rMyCmdBoxWin ); diff --git a/starmath/inc/view.hxx b/starmath/inc/view.hxx index b0528db63e..ef277013da 100644 --- a/starmath/inc/view.hxx +++ b/starmath/inc/view.hxx @@ -229,9 +229,8 @@ class SmViewShell: public SfxViewShell SmViewShell_Impl* pImpl; BOOL bPasteState; - void AddRemoveClipboardListener( BOOL bAdd ); - DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* ); + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); protected: diff --git a/starmath/sdi/makefile.mk b/starmath/sdi/makefile.mk index a10a81adae..768280af97 100644 --- a/starmath/sdi/makefile.mk +++ b/starmath/sdi/makefile.mk @@ -39,7 +39,7 @@ SVSDIINC=$(PRJ)$/inc # --- Settings ----------------------------------------------------- .INCLUDE : settings.mk - +.IF "$(L10N_framework)"=="" # --- Files -------------------------------------------------------- @@ -52,6 +52,7 @@ SVSDI1DEPEND= \ $(SVSDIINC)$/starmath.hrc # --- Targets ------------------------------------------------------- +.ENDIF .INCLUDE : target.mk diff --git a/starmath/sdi/smath.sdi b/starmath/sdi/smath.sdi index c36682b34f..9d1bd22ebb 100644 --- a/starmath/sdi/smath.sdi +++ b/starmath/sdi/smath.sdi @@ -32,7 +32,7 @@ SfxVoidItem Adjust SID_ADJUST [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -259,7 +259,7 @@ SfxVoidItem Draw SID_DRAW [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -488,7 +488,7 @@ SfxVoidItem NextError SID_NEXTERR [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -513,7 +513,7 @@ SfxVoidItem NextMark SID_NEXTMARK [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -563,7 +563,7 @@ SfxVoidItem PrevError SID_PREVERR [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -588,7 +588,7 @@ SfxVoidItem PrevMark SID_PREVMARK [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -612,8 +612,8 @@ SfxBoolItem RedrawAutomatic SID_AUTO_REDRAW [ /* flags: */ - AutoUpdate = FALSE, - Cachable = Volatile, + AutoUpdate = TRUE, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -740,7 +740,7 @@ SfxBoolItem Textmode SID_TEXTMODE [ /* flags: */ AutoUpdate = TRUE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -819,7 +819,7 @@ SfxBoolItem ToolBox SID_TOOLBOX [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx index 0307fc1c7c..355a2baab2 100644 --- a/starmath/source/accessibility.cxx +++ b/starmath/source/accessibility.cxx @@ -1443,6 +1443,18 @@ USHORT SmTextForwarder::GetLineLen( USHORT nPara, USHORT nLine ) const EditEngine *pEditEngine = rEditAcc.GetEditEngine(); return pEditEngine ? pEditEngine->GetLineLen(nPara, nLine) : 0; } + +void SmTextForwarder::GetLineBoundaries( /*out*/USHORT &rStart, /*out*/USHORT &rEnd, USHORT nPara, USHORT nLine ) const +{ + EditEngine *pEditEngine = rEditAcc.GetEditEngine(); + pEditEngine->GetLineBoundaries(rStart, rEnd, nPara, nLine); +} + +USHORT SmTextForwarder::GetLineNumberAtIndex( USHORT nPara, USHORT nIndex ) const +{ + EditEngine *pEditEngine = rEditAcc.GetEditEngine(); + return pEditEngine ? pEditEngine->GetLineNumberAtIndex(nPara, nIndex) : 0; +} sal_Bool SmTextForwarder::QuickFormatDoc( BOOL /*bFull*/ ) { diff --git a/starmath/source/accessibility.hxx b/starmath/source/accessibility.hxx index c2de062bc5..335551aa5d 100644 --- a/starmath/source/accessibility.hxx +++ b/starmath/source/accessibility.hxx @@ -254,6 +254,8 @@ public: virtual sal_Bool GetAttributeRun( USHORT& nStartIndex, USHORT& nEndIndex, USHORT nPara, USHORT nIndex ) const; virtual USHORT GetLineCount( USHORT nPara ) const; virtual USHORT GetLineLen( USHORT nPara, USHORT nLine ) const; + virtual void GetLineBoundaries( /*out*/USHORT &rStart, /*out*/USHORT &rEnd, USHORT nParagraph, USHORT nLine ) const; + virtual USHORT GetLineNumberAtIndex( USHORT nPara, USHORT nLine ) const; virtual sal_Bool Delete( const ESelection& ); virtual sal_Bool InsertText( const String&, const ESelection& ); virtual sal_Bool QuickFormatDoc( BOOL bFull=FALSE ); diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index 7df803ae13..9d34209aff 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -580,19 +580,6 @@ void SmMathConfig::Save() SaveFontFormatList(); } - -USHORT SmMathConfig::GetSymbolCount() const -{ - return ((SmMathConfig *) this)->GetSymSetManager().GetSymbolCount(); -} - - -const SmSym * SmMathConfig::GetSymbol( USHORT nIndex ) const -{ - return ((SmMathConfig *) this)->GetSymSetManager().GetSymbolByPos( nIndex ); -} - - void SmMathConfig::GetSymbols( std::vector< SmSym > &rSymbols ) const { Sequence< OUString > aNodes( ((SmMathConfig*) this)->GetNodeNames( A2OU( SYMBOL_LIST ) ) ); diff --git a/starmath/source/cfgitem.hxx b/starmath/source/cfgitem.hxx index 2578e91072..7b5029f990 100644 --- a/starmath/source/cfgitem.hxx +++ b/starmath/source/cfgitem.hxx @@ -188,8 +188,6 @@ public: SmSymSetManager & GetSymSetManager(); void GetSymbols( std::vector< SmSym > &rSymbols ) const; void SetSymbols( const std::vector< SmSym > &rNewSymbols ); - USHORT GetSymbolCount() const; - const SmSym * GetSymbol( USHORT nIndex ) const; const SmFormat & GetStandardFormat() const; void SetStandardFormat( const SmFormat &rFormat, BOOL bSaveFontFormatList = FALSE ); diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx index e5f975c920..a8b7030313 100644 --- a/starmath/source/document.cxx +++ b/starmath/source/document.cxx @@ -1171,9 +1171,21 @@ void SmDocShell::Execute(SfxRequest& rReq) (pTmpUndoMgr->*fnDo)( 0 ); } Repaint(); + SfxViewFrame* pFrm = SfxViewFrame::GetFirst( this ); + while( pFrm ) + { + SfxBindings& rBind = pFrm->GetBindings(); + rBind.Invalidate(SID_UNDO); + rBind.Invalidate(SID_REDO); + rBind.Invalidate(SID_REPEAT); + rBind.Invalidate(SID_CLEARHISTORY); + pFrm = SfxViewFrame::GetNext( *pFrm, this ); + } } break; } + + rReq.Done(); } diff --git a/starmath/source/edit.cxx b/starmath/source/edit.cxx index 714310ffa4..0e4542b96e 100644 --- a/starmath/source/edit.cxx +++ b/starmath/source/edit.cxx @@ -60,7 +60,7 @@ #include <svx/lrspitem.hxx> #include <svtools/itemset.hxx> #include <svx/fontitem.hxx> - +#include <sfx2/viewfrm.hxx> #include "edit.hxx" #include "view.hxx" @@ -163,6 +163,13 @@ SmEditWindow::~SmEditWindow() delete pScrollBox; } +void SmEditWindow::InvalidateSlots() +{ + SfxBindings& rBind = GetView()->GetViewFrame()->GetBindings(); + rBind.Invalidate(SID_COPY); + rBind.Invalidate(SID_CUT); + rBind.Invalidate(SID_DELETE); +} SmViewShell * SmEditWindow::GetView() { @@ -317,6 +324,7 @@ void SmEditWindow::MouseButtonUp(const MouseEvent &rEvt) // ggf FormulaCursor neu positionieren CursorMoveTimerHdl(&aCursorMoveTimer); + InvalidateSlots(); } void SmEditWindow::MouseButtonDown(const MouseEvent &rEvt) @@ -460,6 +468,8 @@ void SmEditWindow::KeyInput(const KeyEvent& rKEvt) aModifyTimer.Start(); } + + InvalidateSlots(); } } @@ -855,6 +865,7 @@ void SmEditWindow::SetSelection(const ESelection &rSel) DBG_ASSERT( pEditView, "NULL pointer" ); if (pEditView) pEditView->SetSelection(rSel); + InvalidateSlots(); } BOOL SmEditWindow::IsEmpty() const diff --git a/starmath/source/makefile.mk b/starmath/source/makefile.mk index 0f604a22b3..53f6569dcf 100644 --- a/starmath/source/makefile.mk +++ b/starmath/source/makefile.mk @@ -73,7 +73,6 @@ SLO1FILES = \ $(SLO)$/smmod.obj \ $(SLO)$/types.obj \ $(SLO)$/view.obj \ - $(SLO)$/viewhdl.obj \ $(SLO)$/edit.obj \ $(SLO)$/rect.obj \ $(SLO)$/unomodel.obj \ @@ -99,7 +98,6 @@ EXCEPTIONSFILES = \ $(SLO)$/mathmlexport.obj \ $(SLO)$/mathtype.obj \ $(SLO)$/view.obj \ - $(SLO)$/viewhdl.obj \ $(SLO)$/unomodel.obj \ $(SLO)$/smdetect.obj \ $(SLO)$/symbol.obj \ diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index bf719d661d..1f7336db6d 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -318,13 +318,35 @@ ULONG SmXMLImportWrapper::ReadThroughComponent( if ( pFilter && pFilter->GetSuccess() )
nError = 0;
}
- catch( xml::sax::SAXParseException& )
+ catch( xml::sax::SAXParseException& r )
{
+ // sax parser sends wrapped exceptions,
+ // try to find the original one
+ xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r);
+ sal_Bool bTryChild = sal_True;
+
+ while( bTryChild )
+ {
+ xml::sax::SAXException aTmp;
+ if ( aSaxEx.WrappedException >>= aTmp )
+ aSaxEx = aTmp;
+ else
+ bTryChild = sal_False;
+ }
+
+ packages::zip::ZipIOException aBrokenPackage;
+ if ( aSaxEx.WrappedException >>= aBrokenPackage )
+ return ERRCODE_IO_BROKENPACKAGE;
+
if ( bEncrypted )
nError = ERRCODE_SFX_WRONGPASSWORD;
}
- catch( xml::sax::SAXException& )
+ catch( xml::sax::SAXException& r )
{
+ packages::zip::ZipIOException aBrokenPackage;
+ if ( r.WrappedException >>= aBrokenPackage )
+ return ERRCODE_IO_BROKENPACKAGE;
+
if ( bEncrypted )
nError = ERRCODE_SFX_WRONGPASSWORD;
}
diff --git a/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx index df2182fb1e..8898721237 100644 --- a/starmath/source/smdetect.cxx +++ b/starmath/source/smdetect.cxx @@ -220,7 +220,7 @@ SmFilterDetect::~SmFilterDetect() if ( bIsStorage ) { //TODO/LATER: factor this out! - uno::Reference < embed::XStorage > xStorage = aMedium.GetStorage(); + uno::Reference < embed::XStorage > xStorage = aMedium.GetStorage( sal_False ); if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE ) { // error during storage creation means _here_ that the medium diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index 4be3a70eeb..c44b65ff29 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -1184,6 +1184,9 @@ SfxPrinter* SmViewShell::GetPrinter(BOOL bCreate) USHORT SmViewShell::SetPrinter(SfxPrinter *pNewPrinter, USHORT nDiffFlags, bool ) { RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::SetPrinter" ); + SfxPrinter *pOld = GetDoc()->GetPrinter(); + if ( pOld && pOld->IsPrinting() ) + return SFX_PRINTERROR_BUSY; if ((nDiffFlags & SFX_PRINTER_PRINTER) == SFX_PRINTER_PRINTER) GetDoc()->SetPrinter( pNewPrinter ); @@ -1559,7 +1562,7 @@ void SmViewShell::Execute(SfxRequest& rReq) pImpl->pDocInserter = new ::sfx2::DocumentInserter( 0, GetDoc()->GetFactory().GetFactoryName(), 0 ); pImpl->pDocInserter->StartExecuteModal( LINK( this, SmViewShell, DialogClosedHdl ) ); - return; + break; } case SID_NEXTERR: @@ -1687,8 +1690,6 @@ void SmViewShell::Execute(SfxRequest& rReq) SmSymbolDialog( NULL, pDev, pp->GetSymSetManager(), *this ).Execute(); } break; - - } rReq.Done(); } @@ -1715,7 +1716,6 @@ void SmViewShell::GetState(SfxItemSet &rSet) case SID_PASTE: if( !xClipEvtLstnr.is() && pEditWin) { - AddRemoveClipboardListener( TRUE ); TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pEditWin) ); @@ -1805,8 +1805,6 @@ SmViewShell::~SmViewShell() { RTL_LOGFILE_CONTEXT( aLog, "starmath: SmViewShell::~SmViewShell" ); - AddRemoveClipboardListener( FALSE ); - //!! this view shell is not active anymore !! // Thus 'SmGetActiveView' will give a 0 pointer. // Thus we need to supply this view as argument @@ -1883,3 +1881,19 @@ IMPL_LINK( SmViewShell, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg ) return 0; } +void SmViewShell::Notify( SfxBroadcaster& , const SfxHint& rHint ) +{ + if ( rHint.IsA(TYPE(SfxSimpleHint)) ) + { + switch( ( (SfxSimpleHint&) rHint ).GetId() ) + { + case SFX_HINT_MODECHANGED: + case SFX_HINT_DOCCHANGED: + GetViewFrame()->GetBindings().InvalidateAll(FALSE); + break; + default: + break; + } + } +} + diff --git a/starmath/source/viewhdl.cxx b/starmath/source/viewhdl.cxx deleted file mode 100644 index 11ab8d6b9b..0000000000 --- a/starmath/source/viewhdl.cxx +++ /dev/null @@ -1,170 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: viewhdl.cxx,v $ - * $Revision: 1.10 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_starmath.hxx" - - -#include <view.hxx> -#include <comphelper/processfactory.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/datatransfer/clipboard/XClipboardListener.hpp> -#include <com/sun/star/datatransfer/clipboard/XClipboardNotifier.hpp> -#include <vos/mutex.hxx> -#include <cppuhelper/implbase1.hxx> -#include <svtools/transfer.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/sfxsids.hrc> - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::datatransfer::clipboard; - -// --------------------------- Clipboard EventListener ------------------ - -class SmClipboardChangeListener : public ::cppu::WeakImplHelper1< - ::com::sun::star::datatransfer::clipboard::XClipboardListener > -{ - SmViewShell* pView; - - // XEventListener - virtual void SAL_CALL disposing( - const lang::EventObject& rEventObject ) throw ( ::com::sun::star::uno::RuntimeException) -;// throw( UNO_NMSPC::RuntimeException ); - - // XClipboardListener - virtual void SAL_CALL changedContents( - const datatransfer::clipboard::ClipboardEvent& rEventObject ) throw ( ::com::sun::star::uno::RuntimeException) -;// throw( UNO_NMSPC::RuntimeException ); - -public: - SmClipboardChangeListener( SmViewShell& rView ) : pView( &rView ) {} - virtual ~SmClipboardChangeListener(); - - void ViewDestroyed() { pView = 0; } - - void AddRemoveListener( BOOL bAdd ); -}; - - - -// ------------------------- SmClipboardChangeListener --------------------- - -SmClipboardChangeListener::~SmClipboardChangeListener() -{ -} - -void SAL_CALL SmClipboardChangeListener::disposing( - const lang::EventObject& /*rEventObject*/ ) throw ( ::com::sun::star::uno::RuntimeException) -{ -} - -void SAL_CALL SmClipboardChangeListener::changedContents( - const ClipboardEvent& rEventObject ) throw ( ::com::sun::star::uno::RuntimeException) -{ - const ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - if( pView ) - { - { - TransferableDataHelper aDataHelper( rEventObject.Contents ); - sal_Bool bHasTransferable = aDataHelper.GetTransferable().is(); - - //! according to CD the above call to GetTransferable may create a (new) - //! message loop and thus result in re-entrant code. - //! Thus it was suggested to check 'pView' here again. - if (pView) - { - pView->bPasteState = bHasTransferable && - ( aDataHelper.HasFormat( FORMAT_STRING ) || - aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBEDDED_OBJ ) || - (aDataHelper.HasFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ) - && aDataHelper.HasFormat( SOT_FORMATSTR_ID_EMBED_SOURCE ))); - } - } - - if (pView) - { - SfxBindings& rBind = pView->GetViewFrame()->GetBindings(); - rBind.Invalidate( SID_PASTE ); - } - } -} - -void SmClipboardChangeListener::AddRemoveListener( BOOL bAdd ) -{ - try - { - do { - Window* pW; - Reference< XClipboard > xClipboard; - if( pView && 0 != ( pW = pView->GetEditWindow()) ) - xClipboard = pW->GetClipboard(); - if( !xClipboard.is() ) - break; - - Reference< XClipboardNotifier > xClpbrdNtfr( xClipboard, UNO_QUERY ); - if( xClpbrdNtfr.is() ) - { - Reference< XClipboardListener > xClipEvtLstnr( this ); - if( bAdd ) - xClpbrdNtfr->addClipboardListener( xClipEvtLstnr ); - else - xClpbrdNtfr->removeClipboardListener( xClipEvtLstnr ); - } - } while ( FALSE ); - } - catch( const ::com::sun::star::uno::Exception& ) - { - } -} - -// ------------------------- SmViewShell --------------------- - -void SmViewShell::AddRemoveClipboardListener( BOOL bAdd ) -{ - // AddRemoveListener and ViewDestroyed below should be an - // atomic operation and must not be 'interrupted' by other code - const ::vos::OGuard aGuard( Application::GetSolarMutex() ); - - if( bAdd && !xClipEvtLstnr.is() ) - { - xClipEvtLstnr = pClipEvtLstnr = new SmClipboardChangeListener( *this ); - pClipEvtLstnr->AddRemoveListener( TRUE ); - } - else if( !bAdd && xClipEvtLstnr.is() ) - { - pClipEvtLstnr->AddRemoveListener( FALSE ); - pClipEvtLstnr->ViewDestroyed(); - } -} - - - diff --git a/starmath/util/makefile.mk b/starmath/util/makefile.mk index d38e162b21..0e11dc46aa 100644 --- a/starmath/util/makefile.mk +++ b/starmath/util/makefile.mk @@ -57,6 +57,7 @@ SHL1DEF=$(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) SHL1STDLIBS= \ + $(SVXCORELIB) \ $(SVXLIB) \ $(SFX2LIB) \ $(XMLOFFLIB) \ diff --git a/sw/inc/IDocumentContentOperations.hxx b/sw/inc/IDocumentContentOperations.hxx index 67250574a7..b5830d72b2 100644 --- a/sw/inc/IDocumentContentOperations.hxx +++ b/sw/inc/IDocumentContentOperations.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -67,11 +67,19 @@ DOC_NO_DELFRMS = 0x08 }; + // constants for inserting text + enum InsertFlags + { INS_DEFAULT = 0x00 // no extras + , INS_EMPTYEXPAND = 0x01 // expand empty hints at insert position + , INS_NOHINTEXPAND = 0x02 // do not expand any hints at insert pos + , INS_FORCEHINTEXPAND = 0x04 // expand all hints at insert position + }; + public: /** Kopieren eines Bereiches im oder in ein anderes Dokument ! Die Position kann auch im Bereich liegen !! */ - virtual bool Copy(SwPaM&, SwPosition&, bool bCopyAll ) const = 0; + virtual bool CopyRange(SwPaM&, SwPosition&, const bool bCopyAll ) const = 0; /** Loesche die Section, in der der Node steht. */ @@ -79,46 +87,41 @@ /** loeschen eines BereichesSwFlyFrmFmt */ - virtual bool Delete(SwPaM&) = 0; + virtual bool DeleteRange(SwPaM&) = 0; /** loeschen gesamter Absaetze */ virtual bool DelFullPara(SwPaM&) = 0; - /** komplett loeschen eines Bereiches + /** complete delete of a given PaM + + OD 2009-08-20 #i100466# + Add optional parameter <bForceJoinNext>, default value <false> + Needed for hiding of deletion redlines */ - virtual bool DeleteAndJoin(SwPaM&) = 0; + virtual bool DeleteAndJoin( SwPaM&, + const bool bForceJoinNext = false ) = 0; /** verschieben eines Bereiches */ - virtual bool Move(SwPaM&, SwPosition&, SwMoveFlags) = 0; + virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags) = 0; /** verschieben ganzer Nodes */ - virtual bool Move(SwNodeRange&, SwNodeIndex&, SwMoveFlags) = 0; + virtual bool MoveNodeRange(SwNodeRange&, SwNodeIndex&, SwMoveFlags) = 0; /** verschieben eines Bereiches */ virtual bool MoveAndJoin(SwPaM&, SwPosition&, SwMoveFlags) = 0; - /** Ueberschreiben eines einzelnen Zeichens. rRg.Start() bezeichnet - den Node und die Position in dem Node, an der eingefuegt wird, - */ - virtual bool Overwrite(const SwPaM &rRg, sal_Unicode c) = 0; - /** Ueberschreiben eines Strings in einem bestehenden Textnode. */ virtual bool Overwrite(const SwPaM &rRg, const String& rStr) = 0; - /** Einfuegen eines einzelnen Zeichens. rRg.Start() bezeichnet - den Node und die Position in dem Node, an der eingefuegt wird. - */ - virtual bool Insert(const SwPaM &rRg, sal_Unicode c) = 0; - - /** Einfuegen eines Strings in einen bestehenden - Textnode. Der Text wird kopiert. + /** Insert string into existing text node at position rRg.Point(). */ - virtual bool Insert(const SwPaM &rRg, const String&, bool bHintExpand) = 0; + virtual bool InsertString(const SwPaM &rRg, const String&, + const enum InsertFlags nInsertMode = INS_EMPTYEXPAND ) = 0; /** change text to Upper/Lower/Hiragana/Katagana/... */ @@ -166,7 +169,8 @@ z.B.: Fnd: "zzz", Repl: "xx\t\\t..&..\&" --> "xx\t<Tab>..zzz..&" */ - virtual bool Replace(SwPaM& rPam, const String& rNewStr, bool bRegExpRplc) = 0; + virtual bool ReplaceRange(SwPaM& rPam, const String& rNewStr, + const bool bRegExReplace) = 0; /** Einfuegen eines Attributs. Erstreckt sich rRg ueber mehrere Nodes, wird das Attribut aufgespaltet, sofern @@ -182,11 +186,13 @@ hinzugefuegt. Wenn das Attribut nicht eingefuegt werden konnte, liefert die Methode sal_False. */ - virtual bool Insert(const SwPaM &rRg, const SfxPoolItem&, sal_uInt16 nFlags) = 0; + virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&, + const sal_uInt16 nFlags) = 0; /** */ - virtual bool Insert(const SwPaM &rRg, const SfxItemSet&, sal_uInt16 nFlags) = 0; + virtual bool InsertItemSet (const SwPaM &rRg, const SfxItemSet&, + const sal_uInt16 nFlags) = 0; /** Removes any leading white space from the paragraph */ diff --git a/sw/inc/PostItMgr.hxx b/sw/inc/PostItMgr.hxx index c6b1f50e38..f71c0f3e23 100644 --- a/sw/inc/PostItMgr.hxx +++ b/sw/inc/PostItMgr.hxx @@ -177,12 +177,11 @@ class SwPostItMgr: public SfxListener bool HasScrollbars() const; void Focus(SfxBroadcaster& rBC); - sal_Int32 GetInitialAnchorDistance() const; - sal_Int32 GetScrollSize() const; - sal_Int32 GetSpaceBetween() const; + sal_Int32 GetInitialAnchorDistance() const; + sal_Int32 GetScrollSize() const; + sal_Int32 GetSpaceBetween() const; void SetReadOnlyState(); - DECL_LINK( CalcHdl, void*); - + DECL_LINK( CalcHdl, void*); protected: public: @@ -263,6 +262,12 @@ class SwPostItMgr: public SfxListener sal_uInt16 Replace(SvxSearchItem* pItem); sal_uInt16 SearchReplace(const SwFmtFld &pFld, const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward); sal_uInt16 FinishSearchReplace(const ::com::sun::star::util::SearchOptions& rSearchOptions,bool bSrchForward); + + void AssureStdModeAtShell(); }; #endif + + + + diff --git a/sw/inc/bookmrk.hxx b/sw/inc/bookmrk.hxx deleted file mode 100644 index 991b401768..0000000000 --- a/sw/inc/bookmrk.hxx +++ /dev/null @@ -1,218 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: bookmrk.hxx,v $ - * $Revision: 1.11 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _BOOKMRK_HXX -#define _BOOKMRK_HXX - -#include "hintids.hxx" //die Ids der Attribute, vor macitem damit die - //die Attribut richtig angezogen werden. -#include <svtools/macitem.hxx> - -#ifndef _KEYCOD_HXX //autogen -#include <vcl/keycod.hxx> -#endif -#ifndef _TOOLS_REF_HXX -#include <tools/ref.hxx> -#endif -#include <IDocumentBookmarkAccess.hxx> -#include <calbck.hxx> -#include <pam.hxx> - -#ifndef SW_DECL_SWSERVEROBJECT_DEFINED -#define SW_DECL_SWSERVEROBJECT_DEFINED -SV_DECL_REF( SwServerObject ) -#endif - - -struct SwPosition; // fwd Decl. wg. UI - -class SwBookmark : public SwModify -{ - SwPosition *pPos1, *pPos2; // wird im CTOR gesetzt, im DTOR geloescht - // pPos1 is always != 0, pPos2 may be 0 - SwServerObjectRef refObj; // falls DataServer -> Pointer gesetzt - -protected: - String aName; - String aShortName; - KeyCode aCode; - IDocumentBookmarkAccess::BookmarkType eMarkType; - - SwBookmark( const SwPosition& aPos, - const KeyCode& rCode, - const String& rName, const String& rShortName); - -public: - TYPEINFO(); - - SwBookmark( const SwPosition& aPos ); - // --> OD 2007-09-26 #i81002# - SwBookmark( const SwPaM& aPaM, - const KeyCode& rCode, - const String& rName, const String& rShortName); - // <-- - - // Beim Loeschen von Text werden Bookmarks mitgeloescht! - virtual ~SwBookmark(); - - // --> OD 2007-10-10 #i81002# - // made virtual and thus no longer inline - virtual const SwPosition& GetBookmarkPos() const; - virtual const SwPosition* GetOtherBookmarkPos() const; - // <-- - - // nicht undofaehig - const String& GetName() const { return aName; } - // nicht undofaehig - const String& GetShortName() const { return aShortName; } - // nicht undofaehig - const KeyCode& GetKeyCode() const { return aCode; } - - // Vergleiche auf Basis der Dokumentposition - BOOL operator < (const SwBookmark &) const; - BOOL operator ==(const SwBookmark &) const; - // falls man wirklich auf gleiche Position abfragen will. - BOOL IsEqualPos( const SwBookmark &rBM ) const; - - BOOL IsFormFieldMark() const { return IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT == eMarkType || IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT == eMarkType; } - BOOL IsBookMark() const { return IDocumentBookmarkAccess::BOOKMARK == eMarkType || IDocumentBookmarkAccess::FORM_FIELDMARK_TEXT == eMarkType || IDocumentBookmarkAccess::FORM_FIELDMARK_NO_TEXT == eMarkType; } -// // --> OD 2007-10-17 #TESTING# -// BOOL IsBookMark() const -// { -// return IDocumentBookmarkAccess::BOOKMARK == eMarkType || -// IsCrossRefMark(); -// } -// // <-- - BOOL IsMark() const { return IDocumentBookmarkAccess::MARK == eMarkType; } - BOOL IsUNOMark() const { return IDocumentBookmarkAccess::UNO_BOOKMARK == eMarkType; } - // --> OD 2007-10-11 #i81002# - bookmark type for cross-references - BOOL IsCrossRefMark() const { return IDocumentBookmarkAccess::CROSSREF_BOOKMARK == eMarkType; } - // <-- - void SetType( IDocumentBookmarkAccess::BookmarkType eNewType ) { eMarkType = eNewType; } - IDocumentBookmarkAccess::BookmarkType GetType() const { return eMarkType; } - - // Daten Server-Methoden - void SetRefObject( SwServerObject* pObj ); - const SwServerObject* GetObject() const { return &refObj; } - SwServerObject* GetObject() { return &refObj; } - BOOL IsServer() const { return refObj.Is(); } - - // --> OD 2007-10-10 #i81002# - // made virtual and thus no longer inline - // to access start and end of a bookmark. - // start and end may be the same - virtual const SwPosition* BookmarkStart() const; - virtual const SwPosition* BookmarkEnd() const; - // <-- - - // --> OD 2007-09-26 #i81002# - virtual void SetBookmarkPos( const SwPosition* pNewPos1 ); - virtual void SetOtherBookmarkPos( const SwPosition* pNewPos2 ); - // <-- - -private: - // fuer METWARE: - // es wird (vorerst) nicht kopiert und nicht zugewiesen - SwBookmark(const SwBookmark &); - SwBookmark &operator=(const SwBookmark &); -}; - -class SwMark: public SwBookmark -{ -public: - SwMark( const SwPosition& aPos, - const KeyCode& rCode, - const String& rName, const String& rShortName); -}; - -class SW_DLLPUBLIC SwFieldBookmark : public SwBookmark -{ -private: - int fftype; // Type: 0 = Text, 1 = Check Box, 2 = List - int ffres; - bool ffprot; - bool ffsize; // 0 = Auto, 1=Exact (see ffhps) - int fftypetxt; // Type of text field: 0 = Regular text, 1 = Number, 2 = Date, 3 = Current date, 4 = Current time, 5 = Calculation - bool ffrecalc; - int ffmaxlen; // Number of characters for text field. Zero means unlimited. - int ffhps; // Check box size (half-point sizes). - - String ffname; - String ffhelptext; - -public: - SwFieldBookmark(const SwPosition& aPos, - const KeyCode& rCode, - const String& rName, const String& rShortName, - IDocumentBookmarkAccess::BookmarkType eMark); - - void SetFieldType(int fftype); - int GetFieldType(); - - void SetChecked(bool checked); - bool IsChecked(); - - void SetFFName(String aNewName) { - this->ffname=aNewName; - } - - String GetFFName() - { - return ffname; - } - - int GetFFRes() { - return ffres; - } - - void SetFFRes(int nNew) { - this->ffres=nNew; - } - - void SetFFHelpText(String newffhelptext) { - this->ffhelptext=newffhelptext; - } - - String GetFFHelpText() { - return ffhelptext; - } -}; - -class SwUNOMark: public SwBookmark -{ -public: - // --> OD 2007-09-26 #i81002# - SwUNOMark( const SwPaM& aPaM, - const KeyCode& rCode, - const String& rName, const String& rShortName); - // <-- -}; - - -#endif diff --git a/sw/inc/breakit.hxx b/sw/inc/breakit.hxx index bbc2db88ae..5901718c7e 100644 --- a/sw/inc/breakit.hxx +++ b/sw/inc/breakit.hxx @@ -50,6 +50,9 @@ class String; class SW_DLLPUBLIC SwBreakIt { com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF; + mutable com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > xBreak; + com::sun::star::uno::Reference< com::sun::star::i18n::XScriptTypeDetector > xCTLDetect; + com::sun::star::lang::Locale * m_pLocale; com::sun::star::i18n::ForbiddenCharacters * m_pForbidden; @@ -60,6 +63,9 @@ class SW_DLLPUBLIC SwBreakIt void _GetLocale( const LanguageType aLang ); void _GetForbidden( const LanguageType aLang ); + void createBreakIterator() const; + void createScriptTypeDetector(); + // forbidden and not implemented. SwBreakIt(); SwBreakIt( const SwBreakIt &); @@ -79,15 +85,18 @@ public: public: static SwBreakIt * Get(); - // @@@ backward compatibility @@@ - com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > xBreak; - com::sun::star::uno::Reference< com::sun::star::i18n::XScriptTypeDetector > xCTLDetect; - - const com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > & GetBreakIter() + com::sun::star::uno::Reference< com::sun::star::i18n::XBreakIterator > GetBreakIter() { + createBreakIterator(); return xBreak; } + com::sun::star::uno::Reference< com::sun::star::i18n::XScriptTypeDetector > GetScriptTypeDetector() + { + createScriptTypeDetector(); + return xCTLDetect; + } + const com::sun::star::lang::Locale& GetLocale( const LanguageType aLang ) { if( !m_pLocale || aLast != aLang ) diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx index 8c58d4e59b..5a97eba019 100644 --- a/sw/inc/calc.hxx +++ b/sw/inc/calc.hxx @@ -188,7 +188,7 @@ class SwCalc xub_StrLen nCommandPos; SwDoc& rDoc; - LocaleDataWrapper* pLclData; + const LocaleDataWrapper* pLclData; CharClass* pCharClass; USHORT nListPor; diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h index b6be0866ef..a87925bb84 100644 --- a/sw/inc/cmdid.h +++ b/sw/inc/cmdid.h @@ -153,7 +153,6 @@ Achtung: Ab sofort sind in diesem File keine C++-Kommentare (//) mehr #define FN_GOTO (FN_EDIT + 11) /* Gehe zu */ #define FN_PASTE (FN_EDIT + 13) /* Einfuegen */ -#define FN_PASTESPECIAL (FN_EDIT + 14) /* Verknuepfung einfuegen */ #define FN_PASTESPECIAL_DLG (FN_EDIT + 15) /* Verknuepfung einfuegen */ #define FN_NUMBER_BULLETS (FN_EDIT + 21) /* Bullets */ #define FN_REPEAT (FN_EDIT + 22) /* Letzten Befehl wiederholen */ @@ -910,6 +909,7 @@ Achtung: Ab sofort sind in diesem File keine C++-Kommentare (//) mehr #define FN_UNO_PARA_CONT_PREV_SUBTREE (FN_EXTRA2 + 109) #define FN_UNO_PARA_NUM_STRING (FN_EXTRA2 + 110) #define FN_UNO_TABLE_NAME (FN_EXTRA2 + 111) +#define FN_UNO_META (FN_EXTRA2 + 112) /*-------------------------------------------------------------------- Bereich: Hilfe @@ -1257,6 +1257,10 @@ Achtung: Ab sofort sind in diesem File keine C++-Kommentare (//) mehr #define FN_IID_COLRIGHT (FN_FRAME + 17) #define FN_SET_FRM_ALT_NAME (FN_FRAME + 18) +// --> OD 2009-07-13 #i73249# +#define FN_UNO_TITLE (FN_FRAME + 19) +#define FN_UNO_DESCRIPTION (FN_FRAME + 20) +// <-- //Member-Ids fuer Fill/SetVariable an Items diff --git a/sw/inc/crsrsh.hxx b/sw/inc/crsrsh.hxx index 8e1e0cd37a..692184be2d 100644 --- a/sw/inc/crsrsh.hxx +++ b/sw/inc/crsrsh.hxx @@ -150,9 +150,6 @@ const int CRSR_POSOLD = 0x01, // Cursor bleibt an alter Doc-Position String *ReplaceBackReferences( const com::sun::star::util::SearchOptions& rSearchOpt, SwPaM* pPam ); -// #i75172# -enum SwOverlayType { SW_OVERLAY_INVERT, SW_OVERLAY_TRANSPARENT }; - // die Cursor - Shell class SW_DLLPUBLIC SwCrsrShell : public ViewShell, public SwModify { @@ -252,9 +249,6 @@ private: // OD 11.02.2003 #100556# - flag to allow/avoid execution of marcos (default: true) bool mbMacroExecAllowed : 1; - // #i88893# the overlay type to use for cursor - SwOverlayType maSwOverlayType; - SW_DLLPRIVATE void UpdateCrsr( USHORT eFlags =SwCrsrShell::SCROLLWIN|SwCrsrShell::CHKRANGE, BOOL bIdleEnd = FALSE ); @@ -352,9 +346,6 @@ public: // only for usage in special cases allowed! void ExtendedSelectAll(); - // #i88893# the overlay type to use for cursor - SwOverlayType getSwOverlayType() const { return maSwOverlayType; } - SwPaM* GetCrsr( BOOL bMakeTblCrsr = TRUE ) const; inline SwCursor* GetSwCrsr( BOOL bMakeTblCrsr = TRUE ) const; // nur den akt. Cursor returnen diff --git a/sw/inc/dbgoutsw.hxx b/sw/inc/dbgoutsw.hxx index 3575cde6a3..cf794340ea 100644 --- a/sw/inc/dbgoutsw.hxx +++ b/sw/inc/dbgoutsw.hxx @@ -54,6 +54,7 @@ class SwNumRuleTbl; class SwNumRule; class SwOutlineNodes; class SwTxtFmtColl; +class SwNodeRange; #define DBG_OUT_HERE printf("%s(%d):", __FILE__, __LINE__) #define DBG_OUT_HERE_FN printf("%s(%d) %s:", __FILE__, __LINE__, __FUNCTION__) @@ -88,6 +89,7 @@ SW_DLLPUBLIC const char * dbg_out(const SwNumRule & rRule); SW_DLLPUBLIC const char * dbg_out(const SwTxtFmtColl & rFmt); SW_DLLPUBLIC const char * dbg_out(const SwFrmFmts & rFrmFmts); SW_DLLPUBLIC const char * dbg_out(const SwNumRuleTbl & rTbl); +SW_DLLPUBLIC const char * dbg_out(const SwNodeRange & rRange); template<typename tKey, typename tMember, typename fHashFunction> String lcl_dbg_out(const std::hash_map<tKey, tMember, fHashFunction> & rMap) diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index b90c6e5517..19c53674f8 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -252,9 +252,6 @@ public: // Mischen von Datensaetzen in Felder BOOL MergeNew( const SwMergeDescriptor& rMergeDesc ); BOOL Merge(SwWrtShell* pSh); - // printing parts of a merge result document - BOOL MergePrintDocuments( SwView& rView, - SwPrtOptions& rOpt, SfxProgress& rProgress, BOOL bIsAPI ); // Datenbankfelder mit fehlendem Datenbankname initialisieren inline BOOL IsInitDBFields() const { return bInitDBFields; } diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index d3da2d8829..efe7dc93ad 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -225,6 +225,9 @@ class SwViewOption; namespace sw { namespace mark { class MarkManager; }} +namespace sw { + class MetaFieldManager; +} namespace com { namespace sun { namespace star { namespace i18n { @@ -305,6 +308,7 @@ class SW_DLLPUBLIC SwDoc : mutable com::sun::star::uno::Reference< com::sun::star::linguistic2::XProofreadingIterator > m_xGCIterator; const ::boost::scoped_ptr< ::sw::mark::MarkManager> pMarkManager; + const ::boost::scoped_ptr< ::sw::MetaFieldManager > m_pMetaFieldManager; // ------------------------------------------------------------------- // die Pointer @@ -621,8 +625,8 @@ private: // nur fuer den internen Gebrauch deshalb privat. // Kopieren eines Bereiches im oder in ein anderes Dokument ! // Die Position darf nicht im Bereich liegen !! - sal_Bool _Copy( SwPaM&, SwPosition&, - sal_Bool MakeNewFrms /*= sal_True*/, bool bCopyAll, SwPaM* pCpyRng /*= 0*/ ) const; // in ndcopy.cxx + bool CopyImpl( SwPaM&, SwPosition&, const bool MakeNewFrms /*= true */, + const bool bCopyAll, SwPaM *const pCpyRng /*= 0*/ ) const; SwFlyFrmFmt* _MakeFlySection( const SwPosition& rAnchPos, const SwCntntNode& rNode, RndStdIds eRequestId, @@ -634,9 +638,10 @@ private: const SfxItemSet* pGrfAttrSet, SwFrmFmt* = 0 ); - void _CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, - const SwNodeIndex& rSttIdx, - sal_Bool bCopyFlyAtFly = sal_False ) const; // steht im ndcopy.cxx + void CopyFlyInFlyImpl( const SwNodeRange& rRg, + const xub_StrLen nEndContentIndex, + const SwNodeIndex& rStartIdx, + const bool bCopyFlyAtFly = false ) const; sal_Int8 SetFlyFrmAnchor( SwFrmFmt& rFlyFmt, SfxItemSet& rSet, sal_Bool bNewFrms ); // --> OD 2005-01-13 #i40550# @@ -646,7 +651,7 @@ private: FNCopyFmt fnCopyFmt, const SwFmt& rDfltFmt ); void CopyFmtArr( const SvPtrarr& rSourceArr, SvPtrarr& rDestArr, FNCopyFmt fnCopyFmt, SwFmt& rDfltFmt ); - void _CopyPageDescHeaderFooter( sal_Bool bCpyHeader, + void CopyPageDescHeaderFooterImpl( bool bCpyHeader, const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ); SwFmt* FindFmtByName( const SvPtrarr& rFmtArr, const String& rName ) const; @@ -709,6 +714,11 @@ private: void InitTOXTypes(); void Paste( const SwDoc& ); + bool DeleteAndJoinImpl(SwPaM&, const bool); + bool DeleteAndJoinWithRedlineImpl(SwPaM&, const bool unused = false); + bool DeleteRangeImpl(SwPaM&, const bool unused = false); + bool ReplaceRangeImpl(SwPaM&, String const&, const bool); + public: /** Life cycle @@ -885,18 +895,22 @@ public: /** IDocumentContentOperations */ - virtual bool Copy(SwPaM&, SwPosition&, bool bCopyAll) const; + virtual bool CopyRange(SwPaM&, SwPosition&, const bool bCopyAll) const; virtual void DeleteSection(SwNode* pNode); - virtual bool Delete(SwPaM&); + virtual bool DeleteRange(SwPaM&); virtual bool DelFullPara(SwPaM&); - virtual bool DeleteAndJoin(SwPaM&); - virtual bool Move(SwPaM&, SwPosition&, SwMoveFlags); - virtual bool Move(SwNodeRange&, SwNodeIndex&, SwMoveFlags); + // --> OD 2009-08-20 #i100466# + // Add optional parameter <bForceJoinNext>, default value <false> + // Needed for hiding of deletion redlines + virtual bool DeleteAndJoin( SwPaM&, + const bool bForceJoinNext = false ); + // <-- + virtual bool MoveRange(SwPaM&, SwPosition&, SwMoveFlags); + virtual bool MoveNodeRange(SwNodeRange&, SwNodeIndex&, SwMoveFlags); virtual bool MoveAndJoin(SwPaM&, SwPosition&, SwMoveFlags); - virtual bool Overwrite(const SwPaM &rRg, sal_Unicode c); virtual bool Overwrite(const SwPaM &rRg, const String& rStr); - virtual bool Insert(const SwPaM &rRg, sal_Unicode c); - virtual bool Insert(const SwPaM &rRg, const String&, bool bHintExpand); + virtual bool InsertString(const SwPaM &rRg, const String&, + const enum InsertFlags nInsertMode = INS_EMPTYEXPAND ); virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const String& rGrfName, const String& rFltName, const Graphic* pGraphic, const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*); virtual SwFlyFrmFmt* Insert(const SwPaM& rRg, const GraphicObject& rGrfObj, const SfxItemSet* pFlyAttrSet, @@ -904,8 +918,10 @@ public: virtual SwDrawFrmFmt* Insert(const SwPaM &rRg, SdrObject& rDrawObj, const SfxItemSet* pFlyAttrSet, SwFrmFmt*); virtual SwFlyFrmFmt* Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj, const SfxItemSet* pFlyAttrSet, const SfxItemSet* pGrfAttrSet, SwFrmFmt*); - virtual bool Insert(const SwPaM &rRg, const SfxPoolItem&, sal_uInt16 nFlags); - virtual bool Insert(const SwPaM &rRg, const SfxItemSet&, sal_uInt16 nFlags); + virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem&, + const SetAttrMode nFlags); + virtual bool InsertItemSet (const SwPaM &rRg, const SfxItemSet&, + const SetAttrMode nFlags); virtual void ReRead(SwPaM&, const String& rGrfName, const String& rFltName, const Graphic* pGraphic, const GraphicObject* pGrfObj); virtual void TransliterateText(const SwPaM& rPaM, utl::TransliterationWrapper&); virtual SwFlyFrmFmt* InsertOLE(const SwPaM &rRg, const String& rObjName, sal_Int64 nAspect, const SfxItemSet* pFlyAttrSet, @@ -913,7 +929,8 @@ public: virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart); virtual bool AppendTxtNode(SwPosition& rPos); virtual void SetModified(SwPaM &rPaM); - virtual bool Replace(SwPaM& rPam, const String& rNewStr, bool bRegExpRplc); + virtual bool ReplaceRange(SwPaM& rPam, const String& rNewStr, + const bool bRegExReplace); virtual void RemoveLeadingWhiteSpace(const SwPosition & rPos ); /** IDocumentStylePoolAccess @@ -1098,7 +1115,12 @@ public: sal_Bool SetFrmFmtToFly( SwFrmFmt& rFlyFmt, SwFrmFmt& rNewFmt, SfxItemSet* pSet = 0, sal_Bool bKeepOrient = sal_False ); - + // --> OD 2009-07-20 #i73249# + void SetFlyFrmTitle( SwFlyFrmFmt& rFlyFrmFmt, + const String& sNewTitle ); + void SetFlyFrmDescription( SwFlyFrmFmt& rFlyFrmFmt, + const String& sNewDescription ); + // <-- /** Footnotes */ @@ -1364,11 +1386,11 @@ public: // kopiere die Kopzeile (mit dem Inhalt!) aus dem SrcFmt // ins DestFmt ( auch ueber Doc grenzen hinaus!) void CopyHeader( const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ) - { _CopyPageDescHeaderFooter( sal_True, rSrcFmt, rDestFmt ); } + { CopyPageDescHeaderFooterImpl( true, rSrcFmt, rDestFmt ); } // kopiere die Fusszeile (mit dem Inhalt!) aus dem SrcFmt // ins DestFmt ( auch ueber Doc grenzen hinaus!) void CopyFooter( const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ) - { _CopyPageDescHeaderFooter( sal_False, rSrcFmt, rDestFmt ); } + { CopyPageDescHeaderFooterImpl( false, rSrcFmt, rDestFmt ); } //fuer Reader @@ -1400,7 +1422,7 @@ public: // Methoden fuer die Verzeichnisse: // - Verzeichnismarke einfuegen loeschen travel sal_uInt16 GetCurTOXMark( const SwPosition& rPos, SwTOXMarks& ) const; - void Delete( const SwTOXMark* pTOXMark ); + void DeleteTOXMark( const SwTOXMark* pTOXMark ); const SwTOXMark& GotoTOXMark( const SwTOXMark& rCurTOXMark, SwTOXSearch eDir, sal_Bool bInReadOnly ); @@ -1516,13 +1538,16 @@ public: // <-- void SetCounted( const SwPaM&, bool bCounted); - /** - Replace numbering rules in a PaM by another numbering rule. + // --> OD 2009-08-25 #i86492# + // no longer needed. + // SwDoc::SetNumRule( rPaM, rNumRule, false, <ListId>, sal_True, true ) have to be used instead. +// /** +// Replace numbering rules in a PaM by another numbering rule. - \param rPaM PaM to replace the numbering rules in - \param rNumRule numbering rule to replace the present numbering rules - */ - void ReplaceNumRule(const SwPaM & rPaM, const SwNumRule & rNumRule); +// \param rPaM PaM to replace the numbering rules in +// \param rNumRule numbering rule to replace the present numbering rules +// */ +// void ReplaceNumRule(const SwPaM & rPaM, const SwNumRule & rNumRule); void MakeUniqueNumRules(const SwPaM & rPaM); @@ -1582,8 +1607,8 @@ public: - FALSE: search backward \param bNum - TRUE: search for enumeration - FALSE: search for itemize - \param bOutline - TRUE: search for non-outline numbering rule - - FALSE: search for outline numbering rule + \param bOutline - TRUE: search for outline numbering rule + - FALSE: search for non-outline numbering rule \param nNonEmptyAllowed number of non-empty paragraphs allowed between rPos and found paragraph @@ -1595,13 +1620,13 @@ public: input parameter - boolean, indicating, if start node, determined by given start position has to be investigated or not. */ - const SwNumRule * SearchNumRule(SwPosition & rPos, - BOOL bForward, - BOOL bNum, - BOOL bOutline, + const SwNumRule * SearchNumRule(const SwPosition & rPos, + const bool bForward, + const bool bNum, + const bool bOutline, int nNonEmptyAllowed, String& sListId, - bool bInvestigateStartNode = false ); + const bool bInvestigateStartNode = false ); // Absaetze ohne Numerierung, aber mit Einzuegen sal_Bool NoNum( const SwPaM& ); @@ -1773,9 +1798,9 @@ public: inline void SetOle2Link(const Link& rLink) {aOle2Link = rLink;} inline const Link& GetOle2Link() const {return aOle2Link;} - // SS fuer Bereiche - SwSection* Insert( const SwPaM& rRange, const SwSection& rNew, - const SfxItemSet* pAttr = 0, sal_Bool bUpdate = sal_True ); + // insert section (the ODF kind of section, not the nodesarray kind) + SwSection* InsertSwSection( const SwPaM& rRange, const SwSection& rNew, + const SfxItemSet* pAttr = 0, bool bUpdate = true); sal_uInt16 IsInsRegionAvailable( const SwPaM& rRange, const SwNode** ppSttNd = 0 ) const; SwSection* GetCurrSection( const SwPosition& rPos ) const; @@ -2097,6 +2122,7 @@ public: } ::sfx2::IXmlIdRegistry& GetXmlIdRegistry(); + ::sw::MetaFieldManager & GetMetaFieldManager(); SwDoc* CreateCopy() const; }; diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx index b7a1cf300b..62b484809e 100644 --- a/sw/inc/docsh.hxx +++ b/sw/inc/docsh.hxx @@ -151,6 +151,8 @@ public: static SfxInterface *_GetInterface() { return GetStaticInterface(); } + static rtl::OUString GetEventName( sal_Int32 nId ); + //Das Doc wird fuer SO-Datenaustausch benoetigt! SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED, sal_Bool _bScriptingSupport = sal_True ); SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SFX_CREATE_MODE_STANDARD ); diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx index 3340dc6527..e858334fd5 100644 --- a/sw/inc/editsh.hxx +++ b/sw/inc/editsh.hxx @@ -181,7 +181,7 @@ class SW_DLLPUBLIC SwEditShell: public SwCrsrShell public: // Editieren (immer auf allen selektierten Bereichen) void Insert( sal_Unicode, BOOL bOnlyCurrCrsr = FALSE ); - void Insert( const String &); + void Insert2( const String &, const bool bForceExpandHints = false ); void Overwrite( const String & ); // Ersetz einen selektierten Bereich in einem TextNode mit dem @@ -332,7 +332,7 @@ public: { return (SwCharFmt*)SwEditShell::GetFmtFromPool( nId ); } // Felder - void Insert(SwField&); + void Insert2(SwField&, const bool bForceExpandHints = false); SwField* GetCurFld() const; void UpdateFlds( SwField & ); // ein einzelnes Feld @@ -487,8 +487,8 @@ public: // <-- // detect highest and lowest level to check moving of outline levels void GetCurrentOutlineLevels( sal_uInt8& rUpper, sal_uInt8& rLower ); - - + + // get Outline level of current paragraph int GetCurrentParaOutlineLevel( ) const;// #outlinelevel add by zhaojianwei @@ -512,9 +512,9 @@ public: // --> OD 2008-03-18 #refactorlists# - add output parameter <sListId> // in case a list style is found, <sListId> holds the list id, to which the // text node belongs, which applies the found list style. - const SwNumRule * SearchNumRule(BOOL bForward, - BOOL bNum, - BOOL bOutline, + const SwNumRule * SearchNumRule(const bool bForward, + const bool bNum, + const bool bOutline, int nNonEmptyAllowed, String& sListId ); // <-- @@ -622,9 +622,9 @@ public: const Graphic* pGraphic = 0, const GraphicObject* pGrafObj = 0 ); - // alternativen Text einer Grafik/OLe-Objectes abfragen/setzen - const String& GetAlternateText() const; - void SetAlternateText( const String& rTxt ); +// // alternativen Text einer Grafik/OLe-Objectes abfragen/setzen +// const String& GetAlternateText() const; +// void SetAlternateText( const String& rTxt ); //eindeutige Identifikation des Objektes (fuer ImageMapDlg) void *GetIMapInventor() const; @@ -753,7 +753,7 @@ public: ::com::sun::star::linguistic2::XSpellAlternatives > GetCorrection( const Point* pPt, SwRect& rSelectRect ); - + bool GetGrammarCorrection( ::com::sun::star::linguistic2::ProofreadingResult /*out*/ &rResult, sal_Int32 /*out*/ &rErrorPosInText, sal_Int32 /*out*/ &rErrorIndexInResult, diff --git a/sw/inc/fesh.hxx b/sw/inc/fesh.hxx index 5c9014a62e..9673b41855 100644 --- a/sw/inc/fesh.hxx +++ b/sw/inc/fesh.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -353,6 +353,13 @@ public: const Graphic *GetGrfAtPos( const Point &rDocPos, String &rName, BOOL &rbLink ) const; + // --> OD 2009-07-13 #i73249# + const String GetObjTitle() const; + void SetObjTitle( const String& rTitle ); + const String GetObjDescription() const; + void SetObjDescription( const String& rDescription ); + // <-- + //SS fuer Rahmen -------------------------------------------- BOOL IsFrmSelected() const; diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx index 67dfb2df44..7edbb77a0f 100644 --- a/sw/inc/fmtfld.hxx +++ b/sw/inc/fmtfld.hxx @@ -39,6 +39,7 @@ class SwField; class SwTxtFld; +class SwView; // ATT_FLD *********************************** class SW_DLLPUBLIC SwFmtFld : public SfxPoolItem, public SwClient, public SfxBroadcaster @@ -103,16 +104,19 @@ class SW_DLLPUBLIC SwFmtFldHint : public SfxHint const SwFmtFld* pFld; sal_Int16 nWhich; + const SwView* pView; public: - SwFmtFldHint( const SwFmtFld* p, sal_Int16 n ) + SwFmtFldHint( const SwFmtFld* p, sal_Int16 n, const SwView* pV = 0) : pFld(p) , nWhich(n) + , pView(pV) {} TYPEINFO(); const SwFmtFld* GetField() const { return pFld; } sal_Int16 Which() const { return nWhich; } + const SwView* GetView() const { return pView; } }; #endif diff --git a/sw/inc/fmthbsh.hxx b/sw/inc/fmthbsh.hxx deleted file mode 100644 index d06c24cd71..0000000000 --- a/sw/inc/fmthbsh.hxx +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: fmthbsh.hxx,v $ - * $Revision: 1.5 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _FMTHBSH_HXX -#define _FMTHBSH_HXX - - -#include <svtools/poolitem.hxx> - -// ATT_SOFTHYPH ****************************** -// Attribut fuer benutzerdefinierte Trennstellen. - -class SwFmtSoftHyph : public SfxPoolItem -{ -public: - SwFmtSoftHyph(); - - // "pure virtual Methoden" vom SfxPoolItem - virtual int operator==( const SfxPoolItem& ) const; - virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; - - inline SwFmtSoftHyph& operator=(const SwFmtSoftHyph&) { - return *this; - } -}; - -// ATT_HARDBLANK ****************************** -// Attribut fuer geschuetzte Leerzeichen. - -class SW_DLLPUBLIC SwFmtHardBlank : public SfxPoolItem -{ - sal_Unicode cChar; -public: - SwFmtHardBlank( sal_Unicode cCh, BOOL bCheck = TRUE ); - - // "pure virtual Methoden" vom SfxPoolItem - virtual int operator==( const SfxPoolItem& ) const; - virtual SfxPoolItem* Clone( SfxItemPool* pPool = 0 ) const; - - - inline sal_Unicode GetChar() const { return cChar; } - inline SwFmtHardBlank& operator=(const SwFmtHardBlank& rHB) - { cChar = rHB.GetChar(); return *this; } -}; - - -#endif - diff --git a/sw/inc/fmtmeta.hxx b/sw/inc/fmtmeta.hxx new file mode 100755 index 0000000000..952181d049 --- /dev/null +++ b/sw/inc/fmtmeta.hxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: fmtmeta.hxx,v $ + * $Revision: 1.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_FMTMETA_HXX +#define SW_FMTMETA_HXX + +#include <svtools/poolitem.hxx> +#include <sfx2/Metadatable.hxx> + +#include <boost/shared_ptr.hpp> +#include <boost/weak_ptr.hpp> + +#include <vector> + + +namespace com { namespace sun { namespace star { + namespace text { + class XTextField; + } +}}} + + +/** + * The classes that make up a meta entity are: + * <dl> + * <dt>SwTxtMeta</dt><dd>the text hint</dd> + * <dt>SwFmtMeta</dt><dd>the pool item</dd> + * <dt>sw::Meta</dt><dd>the metadatable entity itself</dd> + * <dt>SwXMeta</dt><dd>the UNO wrapper object</dd> + * </dl> + * + * The text hint contains the pool item (as usual) and has a pointer to the + * text node at which it is attached. + * The pool item has a shared pointer to the metadatable entity, and a reverse + * pointer to the text attribute at which it is attached. + * The pool item is non-poolable; it may only be attached to one text + * attribute. + * Of all the pool items that refer to a metadatable entity, only one may be + * in the document content at any time. Others may be in the undo array, or in + * undo objects. + * The metadatable entity has a reverse pointer to the pool item that is + * currently in the document. It also registers as a client at the text node + * at which it is attached via this pool item and its text attribute. + * The UNO wrapper object registers as a client at the metadatable entity. + * + * Copying the metadatable entity proceeds in the following way: + * <ol> + * <li>The pool item is cloned (because it is non-poolable); the clone + * points to the same metadatable entity, but the metadatable entity's + * reverse pointer is unchanged.</li> + * <li>A new text hint is created, taking over the new pool item. + * Unfortunately, this also makes the metadatable entity point at the + * cloned pool item.</li> + * <li>The text hint is inserted into the hints array of some text node.</li> + * <li>The DoCopy() method must be called at the new pool item: + * it will clone the metadatable entity (using RegisterAsCopyOf), + * and fix the reverse pointer of the original to point at the + * original pool item. + * This is necessary, because first, a metadatable entity may + * only be inserted once into a document, and second, the copy may be + * inserted into a different document than the source document!</li> + * </ol> + */ + +class SwTxtMeta; +class SwXMeta; +class SwXMetaField; +namespace sw { + class Meta; +} + +class SwFmtMeta + : public SfxPoolItem +{ +private: + friend class SwTxtMeta; // needs SetTxtAttr + friend class ::sw::Meta; // needs m_pTxtAttr + + ::boost::shared_ptr< ::sw::Meta > m_pMeta; + SwTxtMeta * m_pTxtAttr; + + SwTxtMeta * GetTxtAttr() { return m_pTxtAttr; } + void SetTxtAttr(SwTxtMeta * const i_pTxtAttr); + + explicit SwFmtMeta( const USHORT i_nWhich ); + +public: + // takes ownership + explicit SwFmtMeta( ::boost::shared_ptr< ::sw::Meta > const & i_pMeta, + const USHORT i_nWhich ); + virtual ~SwFmtMeta(); + + // SfxPoolItem + virtual int operator==( const SfxPoolItem & ) const; + virtual SfxPoolItem * Clone( SfxItemPool *pPool = 0 ) const; +// TYPEINFO(); + + // notify clients registered at m_pMeta that this meta is being removed + void NotifyRemoval(); + static SwFmtMeta * CreatePoolDefault( const USHORT i_nWhich ); + ::sw::Meta * GetMeta() { return m_pMeta.get(); } + /// this method <em>must</em> be called when the hint is actually copied + void DoCopy( SwFmtMeta & rOriginalMeta ); +}; + + +namespace sw { + +class MetaFieldManager; + +class Meta + : public ::sfx2::Metadatable + , public SwModify +{ +protected: + friend class ::SwFmtMeta; // SetFmtMeta + friend class ::SwXMeta; // GetTxtNode, GetTxtAttr + + SwFmtMeta * m_pFmt; + + SwTxtMeta * GetTxtAttr() const; + SwTxtNode * GetTxtNode() const; // returns 0 if not in document (undo) + + SwFmtMeta * GetFmtMeta() const { return m_pFmt; } + void SetFmtMeta( SwFmtMeta * const i_pFmt ) { m_pFmt = i_pFmt; }; + +public: + explicit Meta(SwFmtMeta * const i_pFmt = 0); + virtual ~Meta(); + + // SwClient + virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + + // sfx2::Metadatable + virtual ::sfx2::IXmlIdRegistry& GetRegistry(); + virtual bool IsInClipboard() const; + virtual bool IsInUndo() const; + virtual bool IsInContent() const; + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > MakeUnoObject(); +}; + +class MetaField + : public Meta +{ +private: + friend class ::SwFmtMeta; + friend class ::SwXMetaField; + friend class ::sw::MetaFieldManager; + + sal_uInt32 m_nNumberFormat; + bool m_bIsFixedLanguage; + + sal_uInt32 GetNumberFormat(::rtl::OUString const & rContent) const; + void SetNumberFormat(sal_uInt32 nNumberFormat); + bool IsFixedLanguage() const { return m_bIsFixedLanguage; } + void SetIsFixedLanguage(bool b) { m_bIsFixedLanguage = b; } + + explicit MetaField(SwFmtMeta * const i_pFmt = 0, + const sal_uInt32 nNumberFormat = SAL_MAX_UINT32, + const bool bIsFixedLanguage = false ); + +public: + /// get prefix/suffix from the RDF repository. @throws RuntimeException + void GetPrefixAndSuffix( + ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix); +}; + +/** knows all meta-fields in the document. */ +class MetaFieldManager + : private ::boost::noncopyable +{ +private: + typedef ::std::vector< ::boost::weak_ptr<MetaField> > MetaFieldList_t; + MetaFieldList_t m_MetaFields; + +public: + MetaFieldManager(); + ::boost::shared_ptr<MetaField> makeMetaField( + SwFmtMeta * const i_pFmt = 0, + const sal_uInt32 nNumberFormat = SAL_MAX_UINT32, + const bool bIsFixedLanguage = false ); + /// get all meta fields + ::std::vector< ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextField> > getMetaFields(); +}; + +} // namespace sw + +#endif // SW_FMTMETA_HXX + diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx index c416d691d7..12ef87e948 100644 --- a/sw/inc/frmfmt.hxx +++ b/sw/inc/frmfmt.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -176,6 +176,15 @@ public: virtual BOOL GetInfo( SfxPoolItem& rInfo ) const; + // --> OD 2009-07-14 #i73249# + const String GetObjTitle() const; + void SetObjTitle( const String& rTitle, + bool bBroadcast = false ); + const String GetObjDescription() const; + void SetObjDescription( const String& rDescription, + bool bBroadcast = false ); + // <-- + /** SwFlyFrmFmt::IsBackgroundTransparent - for #99657# OD 22.08.2002 - overloading virtual method and its default implementation, diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx index c317539e2a..676698b54f 100644 --- a/sw/inc/hintids.hxx +++ b/sw/inc/hintids.hxx @@ -127,8 +127,8 @@ RES_TXTATR_WITHEND_BEGIN = RES_TXTATR_BEGIN , RES_TXTATR_DUMMY5, // 46 RES_TXTATR_CJK_RUBY, // 47 RES_TXTATR_UNKNOWN_CONTAINER, // 48 - RES_TXTATR_DUMMY6, // 49 - RES_TXTATR_DUMMY7, // 50 + RES_TXTATR_META, // 49 + RES_TXTATR_METAFIELD, // 50 RES_TXTATR_WITHEND_END, // alle TextAttribute ohne ein Ende @@ -136,8 +136,8 @@ RES_TXTATR_NOEND_BEGIN = RES_TXTATR_WITHEND_END, RES_TXTATR_FIELD = RES_TXTATR_NOEND_BEGIN, // 51 RES_TXTATR_FLYCNT, // 52 RES_TXTATR_FTN, // 53 - RES_TXTATR_SOFTHYPH, // 54 - RES_TXTATR_HARDBLANK, // 55 + RES_TXTATR_DUMMY4, // 54 + RES_TXTATR_DUMMY3, // 55 RES_TXTATR_DUMMY1, // 56 RES_TXTATR_DUMMY2, // 57 RES_TXTATR_NOEND_END, @@ -337,7 +337,8 @@ RES_MSG_BEGIN = RES_FMT_END, RES_GRAPHIC_SWAPIN, RES_FIELD_DELETED, RES_NAME_CHANGED, - RES_ALT_TEXT_CHANGED, + RES_TITLE_CHANGED, + RES_DESCRIPTION_CHANGED, RES_UNOCURSOR_LEAVES_SECTION, RES_LINKED_GRAPHIC_STREAM_ARRIVED, RES_MSG_END diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx index a0274c1cb7..755f3694f1 100644 --- a/sw/inc/index.hxx +++ b/sw/inc/index.hxx @@ -132,8 +132,8 @@ class SwIndexReg static SwIndexReg* pEmptyIndexArray; protected: - virtual void Update( const SwIndex & aPos, xub_StrLen nLen, - BOOL bNegativ = FALSE, BOOL bDelete = FALSE ); + virtual void Update( SwIndex const & rPos, const xub_StrLen nChangeLen, + const bool bNegative = false, const bool bDelete = false ); void ChkArr(); diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index dec387d29d..d479fc9e78 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -180,7 +180,7 @@ public: BOOL _MoveNodes( const SwNodeRange&, SwNodes& rNodes, const SwNodeIndex&, BOOL bNewFrms = TRUE ); - void Move( SwPaM&, SwPosition&, SwNodes& rNodes, BOOL bSplitNd=TRUE ); + void MoveRange( SwPaM&, SwPosition&, SwNodes& rNodes ); void _Copy( const SwNodeRange& rRg, const SwNodeIndex& rInsPos, BOOL bNewFrms = TRUE ) const diff --git a/sw/inc/ndhints.hxx b/sw/inc/ndhints.hxx index 851cff58c5..620d8a0c2f 100644 --- a/sw/inc/ndhints.hxx +++ b/sw/inc/ndhints.hxx @@ -34,11 +34,30 @@ #include <svtools/svarray.hxx> #include <tools/mempool.hxx> +#include "swtypes.hxx" + //#include "numrule.hxx" class SwTxtNode; class SwRegHistory; // steht im RolBck.hxx class SwTxtAttr; +class SwTxtAttrNesting; + +class SfxPoolItem; +class SfxItemSet; +class SwDoc; + +SW_DLLPRIVATE SwTxtAttr * +MakeTxtAttr( SwDoc & rDoc, SfxPoolItem & rNew, + xub_StrLen nStt, xub_StrLen nEnd ); +SW_DLLPRIVATE SwTxtAttr * +MakeTxtAttr( SwDoc & rDoc, const SfxItemSet & rSet, + xub_StrLen nStt, xub_StrLen nEnd ); + +// create redline dummy text hint that must not be inserted into hints array +SW_DLLPRIVATE SwTxtAttr* +MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr ); + /* * Ableitung der Klasse SwpHints ueber den Umweg ueber SwpHts, da @@ -148,7 +167,10 @@ private: return m_bHasHiddenParaField; } - void BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMode ); + void InsertNesting(SwTxtAttrNesting & rNewHint); + bool TryInsertNesting(SwTxtNode & rNode, SwTxtAttrNesting & rNewHint); + void BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, + const SetAttrMode nMode ); bool MergePortions( SwTxtNode& rNode ); public: @@ -162,7 +184,10 @@ public: void DeRegister() { Register(0); } SwRegHistory* GetHistory() const { return m_pHistory; } - void Insert( SwTxtAttr* pHt, SwTxtNode &rNode, USHORT nMode = 0 ); + /// try to insert the hint + /// @return true iff hint successfully inserted + bool TryInsertHint( SwTxtAttr * const pHint, SwTxtNode & rNode, + const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); inline bool HasFtn() const { return m_bFootnote; } inline bool IsInSplitNode() const { return m_bInSplitNode; } diff --git a/sw/inc/ndnotxt.hxx b/sw/inc/ndnotxt.hxx index bdb8b8d6a4..4097627f91 100644 --- a/sw/inc/ndnotxt.hxx +++ b/sw/inc/ndnotxt.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -43,7 +43,7 @@ class SW_DLLPUBLIC SwNoTxtNode : public SwCntntNode friend class SwNodes; friend class SwNoTxtFrm; - String aAlternateText; // alternativer Text (HTML) +// String aAlternateText; // alternativer Text (HTML) PolyPolygon *pContour; // Polygon fuer Konturumlauf BOOL bAutomaticContour : 1; // automatic contour polygon, not manipulated @@ -75,19 +75,26 @@ public: virtual BOOL SavePersistentData(); virtual BOOL RestorePersistentData(); - // alternativen Text abfragen/setzen - const String& GetAlternateText() const { return aAlternateText; } - void SetAlternateText( const String& rTxt, sal_Bool bBroadcast=sal_False ); + const String GetTitle() const; + void SetTitle( const String& rTitle, + bool bBroadcast = false ); + const String GetDescription() const; + void SetDescription( const String& rDescription, + bool bBroadcast = false ); + +// const String GetAlternateText() const; +// void SetAlternateText( const String& rTxt, +// sal_Bool bBroadcast=sal_False ); void SetContour( const PolyPolygon *pPoly, BOOL bAutomatic = FALSE ); const PolyPolygon *HasContour() const; - BOOL _HasContour() const { return pContour!=0; }; + BOOL _HasContour() const { return pContour!=0; }; void GetContour( PolyPolygon &rPoly ) const; void CreateContour(); void SetAutomaticContour( BOOL bSet ) { bAutomaticContour = bSet; } - BOOL HasAutomaticContour() const { return bAutomaticContour; } + BOOL HasAutomaticContour() const { return bAutomaticContour; } // set either a MM100 or pixel contour void SetContourAPI( const PolyPolygon *pPoly ); @@ -96,9 +103,9 @@ public: BOOL GetContourAPI( PolyPolygon &rPoly ) const; void SetPixelContour( BOOL bSet ) { bPixelContour = bSet; } - BOOL IsPixelContour() const; + BOOL IsPixelContour() const; - BOOL IsContourMapModeValid() const { return bContourMapModeValid; } + BOOL IsContourMapModeValid() const { return bContourMapModeValid; } //Besorgt die Graphic, mit SwapIn fuer GrfNode, per GetData fuer OLE. Graphic GetGraphic() const; diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx index 490062c02f..37aa87b202 100644 --- a/sw/inc/ndtxt.hxx +++ b/sw/inc/ndtxt.hxx @@ -38,6 +38,7 @@ #include <errhdl.hxx> #include <modeltoviewhelper.hxx> #include <SwNumberTreeTypes.hxx> +#include <IDocumentContentOperations.hxx> #include <sfx2/Metadatable.hxx> @@ -75,11 +76,6 @@ class SwScriptInfo; struct SwDocStat; struct SwParaIdleData_Impl; -// Konstanten fuer das Text-Insert: -#define INS_DEFAULT 0x0000 // keine Extras -#define INS_EMPTYEXPAND 0x0001 // leere Hints beim Einfuegen aufspannen -#define INS_NOHINTEXPAND 0x0002 // Hints an der InsPos nicht aufspannen - namespace com { namespace sun { namespace star { namespace uno { template < class > class Sequence; }}}} @@ -97,8 +93,6 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable friend class SwNodes; friend class SwTxtFrm; friend class SwScriptInfo; - friend void SwpHints::Insert( SwTxtAttr*, SwTxtNode&, USHORT ); - friend void SwpHints::BuildPortions( SwTxtNode&, SwTxtAttr&, USHORT ); //Kann 0 sein, nur dann nicht 0 wenn harte Attribute drin stehen. //Also niemals direkt zugreifen! @@ -148,11 +142,10 @@ class SW_DLLPUBLIC SwTxtNode: public SwCntntNode, public ::sfx2::Metadatable SW_DLLPRIVATE SwTxtNode* _MakeNewTxtNode( const SwNodeIndex&, BOOL bNext = TRUE, BOOL bChgFollow = TRUE ); - SW_DLLPRIVATE void _Cut( SwTxtNode *pDest, const SwIndex &rDestStart, - const SwIndex &rStart, xub_StrLen nLen, BOOL bUpdate = TRUE ); - - SW_DLLPRIVATE SwTxtAttr* MakeTxtAttr( const SfxPoolItem& rNew, xub_StrLen nStt, xub_StrLen nEnd, bool bRedlineAttr = false ); - SW_DLLPRIVATE SwTxtAttr* MakeTxtAttr( const SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd ); + SW_DLLPRIVATE void CutImpl( + SwTxtNode * const pDest, const SwIndex & rDestStart, + const SwIndex & rStart, /*const*/ xub_StrLen nLen, + const bool bUpdate = true ); // Verlagere alles umfassende harte Attribute in den AttrSet des Absatzes SW_DLLPRIVATE void MoveTxtAttr_To_AttrSet(); // wird von SplitNode gerufen. @@ -258,21 +251,30 @@ public: virtual USHORT ResetAllAttr(); // <-- - /* - * Einfuegen anderer Datentypen durch Erzeugen eines - * temporaeren Strings. - */ - SwTxtNode& Insert( xub_Unicode c, const SwIndex &rIdx ); - SwTxtNode& Insert( const XubString &rStr, const SwIndex &rIdx, - const USHORT nMode = INS_DEFAULT ); - - SwTxtNode& Erase( const SwIndex &rIdx, xub_StrLen nCount = STRING_LEN, - const USHORT nMode = INS_DEFAULT ); + /// insert text content + void InsertText( const XubString & rStr, const SwIndex & rIdx, + const enum IDocumentContentOperations::InsertFlags nMode + = IDocumentContentOperations::INS_DEFAULT ); - // Aktionen auf Attributen - // loesche alle TextAttribute die als Attribut im Set vorhanden sind - // (Set-Pointer != 0 ) oder alle deren Which-Wert mit nWhich mappen - // oder wenn Which = 0, alle. + /** delete text content + ATTENTION: must not be called with a range that overlaps the start of + an attribute with both extent and dummy char + */ + void EraseText ( const SwIndex &rIdx, const xub_StrLen nCount = STRING_LEN, + const enum IDocumentContentOperations::InsertFlags nMode + = IDocumentContentOperations::INS_DEFAULT ); + + /** delete all attributes. + If neither pSet nor nWhich is given, delete all attributes (except + refmarks, toxmarks, meta) in range. + @param rIdx start position + @param nLen range in which attributes will be deleted + @param pSet if not 0, delete only attributes contained in pSet + @param nWhich if not 0, delete only attributes with matching which + @param bInclRefToxMark + refmarks, toxmarks, and metas will be ignored unless this is true + ATTENTION: setting bInclRefToxMark is only allowed from UNDO! + */ void RstAttr( const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich = 0, const SfxItemSet* pSet = 0, BOOL bInclRefToxMark = FALSE ); void GCAttr(); @@ -283,17 +285,20 @@ public: // loesche alle Attribute aus dem SwpHintsArray. void ClearSwpHintsArr( bool bDelFields ); - // Insert pAttr into hints array. - BOOL Insert( SwTxtAttr *pAttr, USHORT nMode = 0 ); - // lege ein neues TextAttribut an und fuege es ins SwpHints-Array ein - // returne den neuen Pointer (oder 0 bei Fehlern)! - SwTxtAttr* InsertItem( const SfxPoolItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnd, USHORT nMode = 0 ); + /// Insert pAttr into hints array. @return true iff inserted successfully + bool InsertHint( SwTxtAttr * const pAttr, + const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); + /// create new text attribute from rAttr and insert it + /// @return inserted hint; 0 if not sure the hint is inserted + SwTxtAttr* InsertItem( SfxPoolItem& rAttr, + const xub_StrLen nStart, const xub_StrLen nEnd, + const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); // setze diese Attribute am TextNode. Wird der gesamte Bereich umspannt, // dann setze sie nur im AutoAttrSet (SwCntntNode:: SetAttr) BOOL SetAttr( const SfxItemSet& rSet, - xub_StrLen nStt, xub_StrLen nEnd, USHORT nMode = 0 ); + xub_StrLen nStt, xub_StrLen nEnd, + const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT ); // erfrage die Attribute vom TextNode ueber den Bereich // --> OD 2008-01-16 #newlistlevelattrs# // Introduce 4th optional parameter <bMergeIndentValuesOfNumRule>. @@ -311,32 +316,34 @@ public: // uebertrage Attribute eines AttrSets ( AutoFmt ) in das SwpHintsArray void FmtToTxtAttr( SwTxtNode* pNd ); - // loeschen eines einzelnen Attributes (fuer SwUndoAttr) - // ( nur das Attribut loeschen, dass mit Which,Start und End oder - // mit pTxtHint identisch ist (es gibt nur ein gueltiges)) - // AUSNAHME: ToxMarks !!! - void Delete( USHORT nTxtWhich, xub_StrLen nStart, xub_StrLen nEnd = 0 ); - void Delete( SwTxtAttr * pTxtAttr, BOOL bThisOnly = FALSE ); + /// delete all attributes of type nWhich at nStart (opt. end nEnd) + void DeleteAttributes( const USHORT nWhich, + const xub_StrLen nStart, const xub_StrLen nEnd = 0 ); + /// delete the attribute pTxtAttr + void DeleteAttribute ( SwTxtAttr * const pTxtAttr ); // Aktionen auf Text und Attributen // --> OD 2008-11-18 #i96213# // introduce optional parameter to control, if all attributes have to be copied. - void Copy( SwTxtNode *pDest, + void CopyText( SwTxtNode * const pDest, const SwIndex &rStart, - USHORT nLen, + const xub_StrLen nLen, const bool bForceCopyOfAllAttrs = false ); - void Copy( SwTxtNode *pDest, + void CopyText( SwTxtNode * const pDest, const SwIndex &rDestStart, const SwIndex &rStart, xub_StrLen nLen, const bool bForceCopyOfAllAttrs = false ); // <-- - void Cut(SwTxtNode *pDest, const SwIndex &rStart, xub_StrLen nLen); - inline void Cut(SwTxtNode *pDest, const SwIndex &rDestStart, - const SwIndex &rStart, xub_StrLen nLen); - // ersetze im String an Position nIdx das Zeichen - void Replace( const SwIndex& rStart, xub_Unicode cCh ); - void Replace( const SwIndex& rStart, xub_StrLen nLen, const XubString& rText ); + + void CutText(SwTxtNode * const pDest, + const SwIndex & rStart, const xub_StrLen nLen); + inline void CutText(SwTxtNode * const pDest, const SwIndex &rDestStart, + const SwIndex & rStart, const xub_StrLen nLen); + + /// replace nDelLen characters at rStart with rText + void ReplaceText( const SwIndex& rStart, const xub_StrLen nDelLen, + const XubString& rText ); void ReplaceTextOnly( xub_StrLen nPos, xub_StrLen nLen, const XubString& rText, const ::com::sun::star::uno::Sequence<sal_Int32>& rOffsets ); @@ -355,18 +362,21 @@ public: // gebe das vorgegebene Attribut, welches an der TextPosition (rIdx) // gesetzt ist zurueck. Gibt es keines, returne 0-Pointer // gesetzt heisst: Start <= rIdx < End + // FIXME: this function does not seem to be well-defined for those + // hints of which several may cover a single position, like TOXMark, + // or CharFmt SwTxtAttr *GetTxtAttr( const SwIndex& rIdx, USHORT nWhichHt, BOOL bExpand = FALSE ) const; - // Diese Methode liefert nur Textattribute auf der Position nIdx - // zurueck, die kein EndIdx besitzen und denselben Which besitzen. - // Ueblicherweise steht an dieser Position ein CH_TXTATR. - // Bei RES_TXTATR_END entfaellt die Pruefung auf den Which-Wert. - SwTxtAttr *GetTxtAttr( const xub_StrLen nIdx, - const USHORT nWhichHt = RES_TXTATR_END ) const; - - SwTxtFld *GetTxtFld( const SwIndex& rIdx ) - { return (SwTxtFld *)GetTxtAttr( rIdx, RES_TXTATR_FIELD ); } + /** get the text attribute at position nIndex which owns + the dummy character CH_TXTATR_* at that position, if one exists. + @param nIndex the position in the text + @param nWhich if different from RES_TXTATR_END, return only + attribute with given which id + @return the text attribute at nIndex of type nWhich, if it exists + */ + SwTxtAttr *GetTxtAttrForCharAt( const xub_StrLen nIndex, + const RES_TXTATR nWhich = RES_TXTATR_END ) const; // Aktuelles Wort zurueckliefern XubString GetCurWord(xub_StrLen) const; @@ -754,17 +764,14 @@ public: bool IsHidden() const; // <-- - inline SwTxtAttr* MakeRedlineTxtAttr( const SfxPoolItem& rNew ) - { return MakeTxtAttr( rNew, 0, 0, true ); } - TYPEINFO(); // fuer rtti // fuers Umhaengen der TxtFmtCollections (Outline-Nummerierung!!) virtual void Modify( SfxPoolItem*, SfxPoolItem* ); - // aus SwIndexReg - virtual void Update( const SwIndex & aPos, USHORT xub_StrLen, - BOOL bNegativ = FALSE, BOOL bDelete = FALSE ); + // override SwIndexReg + virtual void Update( SwIndex const & rPos, const xub_StrLen nChangeLen, + const bool bNegative = false, const bool bDelete = false ); // change text to Upper/Lower/Hiragana/Katagana/... void TransliterateText( utl::TransliterationWrapper& rTrans, @@ -774,16 +781,6 @@ public: // count words in given range void CountWords( SwDocStat& rStat, xub_StrLen nStart, xub_StrLen nEnd ) const; - // #111840# - /** - Returns position of certain text attribute. - - @param pAttr text attribute to search - - @return position of given attribute or NULL in case of failure - */ - SwPosition * GetPosition(const SwTxtAttr * pAttr); - // Checks some global conditions like loading or destruction of document // to economize notifications bool IsNotificationEnabled() const; @@ -875,11 +872,11 @@ inline const SwTxtNode *SwNode::GetTxtNode() const } #endif -inline void SwTxtNode::Cut(SwTxtNode *pDest, const SwIndex &rDestStart, - const SwIndex &rStart, xub_StrLen nLen) +inline void +SwTxtNode::CutText(SwTxtNode * const pDest, const SwIndex & rDestStart, + const SwIndex & rStart, const xub_StrLen nLen) { - _Cut( pDest, rDestStart, rStart, nLen, TRUE ); + CutImpl( pDest, rDestStart, rStart, nLen, true ); } - #endif diff --git a/sw/inc/pch/precompiled_sw.hxx b/sw/inc/pch/precompiled_sw.hxx index 299643b56a..52988f293d 100644 --- a/sw/inc/pch/precompiled_sw.hxx +++ b/sw/inc/pch/precompiled_sw.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -626,7 +626,6 @@ #include "svtools/ctloptions.hxx" #include "svtools/ctrlbox.hxx" #include "svtools/ctrltool.hxx" -#include "svtools/docpasswdrequest.hxx" #include "svtools/editbrowsebox.hxx" #include "svtools/ehdl.hxx" #include "svtools/eitem.hxx" diff --git a/sw/inc/postit.hxx b/sw/inc/postit.hxx index 37584791c7..ddc75cc6e6 100644 --- a/sw/inc/postit.hxx +++ b/sw/inc/postit.hxx @@ -181,8 +181,6 @@ class PostItTxt : public Window virtual void DataChanged( const DataChangedEvent& aData); virtual void LoseFocus(); virtual void RequestHelp(const HelpEvent &rEvt); - - // reconversion /*i94374*/ virtual XubString GetSurroundingText() const; virtual Selection GetSurroundingTextSelection() const; @@ -229,6 +227,7 @@ class SwMarginWin : public Window long mPageBorder; SwPostItBits nFlags; bool mbMouseOverButton; + protected: bool mbReadonly; PopupMenu* mpButtonPopup; @@ -241,7 +240,8 @@ class SwMarginWin : public Window virtual void Paint( const Rectangle& rRect); virtual void GetFocus(); - void SetSizePixel( const Size& rNewSize ); + void SetSizePixel( const Size& rNewSize ); + SfxItemSet DefaultItem(); DECL_LINK(ModifyHdl, void*); DECL_LINK(ScrollHdl, ScrollBar*); @@ -289,8 +289,8 @@ class SwMarginWin : public Window void ExecuteCommand(USHORT nSlot); void InitControls(); - void HidePostIt(); - void DoResize(); + void HidePostIt(); + void DoResize(); void ResizeIfNeccessary(long aOldHeight, long aNewHeight); void SetScrollbar(); diff --git a/sw/inc/printdata.hxx b/sw/inc/printdata.hxx index 474b95aa92..4b31dd6cd6 100644 --- a/sw/inc/printdata.hxx +++ b/sw/inc/printdata.hxx @@ -284,6 +284,7 @@ public: void SetPrintEmptyPages(sal_Bool b ) { doSetModified(); bPrintEmptyPages = b;} void SetPrintPostIts ( sal_Int16 n){ doSetModified(); nPrintPostIts = n; } void SetPrintProspect ( sal_Bool b ) { doSetModified(); bPrintProspect = b; } + void SetPrintProspect_RTL ( sal_Bool b ) { doSetModified(); bPrintProspect_RTL = b; } void SetPrintPageBackground(sal_Bool b){ doSetModified(); bPrintPageBackground = b;} void SetPrintBlackFont(sal_Bool b){ doSetModified(); bPrintBlackFont = b;} void SetPrintSingleJobs(sal_Bool b){ doSetModified(); bPrintSingleJobs = b;} @@ -297,4 +298,3 @@ public: //////////////////////////////////////////////////////////// #endif //_SW_PRINTDATA_HXX - diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx index f3d714e94f..0e3c4670c4 100644 --- a/sw/inc/redline.hxx +++ b/sw/inc/redline.hxx @@ -42,6 +42,7 @@ #include <svtools/smplhint.hxx> class SfxItemSet; +class SwView; class SwRedlineExtraData { @@ -297,16 +298,19 @@ class SW_DLLPUBLIC SwRedlineHint : public SfxHint const SwRedline* pRedline; sal_Int16 nWhich; + const SwView* pView; public: - SwRedlineHint( const SwRedline* p, sal_Int16 n ) + SwRedlineHint( const SwRedline* p, sal_Int16 n, const SwView* pV = 0) : pRedline(p) , nWhich(n) - {} + , pView(pV) + {} TYPEINFO(); const SwRedline* GetRedline() const { return pRedline; } sal_Int16 Which() const { return nWhich; } + const SwView* GetView() const { return pView; } }; diff --git a/sw/inc/rolbck.hxx b/sw/inc/rolbck.hxx index 2178c0056c..3fb23fc2e4 100644 --- a/sw/inc/rolbck.hxx +++ b/sw/inc/rolbck.hxx @@ -40,6 +40,10 @@ //Nur die History anziehen, um das docnew.cxx gegen die CLOOK's zu behaupten. +namespace sfx2 { + class MetadatableUndo; +} + class SwDoc; class SwFmt; class SwFmtColl; @@ -164,7 +168,7 @@ class SwHistorySetTxtFld : public SwHistoryHint //!! If they get destroyed in the wrong order sw may crash (namely mail-merge as well) ::std::auto_ptr<SwFieldType> m_pFldType; const ::std::auto_ptr<SwFmtFld> m_pFld; - + ULONG m_nNodeIndex; xub_StrLen m_nPos; USHORT m_nFldWhich; @@ -298,6 +302,7 @@ class SwHistoryBookmark : public SwHistoryHint const bool m_bSaveOtherPos; const bool m_bHadOtherPos; const IDocumentMarkAccess::MarkType m_eBkmkType; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo; }; class SwHistorySetAttrSet : public SwHistoryHint @@ -449,13 +454,16 @@ public: // --> OD 2008-02-27 #refactorlists# - removed <rDoc> SwRegHistory( SwHistory* pHst ); // <-- - SwRegHistory( SwTxtNode* pTxtNode, const SfxItemSet& rSet, - xub_StrLen nStart, xub_StrLen nEnd, USHORT nFlags, - SwHistory* pHst ); SwRegHistory( const SwNode& rNd, SwHistory* pHst ); SwRegHistory( SwModify* pRegIn, const SwNode& rNd, SwHistory* pHst ); virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ); + + /// @return true iff at least 1 item was inserted + bool InsertItems( const SfxItemSet& rSet, + xub_StrLen const nStart, xub_StrLen const nEnd, + SetAttrMode const nFlags ); + void AddHint( SwTxtAttr* pHt, const bool bNew = false ); void RegisterInModify( SwModify* pRegIn, const SwNode& rNd ); diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index f7ea343ca0..4d883e8464 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -128,7 +128,7 @@ public: const String& GetName() const { return sSectionNm; } void SetName( const String& rName ) { sSectionNm = rName; } - SectionType GetType() const { return eType; } + SectionType GetType() const { return eType; } void SetType( SectionType eNew ) { eType = eNew; } SwSectionFmt* GetFmt() { return (SwSectionFmt*)pRegisteredIn; } diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index 22c22a3285..d1ffa05e95 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -514,8 +514,8 @@ public: SvPtrarr& rArr ); // lege einen neuen PaM an der Position an - SwPaM* NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, - BOOL bNodesArray = TRUE ) const; + static SwPaM* NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, + BOOL bNodesArray = TRUE ); // kopiere ggfs. eine lokale Datei ins Internet BOOL CopyLocalFileToINet( String& rFileNm ); diff --git a/sw/inc/swcalwrp.hxx b/sw/inc/swcalwrp.hxx index b3449970ca..8935008998 100644 --- a/sw/inc/swcalwrp.hxx +++ b/sw/inc/swcalwrp.hxx @@ -34,6 +34,7 @@ #include <i18npool/lang.h> #include <tools/string.hxx> #include <unotools/calendarwrapper.hxx> +#include <salhelper/singletonref.hxx> class SwCalendarWrapper : public CalendarWrapper { @@ -42,7 +43,7 @@ class SwCalendarWrapper : public CalendarWrapper public: SwCalendarWrapper( const ::com::sun::star::uno::Reference< - ::com::sun::star::lang::XMultiServiceFactory > & xMSF ) + ::com::sun::star::lang::XMultiServiceFactory > & xMSF = ::comphelper::getProcessServiceFactory() ) : CalendarWrapper( xMSF ), nLang( LANGUAGE_SYSTEM ) {} @@ -50,7 +51,7 @@ public: }; -extern SwCalendarWrapper* pCalendarWrapper; +salhelper::SingletonRef<SwCalendarWrapper>* s_getCalendarWrapper(); #endif diff --git a/sw/inc/swevent.hxx b/sw/inc/swevent.hxx index 6020633ea0..ad6bee69dd 100644 --- a/sw/inc/swevent.hxx +++ b/sw/inc/swevent.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -50,6 +50,20 @@ #define SW_EVENT_FIELD_MERGE_FINISHED ( EVENT_APP_START + 11 ) #define SW_EVENT_LAYOUT_FINISHED ( EVENT_APP_START + 12 ) +#define STR_SW_EVENT_PAGE_COUNT 0 +#define STR_SW_EVENT_MAIL_MERGE 1 +#define STR_SW_EVENT_MAIL_MERGE_END 2 +#define STR_SW_EVENT_FIELD_MERGE 3 +#define STR_SW_EVENT_FIELD_MERGE_FINISHED 4 +#define STR_SW_EVENT_LAYOUT_FINISHED 5 +#define STR_SW_EVENT_OBJECT_SELECT 6 +#define STR_SW_EVENT_START_INS_GLOSSARY 7 +#define STR_SW_EVENT_END_INS_GLOSSARY 8 +#define STR_SW_EVENT_FRM_KEYINPUT_ALPHA 9 +#define STR_SW_EVENT_FRM_KEYINPUT_NOALPHA 10 +#define STR_SW_EVENT_FRM_RESIZE 11 +#define STR_SW_EVENT_FRM_MOVE 12 + class SwFrmFmt; class SwFmtINetFmt; class IMapObject; diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index 63a3f5c2a7..7bc90a4e76 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -229,6 +229,8 @@ namespace nsSetAttrMode const SetAttrMode SETATTR_DONTCHGNUMRULE = 0x0020; // nicht die NumRule veraendern const SetAttrMode SETATTR_APICALL = 0x0040; // called from API (all UI related // functionality will be disabled) + /// force hint expand (only matters for hints with CH_TXTATR) + const SetAttrMode SETATTR_FORCEHINTEXPAND= 0x0080; } //Umrechnung Twip<-> 1/100 mm fuer UNO @@ -259,7 +261,6 @@ namespace nsSetAttrMode // returns the APP - CharClass instance - used for all ToUpper/ToLower/... SW_DLLPUBLIC CharClass& GetAppCharClass(); -SW_DLLPUBLIC LocaleDataWrapper& GetAppLocaleData(); SW_DLLPUBLIC LanguageType GetAppLanguage(); diff --git a/sw/inc/swundo.hxx b/sw/inc/swundo.hxx index b32c9dd0fb..51eea3343d 100644 --- a/sw/inc/swundo.hxx +++ b/sw/inc/swundo.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -156,7 +156,11 @@ enum SwUndoId UNDO_ROW_DELETE, // 109 UNDO_RENAME_PAGEDESC, // 110 UNDO_NUMDOWN, // 111 - UNDO_STD_END= UNDO_NUMDOWN, + // --> OD 2009-07-16 #i73249# + UNDO_FLYFRMFMT_TITLE, // 112 + UNDO_FLYFRMFMT_DESCRIPTION, // 113 + // <-- + UNDO_STD_END= UNDO_FLYFRMFMT_DESCRIPTION, // UI undo ID's... UNDO_UI_REPLACE = UNDO_STD_END + 1, diff --git a/sw/inc/txatbase.hxx b/sw/inc/txatbase.hxx index 503812085c..da08842e02 100644 --- a/sw/inc/txatbase.hxx +++ b/sw/inc/txatbase.hxx @@ -39,76 +39,51 @@ class SfxItemPool; -class SvxBrushItem; -class SvxFontItem; -class SvxPostureItem; -class SvxWeightItem; -class SvxUnderlineItem; -class SvxOverlineItem; -class SvxFontHeightItem; -class SvxPropSizeItem; -class SvxShadowedItem; -class SvxAutoKernItem; -class SvxWordLineModeItem; -class SvxContourItem; -class SvxCrossedOutItem; -class SvxColorItem; -class SvxCharSetColorItem; class SvXMLAttrContainerItem; class SwFmtRuby; -class SvxTwoLinesItem; -class SvxEmphasisMarkItem; -class SvxCharScaleWidthItem; -class SvxCharRotateItem; -class SvxCharReliefItem; -class SvxCharHiddenItem; - class SwFmtCharFmt; class SwFmtAutoFmt; class SwFmtINetFmt; -class SvxKerningItem; -class SvxCaseMapItem; -class SvxLanguageItem; -class SvxEscapementItem; -class SvxBlinkItem; -class SvxNoHyphenItem; -class SwFmtSoftHyph; -class SwFmtHardBlank; class SwFmtFld; class SwFmtFtn; class SwFmtFlyCnt; class SwTOXMark; class SwFmtRefMark; +class SwFmtMeta; + class SwTxtAttr : private boost::noncopyable { - const SfxPoolItem* m_pAttr; +private: + SfxPoolItem * const m_pAttr; xub_StrLen m_nStart; bool m_bDontExpand : 1; bool m_bLockExpandFlag : 1; - bool m_bDontMergeAttr : 1; // refmarks, toxmarks, ruby bool m_bDontMoveAttr : 1; // refmarks, toxmarks bool m_bCharFmtAttr : 1; // charfmt, inet bool m_bOverlapAllowedAttr : 1; // refmarks, toxmarks bool m_bPriorityAttr : 1; // attribute has priority (redlining) bool m_bDontExpandStart : 1; // don't expand start at paragraph start (ruby) + bool m_bNesting : 1; // SwTxtAttrNesting + bool m_bHasDummyChar : 1; // without end + meta protected: - SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStart ); + SwTxtAttr( SfxPoolItem& rAttr, xub_StrLen nStart ); + virtual ~SwTxtAttr(); void SetLockExpandFlag( bool bFlag ) { m_bLockExpandFlag = bFlag; } - void SetDontMergeAttr( bool bFlag ) { m_bDontMergeAttr = bFlag; } void SetDontMoveAttr( bool bFlag ) { m_bDontMoveAttr = bFlag; } void SetCharFmtAttr( bool bFlag ) { m_bCharFmtAttr = bFlag; } void SetOverlapAllowedAttr( bool bFlag ){ m_bOverlapAllowedAttr = bFlag; } void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; } + void SetNesting(const bool bFlag) { m_bNesting = bFlag; } + void SetHasDummyChar(const bool bFlag) { m_bHasDummyChar = bFlag; } public: - virtual ~SwTxtAttr(); - // RemoveFromPool muss immer vorm DTOR Aufruf erfolgen!! - void RemoveFromPool( SfxItemPool& rPool ); + /// destroy instance + static void Destroy( SwTxtAttr * pToDestroy, SfxItemPool& rPool ); /// start position xub_StrLen* GetStart() { return & m_nStart; } @@ -123,44 +98,23 @@ public: inline void SetDontExpand( bool bDontExpand ); bool DontExpand() const { return m_bDontExpand; } bool IsLockExpandFlag() const { return m_bLockExpandFlag; } - bool IsDontMergeAttr() const { return m_bDontMergeAttr; } bool IsDontMoveAttr() const { return m_bDontMoveAttr; } bool IsCharFmtAttr() const { return m_bCharFmtAttr; } bool IsOverlapAllowedAttr() const { return m_bOverlapAllowedAttr; } bool IsPriorityAttr() const { return m_bPriorityAttr; } void SetPriorityAttr( bool bFlag ) { m_bPriorityAttr = bFlag; } bool IsDontExpandStartAttr() const { return m_bDontExpandStart; } + bool IsNesting() const { return m_bNesting; } + bool HasDummyChar() const { return m_bHasDummyChar; } inline const SfxPoolItem& GetAttr() const; + inline SfxPoolItem& GetAttr(); inline USHORT Which() const { return GetAttr().Which(); } virtual int operator==( const SwTxtAttr& ) const; - inline const SvxFontItem &GetFont() const; - inline const SvxPostureItem &GetPosture() const; - inline const SvxWeightItem &GetWeight() const; - inline const SvxUnderlineItem &GetUnderline() const; - inline const SvxOverlineItem &GetOverline() const; - inline const SvxFontHeightItem &GetFontSize() const; - inline const SvxPropSizeItem &GetPropSize() const; - inline const SvxShadowedItem &GetShadowed() const; - inline const SvxAutoKernItem &GetAutoKern() const; - inline const SvxWordLineModeItem &GetWordLineMode() const; - inline const SvxContourItem &GetContour() const; - inline const SvxCrossedOutItem &GetCrossedOut() const; - inline const SvxColorItem &GetColor() const; - inline const SvxCharSetColorItem &GetCharSetColor() const; inline const SwFmtCharFmt &GetCharFmt() const; inline const SwFmtAutoFmt &GetAutoFmt() const; - inline const SvxKerningItem &GetKerning() const; - inline const SvxCaseMapItem &GetCaseMap() const; - inline const SvxLanguageItem &GetLanguage() const; - inline const SvxEscapementItem &GetEscapement() const; - inline const SvxBlinkItem &GetBlink() const; - inline const SvxBrushItem &GetChrBackground() const; - inline const SvxNoHyphenItem &GetNoHyphenHere() const; - inline const SwFmtSoftHyph &GetSoftHyph() const; - inline const SwFmtHardBlank &GetHardBlank() const; inline const SwFmtFld &GetFld() const; inline const SwFmtFtn &GetFtn() const; inline const SwFmtFlyCnt &GetFlyCnt() const; @@ -169,25 +123,19 @@ public: inline const SwFmtINetFmt &GetINetFmt() const; inline const SvXMLAttrContainerItem &GetXMLAttrContainer() const; inline const SwFmtRuby &GetRuby() const; - inline const SvxTwoLinesItem &Get2Lines() const; - inline const SvxEmphasisMarkItem &GetEmphasisMark() const; - inline const SvxCharScaleWidthItem &GetCharScaleW() const; - inline const SvxCharRotateItem &GetCharRotate() const; - inline const SvxCharReliefItem &GetCharRelief() const; - inline const SvxCharHiddenItem &GetCharHidden() const; + inline const SwFmtMeta &GetMeta() const; }; class SwTxtAttrEnd : public SwTxtAttr { - using SwTxtAttr::GetEnd; - protected: xub_StrLen m_nEnd; public: - SwTxtAttrEnd( const SfxPoolItem& rAttr, USHORT nStart, USHORT nEnd ); + SwTxtAttrEnd( SfxPoolItem& rAttr, USHORT nStart, USHORT nEnd ); + using SwTxtAttr::GetEnd; virtual xub_StrLen* GetEnd(); }; @@ -211,6 +159,12 @@ inline const SfxPoolItem& SwTxtAttr::GetAttr() const return *m_pAttr; } +inline SfxPoolItem& SwTxtAttr::GetAttr() +{ + return const_cast<SfxPoolItem&>( + const_cast<const SwTxtAttr*>(this)->GetAttr()); +} + inline void SwTxtAttr::SetDontExpand( bool bDontExpand ) { if ( !m_bLockExpandFlag ) @@ -219,102 +173,7 @@ inline void SwTxtAttr::SetDontExpand( bool bDontExpand ) } } -inline const SvxFontItem& SwTxtAttr::GetFont() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_FONT, "Wrong attribute" ); - return (const SvxFontItem&)(*m_pAttr); -} - -inline const SvxPostureItem& SwTxtAttr::GetPosture() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_POSTURE, - "Wrong attribute" ); - return (const SvxPostureItem&)(*m_pAttr); -} - -inline const SvxWeightItem& SwTxtAttr::GetWeight() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_WEIGHT, - "Wrong attribute" ); - return (const SvxWeightItem&)(*m_pAttr); -} - -inline const SvxUnderlineItem& SwTxtAttr::GetUnderline() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_UNDERLINE, - "Wrong attribute" ); - return (const SvxUnderlineItem&)(*m_pAttr); -} - -inline const SvxOverlineItem& SwTxtAttr::GetOverline() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_OVERLINE, - "Wrong attribute" ); - return (const SvxOverlineItem&)(*m_pAttr); -} - -inline const SvxFontHeightItem& SwTxtAttr::GetFontSize() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_FONTSIZE, - "Wrong attribute" ); - return (const SvxFontHeightItem&)(*m_pAttr); -} - -inline const SvxPropSizeItem& SwTxtAttr::GetPropSize() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_PROPORTIONALFONTSIZE, - "Wrong attribute" ); - return (const SvxPropSizeItem&)(*m_pAttr); -} - -inline const SvxShadowedItem& SwTxtAttr::GetShadowed() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_SHADOWED, - "Wrong attribute" ); - return (const SvxShadowedItem&)(*m_pAttr); -} - -inline const SvxAutoKernItem& SwTxtAttr::GetAutoKern() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_AUTOKERN, - "Wrong attribute" ); - return (const SvxAutoKernItem&)(*m_pAttr); -} - -inline const SvxWordLineModeItem& SwTxtAttr::GetWordLineMode() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_WORDLINEMODE, - "Wrong attribute" ); - return (const SvxWordLineModeItem&)(*m_pAttr); -} - -inline const SvxContourItem& SwTxtAttr::GetContour() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CONTOUR, - "Wrong attribute" ); - return (const SvxContourItem&)(*m_pAttr); -} - -inline const SvxCrossedOutItem& SwTxtAttr::GetCrossedOut() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CROSSEDOUT, - "Wrong attribute" ); - return (const SvxCrossedOutItem&)(*m_pAttr); -} - -inline const SvxColorItem& SwTxtAttr::GetColor() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_COLOR, - "Wrong attribute" ); - return (const SvxColorItem&)(*m_pAttr); -} - -inline const SvxCharSetColorItem& SwTxtAttr::GetCharSetColor() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CHARSETCOLOR, - "Wrong attribute" ); - return (const SvxCharSetColorItem&)(*m_pAttr); -} +//------------------------------------------------------------------------ inline const SwFmtCharFmt& SwTxtAttr::GetCharFmt() const { @@ -330,69 +189,6 @@ inline const SwFmtAutoFmt& SwTxtAttr::GetAutoFmt() const return (const SwFmtAutoFmt&)(*m_pAttr); } -inline const SvxKerningItem& SwTxtAttr::GetKerning() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_KERNING, - "Wrong attribute" ); - return (const SvxKerningItem&)(*m_pAttr); -} - -inline const SvxCaseMapItem& SwTxtAttr::GetCaseMap() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CASEMAP, - "Wrong attribute" ); - return (const SvxCaseMapItem&)(*m_pAttr); -} - -inline const SvxLanguageItem& SwTxtAttr::GetLanguage() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_LANGUAGE, - "Wrong attribute" ); - return (const SvxLanguageItem&)(*m_pAttr); -} - -inline const SvxEscapementItem& SwTxtAttr::GetEscapement() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_ESCAPEMENT, - "Wrong attribute" ); - return (const SvxEscapementItem&)(*m_pAttr); -} - -inline const SvxBlinkItem& SwTxtAttr::GetBlink() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_BLINK, - "Wrong attribute" ); - return (const SvxBlinkItem&)(*m_pAttr); -} - -inline const SvxBrushItem& SwTxtAttr::GetChrBackground() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_BACKGROUND, - "Wrong attribute" ); - return (const SvxBrushItem&)(*m_pAttr); -} - -inline const SvxNoHyphenItem& SwTxtAttr::GetNoHyphenHere() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_NOHYPHEN, - "Wrong attribute" ); - return (const SvxNoHyphenItem&)(*m_pAttr); -} - -inline const SwFmtSoftHyph& SwTxtAttr::GetSoftHyph() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_SOFTHYPH, - "Wrong attribute" ); - return (const SwFmtSoftHyph&)(*m_pAttr); -} - -inline const SwFmtHardBlank& SwTxtAttr::GetHardBlank() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_HARDBLANK, - "Wrong attribute" ); - return (const SwFmtHardBlank&)(*m_pAttr); -} - inline const SwFmtFld& SwTxtAttr::GetFld() const { ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FIELD, @@ -447,46 +243,13 @@ inline const SwFmtRuby& SwTxtAttr::GetRuby() const "Wrong attribute" ); return (const SwFmtRuby&)(*m_pAttr); } -inline const SvxTwoLinesItem& SwTxtAttr::Get2Lines() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_TWO_LINES, - "Wrong attribute" ); - return (const SvxTwoLinesItem&)(*m_pAttr); -} - -inline const SvxEmphasisMarkItem& SwTxtAttr::GetEmphasisMark() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_EMPHASIS_MARK, - "Wrong attribute" ); - return (const SvxEmphasisMarkItem&)(*m_pAttr); -} - -inline const SvxCharScaleWidthItem& SwTxtAttr::GetCharScaleW() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_SCALEW, - "Wrong attribute" ); - return (const SvxCharScaleWidthItem&)(*m_pAttr); -} - -inline const SvxCharRotateItem& SwTxtAttr::GetCharRotate() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_ROTATE, - "Wrong attribute" ); - return (const SvxCharRotateItem&)(*m_pAttr); -} - -inline const SvxCharReliefItem& SwTxtAttr::GetCharRelief() const -{ - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_RELIEF, - "Wrong attribute" ); - return (const SvxCharReliefItem&)(*m_pAttr); -} -inline const SvxCharHiddenItem& SwTxtAttr::GetCharHidden() const +inline const SwFmtMeta& SwTxtAttr::GetMeta() const { - ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_HIDDEN, + ASSERT( m_pAttr && (m_pAttr->Which() == RES_TXTATR_META || + m_pAttr->Which() == RES_TXTATR_METAFIELD), "Wrong attribute" ); - return (const SvxCharHiddenItem&)(*m_pAttr); + return (const SwFmtMeta&)(*m_pAttr); } #endif diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index c6c8f1da9b..5a36625d52 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -29,14 +29,13 @@ ************************************************************************/ #ifndef _TXTATR_HXX #define _TXTATR_HXX -#include <tools/gen.hxx> -#include <tools/color.hxx> + #include <txatbase.hxx> // SwTxtAttr/SwTxtAttrEnd #include <calbck.hxx> + class SwTxtNode; // fuer SwTxtFld class SwCharFmt; -class SvxTwoLinesItem; // ATT_CHARFMT ********************************************* @@ -60,29 +59,45 @@ public: USHORT GetSortNumber() const { return m_nSortNumber; } }; -// ATT_HARDBLANK ****************************** -class SwTxtHardBlank : public SwTxtAttr -{ - sal_Unicode m_Char; +// ATT_XMLCONTAINERITEM ****************************** +class SwTxtXMLAttrContainer : public SwTxtAttrEnd +{ public: - SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStart ); - inline sal_Unicode GetChar() const { return m_Char; } + SwTxtXMLAttrContainer( SvXMLAttrContainerItem& rAttr, + xub_StrLen nStart, xub_StrLen nEnd ); }; -// ATT_XNLCONTAINERITEM ****************************** +// ****************************** -class SwTxtXMLAttrContainer : public SwTxtAttrEnd +class SwTxtAttrNesting : public SwTxtAttrEnd { public: - SwTxtXMLAttrContainer( const SvXMLAttrContainerItem& rAttr, - xub_StrLen nStart, xub_StrLen nEnd ); + SwTxtAttrNesting( SfxPoolItem & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ); + virtual ~SwTxtAttrNesting(); }; +class SwTxtMeta : public SwTxtAttrNesting +{ +private: + SwTxtNode * m_pTxtNode; + +public: + SwTxtMeta( SwFmtMeta & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ); + virtual ~SwTxtMeta(); + + void ChgTxtNode( SwTxtNode * const pNode ) { m_pTxtNode = pNode; } + SwTxtNode * GetTxtNode() const { return m_pTxtNode; } + +}; + + // ****************************** -class SW_DLLPUBLIC SwTxtRuby : public SwTxtAttrEnd, public SwClient +class SW_DLLPUBLIC SwTxtRuby : public SwTxtAttrNesting, public SwClient { SwTxtNode* m_pTxtNode; @@ -101,16 +116,7 @@ public: SwCharFmt* GetCharFmt(); const SwCharFmt* GetCharFmt() const - { return ((SwTxtRuby*)this)->GetCharFmt(); } -}; - -// ****************************** - -class SwTxt2Lines : public SwTxtAttrEnd -{ -public: - SwTxt2Lines( const SvxTwoLinesItem& rAttr, - xub_StrLen nStart, xub_StrLen nEnd ); + { return (const_cast<SwTxtRuby*>(this))->GetCharFmt(); } }; // --------------- Inline Implementierungen ------------------------ diff --git a/sw/inc/txtfld.hxx b/sw/inc/txtfld.hxx index 130f4eff7c..ec4d399b02 100644 --- a/sw/inc/txtfld.hxx +++ b/sw/inc/txtfld.hxx @@ -64,7 +64,7 @@ public: @return position of this field. Has to be deleted explicitly. */ - SwPosition * GetPosition() const; +// SwPosition * GetPosition() const; }; inline SwTxtNode& SwTxtFld::GetTxtNode() const diff --git a/sw/inc/txtftn.hxx b/sw/inc/txtftn.hxx index 5d9c71b21b..4b247b561a 100644 --- a/sw/inc/txtftn.hxx +++ b/sw/inc/txtftn.hxx @@ -52,7 +52,7 @@ public: inline SwNodeIndex *GetStartNode() const { return m_pStartNode; } void SetStartNode( const SwNodeIndex *pNode, BOOL bDelNodes = TRUE ); void SetNumber( const USHORT nNumber, const String* = 0 ); - void CopyFtn( SwTxtFtn *pDest ); + void CopyFtn( SwTxtFtn *pDest ) const; // get and set TxtNode pointer inline const SwTxtNode& GetTxtNode() const; diff --git a/sw/inc/txtinet.hxx b/sw/inc/txtinet.hxx index 173b41164d..c3597d5b2b 100644 --- a/sw/inc/txtinet.hxx +++ b/sw/inc/txtinet.hxx @@ -31,6 +31,7 @@ #define _TXTINET_HXX #include <txatbase.hxx> +#include <txtatr.hxx> #include <calbck.hxx> class SwTxtNode; @@ -38,7 +39,7 @@ class SwCharFmt; // ATT_INETFMT ********************************************* -class SW_DLLPUBLIC SwTxtINetFmt : public SwTxtAttrEnd, public SwClient +class SW_DLLPUBLIC SwTxtINetFmt : public SwTxtAttrNesting, public SwClient { SwTxtNode * m_pTxtNode; bool m_bVisited : 1; // visited link? diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx index e5acda9b83..f45806e558 100644 --- a/sw/inc/undobj.hxx +++ b/sw/inc/undobj.hxx @@ -49,6 +49,7 @@ #include <swundo.hxx> #include <IMark.hxx> +#include <IDocumentContentOperations.hxx> // --> OD 2006-11-01 #130889# #include <vector> // <-- @@ -362,6 +363,8 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt BOOL bIsWordDelim : 1; BOOL bIsAppend : 1; + const IDocumentContentOperations::InsertFlags m_nInsertFlags; + friend class SwDoc; // eigentlich nur SwDoc::Insert( String ) BOOL CanGrouping( sal_Unicode cIns ); BOOL CanGrouping( const SwPosition& rPos ); @@ -373,6 +376,7 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveCntnt public: SwUndoInsert( const SwNodeIndex& rNode, xub_StrLen nCntnt, xub_StrLen nLen, + const IDocumentContentOperations::InsertFlags nInsertFlags, BOOL bWDelim = TRUE ); SwUndoInsert( const SwNodeIndex& rNode ); virtual ~SwUndoInsert(); @@ -572,13 +576,13 @@ class SwUndoAttr : public SwUndo, private SwUndRng ::std::auto_ptr<SwRedlineData> m_pRedlineData; // Redlining ::std::auto_ptr<SwRedlineSaveDatas> m_pRedlineSaveData; ULONG m_nNodeIndex; // Offset: for Redlining - const USHORT m_nInsertFlags; // insert flags + const SetAttrMode m_nInsertFlags; // insert flags void RemoveIdx( SwDoc& rDoc ); public: - SwUndoAttr( const SwPaM&, const SfxItemSet&, USHORT nFlags = 0 ); - SwUndoAttr( const SwPaM&, const SfxPoolItem&, USHORT nFlags = 0 ); + SwUndoAttr( const SwPaM&, const SfxItemSet &, const SetAttrMode nFlags ); + SwUndoAttr( const SwPaM&, const SfxPoolItem&, const SetAttrMode nFlags ); virtual ~SwUndoAttr(); virtual void Undo( SwUndoIter& ); virtual void Redo( SwUndoIter& ); diff --git a/sw/inc/unocoll.hxx b/sw/inc/unocoll.hxx index 0c67b1bd58..eeb3a81af1 100644 --- a/sw/inc/unocoll.hxx +++ b/sw/inc/unocoll.hxx @@ -163,11 +163,11 @@ class SwUnoCollection #define SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY 73 #define SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS 74 #define SW_SERVICE_FIELDTYPE_DROPDOWN 75 -#define SW_SERVICE_FIELDTYPE_DUMMY_4 76 -#define SW_SERVICE_FIELDTYPE_DUMMY_5 77 -#define SW_SERVICE_FIELDTYPE_DUMMY_6 78 -#define SW_SERVICE_FIELDTYPE_DUMMY_7 79 -#define SW_SERVICE_FIELDTYPE_DUMMY_8 80 +#define SW_SERVICE_FIELDTYPE_METAFIELD 76 +#define SW_SERVICE_FIELDTYPE_DUMMY_4 77 +#define SW_SERVICE_FIELDTYPE_DUMMY_5 78 +#define SW_SERVICE_FIELDTYPE_DUMMY_6 79 +#define SW_SERVICE_FIELDTYPE_DUMMY_7 80 #define SW_SERVICE_FIELDMASTER_USER 81 #define SW_SERVICE_FIELDMASTER_DDE 82 #define SW_SERVICE_FIELDMASTER_SET_EXP 83 @@ -196,8 +196,9 @@ class SwUnoCollection #define SW_SERVICE_CHART2_DATA_PROVIDER 106 #define SW_SERVICE_TYPE_FIELDMARK 107 #define SW_SERVICE_TYPE_FORMFIELDMARK 108 +#define SW_SERVICE_TYPE_META 109 -#define SW_SERVICE_LAST SW_SERVICE_TYPE_FORMFIELDMARK +#define SW_SERVICE_LAST SW_SERVICE_TYPE_META #define SW_SERVICE_INVALID USHRT_MAX diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx index 490934a0a3..27a511d969 100644 --- a/sw/inc/unocrsrhelper.hxx +++ b/sw/inc/unocrsrhelper.hxx @@ -96,7 +96,8 @@ namespace SwUnoCursorHelper com::sun::star::beans::PropertyState& eState); sal_Bool DocInsertStringSplitCR( SwDoc &rDoc, - const SwPaM &rNewCursor, const String &rText ); + const SwPaM &rNewCursor, const String &rText, + const bool bForceExpandHints ); void makeRedline( SwPaM& rPaM, const ::rtl::OUString& RedlineType, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& RedlineProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); diff --git a/sw/inc/unofield.hxx b/sw/inc/unofield.hxx index 1a1a489f26..abbd3f9e8f 100644 --- a/sw/inc/unofield.hxx +++ b/sw/inc/unofield.hxx @@ -43,7 +43,6 @@ class SwDoc; class SwFmtFld; class SwField; class SwSetExpField; -class String; class SwTextAPIObject; /* -----------------04.12.98 12:49------------------- @@ -206,15 +205,13 @@ public: const SwField* GetField() const; const SwFmtFld* GetFldFmt(){return GetField() ? pFmtFld : 0; }; - // #111840# - /** - Returns position of this field. - - @return position of this field - */ - SwPosition * GetPosition(); void Invalidate(); }; + +/// @return a SwXTextField, either an already existing one or a new one +SwXTextField * CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFmt); + + /* -----------------21.12.98 10:26------------------- * * --------------------------------------------------*/ diff --git a/sw/inc/unomap.hxx b/sw/inc/unomap.hxx index 11244fe940..0a19f4fbd4 100644 --- a/sw/inc/unomap.hxx +++ b/sw/inc/unomap.hxx @@ -131,8 +131,9 @@ #define PROPERTY_MAP_RUBY_AUTO_STYLE 95 #define PROPERTY_MAP_PARA_AUTO_STYLE 96 #define PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM 97 +#define PROPERTY_MAP_METAFIELD 98 -#define PROPERTY_MAP_END 98 +#define PROPERTY_MAP_END 99 //S&E #define WID_WORDS 0 diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 43dbfffca2..e2e8b02dde 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -30,8 +30,10 @@ ************************************************************************/ #ifndef _UNOOBJ_HXX #define _UNOOBJ_HXX + #include <unoevtlstnr.hxx> #include <unobaseclass.hxx> +#include <unocrsr.hxx> #include <svtools/itemprop.hxx> #include <svtools/svarray.hxx> #include <frmfmt.hxx> @@ -92,13 +94,29 @@ #include <IDocumentMarkAccess.hxx> #include <sfx2/Metadatable.hxx> +#include <deque> +#include <boost/shared_ptr.hpp> + -class SwUnoCrsr; -class SwCursor; class SwFmtFtn; class SwFmtRefMark; class GetCurTxtFmtColl; + +struct FrameDependSortListEntry { + xub_StrLen nIndex; + sal_uInt32 nOrder; + ::boost::shared_ptr<SwDepend> pFrameDepend; + FrameDependSortListEntry (xub_StrLen const i_nIndex, + sal_uInt32 const i_nOrder, SwDepend * const i_pDepend) + : nIndex(i_nIndex), nOrder(i_nOrder), pFrameDepend(i_pDepend) { } +}; +typedef ::std::deque< FrameDependSortListEntry > + FrameDependSortList_t; + +typedef ::std::deque< ::boost::shared_ptr<SwDepend> > + FrameDependList_t; + /* -----------------29.04.98 07:35------------------- * * --------------------------------------------------*/ @@ -114,36 +132,21 @@ enum CursorType CURSOR_REDLINE, CURSOR_ALL, // fuer Search&Replace CURSOR_SELECTION, // create a paragraph enumeration from a text range or cursor - CURSOR_SELECTION_IN_TABLE + CURSOR_SELECTION_IN_TABLE, + CURSOR_META, // meta/meta-field }; -/* -----------------29.04.98 07:35------------------- - * - * --------------------------------------------------*/ -#define PUNOPAM (_pStartCrsr) - -#define FOREACHUNOPAM_START(pCrsr) \ - {\ - SwPaM *_pStartCrsr = pCrsr, *__pStartCrsr = _pStartCrsr; \ - do { - -#define FOREACHUNOPAM_END() \ - } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr ); \ - } - /* -----------------26.06.98 16:18------------------- * * --------------------------------------------------*/ -SV_DECL_PTRARR(SwDependArr, SwDepend*, 2, 2) - SwPageDesc* GetPageDescByName_Impl(SwDoc& rDoc, const String& rName); ::com::sun::star::uno::Sequence< sal_Int8 > CreateUnoTunnelId(); // OD 2004-05-07 #i28701# - adjust 4th parameter void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, - SwDependArr& rFrameArr, + FrameDependSortList_t & rFrames, const bool _bAtCharAnchoredObjs ); /* -----------------29.04.98 07:35------------------- @@ -212,8 +215,13 @@ class SwXText : public ::com::sun::star::lang::XTypeProvider, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & CharacterAndParagraphProperties ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); -protected: + virtual void PrepareForAttach( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const SwXTextRange* const pRange, const SwPaM * const pPam); + +public: /*not protected because C++ is retarded*/ virtual const SwStartNode *GetStartNode() const; + public: SwXText(SwDoc* pDc, CursorType eType); virtual ~SwXText(); @@ -293,6 +301,10 @@ public: virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextCursor > createCursor()throw(::com::sun::star::uno::RuntimeException); INT16 ComparePositions(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange>& xPos1, const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange>& xPos2) throw (com::sun::star::lang::IllegalArgumentException, com::sun::star::uno::RuntimeException); BOOL CheckForOwnMember(const SwXTextRange* pRange1, const OTextCursorHelper* pCursor1)throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); + virtual bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); // void Invalidate() {bObjectValid = sal_False;} BOOL IsValid()const {return bObjectValid;} @@ -345,8 +357,6 @@ class SwXTextCursor : public SwXTextCursor_Base, bool mbRemoveUserEvent; // <-- - void DeleteAndInsert(const String& rText); - DECL_STATIC_LINK( SwXTextCursor, RemoveCursor_Impl, ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>* ); @@ -354,6 +364,7 @@ class SwXTextCursor : public SwXTextCursor_Base, protected: virtual ~SwXTextCursor(); public: + void DeleteAndInsert(const String& rText, const bool bForceExpandHints); SwXTextCursor(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, const SwPosition& rPos, CursorType eSet, SwDoc* pDoc, const SwPosition* pMark = 0); SwXTextCursor(::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, SwUnoCrsr* pSourceCrsr, CursorType eSet = CURSOR_ALL); @@ -506,6 +517,8 @@ public: // --> FME 2006-03-07 #126177# void DoNotRemoveUserEvent() { mbRemoveUserEvent = false; } // <-- + + bool IsAtEndOfMeta() const; }; /*-----------------20.03.98 07:47------------------- @@ -557,18 +570,19 @@ public: }; */ -typedef cppu::WeakImplHelper5 +typedef ::cppu::ImplInheritanceHelper5 < + ::sfx2::MetadatableMixin, ::com::sun::star::text::XTextContent, ::com::sun::star::beans::XPropertySet, ::com::sun::star::lang::XServiceInfo, ::com::sun::star::container::XNamed, ::com::sun::star::lang::XUnoTunnel > -SwRefMarkBaseClass; +SwBookmarkBaseClass; class SwXBookmark - : public SwRefMarkBaseClass + : public SwBookmarkBaseClass , private SwClient { private: @@ -634,8 +648,15 @@ class SwXBookmark //SwClient virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + // MetadatableMixin + virtual ::sfx2::Metadatable* GetCoreObject(); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > GetModel(); + const ::sw::mark::IMark* GetBookmark() const { return m_pRegisteredBookmark; } + ::sw::mark::IMark* GetBookmark() + { return m_pRegisteredBookmark; } SwDoc* GetDoc() { return m_pDoc; } }; @@ -740,7 +761,8 @@ class SW_DLLPUBLIC SwXTextRange : public cppu::WeakImplHelper8 void _CreateNewBookmark(SwPaM& rPam); //TODO: new exception type for protected content - void DeleteAndInsert(const String& rText) throw( ::com::sun::star::uno::RuntimeException ); + void DeleteAndInsert(const String& rText, const bool bForceExpandHints) + throw( ::com::sun::star::uno::RuntimeException ); protected: virtual ~SwXTextRange(); @@ -1277,79 +1299,39 @@ class SwXParaFrameEnumeration : public cppu::WeakImplHelper2 >, public SwClient { - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xNextObject; //hasMoreElements legt das Objekt schon an - SwDependArr aFrameArr; //wird im Ctor gefuellt + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xNextObject; // created by hasMoreElements + FrameDependList_t m_Frames; - SwUnoCrsr* GetCrsr(){return (SwUnoCrsr*)GetRegisteredIn();} - BOOL CreateNextObject(); - void FillFrame(SwUnoCrsr& rUnoCrsr); + SwUnoCrsr* GetCursor() const + {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));} public: SwXParaFrameEnumeration(const SwPaM& rPaM, sal_uInt8 nParaFrameMode, SwFrmFmt* pFmt = 0); ~SwXParaFrameEnumeration(); - //XEnumeration - virtual BOOL SAL_CALL hasMoreElements(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL nextElement(void) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + // XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() + throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL nextElement() + throw( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException ); + + // XServiceInfo + virtual rtl::OUString SAL_CALL getImplementationName() + throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) + throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw( ::com::sun::star::uno::RuntimeException ); //SwClient virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); }; -/* -----------------29.05.98 14:42------------------- - * - * --------------------------------------------------*/ -class SwXTextPortionEnumeration : public cppu::WeakImplHelper3 -< - ::com::sun::star::container::XEnumeration, - ::com::sun::star::lang::XServiceInfo, - ::com::sun::star::lang::XUnoTunnel ->, - public SwClient -{ - XTextRangeArr aPortionArr; //all portions are created in the ctor - SwDependArr aFrameArr; //wird im Ctor gefuellt - mit am Zeichen gebundenen Rahmen - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent; - BOOL bAtEnd; - BOOL bFirstPortion; - - const sal_Int32 nStartPos; - const sal_Int32 nEndPos; - - SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } - SwXTextPortionEnumeration(); - void CreatePortions(); -protected: - virtual ~SwXTextPortionEnumeration(); -public: - SwXTextPortionEnumeration(SwPaM& rParaCrsr, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParent, - sal_Int32 nStart, sal_Int32 nEnd ); - - - static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); - - //XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); - - //XEnumeration - virtual BOOL SAL_CALL hasMoreElements(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL nextElement(void) throw( ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException ); - - //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); - - //SwClient - virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); -}; /* -----------------29.09.98 09:01------------------- * @@ -1437,6 +1419,16 @@ public: /* -----------------27.08.98 15:11------------------- * * --------------------------------------------------*/ +typedef ::cppu::WeakImplHelper5 +< + ::com::sun::star::text::XTextContent, + ::com::sun::star::beans::XPropertySet, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::container::XNamed, + ::com::sun::star::lang::XUnoTunnel +> +SwRefMarkBaseClass; + class SwXReferenceMark : public SwRefMarkBaseClass, public SwClient { @@ -1447,7 +1439,7 @@ class SwXReferenceMark : public SwRefMarkBaseClass, BOOL m_bIsDescriptor; BOOL IsValid() const {return 0 != GetRegisteredIn();} - void InsertRefMark( SwPaM& rPam ); + void InsertRefMark( SwPaM& rPam, SwXTextCursor * pCursor ); public: SwXReferenceMark(SwDoc* pDoc, const SwFmtRefMark* pMark); ~SwXReferenceMark(); diff --git a/sw/inc/unoport.hxx b/sw/inc/unoport.hxx index a94f312eba..b395d1c107 100644 --- a/sw/inc/unoport.hxx +++ b/sw/inc/unoport.hxx @@ -29,27 +29,41 @@ ************************************************************************/ #ifndef _UNOPORT_HXX #define _UNOPORT_HXX + +#include <unocrsr.hxx> #include <unoevtlstnr.hxx> #include <calbck.hxx> -#include <cppuhelper/implbase6.hxx> + #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/text/XTextRange.hpp> +#include <com/sun/star/container/XEnumeration.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/beans/XTolerantMultiPropertySet.hpp> #include <com/sun/star/text/XTextField.hpp> +#include <com/sun/star/text/XFootnote.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <cppuhelper/implbase8.hxx> -#include <cppuhelper/implbase9.hxx> +#include <cppuhelper/implbase3.hxx> #include <svtools/itemprop.hxx> +#include <memory> +#include <deque> + + class SwFmtFld; class SwFrmFmt; -class SwUnoCrsr; class SwTxtRuby; + + +typedef ::std::deque< + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > + TextRangeList_t; + + /* -----------------29.05.98 14:42------------------- * * --------------------------------------------------*/ @@ -59,7 +73,7 @@ enum SwTextPortionType PORTION_FIELD, PORTION_FRAME, PORTION_FOOTNOTE, - PORTION_CONTROL_CHAR, +// obsolete! PORTION_CONTROL_CHAR, PORTION_REFMARK_START, PORTION_REFMARK_END, PORTION_TOXMARK_START, @@ -71,20 +85,19 @@ enum SwTextPortionType PORTION_RUBY_START, PORTION_RUBY_END, PORTION_SOFT_PAGEBREAK, + PORTION_META, PORTION_FIELD_START, PORTION_FIELD_END, PORTION_FIELD_START_END }; -class SwXRubyPortion; -class SwXTextPortion : public cppu::WeakImplHelper9 +class SwXTextPortion : public cppu::WeakImplHelper8 < ::com::sun::star::beans::XTolerantMultiPropertySet, ::com::sun::star::beans::XMultiPropertySet, ::com::sun::star::beans::XPropertySet, ::com::sun::star::text::XTextRange, - ::com::sun::star::text::XTextField, ::com::sun::star::beans::XPropertyState, ::com::sun::star::container::XContentEnumerationAccess, ::com::sun::star::lang::XUnoTunnel, @@ -92,29 +105,39 @@ class SwXTextPortion : public cppu::WeakImplHelper9 >, public SwClient { - friend class SwXRubyPortion; - SwEventListenerContainer aLstnrCntnr; - const SfxItemPropertySet* m_pPropSet; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > xParentText; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xRefMark; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xTOXMark; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xBookmark; - ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xFootnote; - ::com::sun::star::uno::Any* pRubyText; - ::com::sun::star::uno::Any* pRubyStyle; - ::com::sun::star::uno::Any* pRubyAdjust; - ::com::sun::star::uno::Any* pRubyIsAbove; - - const SwFmtFld* pFmtFld; - SwDepend aFrameDepend; - SwFrmFmt* pFrameFmt; - SwTextPortionType ePortionType; - sal_Int16 nControlChar; - - BOOL bIsCollapsed; - - SwFmtFld* GetFldFmt(BOOL bInit = sal_False); +private: + + SwEventListenerContainer m_ListenerContainer; + const SfxItemPropertySet * m_pPropSet; + const ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + m_xParentText; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xRefMark; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xTOXMark; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xBookmark; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XFootnote > + m_xFootnote; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextField > + m_xTextField; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > + m_xMeta; + ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyText; + ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyStyle; + ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyAdjust; + ::std::auto_ptr< ::com::sun::star::uno::Any > m_pRubyIsAbove; + + const SwDepend m_FrameDepend; + SwFrmFmt * m_pFrameFmt; + const SwTextPortionType m_ePortionType; + + bool m_bIsCollapsed; + + SwFmtFld * GetFldFmt(bool bInit = false); + protected: + //SfxItemPropertySet& GetPropSet() { return aPropSet; } void SAL_CALL SetPropertyValues_Impl( @@ -140,16 +163,23 @@ protected: sal_Bool bDirectValuesOnly ) throw (::com::sun::star::uno::RuntimeException); virtual ~SwXTextPortion(); + public: SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwTextPortionType eType ); SwXTextPortion(const SwUnoCrsr* pPortionCrsr, ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, SwFrmFmt& rFmt ); + // for Ruby + SwXTextPortion(const SwUnoCrsr* pPortionCrsr, + SwTxtRuby const& rAttr, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + const& xParent, + sal_Bool bIsEnd ); //XTextRange - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual rtl::OUString SAL_CALL getString(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > SAL_CALL getText() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getStart() throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getEnd() throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString SAL_CALL getString() throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL setString(const rtl::OUString& aString) throw( ::com::sun::star::uno::RuntimeException ); //XTolerantMultiPropertySet @@ -180,15 +210,12 @@ public: virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); - //XTextField - virtual rtl::OUString SAL_CALL getPresentation(BOOL bShowCommand) throw( ::com::sun::star::uno::RuntimeException ); - //XTextContent virtual void SAL_CALL attach(const ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > & xTextRange) throw( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL getAnchor( ) throw(::com::sun::star::uno::RuntimeException); //XComponent - virtual void SAL_CALL dispose(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & aListener) throw( ::com::sun::star::uno::RuntimeException ); @@ -197,48 +224,105 @@ public: virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException); //XServiceInfo - virtual rtl::OUString SAL_CALL getImplementationName(void) throw( ::com::sun::star::uno::RuntimeException ); - virtual BOOL SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); //XContentEnumerationAccess virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createContentEnumeration(const rtl::OUString& aServiceName) throw( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames(void) throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames() throw( ::com::sun::star::uno::RuntimeException ); //SwClient virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); - void SetRefMark( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xMark) - {xRefMark = xMark;} + void SetRefMark( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > xMark) + { m_xRefMark = xMark; } - void SetTOXMark( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xMark) - {xTOXMark = xMark;} + void SetTOXMark( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > xMark) + { m_xTOXMark = xMark; } - void SetBookmark( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xMark) - {xBookmark = xMark;} + void SetBookmark( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > xMark) + { m_xBookmark = xMark; } - void SetFootnote( ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextContent > xMark) - {xFootnote = xMark;} + void SetFootnote( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XFootnote > xNote) + { m_xFootnote = xNote; } - void SetControlChar(sal_Int16 nSet) {nControlChar = nSet;} + void SetTextField( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextField> xField) + { m_xTextField = xField; } - BOOL IsCollapsed() const { return bIsCollapsed;} - void SetCollapsed(BOOL bSet) { bIsCollapsed = bSet;} + void SetMeta( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > xMeta) + { m_xMeta = xMeta; } - SwTextPortionType GetTextPortionType() const {return ePortionType;} + bool IsCollapsed() const { return m_bIsCollapsed; } + void SetCollapsed(bool bSet) { m_bIsCollapsed = bSet;} - SwUnoCrsr* GetCrsr() const { return (SwUnoCrsr*)GetRegisteredIn(); } + SwTextPortionType GetTextPortionType() const { return m_ePortionType; } + + SwUnoCrsr* GetCursor() const + {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));} }; -/* -----------------------------19.02.01 10:46-------------------------------- - ---------------------------------------------------------------------------*/ -class SwXRubyPortion : public SwXTextPortion +/* -----------------29.05.98 14:42------------------- + * + * --------------------------------------------------*/ +class SwXTextPortionEnumeration + : public ::cppu::WeakImplHelper3 + < ::com::sun::star::container::XEnumeration + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XUnoTunnel + > + , public SwClient { + TextRangeList_t m_Portions; // contains all portions, filled by ctor + + SwUnoCrsr* GetCursor() const + {return static_cast<SwUnoCrsr*>(const_cast<SwModify*>(GetRegisteredIn()));} + +protected: + virtual ~SwXTextPortionEnumeration(); + public: - SwXRubyPortion(const SwUnoCrsr* pPortionCrsr, - SwTxtRuby& rAttr, - ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > const& rParent, - sal_Bool bEnd ); - ~SwXRubyPortion(); + SwXTextPortionEnumeration(SwPaM& rParaCrsr, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + const & xParent, + const sal_Int32 nStart, const sal_Int32 nEnd ); + + SwXTextPortionEnumeration(SwPaM& rParaCrsr, + TextRangeList_t const & rPortions ); + + + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); + + //XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) + throw(::com::sun::star::uno::RuntimeException); + + //XEnumeration + virtual sal_Bool SAL_CALL hasMoreElements() + throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Any SAL_CALL nextElement() + throw( ::com::sun::star::container::NoSuchElementException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException ); + + //XServiceInfo + virtual rtl::OUString SAL_CALL getImplementationName() + throw( ::com::sun::star::uno::RuntimeException ); + virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) + throw( ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw( ::com::sun::star::uno::RuntimeException ); + + //SwClient + virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew); }; + #endif diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx index 526f288095..0b59929824 100644 --- a/sw/inc/unoprnms.hxx +++ b/sw/inc/unoprnms.hxx @@ -203,7 +203,7 @@ enum SwPropNameIds /* 0161 */ UNO_NAME_PARA_BACK_TRANSPARENT, /* 0162 */ UNO_NAME_POSITION_END_OF_DOC, /* 0163 */ UNO_NAME_POSITION_PROTECTED, -/* 0164 */ UNO_NAME_ALTERNATIVE_TEXT, +/* 0164 */ UNO_NAME_ALTERNATIVE_TEXT, /* 0165 */ UNO_NAME_PRIMARY_KEY, /* 0166 */ UNO_NAME_PRINT_TABLES, /* 0167 */ UNO_NAME_PRINT_GRAPHICS, @@ -804,7 +804,11 @@ enum SwPropNameIds /* 0734 */ UNO_NAME_CHAR_OVERLINE_COLOR, /* 0735 */ UNO_NAME_CHAR_OVERLINE_HAS_COLOR, /* 0736 */ UNO_NAME_OUTLINE_LEVEL, //#outline level,add<-zhaojianwei outlinelevel -/* 0737 */ SW_PROPNAME_END +// --> OD 2009-07-13 #i73249# +/* 0737 */ UNO_NAME_DESCRIPTION, +// <-- +/* 0738 */ UNO_NAME_META, // #i91565# +/* 0739 */ SW_PROPNAME_END }; diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index e08028525f..eafb07fdd5 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -179,7 +179,7 @@ typedef cppu::WeakImplHelper32 > SwXTextDocumentBaseClass; -class SwXTextDocument : public SwXTextDocumentBaseClass, +class SW_DLLPUBLIC SwXTextDocument : public SwXTextDocumentBaseClass, public SvxFmMSFactory, public SfxBaseModel { diff --git a/sw/prj/build.lst b/sw/prj/build.lst index 1ea52fbe58..d8cac64ff9 100644 --- a/sw/prj/build.lst +++ b/sw/prj/build.lst @@ -1,4 +1,4 @@ -sw sw : l10n connectivity OOo:writerperfect svx stoc uui NULL +sw sw : l10n connectivity OOo:writerperfect svx stoc uui writerfilter NULL sw sw usr1 - all sw_mkout NULL sw sw\inc nmake - all sw_inc NULL sw sw\uiconfig\layout nmake - all sw_layout NULL diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java new file mode 100755 index 0000000000..aec77b891a --- /dev/null +++ b/sw/qa/complex/writer/TextPortionEnumerationTest.java @@ -0,0 +1,3858 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package complex.writer; + +import complexlib.ComplexTestCase; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.XComponentContext; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.Pair; +import com.sun.star.beans.StringPair; +import com.sun.star.container.XNamed; +import com.sun.star.container.XContentEnumerationAccess; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.container.XEnumeration; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.frame.XStorable; +import com.sun.star.util.XCloseable; +import com.sun.star.text.XText; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XWordCursor; +import com.sun.star.text.XSentenceCursor; +import com.sun.star.text.XParagraphCursor; +import com.sun.star.text.XFootnote; +import com.sun.star.text.XTextField; +import com.sun.star.text.TextContentAnchorType; +import static com.sun.star.text.TextContentAnchorType.*; +import static com.sun.star.text.ControlCharacter.*; +import com.sun.star.rdf.XMetadatable; + +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.ArrayList; +import java.util.Stack; + + +class TreeNodeEnum +{ + private Object[] m_Elements; + private int m_Pos; + TreeNodeEnum(Object[] Elements) { m_Elements = Elements; m_Pos = 0; } + boolean hasNext() { return m_Pos < m_Elements.length; } + TreeNode next() { return (TreeNode) m_Elements[m_Pos++]; } +} + +/** base class for tree nodes. only instance: root of tree. */ +class TreeNode +{ + private List<TreeNode> m_Children; + String getType() { return "__ROOT__"; } + boolean hasContent() { return false; } + boolean isNesting() { return false; } + TreeNode dup() { throw new RuntimeException("TreeNode.dup"); } + TreeNodeEnum createEnumeration() { + return new TreeNodeEnum(m_Children.toArray()); + } + TreeNode() { m_Children = new ArrayList<TreeNode>(); } + TreeNode appendChild(TreeNode child) + { m_Children.add(child); return this; } + public String toString() { + return "<" + getType() + ">"; + } +} + +abstract class MarkNode extends TreeNode +{ + boolean m_isPoint; + boolean m_isStart = false; + String m_Name; + boolean isPoint() { return m_isPoint; } + boolean isStart() { return m_isStart; } + String getName() { return m_Name; } + MarkNode(String name) { m_Name = name; m_isPoint = true; } + boolean equals(MarkNode other) { + return (other.m_Name.equals(m_Name)) && (other.m_isPoint == m_isPoint) + && (other.m_isStart == m_isStart); + } + public String toString() { + return super.toString() + "\tname: " + m_Name + + "\tisPoint: " + m_isPoint + "\tisStart: " + m_isStart; + } +} + +class BookmarkNode extends MarkNode +{ + private StringPair m_XmlId; + StringPair getXmlId() { return m_XmlId; } + BookmarkNode dup() { return new BookmarkNode(getName(), getXmlId()); } + BookmarkNode(String name) { this(name, new StringPair()); } + BookmarkNode(String name, StringPair xmlid) { + super(name); m_XmlId = xmlid; + } + String getType() { return "Bookmark"; } + public boolean equals(Object other) { + return (other instanceof BookmarkNode) + && super.equals((MarkNode) other) + && MetaNode.eq(((BookmarkNode) other).m_XmlId, m_XmlId); + } + public String toString() { + return super.toString() + + "\txmlid: " + m_XmlId.First + "#" + m_XmlId.Second; + } +} + +class BookmarkStartNode extends BookmarkNode +{ + BookmarkStartNode dup() { return new BookmarkStartNode(getName()); } + BookmarkStartNode(String name) { this(name, new StringPair()); } + BookmarkStartNode(String name, StringPair xmlid) { + super(name, xmlid); m_isPoint = false; m_isStart = true; + } +} + +class BookmarkEndNode extends BookmarkNode +{ + BookmarkEndNode dup() { return new BookmarkEndNode(getName()); } + BookmarkEndNode(String name) { this(name, new StringPair()); } + BookmarkEndNode(String name, StringPair xmlid) { + super(name, xmlid); m_isPoint = false; m_isStart = false; + } +} + +class ReferenceMarkNode extends MarkNode +{ + ReferenceMarkNode dup() { return new ReferenceMarkNode(getName()); } + ReferenceMarkNode(String name) { super(name); } + String getType() { return "ReferenceMark"; } + public boolean equals(Object other) { + return (other instanceof ReferenceMarkNode) + && super.equals((MarkNode) other); + } +} + +class ReferenceMarkStartNode extends ReferenceMarkNode +{ + ReferenceMarkStartNode dup() + { return new ReferenceMarkStartNode(getName()); } + ReferenceMarkStartNode(String name) { + super(name); m_isPoint = false; m_isStart = true; + } +} + +class ReferenceMarkEndNode extends ReferenceMarkNode +{ + ReferenceMarkEndNode dup() + { return new ReferenceMarkEndNode(getName()); } + ReferenceMarkEndNode(String name) { + super(name); m_isPoint = false; m_isStart = false; + } +} + +class DocumentIndexMarkNode extends MarkNode +{ + DocumentIndexMarkNode dup() + { return new DocumentIndexMarkNode(getName()); } + DocumentIndexMarkNode(String name) { super(name); } + String getType() { return "DocumentIndexMark"; } + public boolean equals(Object other) { + return (other instanceof DocumentIndexMarkNode) + && super.equals((MarkNode) other); + } +} + +class DocumentIndexMarkStartNode extends DocumentIndexMarkNode +{ + DocumentIndexMarkStartNode dup() + { return new DocumentIndexMarkStartNode(getName()); } + DocumentIndexMarkStartNode(String name) { + super(name); m_isPoint = false; m_isStart = true; + } +} + +class DocumentIndexMarkEndNode extends DocumentIndexMarkNode +{ + DocumentIndexMarkEndNode dup() + { return new DocumentIndexMarkEndNode(getName()); } + DocumentIndexMarkEndNode(String name) { + super(name); m_isPoint = false; m_isStart = false; + } +} + +abstract class ContentNode extends TreeNode +{ + private String m_Content; + String getContent() { return m_Content; } + boolean hasContent() { return true; } + ContentNode(String content) { + m_Content = content; + } + TreeNode appendChild(TreeNode t) { + throw new RuntimeException("ContentNode.appendChild"); + } + public String toString() { + return super.toString() + "\tcontent: " + m_Content; + } + boolean equals(ContentNode other) { + return (other.m_Content.equals(m_Content)); + } +} + +class TextNode extends ContentNode +{ + TextNode dup() { return new TextNode(getContent()); } + TextNode(String content) { super(content); } + String getType() { return "Text"; } + public boolean equals(Object other) { + return (other instanceof TextNode) && super.equals((ContentNode) other); + } +} + +class TextFieldNode extends ContentNode +{ + TextFieldNode dup() { return new TextFieldNode(getContent()); } + TextFieldNode(String content) { super(content); } + String getType() { return "TextField"; } + public boolean equals(Object other) { + return (other instanceof TextFieldNode) + && super.equals((ContentNode) other); + } +} + +class FrameNode extends TreeNode +{ + private String m_Name; + private TextContentAnchorType m_Anchor; + String getName() { return m_Name; } + TextContentAnchorType getAnchor() { return m_Anchor; } + FrameNode dup() { return new FrameNode(getName(), getAnchor()); } + FrameNode(String name, TextContentAnchorType anchor) { + m_Name = name; m_Anchor = anchor; + } + String getType() { return "Frame"; } + public boolean equals(Object other) { + return (other instanceof FrameNode) + && (((FrameNode) other).m_Name.equals(m_Name)) + && (((FrameNode) other).m_Anchor == m_Anchor); + } + public String toString() { + return super.toString() + + "\tname: " + m_Name + "\tanchor: " + toString(m_Anchor); + } + static String toString(TextContentAnchorType anchor) { + switch (anchor.getValue()) { + case AS_CHARACTER_value: return "AS_CHARACTER"; + case AT_CHARACTER_value: return "AT_CHARACTER"; + case AT_PARAGRAPH_value: return "AT_PARAGRAPH"; + case AT_PAGE_value: return "AT_PAGE"; + case AT_FRAME_value: return "AT_FRAME"; + default: throw new RuntimeException("unknown anchor"); + } + } +} + +class FootnoteNode extends TreeNode +{ + private String m_Label; + String getLabel() { return m_Label; } + FootnoteNode dup() { return new FootnoteNode(getLabel()); } + FootnoteNode(String label) { m_Label = label; } + String getType() { return "Footnote"; } + public boolean equals(Object other) { + return (other instanceof FootnoteNode) + && (((FootnoteNode) other).m_Label.equals(m_Label)); + } + public String toString() { + return super.toString() + "\tlabel: " + m_Label; + } +} + +class ControlCharacterNode extends TreeNode +{ + private short m_Char; + short getChar() { return m_Char; } + ControlCharacterNode dup() { return new ControlCharacterNode(getChar()); } + ControlCharacterNode(short c) { m_Char = c; } + String getType() { return "ControlCharacter"; } + public boolean equals(Object other) { + return (other instanceof ControlCharacterNode) + && (((ControlCharacterNode) other).m_Char == m_Char); + } + public String toString() { + return super.toString() + "\tchar: " + m_Char; + } +} + +class SoftPageBreakNode extends TreeNode +{ + String getType() { return "SoftPageBreak"; } + public boolean equals(Object other) { + return (other instanceof SoftPageBreakNode); + } +} + +class HyperlinkNode extends TreeNode +{ + private String m_URL; + String getURL() { return m_URL; } + HyperlinkNode dup() { return new HyperlinkNode(getURL()); } + HyperlinkNode(String url) { + if (url.length() == 0) throw new RuntimeException("HyperlinkNode"); + m_URL = url; + } + String getType() { return "Hyperlink"; } + boolean isNesting() { return true; } + public boolean equals(Object other) { + return (other instanceof HyperlinkNode) + && (((HyperlinkNode) other).m_URL.equals(m_URL)); + } + public String toString() { + return super.toString() + "\turl: " + m_URL; + } +} + +class RubyNode extends TreeNode +{ + private String m_Ruby; + String getRubyText() { return m_Ruby; } + RubyNode dup() { return new RubyNode(getRubyText()); } + RubyNode(String ruby) { + if (ruby.length() == 0) throw new RuntimeException("RubyNode"); + m_Ruby = ruby; + } + String getType() { return "Ruby"; } + boolean isNesting() { return true; } + public boolean equals(Object other) { + return (other instanceof RubyNode) + && (((RubyNode) other).m_Ruby.equals(m_Ruby)); + } + public String toString() { + return super.toString() + "\trubytext: " + m_Ruby; + } +} + +class MetaNode extends TreeNode +{ + private StringPair m_XmlId; + StringPair getXmlId() { return m_XmlId; } + MetaNode dup() { return new MetaNode(getXmlId()); } + MetaNode (StringPair xmlid) { m_XmlId = xmlid; } + String getType() { return "InContentMetadata"; } + boolean isNesting() { return true; } + public boolean equals(Object other) { + return (other instanceof MetaNode) + && eq(((MetaNode) other).m_XmlId, m_XmlId); + } + static boolean eq(StringPair left, StringPair right) + { + return left.First.equals(right.First) + && left.Second.equals(right.Second); + } + public String toString() { + return super.toString() + + "\txmlid: " + m_XmlId.First + "#" + m_XmlId.Second; + } +} + +class MetaFieldNode extends MetaNode +{ + MetaFieldNode dup() { return new MetaFieldNode(getXmlId()); } + MetaFieldNode (StringPair xmlid) { super(xmlid); } + String getType() { return "MetadataField"; } +} + +class Range +{ + private short m_Start; + private short m_End; + private TreeNode m_Node; + short getStart() { return m_Start; } + short getEnd() { return m_End ; } + short getExtent() { return (short) (m_End - m_Start); } + TreeNode getNode() { return m_Node; } + Range(int start, int end, TreeNode node) + { m_Start = (short) start; m_End = (short) end; m_Node = node; } +} + +//---------------------------------------------------------------------- + +/* this is where we nail the pudding to the wall */ +class FuzzyTester +{ + private long m_DiffContent = 0; + private long m_DiffMissing = 0; + private long m_DiffNesting = 0; + private long m_DiffSpuriousEmptyText = 0; + private long m_DiffSequence = 0; // ignored? + private Stack<Pair<TreeNode, TreeNodeEnum>> m_StackExpected; + private Stack<Pair<TreeNode, TreeNodeEnum>> m_StackActual; + private List<TreeNode> m_BufferExpected; + private List<TreeNode> m_BufferActual; + private share.LogWriter m_Log; + + FuzzyTester(share.LogWriter log) { + m_Log = log; + m_BufferExpected = new ArrayList<TreeNode>(); + m_BufferActual = new ArrayList<TreeNode>(); + m_StackExpected = new Stack<Pair<TreeNode, TreeNodeEnum>>(); + m_StackActual = new Stack<Pair<TreeNode, TreeNodeEnum>>(); + } + + /** idea: traverse both trees, enumerate nodes, stopping at content nodes. + then compare buffers. */ + boolean doTest(TreeNode expected, TreeNode actual) + { + if (!expected.getType().equals("__ROOT__")) + throw new RuntimeException("doTest: expected: root"); + if (!actual.getType().equals("__ROOT__")) + throw new RuntimeException("doTest: actual: root"); + m_StackExpected.push(new Pair(expected, expected.createEnumeration())); + m_StackActual.push(new Pair(actual, actual.createEnumeration())); + do { + traverse(m_StackExpected, m_BufferExpected); + traverse(m_StackActual, m_BufferActual); + //??? root? + testBuffer(); + } while (!m_StackExpected.empty() || !m_StackActual.empty()); + if (m_DiffSequence != 0) { + m_Log.println("warning: " + m_DiffSequence + + " differences in sequence"); + } + if (m_DiffSpuriousEmptyText != 0) { + m_Log.println("warning: " + m_DiffSpuriousEmptyText + + " spurious empty text nodes"); + } + if (m_DiffNesting != 0) { + m_Log.println("WARNING: " + m_DiffNesting + + " differences in nesting"); + } + return (m_DiffContent == 0) && (m_DiffMissing == 0); + } + + private void traverse(Stack<Pair<TreeNode, TreeNodeEnum>> stack, + List<TreeNode> buffer) + { + while (!stack.empty()) { + TreeNodeEnum topEnum = stack.peek().Second; + if (topEnum.hasNext()) { + TreeNode node = topEnum.next(); + buffer.add(node); + TreeNodeEnum nodeEnum = node.createEnumeration(); + if (nodeEnum.hasNext()) { + stack.push(new Pair(node, nodeEnum)); + } + if (node.hasContent()) { + if (!((node instanceof TextNode) // spurious empty text? + && ((TextNode) node).getContent().length() == 0)) { + return; // break here + } + } + } else { + buffer.add(stack.peek().First); + stack.pop(); + } + } + } + + private void testTerminatingNode() + { + int lenExpected = m_BufferExpected.size(); + int lenActual = m_BufferActual.size(); + if (lenExpected == 0 || lenActual == 0) + return; + TreeNode expected = m_BufferExpected.get(lenExpected - 1); + TreeNode actual = m_BufferActual.get(lenActual - 1); + + boolean eRoot = expected.getType().equals("__ROOT__"); + boolean aRoot = actual.getType().equals("__ROOT__"); + if (eRoot || aRoot) { + if (!(eRoot && aRoot)) { + if (aRoot) printMissing(expected); + else printUnexpected(actual); + m_DiffMissing++; + } + return; + } + + testContentNode((ContentNode) expected, (ContentNode) actual); + + m_BufferExpected.set(lenExpected - 1, null); + m_BufferActual.set(lenActual - 1, null); + } + + private void testContentNode(ContentNode expected, ContentNode actual) + { + String contentExpected = expected.getContent(); + String contentActual = actual.getContent(); + if (!expected.equals(actual)) { + printDiff("text content differs", contentExpected, contentActual); + m_DiffContent++; + } + } + + private void testBuffer() + { + int lenExpected = m_BufferExpected.size(); + int lenActual = m_BufferActual.size(); + for (int i = 0; i < lenExpected - 1; i++ ) + { + TreeNode node = m_BufferExpected.get(i); + int j = m_BufferActual.indexOf(node); + if (j >= 0) { + TreeNode other = m_BufferActual.get(j); + if (j != i) + { + //FIXME how bad is this? + printDiff("position differs", + String.valueOf(i), String.valueOf(j)); + // a hacky hack + int min = Math.min(i,j); + int max = Math.max(Math.min(lenActual - 1, i),j); + for (int k = min; k != max; k ++) { + TreeNode tmp = m_BufferActual.get(k); + if (tmp != null && tmp.isNesting()) { + printNesting(node, tmp); + m_DiffNesting++; + } + } + m_DiffSequence++; + } + m_BufferActual.set(j, null); + } else { +//m_Log.println("testBuffer:"); + printMissing(node); + m_DiffMissing++; + } + } + for (int j = 0; j < lenActual - 1; j++) + { + TreeNode node = m_BufferActual.get(j); + if (node != null) + { +//m_Log.println("testBuffer:"); + printUnexpected(node); + if ((node instanceof TextNode) && + ((TextNode) node).getContent().length() == 0) { + m_DiffSpuriousEmptyText++; + } else { + m_DiffMissing++; + } + } + } + testTerminatingNode(); + m_BufferExpected.clear(); + m_BufferActual.clear(); + } + + void printDiff(String prefix, String expected, String actual) + { + m_Log.println(prefix + + ":\texpected: " + expected + "\tactual: " + actual); + } + + void printNesting(TreeNode node, TreeNode nesting) + { + m_Log.println("node: " + node.toString() + + " possibly moved across nesting " + nesting.toString()); + } + + void printMissing(TreeNode node) + { + m_Log.println(" missing node: " + node.toString()); + + } + + void printUnexpected(TreeNode node) + { + m_Log.println("unexpected node: " + node.toString()); + + } +} + + +//---------------------------------------------------------------------- + +class EnumConverter +{ + private Stack<TreeNode> m_Stack; + TextPortionEnumerationTest m_T; + + EnumConverter(TextPortionEnumerationTest err) { + m_Stack = new Stack<TreeNode>(); m_T = err; + } + + TreeNode convert(XEnumeration xEnum) throws Exception + { + TreeNode root = new TreeNode(); + m_Stack.push(root); + TreeNode ret = convertChildren(xEnum); + m_T.assure("EnumConverter.convert: stack", m_Stack.empty()); + return ret; + } + + TreeNode convertChildren(XEnumeration xEnum) throws Exception + { + while (xEnum.hasMoreElements()) { + TreeNode node; + Object xElement = xEnum.nextElement(); + XTextRange xPortion = (XTextRange) + UnoRuntime.queryInterface(XTextRange.class, xElement); + XPropertySet xPropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xPortion); + String type = (String) xPropSet.getPropertyValue("TextPortionType"); + if (type.equals("Text")) { + String text = xPortion.getString(); + node = new TextNode(text); + String url = (String) xPropSet.getPropertyValue("HyperLinkURL"); + if (url.length() > 0) { + TreeNode temp = node; + node = new HyperlinkNode(url); + node.appendChild(temp); + } + } else if (type.equals("TextField")) { + Object xField = xPropSet.getPropertyValue("TextField"); + XServiceInfo xService = (XServiceInfo) + UnoRuntime.queryInterface(XServiceInfo.class, xField); + if (xService.supportsService( + "com.sun.star.text.textfield.MetadataField")) + { + XMetadatable xMeta = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xField); + StringPair xmlid = xMeta.getMetadataReference(); + node = new MetaFieldNode(xmlid); + m_Stack.push(node); + XEnumerationAccess xEA = (XEnumerationAccess) + UnoRuntime.queryInterface(XEnumerationAccess.class, + xMeta); + XEnumeration xEnumChildren = xEA.createEnumeration(); + TreeNode node2 = convertChildren(xEnumChildren); + m_T.assure("stack error: meta-field", node == node2); + } else { + XPropertySet xFieldPropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xField); + String content = (String) + xFieldPropSet.getPropertyValue("Content"); + boolean isFixed = (Boolean) + xFieldPropSet.getPropertyValue("IsFixed"); + m_T.assure("field not fixed?", isFixed); + node = new TextFieldNode(content); + } + } else if (type.equals("Footnote")) { + Object xNote = xPropSet.getPropertyValue("Footnote"); + XFootnote xFootnote = (XFootnote) + UnoRuntime.queryInterface(XFootnote.class, xNote); + String label = xFootnote.getLabel(); + node = new FootnoteNode(label); + } else if (type.equals("Frame")) { + XContentEnumerationAccess xCEA = (XContentEnumerationAccess) + UnoRuntime.queryInterface(XContentEnumerationAccess.class, + xPortion); + XEnumeration xContentEnum = xCEA.createContentEnumeration(""); + while (xContentEnum.hasMoreElements()) { + Object xFrame = xContentEnum.nextElement(); + XPropertySet xFramePropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xFrame); + TextContentAnchorType anchor = (TextContentAnchorType) + xFramePropSet.getPropertyValue("AnchorType"); + XNamed xNamed = (XNamed) + UnoRuntime.queryInterface(XNamed.class, xFrame); + String name = xNamed.getName(); + node = new FrameNode(name, anchor); + m_Stack.peek().appendChild(node); + } + continue; + } else if (type.equals("ControlCharacter")) { + short c = (Short) + xPropSet.getPropertyValue("ControlCharacter"); + node = new ControlCharacterNode(c); + } else if (type.equals("Bookmark")) { + Object xMark = xPropSet.getPropertyValue("Bookmark"); + XNamed xNamed = (XNamed) + UnoRuntime.queryInterface(XNamed.class, xMark); + String name = xNamed.getName(); + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xMark); + StringPair xmlid = xMetadatable.getMetadataReference(); + boolean isCollapsed = (Boolean) + xPropSet.getPropertyValue("IsCollapsed"); + if (isCollapsed) { + node = new BookmarkNode(name, xmlid); + } else { + boolean isStart = (Boolean) + xPropSet.getPropertyValue("IsStart"); + if (isStart) { + node = new BookmarkStartNode(name, xmlid); + } else { + node = new BookmarkEndNode(name, xmlid); + } + } + } else if (type.equals("ReferenceMark")) { + Object xMark = xPropSet.getPropertyValue("ReferenceMark"); + XNamed xNamed = (XNamed) + UnoRuntime.queryInterface(XNamed.class, xMark); + String name = xNamed.getName(); + boolean isCollapsed = (Boolean) + xPropSet.getPropertyValue("IsCollapsed"); + if (isCollapsed) { + node = new ReferenceMarkNode(name); + } else { + boolean isStart = (Boolean) + xPropSet.getPropertyValue("IsStart"); + if (isStart) { + node = new ReferenceMarkStartNode(name); + } else { + node = new ReferenceMarkEndNode(name); + } + } + } else if (type.equals("DocumentIndexMark")) { + Object xMark = xPropSet.getPropertyValue("DocumentIndexMark"); + XPropertySet xMarkSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xMark); + String name = (String) xMarkSet.getPropertyValue("PrimaryKey"); + boolean isCollapsed = (Boolean) + xPropSet.getPropertyValue("IsCollapsed"); + if (isCollapsed) { + node = new DocumentIndexMarkNode(name); + } else { + boolean isStart = (Boolean) + xPropSet.getPropertyValue("IsStart"); + if (isStart) { + node = new DocumentIndexMarkStartNode(name); + } else { + node = new DocumentIndexMarkEndNode(name); + } + } + } else if (type.equals("SoftPageBreak")) { + node = new SoftPageBreakNode(); + } else if (type.equals("Ruby")) { + boolean isStart = (Boolean) + xPropSet.getPropertyValue("IsStart"); + if (isStart) { + // ARRGH!!! stupid api... + // the text is ONLY at the start! + String ruby = (String) + xPropSet.getPropertyValue("RubyText"); + node = new RubyNode(ruby); + m_Stack.push(node); + continue; + } else { + node = m_Stack.pop(); + m_T.assure("stack error: Ruby expected; is: " + + node.toString(), node instanceof RubyNode); +// m_T.assure("stack error: ruby", +// ruby.equals(((RubyNode)node).getRubyText())); + } + } else if (type.equals("InContentMetadata")) { + Object xMeta = xPropSet.getPropertyValue("InContentMetadata"); + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xMeta); + StringPair xmlid = xMetadatable.getMetadataReference(); + node = new MetaNode(xmlid); + m_Stack.push(node); + XEnumerationAccess xEA = (XEnumerationAccess) + UnoRuntime.queryInterface(XEnumerationAccess.class, xMeta); + XEnumeration xEnumChildren = xEA.createEnumeration(); + TreeNode node2 = convertChildren(xEnumChildren); + m_T.assure("stack error: meta", node == node2); +// } else if (type.equals("MetadataField")) { +// Object xMeta = xPropSet.getPropertyValue("MetadataField"); + } else { + throw new RuntimeException("unexpected type: " + type); + } + m_Stack.peek().appendChild(node); + } + TreeNode ret = m_Stack.pop(); + return ret; + } +} + + +//---------------------------------------------------------------------- + +abstract class Inserter +{ + private XMultiServiceFactory m_xDocFactory; + XText m_xText; + XParagraphCursor m_xCursor; + + Inserter(XTextDocument xDoc) + { + m_xDocFactory = (XMultiServiceFactory) + UnoRuntime.queryInterface(XMultiServiceFactory.class, xDoc); + m_xText = xDoc.getText(); + XTextCursor xCursor = m_xText.createTextCursor(); + m_xCursor = (XParagraphCursor) + UnoRuntime.queryInterface(XParagraphCursor.class, xCursor); + } + + void initParagraph() throws Exception + { + m_xCursor.gotoStartOfParagraph(false); + m_xText.insertControlCharacter(m_xCursor, PARAGRAPH_BREAK, false); + // we split the first (empty) paragraph, and then insert into the + // second (empty) paragraph; this ensures first is always empty! + } + + void insertControlCharacter(XTextCursor xCursor, short cchar) + throws Exception + { + m_xText.insertControlCharacter(xCursor, cchar, false); + } + + void insertText(XTextCursor xCursor, String text) + { + xCursor.setString(text); + } + + void insertTextField(XTextCursor xCursor, String content) throws Exception + { + XTextContent xContent = makeTextField(content); + xContent.attach(xCursor); + } + + XTextContent makeTextField(String content) + throws Exception + { + Object xField = + m_xDocFactory.createInstance("com.sun.star.text.textfield.Author"); + XTextContent xContent = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, xField); + XPropertySet xPropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xField); + xPropSet.setPropertyValue("IsFixed", true); + xPropSet.setPropertyValue("FullName", false); + xPropSet.setPropertyValue("Content", content); + return xContent; + } + + void insertFrame(XTextRange xCursor, String name, + TextContentAnchorType anchor) throws Exception + { + XTextContent xContent = makeFrame(name, anchor); + xContent.attach(xCursor); + } + + XTextContent makeFrame(String name, TextContentAnchorType anchor) + throws Exception + { + Object xFrame = + m_xDocFactory.createInstance("com.sun.star.text.TextFrame"); + XTextContent xContent = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, xFrame); + XPropertySet xPropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xFrame); + xPropSet.setPropertyValue("AnchorType", anchor); + XNamed xNamed = (XNamed) + UnoRuntime.queryInterface(XNamed.class, xContent); + xNamed.setName(name); + return xContent; + } + + void insertFootnote(XTextCursor xCursor, String label) throws Exception + { + XTextContent xContent = makeFootnote(label); + xContent.attach(xCursor); + } + + XTextContent makeFootnote(String label) throws Exception + { + Object xNote = + m_xDocFactory.createInstance("com.sun.star.text.Footnote"); + XTextContent xContent = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, xNote); + XFootnote xFootnote = (XFootnote) + UnoRuntime.queryInterface(XFootnote.class, xNote); + xFootnote.setLabel(label); + return xContent; + } + + void insertBookmark(XTextCursor xCursor, String name, StringPair xmlid) + throws Exception + { + XTextContent xContent = makeBookmark(name); + xContent.attach(xCursor); + if (!xmlid.First.equals("")) + { + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xContent); + xMetadatable.setMetadataReference(xmlid); + } + } + + XTextContent makeBookmark(String name) throws Exception + { + Object xBookmark = + m_xDocFactory.createInstance("com.sun.star.text.Bookmark"); + XTextContent xContent = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, xBookmark); + XNamed xNamed = (XNamed) + UnoRuntime.queryInterface(XNamed.class, xContent); + xNamed.setName(name); + return xContent; + } + + void insertReferenceMark(XTextCursor xCursor, String name) throws Exception + { + XTextContent xContent = makeReferenceMark(name); + xContent.attach(xCursor); + } + + XTextContent makeReferenceMark(String name) throws Exception + { + Object xMark = + m_xDocFactory.createInstance("com.sun.star.text.ReferenceMark"); + XTextContent xContent = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, xMark); + XNamed xNamed = (XNamed) + UnoRuntime.queryInterface(XNamed.class, xContent); + xNamed.setName(name); + return xContent; + } + + void insertDocumentIndexMark(XTextCursor xCursor, String key) + throws Exception + { + XTextContent xContent = makeDocumentIndexMark(key); + xContent.attach(xCursor); + } + + XTextContent makeDocumentIndexMark(String key) throws Exception + { + Object xMark = + m_xDocFactory.createInstance("com.sun.star.text.DocumentIndexMark"); + XTextContent xContent = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, xMark); + XPropertySet xPropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xMark); + xPropSet.setPropertyValue("PrimaryKey", key); + return xContent; + } + + void insertHyperlink(XTextCursor xCursor, String url) throws Exception + { + XPropertySet xPropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xCursor); + xPropSet.setPropertyValue("HyperLinkURL", url); + } + + void insertRuby(XTextCursor xCursor, String rubytext) throws Exception + { + XPropertySet xPropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xCursor); + xPropSet.setPropertyValue("RubyText", rubytext); + } + + void insertMeta(XTextCursor xCursor, StringPair xmlid) + throws Exception + { + XTextContent xContent = makeMeta(); + xContent.attach(xCursor); + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xContent); + xMetadatable.setMetadataReference(xmlid); + } + + XTextContent makeMeta() throws Exception + { + Object xMeta = m_xDocFactory.createInstance( + "com.sun.star.text.InContentMetadata"); + XTextContent xContent = (XTextContent) + UnoRuntime.queryInterface(XTextContent.class, xMeta); + return xContent; + } + + void insertMetaField(XTextCursor xCursor, StringPair xmlid) + throws Exception + { + XTextContent xContent = makeMetaField(); + xContent.attach(xCursor); + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xContent); + xMetadatable.setMetadataReference(xmlid); + } + + XTextField makeMetaField() throws Exception + { + Object xMeta = m_xDocFactory.createInstance( + "com.sun.star.text.textfield.MetadataField"); + XTextField xContent = (XTextField) + UnoRuntime.queryInterface(XTextField.class, xMeta); + return xContent; + } + +} + +class TreeInserter extends Inserter +{ + private Map<String, XTextRange> m_BookmarkStarts; + private Map<String, XTextRange> m_ReferenceMarkStarts; + private Map<String, XTextRange> m_DocumentIndexMarkStarts; + private List<Pair<XTextRange, FrameNode>> m_FrameHints; + + TreeInserter(XTextDocument xDoc) + { + super(xDoc); + m_BookmarkStarts = new HashMap<String, XTextRange>(); + m_ReferenceMarkStarts = new HashMap<String, XTextRange>(); + m_DocumentIndexMarkStarts = new HashMap<String, XTextRange>(); + m_FrameHints = new ArrayList<Pair<XTextRange, FrameNode>>(); + } + + void insertTree(TreeNode tree) throws Exception + { + if (!tree.getType().equals("__ROOT__")) + throw new RuntimeException("insertTree: test error: no root"); + initParagraph(); + insertChildren(tree.createEnumeration()); + for (int i = 0; i < m_FrameHints.size(); ++i) { + Pair<XTextRange, FrameNode> p = m_FrameHints.get(i); + insertFrame(p.First, p.Second.getName(), p.Second.getAnchor()); + } + } + + void insertChildren(TreeNodeEnum children) throws Exception + { + while (children.hasNext()) { + m_xCursor.gotoEndOfParagraph(false); + TreeNode node = children.next(); + String type = node.getType(); + if (type.equals("Bookmark")) { + BookmarkNode bkmk = (BookmarkNode) node; + String name = bkmk.getName(); + StringPair id = bkmk.getXmlId(); + if (bkmk.isPoint()) { + insertBookmark(m_xCursor, name, id); + } else if (bkmk.isStart()) { + m_BookmarkStarts.put(name, m_xCursor.getStart()); + } else { + XTextRange xRange = m_BookmarkStarts.get(name); + XParagraphCursor xCursor = mkCursor(xRange); + insertBookmark(xCursor, name, id); + } + } else if (type.equals("ReferenceMark")) { + ReferenceMarkNode mark = (ReferenceMarkNode) node; + String name = mark.getName(); + if (mark.isPoint()) { + insertReferenceMark(m_xCursor, name); + } else if (mark.isStart()) { + m_ReferenceMarkStarts.put(name, m_xCursor.getStart()); + } else { + XTextRange xRange = m_ReferenceMarkStarts.get(name); + XParagraphCursor xCursor = mkCursor(xRange); + insertReferenceMark(xCursor, name); + } + } else if (type.equals("DocumentIndexMark")) { + DocumentIndexMarkNode mark = (DocumentIndexMarkNode) node; + String name = mark.getName(); + if (mark.isPoint()) { + insertDocumentIndexMark(m_xCursor, name); + } else if (mark.isStart()) { + m_DocumentIndexMarkStarts.put(name, m_xCursor.getStart()); + } else { + XTextRange xRange = m_DocumentIndexMarkStarts.get(name); + XParagraphCursor xCursor = mkCursor(xRange); + insertDocumentIndexMark(xCursor, name); + } + } else if (type.equals("Hyperlink")) { + HyperlinkNode href = (HyperlinkNode) node; + XTextRange xRange = m_xCursor.getStart(); + insertChildren(href.createEnumeration()); + XParagraphCursor xCursor = mkCursor(xRange); + insertHyperlink(xCursor, href.getURL()); + } else if (type.equals("Ruby")) { + RubyNode ruby = (RubyNode) node; + XTextRange xRange = m_xCursor.getStart(); + insertChildren(ruby.createEnumeration()); + XParagraphCursor xCursor = mkCursor(xRange); + insertRuby(xCursor, ruby.getRubyText()); + } else if (type.equals("InContentMetadata")) { + MetaNode meta = (MetaNode) node; + XTextRange xRange = m_xCursor.getStart(); + insertChildren(meta.createEnumeration()); + XParagraphCursor xCursor = mkCursor(xRange); + insertMeta(xCursor, meta.getXmlId()); + } else if (type.equals("MetadataField")) { + MetaFieldNode meta = (MetaFieldNode) node; + XTextRange xRange = m_xCursor.getStart(); + insertChildren(meta.createEnumeration()); + XParagraphCursor xCursor = mkCursor(xRange); + insertMetaField(xCursor, meta.getXmlId()); + } else if (type.equals("Text")) { + TextNode text = (TextNode) node; + insertText(m_xCursor, text.getContent()); + } else if (type.equals("TextField")) { + TextFieldNode field = (TextFieldNode) node; + insertTextField(m_xCursor, field.getContent()); + } else if (type.equals("Footnote")) { + FootnoteNode note = (FootnoteNode) node; + insertFootnote(m_xCursor, note.getLabel()); + } else if (type.equals("Frame")) { + FrameNode frame = (FrameNode) node; + if (frame.getAnchor() == AT_CHARACTER) { + m_FrameHints.add( new Pair(m_xCursor.getStart(), frame) ); + } else { + insertFrame(m_xCursor, frame.getName(), frame.getAnchor()); + } + } else if (type.equals("ControlCharacter")) { + ControlCharacterNode cchar = (ControlCharacterNode) node; + insertControlCharacter(m_xCursor, cchar.getChar()); + } else if (type.equals("SoftPageBreak")) { + SoftPageBreakNode spbk = (SoftPageBreakNode) node; + throw new RuntimeException("sorry, cannot test SoftPageBreak"); + } else { + throw new RuntimeException("unexpected type: " + type); + } + } + } + + XParagraphCursor mkCursor(XTextRange xRange) + { + XTextCursor xCursor = m_xText.createTextCursorByRange(xRange); + XParagraphCursor xParaCursor = (XParagraphCursor) + UnoRuntime.queryInterface(XParagraphCursor.class, xCursor); + xParaCursor.gotoEndOfParagraph(true); + return xParaCursor; + } +} + + +// FIXME: this does not account for inserted dummy characters! +class RangeInserter extends Inserter +{ + RangeInserter(XTextDocument xDoc) throws Exception + { super(xDoc); initParagraph(); } + + /* + void insertText(int pos, String text) + { + m_xCursor.gotoStartOfParagraph(false); + m_xCursor.goRight((short) pos, false); + insertText(m_xCursor, text); + } + */ + + void insertRange(Range range) throws Exception + { + m_xCursor.gotoStartOfParagraph(false); + m_xCursor.goRight(range.getStart(), false); + m_xCursor.goRight(range.getExtent(), true); + insertNode(m_xCursor, range.getNode()); + } + + void insertNode(XParagraphCursor xCursor, TreeNode node) throws Exception + { + String type = node.getType(); + if (type.equals("Bookmark")) { + BookmarkNode bkmk = (BookmarkNode) node; + if (bkmk.isPoint()) throw new RuntimeException("range only"); + insertBookmark(xCursor, bkmk.getName(), bkmk.getXmlId()); + } else if (type.equals("ReferenceMark")) { + ReferenceMarkNode mark = (ReferenceMarkNode) node; + if (mark.isPoint()) throw new RuntimeException("range only"); + insertReferenceMark(xCursor, mark.getName()); + } else if (type.equals("DocumentIndexMark")) { + DocumentIndexMarkNode mark = (DocumentIndexMarkNode) node; + if (mark.isPoint()) throw new RuntimeException("range only"); + insertDocumentIndexMark(xCursor, mark.getName()); + } else if (type.equals("Hyperlink")) { + HyperlinkNode href = (HyperlinkNode) node; + insertHyperlink(xCursor, href.getURL()); + } else if (type.equals("Ruby")) { + RubyNode ruby = (RubyNode) node; + insertRuby(xCursor, ruby.getRubyText()); + } else if (type.equals("InContentMetadata")) { + MetaNode meta = (MetaNode) node; + insertMeta(xCursor, meta.getXmlId()); + } else if (type.equals("MetadataField")) { + MetaFieldNode meta = (MetaFieldNode) node; + insertMetaField(xCursor, meta.getXmlId()); + } else if (type.equals("Text")) { + TextNode text = (TextNode) node; + insertText(xCursor, text.getContent()); + } else if (type.equals("TextField")) { + TextFieldNode field = (TextFieldNode) node; + insertTextField(m_xCursor, field.getContent()); + } else if (type.equals("Footnote")) { + FootnoteNode note = (FootnoteNode) node; + insertFootnote(m_xCursor, note.getLabel()); + } else if (type.equals("Frame")) { + FrameNode frame = (FrameNode) node; + insertFrame(xCursor, frame.getName(), frame.getAnchor()); + } else if (type.equals("ControlCharacter")) { + ControlCharacterNode cchar = (ControlCharacterNode) node; + insertControlCharacter(m_xCursor, cchar.getChar()); + } else if (type.equals("SoftPageBreak")) { + throw new RuntimeException("sorry, cannot test SoftPageBreak"); + } else { + throw new RuntimeException("unexpected type: " + type); + } + } +} + + +//---------------------------------------------------------------------- + +public class TextPortionEnumerationTest extends ComplexTestCase +{ + private XMultiServiceFactory m_xMSF = null; + private XComponentContext m_xContext = null; + private XTextDocument m_xDoc = null; + private String m_TmpDir = null; + + private int m_Count = 1; + +// public String[] getTestMethodNames() { return new String[] { "testLoadStore" }; } + public String[] getTestMethodNames() { + return new String[] { + "testText", + "testTextField", +// "testControlChar", +// "testSoftPageBreak", + "testFootnote", + "testFrameAs", + "testFrameAt", + "testBookmarkPoint", + "testBookmark", + "testBookmarkPointXmlId", + "testBookmarkXmlId", + "testRefmarkPoint", + "testRefmark", + "testToxmarkPoint", + "testToxmark", + "testHyperlink", + "testHyperlinkEmpty", + "testRuby", + "testRubyEmpty", + "testMeta", + "testMetaEmpty", + "testMetaField", + "testMetaFieldEmpty", + "testBookmark1", + "testBookmark2", + "testRefMark2", + "testRefMark3", + "testToxMark2", + "testToxMark3", + "testMarks1", + "testMarks2", + "testMarks3", + "testFrameMark1", + "testFrameMark2", + "testFrameMark3", + "testFrameMark4", + "testFrames1", + "testFrames2", + "testFrames3", + "testFrames4", + "testFrames5", + "testRubyHyperlink1", + "testRubyHyperlink2", + "testEnd1", + "testEnd2", + "testEnd3", + "testEnd4", + "testEnd5", + "testEmpty1", + "testEmpty2", + "testEmpty3", + "test1", + "testRange1", + "testRangeHyperlinkHyperlink", + "testRangeHyperlinkRuby", + "testRangeRubyHyperlink", + "testRangeRubyRuby", + "testRangeHyperlinkMeta", + "testRangeRubyMeta", + "testRangeMetaHyperlink", + "testRangeMetaRuby", + "testRangeMetaMeta", + "testRange2", + "testRange3", + "testRange4", + "testRange5", + "testRange6", + "testRange7", + "testMetaXText", + "testMetaXTextCursor", + "testMetaXTextAttachToxMark", + "testMetaXTextAttachRefMark", + "testMetaXTextAttachTextField", + "testMetaXTextAttachFootnote", + "testMetaXTextAttachMeta", + "testMetaFieldXTextField", + "testMetaFieldXPropertySet", + "testLoadStore", + }; + } + + public void before() throws Exception + { + m_xMSF = (XMultiServiceFactory) param.getMSF(); + XPropertySet xPropertySet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, m_xMSF); + Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext"); + m_xContext = (XComponentContext) + UnoRuntime.queryInterface(XComponentContext.class, defaultCtx); + assure("could not get component context.", m_xContext != null); + m_xDoc = util.WriterTools.createTextDoc(m_xMSF); + m_TmpDir = util.utils.getOfficeTemp/*Dir*/(m_xMSF); + log.println("tempdir: " + m_TmpDir); + } + + public void after() + { + if (m_xDoc != null) { + util.DesktopTools.closeDoc(m_xDoc); + m_xDoc = null; + } + } + + public void testText() throws Exception + { + TreeNode root = new TreeNode(); + TreeNode text = new TextNode("abc"); + root.appendChild(text); + doTest(root); + } + + public void testTextField() throws Exception + { + String name = mkName("ruby"); + TreeNode root = new TreeNode(); + TreeNode txtf = new TextFieldNode("abc"); + root.appendChild(txtf); + doTest(root); + } + + public void testControlChar() throws Exception + { +//FIXME this is converted to a text portion: ControlCharacter is obsolete + TreeNode root = new TreeNode(); + TreeNode cchr = new ControlCharacterNode(HARD_HYPHEN); + root.appendChild(cchr); + doTest(root); + } + + public void testSoftPageBreak() throws Exception + { +//FIXME: insert a soft page break: not done + TreeNode root = new TreeNode(); + TreeNode spbk = new SoftPageBreakNode(); + TreeNode text = new TextNode("abc"); + root.appendChild(spbk); + root.appendChild(text); + doTest(root); + } + + public void testFootnote() throws Exception + { + String name = mkName("ftn"); + TreeNode root = new TreeNode(); + TreeNode ftnd = new FootnoteNode(name); + root.appendChild(ftnd); + doTest(root); + } + + public void testFrameAs() throws Exception + { + String name = mkName("frame"); + TreeNode root = new TreeNode(); + TreeNode fram = new FrameNode(name, AS_CHARACTER); + root.appendChild(fram); + doTest(root); + } + + public void testFrameAt() throws Exception + { + String name = mkName("frame"); + TreeNode root = new TreeNode(); +// TreeNode text = new TextNode(""); // necessary? + TreeNode fram = new FrameNode(name, AT_CHARACTER); +// root.appendChild(text); + root.appendChild(fram); + doTest(root); + } + + public void testBookmarkPoint() throws Exception + { + String name = mkName("mark"); + TreeNode root = new TreeNode(); + TreeNode bkmk = new BookmarkNode(name); + TreeNode text = new TextNode("abc"); + root.appendChild(bkmk); + root.appendChild(text); + doTest(root); + } + + public void testBookmark() throws Exception + { + String name = mkName("mark"); + TreeNode root = new TreeNode(); + TreeNode bkm1 = new BookmarkStartNode(name); + TreeNode text = new TextNode("abc"); + TreeNode bkm2 = new BookmarkEndNode(name); + root.appendChild(bkm1); + root.appendChild(text); + root.appendChild(bkm2); + doTest(root); + } + + public void testBookmarkPointXmlId() throws Exception + { + String name = mkName("mark"); + StringPair id = mkId("id"); + TreeNode root = new TreeNode(); + TreeNode bkmk = new BookmarkNode(name, id); + TreeNode text = new TextNode("abc"); + root.appendChild(bkmk); + root.appendChild(text); + doTest(root); + } + + public void testBookmarkXmlId() throws Exception + { + String name = mkName("mark"); + StringPair id = mkId("id"); + TreeNode root = new TreeNode(); + TreeNode bkm1 = new BookmarkStartNode(name, id); + TreeNode text = new TextNode("abc"); + TreeNode bkm2 = new BookmarkEndNode(name, id); + root.appendChild(bkm1); + root.appendChild(text); + root.appendChild(bkm2); + doTest(root); + } + + public void testRefmarkPoint() throws Exception + { + String name = mkName("refmark"); + TreeNode root = new TreeNode(); + TreeNode rfmk = new ReferenceMarkNode(name); + TreeNode text = new TextNode("abc"); + root.appendChild(rfmk); + root.appendChild(text); + doTest(root); + } + + public void testRefmark() throws Exception + { + String name = mkName("refmark"); + TreeNode root = new TreeNode(); + TreeNode rfm1 = new ReferenceMarkStartNode(name); + TreeNode text = new TextNode("abc"); + TreeNode rfm2 = new ReferenceMarkEndNode(name); + root.appendChild(rfm1); + root.appendChild(text); + root.appendChild(rfm2); + doTest(root); + } + + public void testToxmarkPoint() throws Exception + { + String name = mkName("toxmark"); + TreeNode root = new TreeNode(); + TreeNode txmk = new DocumentIndexMarkNode(name); + TreeNode text = new TextNode("abc"); + root.appendChild(txmk); + root.appendChild(text); + doTest(root); + } + + public void testToxmark() throws Exception + { + String name = mkName("toxmark"); + TreeNode root = new TreeNode(); + TreeNode txm1 = new DocumentIndexMarkStartNode(name); + TreeNode text = new TextNode("abc"); + TreeNode txm2 = new DocumentIndexMarkEndNode(name); + root.appendChild(txm1); + root.appendChild(text); + root.appendChild(txm2); + doTest(root); + } + + public void testHyperlink() throws Exception + { + String name = mkName("url"); + TreeNode root = new TreeNode(); + TreeNode href = new HyperlinkNode(name); + TreeNode text = new TextNode("abc"); + href.appendChild(text); + root.appendChild(href); + doTest(root); + } + + public void testHyperlinkEmpty() throws Exception + { + String name = mkName("url"); + TreeNode root = new TreeNode(); + TreeNode href = new HyperlinkNode(name); + TreeNode text = new TextNode(""); + href.appendChild(text); + root.appendChild(href); + doTest(root); + } + + public void testRuby() throws Exception + { + String name = mkName("ruby"); + TreeNode root = new TreeNode(); + TreeNode ruby = new RubyNode(name); + TreeNode text = new TextNode("abc"); + ruby.appendChild(text); + root.appendChild(ruby); + doTest(root); + } + + public void testRubyEmpty() throws Exception + { + // BUG: #i91534# + String name = mkName("ruby"); + TreeNode root = new TreeNode(); + TreeNode ruby = new RubyNode(name); + root.appendChild(ruby); + doTest(root); + } + + public void testMeta() throws Exception + { + StringPair id = new StringPair("content.xml", mkName("id")); + TreeNode root = new TreeNode(); + TreeNode meta = new MetaNode(id); + TreeNode text = new TextNode("abc"); + root.appendChild(new TextNode("123")); + meta.appendChild(text); + root.appendChild(meta); + doTest(root); + } + + public void testMetaEmpty() throws Exception + { + StringPair id = new StringPair("content.xml", mkName("id")); + TreeNode root = new TreeNode(); + TreeNode meta = new MetaNode(id); +// TreeNode text = new TextNode(""); +// meta.appendChild(text); + root.appendChild(meta); + doTest(root); + } + + public void testMetaField() throws Exception + { + StringPair id = new StringPair("content.xml", mkName("id")); + TreeNode root = new TreeNode(); + TreeNode meta = new MetaFieldNode(id); + TreeNode text = new TextNode("abc"); + root.appendChild(new TextNode("123")); + meta.appendChild(text); + root.appendChild(meta); + doTest(root); + } + + public void testMetaFieldEmpty() throws Exception + { + StringPair id = new StringPair("content.xml", mkName("id")); + TreeNode root = new TreeNode(); + TreeNode meta = new MetaFieldNode(id); +// TreeNode text = new TextNode(""); +// meta.appendChild(text); + root.appendChild(meta); + doTest(root); + } + + public void testBookmark1() throws Exception + { + String name1 = mkName("mark"); + String name2 = mkName("mark"); + String name3 = mkName("mark"); + TreeNode root = new TreeNode(); + root.appendChild( new BookmarkStartNode(name1) ); + root.appendChild( new BookmarkNode(name2) ); + root.appendChild( new BookmarkStartNode(name3) ); + root.appendChild( new TextNode("abc") ); + root.appendChild( new BookmarkEndNode(name1) ); + root.appendChild( new TextNode("de") ); + root.appendChild( new BookmarkEndNode(name3) ); + doTest(root); + } + + public void testBookmark2() throws Exception + { + String name1 = mkName("mark"); + String name2 = mkName("mark"); + String name3 = mkName("mark"); + TreeNode root = new TreeNode(); + root.appendChild( new BookmarkStartNode(name1) ); + root.appendChild( new TextNode("abc") ); + root.appendChild( new BookmarkNode(name2) ); + root.appendChild( new BookmarkStartNode(name3) ); + root.appendChild( new BookmarkEndNode(name1) ); + root.appendChild( new TextNode("de") ); + root.appendChild( new BookmarkEndNode(name3) ); + doTest(root); + } + + public void testRefMark2() throws Exception + { + String name1 = mkName("refmark"); + TreeNode root = new TreeNode(); + root.appendChild( new ReferenceMarkStartNode(name1) ); + root.appendChild( new TextNode("abc") ); + // BUG: #i102541# (this is actually not unoportenum's fault) + root.appendChild( new ReferenceMarkEndNode(name1) ); + root.appendChild( new TextNode("de") ); + doTest(root); + } + + public void testRefMark3() throws Exception + { + String name1 = mkName("refmark"); + String name2 = mkName("refmark"); + TreeNode root = new TreeNode(); + root.appendChild( new ReferenceMarkStartNode(name1) ); + root.appendChild( new ReferenceMarkStartNode(name2) ); + root.appendChild( new TextNode("abc") ); + root.appendChild( new ReferenceMarkEndNode(name2) ); + root.appendChild( new ReferenceMarkEndNode(name1) ); + root.appendChild( new TextNode("de") ); + doTest(root); + } + + public void testToxMark2() throws Exception + { + String name1 = mkName("toxmark"); + TreeNode root = new TreeNode(); + root.appendChild( new DocumentIndexMarkStartNode(name1) ); + root.appendChild( new TextNode("abc") ); + root.appendChild( new DocumentIndexMarkEndNode(name1) ); + root.appendChild( new TextNode("de") ); + doTest(root); + } + + public void testToxMark3() throws Exception + { + String name1 = mkName("toxmark"); + String name2 = mkName("toxmark"); + TreeNode root = new TreeNode(); + root.appendChild( new DocumentIndexMarkStartNode(name1) ); + root.appendChild( new DocumentIndexMarkStartNode(name2) ); + root.appendChild( new TextNode("abc") ); + root.appendChild( new DocumentIndexMarkEndNode(name2) ); + root.appendChild( new DocumentIndexMarkEndNode(name1) ); + root.appendChild( new TextNode("de") ); + doTest(root); + } + + public void testMarks1() throws Exception + { + String name1 = mkName("bookmark"); + String name2 = mkName("toxmark"); + String name3 = mkName("refmark"); + String name4 = mkName("toxmark"); + TreeNode root = new TreeNode(); + root.appendChild( new BookmarkStartNode(name1) ); + root.appendChild( new DocumentIndexMarkNode(name2) ); + root.appendChild( new ReferenceMarkStartNode(name3) ); + root.appendChild( new TextNode("abc") ); + root.appendChild( new BookmarkEndNode(name1) ); + root.appendChild( new DocumentIndexMarkStartNode(name4) ); + root.appendChild( new TextNode("de") ); + root.appendChild( new DocumentIndexMarkEndNode(name4) ); + root.appendChild( new ReferenceMarkEndNode(name3) ); + doTest(root); + } + + public void testMarks2() throws Exception + { + String name1 = mkName("bookmark"); + String name2 = mkName("refmark"); + String name3 = mkName("refmark"); + String name4 = mkName("toxmark"); + String name5 = mkName("refmark"); + TreeNode root = new TreeNode(); + root.appendChild( new BookmarkStartNode(name1) ); + root.appendChild( new ReferenceMarkNode(name2) ); + root.appendChild( new ReferenceMarkStartNode(name3) ); + root.appendChild( new TextNode("abc") ); + root.appendChild( new DocumentIndexMarkStartNode(name4) ); + root.appendChild( new ReferenceMarkStartNode(name5) ); + // BUG: #i102541# (this is actually not unoportenum's fault) + root.appendChild( new ReferenceMarkEndNode(name3) ); + root.appendChild( new TextNode("de") ); + root.appendChild( new DocumentIndexMarkEndNode(name4) ); + root.appendChild( new BookmarkEndNode(name1) ); + root.appendChild( new ReferenceMarkEndNode(name5) ); + doTest(root); + } + + public void testMarks3() throws Exception + { + String name1 = mkName("bookmark"); + String name2 = mkName("refmark"); + String name3 = mkName("refmark"); + String name4 = mkName("toxmark"); + String name5 = mkName("refmark"); + TreeNode root = new TreeNode(); + root.appendChild( new BookmarkStartNode(name1) ); + root.appendChild( new DocumentIndexMarkNode(name2) ); + root.appendChild( new DocumentIndexMarkStartNode(name3) ); + root.appendChild( new TextNode("abc") ); + root.appendChild( new ReferenceMarkStartNode(name4) ); + root.appendChild( new DocumentIndexMarkStartNode(name5) ); + root.appendChild( new DocumentIndexMarkEndNode(name3) ); + root.appendChild( new TextNode("de") ); + root.appendChild( new ReferenceMarkEndNode(name4) ); + root.appendChild( new BookmarkEndNode(name1) ); + root.appendChild( new DocumentIndexMarkEndNode(name5) ); + doTest(root); + } + + public void testFrameMark1() throws Exception + { + String name1 = mkName("bookmark"); + String name2 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new TextNode("abc") ); + root.appendChild( new BookmarkNode(name1) ); + root.appendChild( new TextNode("de") ); + root.appendChild( new FrameNode(name2, AS_CHARACTER) ); + doTest(root); + } + + public void testFrameMark2() throws Exception + { + // BUG: #i98530# + String name1 = mkName("bookmark"); + String name2 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new TextNode("abc") ); + root.appendChild( new BookmarkNode(name1) ); + root.appendChild( new TextNode("de") ); + root.appendChild( new FrameNode(name2, AT_CHARACTER) ); + doTest(root); + } + + public void testFrameMark3() throws Exception + { + String name1 = mkName("frame"); + String name2 = mkName("bookmark"); + TreeNode root = new TreeNode(); + root.appendChild( new TextNode("abc") ); + root.appendChild( new FrameNode(name1, AS_CHARACTER) ); + root.appendChild( new TextNode("de") ); + root.appendChild( new BookmarkNode(name2) ); + doTest(root); + } + + public void testFrameMark4() throws Exception + { + String name1 = mkName("frame"); + String name2 = mkName("bookmark"); + TreeNode root = new TreeNode(); + root.appendChild( new TextNode("abc") ); + root.appendChild( new FrameNode(name1, AT_CHARACTER) ); + root.appendChild( new TextNode("de") ); + root.appendChild( new BookmarkNode(name2) ); + doTest(root); + } + + public void testFrames1() throws Exception + { + String name1 = mkName("frame"); + String name2 = mkName("frame"); + String name3 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new FrameNode(name1, AT_CHARACTER) ); + root.appendChild( new FrameNode(name2, AT_CHARACTER) ); + root.appendChild( new FrameNode(name3, AT_CHARACTER) ); + doTest(root); + } + + public void testFrames2() throws Exception + { + String name1 = mkName("frame"); + String name2 = mkName("frame"); + String name3 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new FrameNode(name1, AS_CHARACTER) ); + root.appendChild( new FrameNode(name2, AS_CHARACTER) ); + root.appendChild( new FrameNode(name3, AS_CHARACTER) ); + doTest(root); + } + + public void testFrames3() throws Exception + { + String name1 = mkName("frame"); + String name2 = mkName("frame"); + String name3 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new FrameNode(name1, AT_CHARACTER) ); + root.appendChild( new FrameNode(name2, AS_CHARACTER) ); + root.appendChild( new FrameNode(name3, AT_CHARACTER) ); + doTest(root); + } + + public void testFrames4() throws Exception + { + String name1 = mkName("frame"); + String name2 = mkName("frame"); + String name3 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new FrameNode(name1, AT_CHARACTER) ); + root.appendChild( new FrameNode(name2, AT_CHARACTER) ); + root.appendChild( new FrameNode(name3, AS_CHARACTER) ); + doTest(root); + } + + public void testFrames5() throws Exception + { + String name1 = mkName("frame"); + String name2 = mkName("frame"); + String name3 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new FrameNode(name1, AS_CHARACTER) ); + root.appendChild( new FrameNode(name2, AT_CHARACTER) ); + root.appendChild( new FrameNode(name3, AT_CHARACTER) ); + doTest(root); + } + + public void testRubyHyperlink1() throws Exception + { + String name1 = mkName("ruby"); + String name2 = mkName("url"); + TreeNode root = new TreeNode(); + TreeNode ruby = new RubyNode(name1); + TreeNode href = new HyperlinkNode(name2); + href.appendChild( new TextNode("abc") ); + ruby.appendChild(href); + root.appendChild(ruby); + doTest(root); + } + + public void testRubyHyperlink2() throws Exception + { + String name1 = mkName("url"); + String name2 = mkName("ruby"); + TreeNode root = new TreeNode(); + TreeNode href = new HyperlinkNode(name1); + TreeNode ruby = new RubyNode(name2); + ruby.appendChild( new TextNode("abc") ); + href.appendChild(ruby); + root.appendChild(href); + doTest(root); + } + + public void testEnd1() throws Exception + { + String name1 = mkName("bookmark"); + String name2 = mkName("toxmark"); + String name3 = mkName("refmark"); + TreeNode root = new TreeNode(); + root.appendChild( new TextNode("abc") ); + root.appendChild( new BookmarkNode(name1) ); + root.appendChild( new DocumentIndexMarkNode(name2) ); + root.appendChild( new ReferenceMarkNode(name3) ); + doTest(root); + } + + public void testEnd2() throws Exception + { + String name1 = mkName("bookmark"); + String name2 = mkName("frame"); + String name3 = mkName("refmark"); + String name4 = mkName("frame"); + String name5 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new TextNode("abc") ); + root.appendChild( new BookmarkNode(name1) ); + root.appendChild( new FrameNode(name2, AT_CHARACTER) ); + root.appendChild( new ReferenceMarkNode(name3) ); + root.appendChild( new FrameNode(name4, AT_CHARACTER) ); + root.appendChild( new FrameNode(name5, AT_CHARACTER) ); + doTest(root); + } + + public void testEnd3() throws Exception + { + String name1 = mkName("ftn"); + String name2 = mkName("toxmark"); + TreeNode root = new TreeNode(); + root.appendChild( new TextNode("abc") ); + root.appendChild( new FootnoteNode(name1) ); + root.appendChild( new DocumentIndexMarkNode(name2) ); + doTest(root); + } + + public void testEnd4() throws Exception + { + String name1 = mkName("bookmark"); + String name2 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new BookmarkStartNode(name1) ); + root.appendChild( new TextNode("abc") ); + root.appendChild( new FrameNode(name2, AS_CHARACTER) ); + root.appendChild( new BookmarkEndNode(name1) ); + doTest(root); + } + + public void testEnd5() throws Exception + { + String name1 = mkName("refmark"); + String name2 = mkName("ruby"); + TreeNode root = new TreeNode(); + root.appendChild( new ReferenceMarkStartNode(name1) ); + root.appendChild( new TextNode("abc") ); + TreeNode ruby = new RubyNode(name2); + ruby.appendChild( new TextFieldNode("de") ); + root.appendChild(ruby); + root.appendChild( new ReferenceMarkEndNode(name1) ); + doTest(root); + } + + public void testEmpty1() throws Exception + { + String name1 = mkName("refmark"); + String name2 = mkName("toxmark"); + String name3 = mkName("bookmark"); + String name4 = mkName("frame"); + String name7 = mkName("refmark"); + String name8 = mkName("toxmark"); + String name9 = mkName("bookmark"); + String nameA = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new ReferenceMarkNode(name1) ); + root.appendChild( new DocumentIndexMarkNode(name2) ); + root.appendChild( new BookmarkNode(name3) ); + root.appendChild( new FrameNode(name4, AT_CHARACTER) ); + root.appendChild( new ReferenceMarkNode(name7) ); + root.appendChild( new DocumentIndexMarkNode(name8) ); + root.appendChild( new BookmarkNode(name9) ); + root.appendChild( new FrameNode(nameA, AT_CHARACTER) ); + doTest(root); + } + + public void testEmpty2() throws Exception + { + String name3 = mkName("bookmark"); + String name4 = mkName("frame"); + String name9 = mkName("bookmark"); + String nameA = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new BookmarkNode(name3) ); + root.appendChild( new FrameNode(name4, AT_CHARACTER) ); + root.appendChild( new BookmarkNode(name9) ); + root.appendChild( new FrameNode(nameA, AT_CHARACTER) ); + doTest(root); + } + + public void testEmpty3() throws Exception + { + String name1 = mkName("refmark"); + String name2 = mkName("toxmark"); + String name3 = mkName("bookmark"); + String name4 = mkName("frame"); + String name5 = mkName("url"); + String name6 = mkName("ruby"); + String name7 = mkName("refmark"); + String name8 = mkName("toxmark"); + String name9 = mkName("bookmark"); + String nameA = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new ReferenceMarkNode(name1) ); + root.appendChild( new DocumentIndexMarkNode(name2) ); + root.appendChild( new BookmarkNode(name3) ); + root.appendChild( new FrameNode(name4, AT_CHARACTER) ); + /* currently empty hyperlinks may get eaten... + TreeNode href = new HyperlinkNode(name5); + href.appendChild( new TextNode("") ); + root.appendChild(href); + */ + TreeNode ruby = new RubyNode(name6); + root.appendChild(ruby); + root.appendChild( new ReferenceMarkNode(name7) ); + root.appendChild( new DocumentIndexMarkNode(name8) ); + root.appendChild( new BookmarkNode(name9) ); + root.appendChild( new FrameNode(nameA, AT_CHARACTER) ); + doTest(root); + } + + public void test1() throws Exception + { + String name1 = mkName("frame"); + String name2 = mkName("bookmark"); + String name3 = mkName("ruby"); + String name4 = mkName("ftn"); + String name5 = mkName("frame"); + TreeNode root = new TreeNode(); + root.appendChild( new FrameNode(name1, AT_CHARACTER) ); + root.appendChild( new BookmarkStartNode(name2) ); + root.appendChild( new TextNode("abc") ); + TreeNode ruby = new RubyNode(name3); + ruby.appendChild( new TextNode("de") ); + ruby.appendChild( new FootnoteNode(name4) ); + ruby.appendChild( new BookmarkEndNode(name2) ); + root.appendChild(ruby); + root.appendChild( new TextNode("fg") ); + root.appendChild( new FrameNode(name5, AT_CHARACTER) ); + root.appendChild( new TextFieldNode("h") ); + doTest(root); + } + + /* some range tests for the insertion: these are for the current + API which treats hyperlinks and rubys not as entities, but as formatting + attributes; if these ever become entities, they should not be split! + */ + + public void testRange1() throws Exception + { + String name1 = mkName("url"); + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("12345"); + inserter.insertRange(new Range(0, 0, text)); + TreeNode url1 = new HyperlinkNode(name1); + Range range1 = new Range(0, 5, url1); + inserter.insertRange(range1); + TreeNode root = new TreeNode(); + root.appendChild( url1 ); + url1.appendChild( text ); + doTest(root, false); + } + + public void testRangeHyperlinkHyperlink() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode url1 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(1, 4, url1) ); + // overlap left + TreeNode url2 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(0, 2, url2) ); + TreeNode root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("12") ) ) + .appendChild( url1.dup().appendChild( new TextNode("34") ) ) + .appendChild( new TextNode("56789") ); + doTest(root, false); + // overlap right + TreeNode url3 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(3, 7, url3) ); + root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("12") ) ) + .appendChild( url1.dup().appendChild( new TextNode("3") ) ) + .appendChild( url3.dup().appendChild( new TextNode("4567") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + // around + TreeNode url4 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(3, 7, url4) ); + root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("12") ) ) + .appendChild( url1.dup().appendChild( new TextNode("3") ) ) + .appendChild( url4.dup().appendChild( new TextNode("4567") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + // inside + TreeNode url5 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(4, 6, url5) ); + root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("12") ) ) + .appendChild( url1.dup().appendChild( new TextNode("3") ) ) + .appendChild( url4.dup().appendChild( new TextNode("4") ) ) + .appendChild( url5.dup().appendChild( new TextNode("56") ) ) + .appendChild( url4.dup().appendChild( new TextNode("7") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + } + + public void testRangeHyperlinkRuby() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode url1 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(1, 4, url1) ); + // overlap left + TreeNode rby2 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(0, 2, rby2) ); + TreeNode root = new TreeNode() + .appendChild( rby2.dup() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( url1.dup().appendChild( new TextNode("34") ) ) + .appendChild( new TextNode("56789") ); + doTest(root, false); + // overlap right + TreeNode rby3 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(3, 5, rby3) ); + root = new TreeNode() + .appendChild( rby2.dup() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( url1.dup().appendChild( new TextNode("3") ) ) + .appendChild( rby3.dup() + .appendChild( url1.dup().appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + // around + TreeNode rby4 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(2, 3, rby4) ); + root = new TreeNode() + .appendChild( rby2.dup() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( rby4.dup() + .appendChild( url1.dup().appendChild( new TextNode("3") ) ) ) + .appendChild( rby3.dup() + .appendChild( url1.dup().appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + // inside + TreeNode url5 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(6, 9, url5) ); + TreeNode rby6 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(7, 8, rby6) ); + root = new TreeNode() + .appendChild( rby2.dup() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( rby4.dup() + .appendChild( url1.dup().appendChild( new TextNode("3") ) ) ) + .appendChild( rby3.dup() + .appendChild( url1.dup().appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6") ) + .appendChild( url5.dup().appendChild( new TextNode("7") ) ) + .appendChild( rby6.dup() + .appendChild( url5.dup().appendChild( new TextNode("8") ) ) ) + .appendChild( url5.dup().appendChild( new TextNode("9") ) ); + doTest(root, false); + } + + public void testRangeRubyHyperlink() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode rby1 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(1, 6, rby1) ); + // overlap left + TreeNode url2 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(0, 3, url2) ); + TreeNode root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("1") ) ) + .appendChild( rby1.dup() + .appendChild( url2.dup().appendChild( new TextNode("23") ) ) + .appendChild( new TextNode("456") ) ) + .appendChild( new TextNode("789") ); + doTest(root, false); + // overlap right + TreeNode url3 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(5, 7, url3) ); + root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("1") ) ) + .appendChild( rby1.dup() + .appendChild( url2.dup().appendChild( new TextNode("23") ) ) + .appendChild( new TextNode("45") ) + .appendChild( url3.dup().appendChild( new TextNode("6") ) ) ) + .appendChild( url3.dup().appendChild( new TextNode("7") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + // around (not quite, due to API) + TreeNode url4 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(1, 8, url4) ); + root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("1") ) ) + .appendChild( rby1.dup() + .appendChild( url4.dup() + .appendChild( new TextNode("23456") ) ) ) + .appendChild( url4.dup().appendChild( new TextNode("78") ) ) + .appendChild( new TextNode("9") ); + doTest(root, false); + // inside + TreeNode url5 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(3, 5, url5) ); + root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("1") ) ) + .appendChild( rby1.dup() + .appendChild( url4.dup() + .appendChild( new TextNode("23") ) ) + .appendChild( url5.dup() + .appendChild( new TextNode("45") ) ) + .appendChild( url4.dup() + .appendChild( new TextNode("6") ) ) ) + .appendChild( url4.dup().appendChild( new TextNode("78") ) ) + .appendChild( new TextNode("9") ); + doTest(root, false); + } + + public void testRangeRubyRuby() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode rby1 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(1, 4, rby1) ); + // overlap left + TreeNode rby2 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(0, 2, rby2) ); + TreeNode root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("12") ) ) + .appendChild( rby1.dup().appendChild( new TextNode("34") ) ) + .appendChild( new TextNode("56789") ); + doTest(root, false); + // overlap right + TreeNode rby3 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(3, 7, rby3) ); + root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("12") ) ) + .appendChild( rby1.dup().appendChild( new TextNode("3") ) ) + .appendChild( rby3.dup().appendChild( new TextNode("4567") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + // around + TreeNode rby4 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(3, 7, rby4) ); + root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("12") ) ) + .appendChild( rby1.dup().appendChild( new TextNode("3") ) ) + .appendChild( rby4.dup().appendChild( new TextNode("4567") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + // inside + TreeNode rby5 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(4, 6, rby5) ); + root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("12") ) ) + .appendChild( rby1.dup().appendChild( new TextNode("3") ) ) + .appendChild( rby4.dup().appendChild( new TextNode("4") ) ) + .appendChild( rby5.dup().appendChild( new TextNode("56") ) ) + .appendChild( rby4.dup().appendChild( new TextNode("7") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + } + + public void testRangeHyperlinkMeta() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode url1 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(1, 4, url1) ); + // overlap left + TreeNode met2 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(0, 2, met2) ); + TreeNode root = new TreeNode() + .appendChild( met2.dup() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( url1.dup().appendChild( new TextNode("34") ) ) + .appendChild( new TextNode("56789") ); + doTest(root, false); + // overlap right + TreeNode met3 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(4/*-1*/, 6/*-1*/, met3) ); + root = new TreeNode() + .appendChild( met2.dup() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( url1.dup().appendChild( new TextNode("3") ) ) + .appendChild( met3.dup() + .appendChild( url1.dup().appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + // around + TreeNode met4 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(3/*-1*/, 4/*-1*/, met4) ); + root = new TreeNode() + .appendChild( met2.dup() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( met4.dup() + .appendChild( url1.dup().appendChild( new TextNode("3") ) ) ) + .appendChild( met3.dup() + .appendChild( url1.dup().appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + // inside + TreeNode url5 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(9/*-3*/, 12/*-3*/, url5) ); + TreeNode met6 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(10/*-3*/, 11/*-3*/, met6) ); + root = new TreeNode() + .appendChild( met2.dup() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( met4.dup() + .appendChild( url1.dup().appendChild( new TextNode("3") ) ) ) + .appendChild( met3.dup() + .appendChild( url1.dup().appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6") ) + .appendChild( url5.dup().appendChild( new TextNode("7") ) ) + .appendChild( met6.dup() + .appendChild( url5.dup().appendChild( new TextNode("8") ) ) ) + .appendChild( url5.dup().appendChild( new TextNode("9") ) ); + doTest(root, false); + } + + public void testRangeRubyMeta() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode rby1 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(1, 4, rby1) ); + // overlap left + TreeNode met2 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(0, 2, met2) ); + TreeNode root = new TreeNode() + .appendChild( met2.dup() + .appendChild( new TextNode("1") ) + .appendChild( rby1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( rby1.dup().appendChild( new TextNode("34") ) ) + .appendChild( new TextNode("56789") ); + doTest(root, false); + // overlap right + TreeNode met3 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(4/*-1*/, 6/*-1*/, met3) ); + root = new TreeNode() + .appendChild( met2.dup() + .appendChild( new TextNode("1") ) + .appendChild( rby1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( rby1.dup().appendChild( new TextNode("3") ) ) + .appendChild( met3.dup() + .appendChild( rby1.dup().appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + // around + TreeNode met4 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(3/*-1*/, 4/*-1*/, met4) ); + root = new TreeNode() + .appendChild( met2.dup() + .appendChild( new TextNode("1") ) + .appendChild( rby1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( met4.dup() + .appendChild( rby1.dup().appendChild( new TextNode("3") ) ) ) + .appendChild( met3.dup() + .appendChild( rby1.dup().appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + // inside + TreeNode rby5 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(9/*-3*/, 12/*-3*/, rby5) ); + TreeNode met6 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(10/*-3*/, 11/*-3*/, met6) ); + root = new TreeNode() + .appendChild( met2.dup() + .appendChild( new TextNode("1") ) + .appendChild( rby1.dup().appendChild( new TextNode("2") ) ) ) + .appendChild( met4.dup() + .appendChild( rby1.dup().appendChild( new TextNode("3") ) ) ) + .appendChild( met3.dup() + .appendChild( rby1.dup().appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6") ) + .appendChild( rby5.dup() + .appendChild( new TextNode("7") ) + .appendChild( met6.dup() + .appendChild( new TextNode("8") ) ) + .appendChild( new TextNode("9") ) ); + doTest(root, false); + } + + public void testRangeMetaHyperlink() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode met1 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(1, 6, met1) ); + // overlap left + TreeNode url2 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(0, 4/*-1*/, url2) ); + TreeNode root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("1") ) ) + .appendChild( met1.dup() + .appendChild( url2.dup().appendChild( new TextNode("23") ) ) + .appendChild( new TextNode("456") ) ) + .appendChild( new TextNode("789") ); + doTest(root, false); + // overlap right + TreeNode url3 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(6/*-1*/, 8/*-1*/, url3) ); + root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("1") ) ) + .appendChild( met1.dup() + .appendChild( url2.dup().appendChild( new TextNode("23") ) ) + .appendChild( new TextNode("45") ) + .appendChild( url3.dup().appendChild( new TextNode("6") ) ) ) + .appendChild( url3.dup().appendChild( new TextNode("7") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + // around (not quite, due to API) + TreeNode url4 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(1, 9/*-1*/, url4) ); + root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("1") ) ) + .appendChild( met1.dup() + .appendChild( url4.dup() + .appendChild( new TextNode("23456") ) ) ) + .appendChild( url4.dup().appendChild( new TextNode("78") ) ) + .appendChild( new TextNode("9") ); + doTest(root, false); + // inside + TreeNode url5 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(4/*-1*/, 6/*-1*/, url5) ); + root = new TreeNode() + .appendChild( url2.dup().appendChild( new TextNode("1") ) ) + .appendChild( met1.dup() + .appendChild( url4.dup() + .appendChild( new TextNode("23") ) ) + .appendChild( url5.dup() + .appendChild( new TextNode("45") ) ) + .appendChild( url4.dup() + .appendChild( new TextNode("6") ) ) ) + .appendChild( url4.dup().appendChild( new TextNode("78") ) ) + .appendChild( new TextNode("9") ); + doTest(root, false); + } + + public void testRangeMetaRuby() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode met1 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(1, 5, met1) ); + // overlap left + TreeNode rby2 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(0, 3/*-1*/, rby2) ); + TreeNode root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) + .appendChild( met1.dup() + .appendChild( rby2.dup().appendChild( new TextNode("2") ) ) + .appendChild( new TextNode("345") ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + // overlap right + TreeNode rby3 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(5/*-1*/, 7/*-1*/, rby3) ); + root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) + .appendChild( met1.dup() + .appendChild( rby2.dup().appendChild( new TextNode("2") ) ) + .appendChild( new TextNode("34") ) + .appendChild( rby3.dup().appendChild( new TextNode("5") ) ) ) + .appendChild( rby3.dup().appendChild( new TextNode("6") ) ) + .appendChild( new TextNode("789") ); + doTest(root, false); + // around + TreeNode rby4 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(1, 7/*-1*/, rby4) ); + root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) + .appendChild( rby4.dup() + .appendChild( met1.dup() + .appendChild( new TextNode("2345") ) ) + .appendChild( new TextNode("6") ) ) + .appendChild( new TextNode("789") ); + doTest(root, false); + // inside + TreeNode met5 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(7/*-1*/, 9/*-1*/, met5) ); + TreeNode rby6 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(9/*-2*/, 10/*-2*/, rby6) ); + root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) + .appendChild( rby4.dup() + .appendChild( met1.dup() + .appendChild( new TextNode("2345") ) ) + .appendChild( new TextNode("6") ) ) + .appendChild( met5.dup() + .appendChild( new TextNode("7") ) + .appendChild( rby6.dup() + .appendChild( new TextNode("8") ) ) ) + .appendChild( new TextNode("9") ); + doTest(root, false); + // inside, with invalid range that includes the dummy char + TreeNode rby7 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(7/*-1*/, 9/*-2*/, rby7) ); + root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) + .appendChild( rby4.dup() + .appendChild( met1.dup() + .appendChild( new TextNode("2345") ) ) + .appendChild( new TextNode("6") ) ) + .appendChild( met5.dup() + .appendChild( rby7.dup() + .appendChild( new TextNode("7") ) ) + .appendChild( rby6.dup() + .appendChild( new TextNode("8") ) ) ) + .appendChild( new TextNode("9") ); + doTest(root, false); + // around, at same position as meta + TreeNode rby8 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(7/*-1*/, 10/*-2*/, rby8) ); + root = new TreeNode() + .appendChild( rby2.dup().appendChild( new TextNode("1") ) ) + .appendChild( rby4.dup() + .appendChild( met1.dup() + .appendChild( new TextNode("2345") ) ) + .appendChild( new TextNode("6") ) ) + .appendChild( rby8.dup() + .appendChild( met5.dup() + .appendChild( new TextNode("78") ) ) ) + .appendChild( new TextNode("9") ); + doTest(root, false); + } + + public void testRangeMetaMeta() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode met1 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(3, 6, met1) ); + // overlap left + TreeNode met2 = new MetaNode( mkId("id") ); + try { + inserter.insertRange( new Range(0, 4, met2) ); + assure("testRangeMetaMeta: overlap left allowed", false); + } catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ } + TreeNode root = new TreeNode() + .appendChild( new TextNode("123") ) + .appendChild( met1.dup().appendChild( new TextNode("456") ) ) + .appendChild( new TextNode("789") ); + doTest(root, false); + // overlap right + TreeNode met3 = new MetaNode( mkId("id") ); + try { + inserter.insertRange( new Range(5/*-1*/, 8/*-1*/, met3) ); + assure("testRangeMetaMeta: overlap right allowed", false); + } catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ } + root = new TreeNode() + .appendChild( new TextNode("123") ) + .appendChild( met1.dup().appendChild( new TextNode("456") ) ) + .appendChild( new TextNode("789") ); + doTest(root, false); + // around + TreeNode met4 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(3, 7/*-1*/, met4) ); + root = new TreeNode() + .appendChild( new TextNode("123") ) + .appendChild( met4.dup() + .appendChild( met1.dup().appendChild( new TextNode("456") ) ) ) + .appendChild( new TextNode("789") ); + doTest(root, false); + // inside + TreeNode met5 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(6/*-2*/, 8/*-2*/, met5) ); + root = new TreeNode() + .appendChild( new TextNode("123") ) + .appendChild( met4.dup() + .appendChild( met1.dup() + .appendChild( new TextNode("4") ) + .appendChild( met5.dup() + .appendChild( new TextNode("56") ) ) ) ) + .appendChild( new TextNode("789") ); + doTest(root, false); + } + + public void testRange2() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode met1 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(1, 8, met1) ); + TreeNode met2 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(3/*-1*/, 8/*-1*/, met2) ); + TreeNode met3 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(5/*-2*/, 8/*-2*/, met3) ); + TreeNode root = new TreeNode() + .appendChild( new TextNode("1") ) + .appendChild( met1.dup() + .appendChild( new TextNode("2") ) + .appendChild( met2.dup() + .appendChild( new TextNode("3") ) + .appendChild( met3.dup() + .appendChild( new TextNode("456") ) ) + .appendChild( new TextNode("7") ) ) + .appendChild( new TextNode("8") ) ) + .appendChild( new TextNode("9") ); + doTest(root, false); + // split ruby at every meta start! + TreeNode rby4 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(0, 7/*-3*/, rby4) ); + root = new TreeNode() + .appendChild( rby4.dup() + .appendChild( new TextNode("1") ) ) + .appendChild( met1.dup() + .appendChild( rby4.dup() + .appendChild( new TextNode("2") ) ) + .appendChild( met2.dup() + .appendChild( rby4.dup() + .appendChild( new TextNode("3") ) ) + .appendChild( met3.dup() + .appendChild( rby4.dup() + .appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("56") ) ) + .appendChild( new TextNode("7") ) ) + .appendChild( new TextNode("8") ) ) + .appendChild( new TextNode("9") ); + doTest(root, false); + // split ruby at every meta end! + TreeNode rby5 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(8/*-3*/, 12/*-3*/, rby5) ); + root = new TreeNode() + .appendChild( rby4.dup() + .appendChild( new TextNode("1") ) ) + .appendChild( met1.dup() + .appendChild( rby4.dup() + .appendChild( new TextNode("2") ) ) + .appendChild( met2.dup() + .appendChild( rby4.dup() + .appendChild( new TextNode("3") ) ) + .appendChild( met3.dup() + .appendChild( rby4.dup() + .appendChild( new TextNode("4") ) ) + .appendChild( new TextNode("5") ) + .appendChild( rby5.dup() + .appendChild( new TextNode("6") ) ) ) + .appendChild( rby5.dup() + .appendChild( new TextNode("7") ) ) ) + .appendChild( rby5.dup() + .appendChild( new TextNode("8") ) ) ) + .appendChild( rby5.dup() + .appendChild( new TextNode("9") ) ); + doTest(root, false); + } + + public void testRange3() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode rby1 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(0, 9, rby1) ); + TreeNode met2 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(2, 7, met2) ); + TreeNode root = new TreeNode() + .appendChild( rby1.dup() + .appendChild( new TextNode("12") ) + .appendChild( met2.dup() + .appendChild( new TextNode("34567") ) ) + .appendChild( new TextNode("89") ) ); + doTest(root, false); + // overwrite outer ruby, split remains at inner meta! + TreeNode rby3 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(5/*-1*/, 6/*-1*/, rby3) ); + root = new TreeNode() + .appendChild( rby1.dup() + .appendChild( new TextNode("12") ) ) + .appendChild( met2.dup() + .appendChild( rby1.dup() + .appendChild( new TextNode("34") ) ) + .appendChild( rby3.dup() + .appendChild( new TextNode("5") ) ) + .appendChild( rby1.dup() + .appendChild( new TextNode("67") ) ) ) + .appendChild( rby1.dup() + .appendChild( new TextNode("89") ) ); + doTest(root, false); + } + + public void testRange4() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode rby1 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(0, 9, rby1) ); + TreeNode met2 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(1, 8, met2) ); + TreeNode met3 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(3/*-1*/, 8/*-1*/, met3) ); + TreeNode met4 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(5/*-2*/, 8/*-2*/, met4) ); + TreeNode root = new TreeNode() + .appendChild( rby1.dup() + .appendChild( new TextNode("1") ) + .appendChild( met2.dup() + .appendChild( new TextNode("2") ) + .appendChild( met3.dup() + .appendChild( new TextNode("3") ) + .appendChild( met4.dup() + .appendChild( new TextNode("456") ) ) + .appendChild( new TextNode("7") ) ) + .appendChild( new TextNode("8") ) ) + .appendChild( new TextNode("9") ) ); + doTest(root, false); + // overwrite outer ruby, split remains at every inner meta! + TreeNode rby5 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(7/*-3*/, 8/*-3*/, rby5) ); + root = new TreeNode() + .appendChild( rby1.dup() + .appendChild( new TextNode("1") ) ) + .appendChild( met2.dup() + .appendChild( rby1.dup() + .appendChild( new TextNode("2") ) ) + .appendChild( met3.dup() + .appendChild( rby1.dup() + .appendChild( new TextNode("3") ) ) + .appendChild( met4.dup() + .appendChild( rby1.dup() + .appendChild( new TextNode("4") ) ) + .appendChild( rby5.dup() + .appendChild( new TextNode("5") ) ) + .appendChild( rby1.dup() + .appendChild( new TextNode("6") ) ) ) + .appendChild( rby1.dup() + .appendChild( new TextNode("7") ) ) ) + .appendChild( rby1.dup() + .appendChild( new TextNode("8") ) ) ) + .appendChild( rby1.dup() + .appendChild( new TextNode("9") ) ); + doTest(root, false); + } + + public void testRange5() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode rby1 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(0, 9, rby1) ); + TreeNode met2 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(1, 3, met2) ); + TreeNode met3 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(5/*-1*/, 6/*-1*/, met3) ); + TreeNode met4 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(8/*-2*/, 10/*-2*/, met4) ); + TreeNode root = new TreeNode() + .appendChild( rby1.dup() + .appendChild( new TextNode("1") ) + .appendChild( met2.dup().appendChild( new TextNode("23") ) ) + .appendChild( new TextNode("4") ) + .appendChild( met3.dup().appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6") ) + .appendChild( met4.dup().appendChild( new TextNode("78") ) ) + .appendChild( new TextNode("9") ) ); + doTest(root, false); + // overwrite outer ruby, but split at inner metas! + TreeNode rby5 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(3/*-1*/, 10/*-3*/, rby5) ); + root = new TreeNode() + .appendChild( rby1.dup() + .appendChild( new TextNode("1") ) ) + .appendChild( met2.dup() + .appendChild( rby1.dup() + .appendChild( new TextNode("2") ) ) + .appendChild( rby5.dup() + .appendChild( new TextNode("3") ) ) ) + .appendChild( rby5.dup() + .appendChild( new TextNode("4") ) + .appendChild( met3.dup() + .appendChild( new TextNode("5") ) ) + .appendChild( new TextNode("6") ) ) + .appendChild( met4.dup() + .appendChild( rby5.dup() + .appendChild( new TextNode("7") ) ) + .appendChild( rby1.dup() + .appendChild( new TextNode("8") ) ) ) + .appendChild( rby1.dup() + .appendChild( new TextNode("9") ) ); + doTest(root, false); + } + + public void testRange6() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode met1 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(1, 5, met1) ); + TreeNode met2 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(3/*-1*/, 6/*-1*/, met2) ); + TreeNode met3 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(5/*-2*/, 7/*-2*/, met3) ); + TreeNode root = new TreeNode() + .appendChild( new TextNode("1") ) + .appendChild( met1.dup() + .appendChild( new TextNode("2") ) + .appendChild( met2.dup() + .appendChild( new TextNode("3") ) + .appendChild( met3.dup() + .appendChild( new TextNode("45") ) ) ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + // split at 3 metas, all at same position + TreeNode rby4 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(7/*-3*/, 10/*-3*/, rby4) ); + root = new TreeNode() + .appendChild( new TextNode("1") ) + .appendChild( met1.dup() + .appendChild( new TextNode("2") ) + .appendChild( met2.dup() + .appendChild( new TextNode("3") ) + .appendChild( met3.dup() + .appendChild( new TextNode("4") ) + .appendChild( rby4.dup() + .appendChild( new TextNode("5") ) ) ) ) ) + .appendChild( rby4.dup() + .appendChild( new TextNode("67") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + } + + public void testRange7() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123456789"); + inserter.insertRange( new Range(0, 0, text) ); + TreeNode url1 = new HyperlinkNode( mkName("url") ); + inserter.insertRange( new Range(1, 5, url1) ); + TreeNode met2 = new MetaNode( mkId("id") ); + inserter.insertRange( new Range(3, 5, met2) ); + TreeNode root = new TreeNode() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup() + .appendChild( new TextNode("23") ) ) + .appendChild( met2.dup() + .appendChild( url1.dup() + .appendChild( new TextNode("45") ) ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + // this should result in not splitting the hyperlink, but due to API + // we can't tell :( + TreeNode rby3 = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(5/*-1*/, 8/*-1*/, rby3) ); + root = new TreeNode() + .appendChild( new TextNode("1") ) + .appendChild( url1.dup() + .appendChild( new TextNode("23") ) ) + .appendChild( met2.dup() + .appendChild( url1.dup() + .appendChild( new TextNode("4") ) ) + .appendChild( rby3.dup() + .appendChild( url1.dup() + .appendChild( new TextNode("5") ) ) ) ) + .appendChild( rby3.dup() + .appendChild( new TextNode("67") ) ) + .appendChild( new TextNode("89") ); + doTest(root, false); + } + + /* TODO: test partial selection, test UNDO/REDO */ + + /** test SwXMeta XText interface */ + public void testMetaXText() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("12AB6789"); + inserter.insertRange( new Range(0, 0, text) ); + MetaNode meta = new MetaNode( mkId("id") ); +// inserter.insertRange( new Range(3, 5, met2) ); + XTextContent xMeta = inserter.makeMeta(); + + XText xDocText = m_xDoc.getText(); + XTextCursor xDocTextCursor = xDocText.createTextCursor(); + xDocTextCursor.goRight((short)3, false); + xDocTextCursor.goRight((short)2, true); + xDocText.insertTextContent(xDocTextCursor, xMeta, true); +// xMeta.attach(xDocTextCursor); + + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xMeta); + xMetadatable.setMetadataReference(meta.getXmlId()); + XText xText = (XText) UnoRuntime.queryInterface(XText.class, xMeta); + + XText xParentText = xText.getText(); + assure("getText(): no parent", xParentText != null); + + XTextRange xStart = xText.getStart(); + assure("getStart(): no start", xStart != null); + + XTextRange xEnd = xText.getEnd(); + assure("getEnd(): no end", xEnd != null); + + /* + String string = xText.getString(); + assure("getString(): invalid string returned", + string != null && "AB".equals(string) ); + */ + + xText.setString("45"); + + { + String string = xText.getString(); + assure("getString(): invalid string returned: " + string, + string != null && "45".equals(string) ); + } + + XTextCursor xTextCursor = xText.createTextCursor(); + assure("createTextCursor(): failed", xTextCursor != null); + + try { + xText.createTextCursorByRange(null); + assure("createTextCursorByRange(): null allowed?", false); + } catch (RuntimeException e) { /* expected */ } + + XTextCursor xTextCursorStart = xText.createTextCursorByRange(xStart); + assure("createTextCursorByRange(): failed for start", + xTextCursorStart != null); + + XTextCursor xTextCursorEnd = xText.createTextCursorByRange(xEnd); + assure("createTextCursorByRange(): failed for end", + xTextCursorEnd != null); + + // move outside meta + xDocTextCursor.gotoStart(false); + + try { + xText.insertString(null, "foo", false); + assure("insertString(): null allowed?", false); + } catch (RuntimeException e) { /* expected */ } + + try { + xText.insertString(xDocTextCursor, "foo", false); + assure("insertString(): cursor outside allowed?", false); + } catch (RuntimeException e) { /* expected */ } + + xStart = xText.getStart(); + xText.insertString(xStart, "A", false); + { + String string = xText.getString(); + assure("getString(): invalid string returned: " + string, + string != null && "A45".equals(string) ); + } + + xText.insertString(xEnd, "B", false); + { + String string = xText.getString(); + assure("getString(): invalid string returned: " + string, + string != null && "A45B".equals(string) ); + } + + try { + xText.insertControlCharacter(null, HARD_HYPHEN, false); + assure("insertControlCharacter(): null allowed?", false); + } catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ } + + xStart = xText.getStart(); + try { + xText.insertControlCharacter(xDocTextCursor, HARD_HYPHEN, false); + assure("insertControlCharacter(): cursor outside allowed?", false); + } catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ } + + xText.insertControlCharacter(xStart, HARD_HYPHEN, false); + { + String string = xText.getString(); + assure("getString(): invalid string returned: " + string, + string != null && ('\u2011' + "A45B").equals(string) ); + } + + xText.insertControlCharacter(xEnd, HARD_HYPHEN, false); + { + String string = xText.getString(); + assure("getString(): invalid string returned: " + string, + string != null && + ('\u2011' + "A45B" + '\u2011').equals(string) ); + } + + xText.setString("45"); + + try { + xText.insertTextContent(null, xMeta, false); + assure("insertTextContent(): null range allowed?", false); + } catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ } + + try { + xText.insertTextContent(xStart, null, false); + assure("insertTextContent(): null content allowed?", false); + } catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ } + + try { + xText.insertTextContent(xDocTextCursor, xMeta, false); + assure("insertTextContent(): cursor outside allowed?", false); + } catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ } + + TextFieldNode field1 = new TextFieldNode( "f1" ); + TextFieldNode field2 = new TextFieldNode( "f2" ); + XTextContent xField1 = inserter.makeTextField(field1.getContent()); + XTextContent xField2 = inserter.makeTextField(field2.getContent()); + + xStart = xText.getStart(); + xText.insertTextContent(xStart, xField1, false); + + TreeNode root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( meta.dup() + .appendChild( field1.dup() ) + .appendChild( new TextNode("45") ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + + xText.insertTextContent(xEnd, xField2, false); + + root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( meta.dup() + .appendChild( field1.dup() ) + .appendChild( new TextNode("45") ) + .appendChild( field2.dup() ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + + try { + xText.removeTextContent(null); + assure("removeTextContent(): null content allowed?", false); + } catch (RuntimeException e) { /* expected */ } + + xText.removeTextContent(xField1); + + XTextRange xAnchor = xMeta.getAnchor(); + assure("getAnchor(): null", xAnchor != null); + + // evil test case: insert ruby around meta + RubyNode ruby = new RubyNode( mkName("ruby") ); + inserter.insertRange( new Range(2, 6, ruby) ); + + /* prevent caching... + root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( ruby.dup() + .appendChild( meta.dup() + .appendChild( new TextNode("45") ) + .appendChild( field2.dup() ) ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + */ + + XEnumerationAccess xEA = (XEnumerationAccess) + UnoRuntime.queryInterface(XEnumerationAccess.class, xMeta); + XEnumeration xEnum = xEA.createEnumeration(); + assure("createEnumeration(): returns null", xEnum != null); + { + assure("hasNext(): first missing", xEnum.hasMoreElements()); + Object xElement = xEnum.nextElement(); + XTextRange xPortion = (XTextRange) + UnoRuntime.queryInterface(XTextRange.class, xElement); + XPropertySet xPropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xPortion); + String type = (String) xPropSet.getPropertyValue("TextPortionType"); + assure("first: not text", type.equals("Text")); + String txt = xPortion.getString(); + assure("first: text differs: " + txt, "45".equals(txt)); + } + { + assure("hasNext(): second missing", xEnum.hasMoreElements()); + Object xElement = xEnum.nextElement(); + XTextRange xPortion = (XTextRange) + UnoRuntime.queryInterface(XTextRange.class, xElement); + XPropertySet xPropSet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xPortion); + String type = (String) xPropSet.getPropertyValue("TextPortionType"); + assure("second: not text", type.equals("TextField")); + } + // no ruby end here!!! + assure("hasNext(): more elements?", !xEnum.hasMoreElements()); + + XComponent xComponent = (XComponent) + UnoRuntime.queryInterface(XComponent.class, xMeta); + xComponent.dispose(); + + try { + XTextCursor xCursor = xText.createTextCursor(); + assure("createTextCursor(): succeeds on disposed object?", + xCursor == null); + } catch (RuntimeException e) { /* expected */ } + } + + /** check that cursor move methods move to positions in the meta, + but do not move to positions outside the meta. */ + public void testMetaXTextCursor() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("Text. 12 More text here."); + inserter.insertRange( new Range(0, 0, text) ); + MetaNode met1 = new MetaNode( mkId("id") ); + XTextContent xMeta = inserter.makeMeta(); + + XText xDocText = m_xDoc.getText(); + XTextCursor xDocTextCursor = xDocText.createTextCursor(); + xDocTextCursor.goRight((short)7, false); + xDocTextCursor.goRight((short)2, true); + xDocText.insertTextContent(xDocTextCursor, xMeta, true); + xDocTextCursor.gotoStart(true); + + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xMeta); + xMetadatable.setMetadataReference(met1.getXmlId()); + XText xText = (XText) UnoRuntime.queryInterface(XText.class, xMeta); + + XTextRange xStart = xText.getStart(); + assure("getStart(): no start", xStart != null); + XTextRange xEnd = xText.getEnd(); + assure("getEnd(): no end", xEnd != null); + + XTextCursor xTextCursor = xText.createTextCursor(); + assure("createTextCursor(): no cursor", xTextCursor != null); + + // XTextCursor + boolean bSuccess = false; + xTextCursor.gotoStart(false); + xTextCursor.gotoEnd(false); + bSuccess = xTextCursor.goLeft((short)1, false); + assure("goLeft(): failed", bSuccess); + bSuccess = xTextCursor.goLeft((short)1000, false); + assure("goLeft(): succeeded", !bSuccess); + bSuccess = xTextCursor.goRight((short)1, false); + assure("goRight(): failed", bSuccess); + bSuccess = xTextCursor.goRight((short)1000, false); + assure("goRight(): succeeded", !bSuccess); + xTextCursor.gotoRange(xStart, false); + xTextCursor.gotoRange(xEnd, false); + try { + xTextCursor.gotoRange(xDocTextCursor, false); + assure("gotoRange(): succeeded", false); + } catch (RuntimeException e) { /* expected */ } + + // XWordCursor + xText.setString("Two words"); + xTextCursor.gotoStart(false); + XWordCursor xWordCursor = (XWordCursor) + UnoRuntime.queryInterface(XWordCursor.class, xTextCursor); + + bSuccess = xWordCursor.gotoNextWord(true); + assure("gotoNextWord(): failed", bSuccess); + { + String string = xTextCursor.getString(); + assure("gotoNextWord(): wrong string: " + string, + "Two ".equals(string)); + } + bSuccess = xWordCursor.gotoNextWord(false); + assure("gotoNextWord(): succeeded", !bSuccess); + xTextCursor.collapseToEnd(); + bSuccess = xWordCursor.gotoPreviousWord(true); + assure("gotoPreviousWord(): failed", bSuccess); + { + String string = xTextCursor.getString(); + assure("gotoPreviousWord(): wrong string: " + string, + "words".equals(string)); + } + bSuccess = xWordCursor.gotoPreviousWord(false); + assure("gotoPreviousWord(): succeeded", !bSuccess); + bSuccess = xWordCursor.gotoEndOfWord(true); + assure("gotoEndOfWord(): failed", bSuccess); + { + String string = xTextCursor.getString(); + assure("gotoEndOfWord(): wrong string: " + string, + "Two".equals(string)); + } + xTextCursor.gotoEnd(false); + bSuccess = xWordCursor.gotoStartOfWord(true); + assure("gotoStartOfWord(): failed", bSuccess); + { + String string = xTextCursor.getString(); + assure("gotoStartOfWord(): wrong string: " + string, + "words".equals(string)); + } + xText.setString(""); + bSuccess = xWordCursor.gotoEndOfWord(false); + assure("gotoEndOfWord(): succeeded", !bSuccess); + bSuccess = xWordCursor.gotoStartOfWord(false); + assure("gotoStartOfWord(): succeeded", !bSuccess); + + // XSentenceCursor + xText.setString("This is a sentence. Another sentence."); + xTextCursor.gotoStart(false); + XSentenceCursor xSentenceCursor = (XSentenceCursor) + UnoRuntime.queryInterface(XSentenceCursor.class, xTextCursor); + + bSuccess = xSentenceCursor.gotoNextSentence(true); + assure("gotoNextSentence(): failed", bSuccess); + { + String string = xTextCursor.getString(); + assure("gotoNextSentence(): wrong string: " + string, + "This is a sentence. ".equals(string)); + } + bSuccess = xSentenceCursor.gotoNextSentence(false); + assure("gotoNextSentence(): succeeded", !bSuccess); + // FIXME: + // the sentence cursor seems to work differently than the word cursor + xText.setString("This is a sentence. Another sentence. Sentence 3."); + xTextCursor.gotoEnd(false); + bSuccess = xSentenceCursor.gotoPreviousSentence(true); + assure("gotoPreviousSentence(): failed", bSuccess); + { + String string = xTextCursor.getString(); + assure("gotoPreviousSentence(): wrong string: " + string, + "Another sentence. Sentence 3.".equals(string)); + } + bSuccess = xSentenceCursor.gotoPreviousSentence(false); + assure("gotoPreviousSentence(): succeeded", !bSuccess); + bSuccess = xSentenceCursor.gotoEndOfSentence(true); + assure("gotoEndOfSentence(): failed", bSuccess); + { + String string = xTextCursor.getString(); + assure("gotoEndOfSentence(): wrong string: " + string, + "This is a sentence.".equals(string)); + } + xTextCursor.gotoEnd(false); + bSuccess = xSentenceCursor.gotoStartOfSentence(true); + assure("gotoStartOfSentence(): failed", bSuccess); + { + String string = xTextCursor.getString(); + assure("gotoStartOfSentence(): wrong string: " + string, + "Sentence 3.".equals(string)); + } + xText.setString(""); + bSuccess = xSentenceCursor.gotoEndOfSentence(false); + assure("gotoEndOfSentence(): succeeded", !bSuccess); + bSuccess = xSentenceCursor.gotoStartOfSentence(false); + assure("gotoStartOfSentence(): succeeded", !bSuccess); + + XParagraphCursor xParagraphCursor = (XParagraphCursor) + UnoRuntime.queryInterface(XParagraphCursor.class, xTextCursor); + + // XParagraphCursor (does not make sense) + bSuccess = xParagraphCursor.gotoNextParagraph(false); + assure("gotoNextParagraph(): succeeded", !bSuccess); + bSuccess = xParagraphCursor.gotoPreviousParagraph(false); + assure("gotoPreviousParagraph(): succeeded", !bSuccess); + bSuccess = xParagraphCursor.gotoStartOfParagraph(false); + assure("gotoStartOfParagraph(): succeeded", !bSuccess); + bSuccess = xParagraphCursor.gotoEndOfParagraph(false); + assure("gotoEndOfParagraph(): succeeded", !bSuccess); + } + + + abstract class AttachHelper + { + abstract boolean isAttribute(); + abstract TreeNode mkTreeNode(); + abstract XTextContent mkTextContent(Inserter inserter, TreeNode node) + throws Exception; + void postInserted(TreeNode node, XTextContent xContent) + throws Exception { } + } + + public void testMetaXTextAttachToxMark() throws Exception + { + doMetaXTextAttach( new AttachHelper() + { + boolean isAttribute() { return true; } + TreeNode mkTreeNode() { + return new DocumentIndexMarkNode( mkName("toxmark") ); + } + XTextContent mkTextContent(Inserter inserter, TreeNode node) + throws Exception { + return inserter.makeDocumentIndexMark( + ((DocumentIndexMarkNode)node).getName()); + } + }); + } + + public void testMetaXTextAttachRefMark() throws Exception + { + doMetaXTextAttach( new AttachHelper() + { + boolean isAttribute() { return true; } + TreeNode mkTreeNode() { + return new ReferenceMarkNode( mkName("refmark") ); + } + XTextContent mkTextContent(Inserter inserter, TreeNode node) + throws Exception { + return inserter.makeReferenceMark( + ((ReferenceMarkNode)node).getName()); + } + }); + } + + public void testMetaXTextAttachTextField() throws Exception + { + doMetaXTextAttach( new AttachHelper() + { + boolean isAttribute() { return false; } + TreeNode mkTreeNode() { + return new TextFieldNode( mkName("field") ); + } + XTextContent mkTextContent(Inserter inserter, TreeNode node) + throws Exception { + return inserter.makeTextField( + ((TextFieldNode)node).getContent()); + } + }); + } + + public void testMetaXTextAttachFootnote() throws Exception + { + doMetaXTextAttach( new AttachHelper() + { + boolean isAttribute() { return false; } + TreeNode mkTreeNode() { + return new FootnoteNode( mkName("ftn") ); + } + XTextContent mkTextContent(Inserter inserter, TreeNode node) + throws Exception { + return inserter.makeFootnote( + ((FootnoteNode)node).getLabel()); + } + }); + } + + public void testMetaXTextAttachMeta() throws Exception + { + doMetaXTextAttach( new AttachHelper() + { + boolean isAttribute() { return true; } + TreeNode mkTreeNode() { + return new MetaNode( mkId("id") ); + } + XTextContent mkTextContent(Inserter inserter, TreeNode node) + throws Exception { + return inserter.makeMeta(); + } + void postInserted(TreeNode node, XTextContent xContent) + throws Exception { + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xContent); + xMetadatable.setMetadataReference( + ((MetaNode)node).getXmlId()); + } + }); + } + + void doMetaXTextAttach(AttachHelper helper) throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("12AB6789"); + inserter.insertRange( new Range(0, 0, text) ); + MetaNode met1 = new MetaNode( mkId("id") ); + XTextContent xMeta = inserter.makeMeta(); + + XText xDocText = m_xDoc.getText(); + XTextCursor xDocTextCursor = xDocText.createTextCursor(); + xDocTextCursor.goRight((short)3, false); + xDocTextCursor.goRight((short)2, true); + xDocText.insertTextContent(xDocTextCursor, xMeta, true); + + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xMeta); + xMetadatable.setMetadataReference(met1.getXmlId()); + XText xText = (XText) UnoRuntime.queryInterface(XText.class, xMeta); + XTextRange xStart = null; + XTextRange xEnd = null; + + { + xStart = xText.getStart(); + xEnd = xText.getEnd(); + + TreeNode nod1 = helper.mkTreeNode(); + TreeNode nod2 = helper.mkTreeNode(); + XTextContent xContent1 = helper.mkTextContent(inserter, nod1); + XTextContent xContent2 = helper.mkTextContent(inserter, nod2); + + // insertTextContent with meta getStart()/getEnd() + xText.insertTextContent(xStart, xContent1, false); + xText.insertTextContent(xEnd , xContent2, false); + + helper.postInserted(nod1, xContent1); + helper.postInserted(nod2, xContent2); + + TreeNode root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( met1.dup() + .appendChild( nod1.dup() ) + .appendChild( new TextNode("AB") ) + .appendChild( nod2.dup() ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + } + { + xText.setString("AB"); + xStart = xText.getStart(); + xEnd = xText.getEnd(); + + TreeNode nod1 = helper.mkTreeNode(); + TreeNode nod2 = helper.mkTreeNode(); + XTextContent xContent1 = helper.mkTextContent(inserter, nod1); + XTextContent xContent2 = helper.mkTextContent(inserter, nod2); + + XTextCursor xTextCursor = xText.createTextCursor(); + xTextCursor.gotoStart(false); + + // insertTextContent with meta cursor + xText.insertTextContent(xTextCursor, xContent1, false); + xTextCursor.gotoEnd(false); + xText.insertTextContent(xTextCursor, xContent2, false); + + helper.postInserted(nod1, xContent1); + helper.postInserted(nod2, xContent2); + + TreeNode root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( met1.dup() + .appendChild( nod1.dup() ) + .appendChild( new TextNode("AB") ) + .appendChild( nod2.dup() ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + } + if (!helper.isAttribute()) + { +// xText.setString("AB"); + xStart = xText.getStart(); + xEnd = xText.getEnd(); + + TreeNode nod1 = helper.mkTreeNode(); + TreeNode nod2 = helper.mkTreeNode(); + XTextContent xContent1 = helper.mkTextContent(inserter, nod1); + XTextContent xContent2 = helper.mkTextContent(inserter, nod2); + + XTextCursor xTextCursor = xText.createTextCursor(); + xTextCursor.gotoStart(false); + xTextCursor.goRight((short)1, true); + + // insertTextContent with meta cursor and absorb + xText.insertTextContent(xTextCursor, xContent1, true); + xTextCursor.gotoEnd(false); + xTextCursor.goLeft((short)1, true); + xText.insertTextContent(xTextCursor, xContent2, true); + + helper.postInserted(nod1, xContent1); + helper.postInserted(nod2, xContent2); + + TreeNode root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( met1.dup() + .appendChild( nod1.dup() ) + .appendChild( new TextNode("AB") ) + .appendChild( nod2.dup() ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + } + { + xText.setString("AB"); + xStart = xText.getStart(); + xEnd = xText.getEnd(); + + TreeNode nod1 = helper.mkTreeNode(); + TreeNode nod2 = helper.mkTreeNode(); + XTextContent xContent1 = helper.mkTextContent(inserter, nod1); + XTextContent xContent2 = helper.mkTextContent(inserter, nod2); + + xDocTextCursor.gotoRange(xStart, false); + + // insertTextContent with document cursor + xText.insertTextContent(xDocTextCursor, xContent1, false); + xDocTextCursor.gotoRange(xEnd, false); + xText.insertTextContent(xDocTextCursor, xContent2, false); + + helper.postInserted(nod1, xContent1); + helper.postInserted(nod2, xContent2); + + TreeNode root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( met1.dup() + .appendChild( nod1.dup() ) + .appendChild( new TextNode("AB") ) + .appendChild( nod2.dup() ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + } + if (!helper.isAttribute()) + { +// xText.setString("AB"); + xStart = xText.getStart(); + xEnd = xText.getEnd(); + + TreeNode nod1 = helper.mkTreeNode(); + TreeNode nod2 = helper.mkTreeNode(); + XTextContent xContent1 = helper.mkTextContent(inserter, nod1); + XTextContent xContent2 = helper.mkTextContent(inserter, nod2); + + xDocTextCursor.gotoRange(xStart, false); + xDocTextCursor.goRight((short)1, true); + + // insertTextContent with document cursor and absorb + xText.insertTextContent(xDocTextCursor, xContent1, true); + xDocTextCursor.gotoRange(xEnd, false); + xDocTextCursor.goLeft((short)1, true); + xText.insertTextContent(xDocTextCursor, xContent2, true); + + helper.postInserted(nod1, xContent1); + helper.postInserted(nod2, xContent2); + + TreeNode root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( met1.dup() + .appendChild( nod1.dup() ) + .appendChild( new TextNode("AB") ) + .appendChild( nod2.dup() ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + } + { + xText.setString("AB"); + xStart = xText.getStart(); + xEnd = xText.getEnd(); + + TreeNode nod1 = helper.mkTreeNode(); + TreeNode nod2 = helper.mkTreeNode(); + XTextContent xContent1 = helper.mkTextContent(inserter, nod1); + XTextContent xContent2 = helper.mkTextContent(inserter, nod2); + + // attach to range from meta getStart()/getEnd() + xContent1.attach(xStart); + xContent2.attach(xEnd); + + helper.postInserted(nod1, xContent1); + helper.postInserted(nod2, xContent2); + + TreeNode root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( met1.dup() + .appendChild( nod1.dup() ) + .appendChild( new TextNode("AB") ) + .appendChild( nod2.dup() ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + } + { + xText.setString("AB"); + xStart = xText.getStart(); + xEnd = xText.getEnd(); + + TreeNode nod1 = helper.mkTreeNode(); + TreeNode nod2 = helper.mkTreeNode(); + XTextContent xContent1 = helper.mkTextContent(inserter, nod1); + XTextContent xContent2 = helper.mkTextContent(inserter, nod2); + + XTextCursor xTextCursor = xText.createTextCursor(); + xTextCursor.gotoStart(false); + + // attach to cursor from meta XText + xContent1.attach(xTextCursor); + xTextCursor.gotoEnd(false); + xContent2.attach(xTextCursor); + + helper.postInserted(nod1, xContent1); + helper.postInserted(nod2, xContent2); + + TreeNode root = new TreeNode() + .appendChild( new TextNode("12") ) + .appendChild( met1.dup() + .appendChild( nod1.dup() ) + .appendChild( new TextNode("AB") ) + .appendChild( nod2.dup() ) ) + .appendChild( new TextNode("6789") ); + doTest(root, false); + } + } + + public void testMetaFieldXTextField() throws Exception + { + com.sun.star.rdf.XRepositorySupplier xModel = + (com.sun.star.rdf.XRepositorySupplier) UnoRuntime.queryInterface( + com.sun.star.rdf.XRepositorySupplier.class, m_xDoc); + com.sun.star.rdf.XRepository xRepo = xModel.getRDFRepository(); + // for testing just add it to the first graph + com.sun.star.rdf.XURI[] Graphs = xRepo.getGraphNames(); + com.sun.star.rdf.XNamedGraph xGraph = xRepo.getGraph(Graphs[0]); + com.sun.star.rdf.XURI xOdfPrefix = + com.sun.star.rdf.URI.createKnown(m_xContext, + com.sun.star.rdf.URIs.ODF_PREFIX); + com.sun.star.rdf.XURI xOdfSuffix = + com.sun.star.rdf.URI.createKnown(m_xContext, + com.sun.star.rdf.URIs.ODF_SUFFIX); + com.sun.star.rdf.XNode xPrefix = + com.sun.star.rdf.Literal.create(m_xContext, "foo"); + com.sun.star.rdf.XNode xSuffix = + com.sun.star.rdf.Literal.create(m_xContext, "bar"); + + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("abc"); + inserter.insertRange( new Range(0, 0, text) ); + XText xDocText = m_xDoc.getText(); + XTextCursor xDocTextCursor = xDocText.createTextCursor(); + xDocTextCursor.goRight((short)1, false); + xDocTextCursor.goRight((short)3, true); + + XTextField xMetaField = inserter.makeMetaField(); + + xDocText.insertTextContent(xDocTextCursor, xMetaField, true); + + XMetadatable xMetadatable = (XMetadatable) + UnoRuntime.queryInterface(XMetadatable.class, xMetaField); + xMetadatable.ensureMetadataReference(); + + xGraph.addStatement(xMetadatable, xOdfPrefix, xPrefix); + xGraph.addStatement(xMetadatable, xOdfSuffix, xSuffix); + assure("getPresentation(): wrong", + "fooabcbar".equals(xMetaField.getPresentation(false))); + inserter.insertRange( new Range(0, 0, text) ); + } + + public void testMetaFieldXPropertySet() throws Exception + { + RangeInserter inserter = new RangeInserter(m_xDoc); + TreeNode text = new TextNode("123"); + inserter.insertRange( new Range(0, 0, text) ); + XText xDocText = m_xDoc.getText(); + XTextCursor xDocTextCursor = xDocText.createTextCursor(); + xDocTextCursor.goRight((short)1, false); + xDocTextCursor.goRight((short)3, true); + + XTextField xMetaField = inserter.makeMetaField(); + + xDocText.insertTextContent(xDocTextCursor, xMetaField, true); + + XPropertySet xPropertySet = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, xMetaField); + assure("PropertySet: not supported?", xPropertySet != null); + XPropertySetInfo xPropertySetInfo = xPropertySet.getPropertySetInfo(); + assure("hasPropertyByName(\"NumberFormat\"):", + xPropertySetInfo.hasPropertyByName("NumberFormat")); + assure("hasPropertyByName(\"IsFixedLanguage\"):", + xPropertySetInfo.hasPropertyByName("IsFixedLanguage")); + + int def = (Integer) xPropertySet.getPropertyValue("NumberFormat"); + log.println("NumberFormat: default is " + def); + short INT = com.sun.star.i18n.NumberFormatIndex.NUMBER_INT; + xPropertySet.setPropertyValue("NumberFormat", INT); + xPropertySet.setPropertyValue("IsFixedLanguage", true); + int format = (Integer) xPropertySet.getPropertyValue("NumberFormat"); + assure("NumberFormat: failed", format == INT); + boolean isFixed = (Boolean) + xPropertySet.getPropertyValue("IsFixedLanguage"); + assure("IsFixedLanguage: failed", isFixed); + } + + public void testLoadStore() throws Exception + { + XComponent xComp = null; + String filename = "TESTMETA.odt"; + String file; + try { + file = util.utils.getFullTestURL(filename); + xComp = doLoad(file); + if (xComp != null) + { + file = m_TmpDir + filename; + doStore(xComp, file); + close(xComp); + xComp = doLoad(file); + } + } finally { + close(xComp); + } + } + + private void doStore(XComponent xComp, String file) throws Exception + { + log.println("Storing test document..."); + + XStorable xStor = (XStorable) UnoRuntime.queryInterface( + XStorable.class, xComp); + + xStor.storeToURL(file, new PropertyValue[0]); + + log.println("...done"); + } + + public XComponent doLoad(String file) throws Exception + { + XComponent xComp = null; + + log.println("Loading test document..."); + + PropertyValue[] loadProps = new PropertyValue[1]; + loadProps[0] = new PropertyValue(); + loadProps[0].Name = "Hidden"; + loadProps[0].Value = new Boolean(true); + + xComp = util.DesktopTools.loadDoc(m_xMSF, file, loadProps); +// xComp = util.DesktopTools.getCLoader(m_xMSF).loadComponentFromURL(file, "_blank", 0, loadProps); + + + XTextDocument xTextDoc = (XTextDocument) + UnoRuntime.queryInterface(XTextDocument.class, xComp); + + XText xText = xTextDoc.getText(); + + log.println("...done"); + + log.println("Checking meta(-field)s in loaded test document..."); + + TreeNode root = new TreeNode() + .appendChild( new RubyNode("ruby1") + .appendChild( new TextNode("1") ) ) + .appendChild( new MetaNode(mkId_("id1")) + .appendChild( new TextNode("2") ) ) + .appendChild( new MetaFieldNode(mkId_("id2")) + .appendChild( new TextNode("3") ) ) + .appendChild( new RubyNode("ruby2") + .appendChild( new MetaNode(mkId_("id3")) + .appendChild( new TextNode("4") ) ) ) + .appendChild( new RubyNode("ruby3") + .appendChild( new MetaFieldNode(mkId_("id4")) + .appendChild( new TextNode("5") ) ) ) + .appendChild( new MetaNode(mkId_("id5")) + .appendChild( new RubyNode("ruby4") + .appendChild( new TextNode("6") ) ) ) + .appendChild( new MetaFieldNode(mkId_("id6")) + .appendChild( new RubyNode("ruby5") + .appendChild( new TextNode("7") ) ) ) + .appendChild( new MetaNode(mkId_("id7")) + .appendChild( new MetaNode(mkId_("id8")) + .appendChild( new TextNode("8") ) ) ) + .appendChild( new MetaNode(mkId_("id9")) + .appendChild( new MetaFieldNode(mkId_("id10")) + .appendChild( new TextNode("9") ) ) ) + .appendChild( new MetaFieldNode(mkId_("id11")) + .appendChild( new MetaNode(mkId_("id12")) + .appendChild( new TextNode("10") ) ) ) + .appendChild( new MetaFieldNode(mkId_("id13")) + .appendChild( new MetaFieldNode(mkId_("id14")) + .appendChild( new TextNode("11") ) ) ) + .appendChild( new MetaNode(mkId_("id15")) + .appendChild( new RubyNode("ruby6") + .appendChild( new MetaFieldNode(mkId_("id16")) + .appendChild( new TextNode("12") ) ) ) ) + .appendChild( new MetaNode(mkId_("")) { + public boolean equals(Object other) { + return (other instanceof MetaNode); + } } + .appendChild( new TextNode("13") ) ) + .appendChild( new TextNode(" X X ") ); + doTest(xTextDoc, root, false); + + log.println("...done"); + + return xComp; + } + + static void close(XComponent i_comp) + { + try { + XCloseable xClos = (XCloseable) UnoRuntime.queryInterface( + XCloseable.class, i_comp); + if (xClos != null) xClos.close(true); + } catch (Exception e) { + } + } + + private void doTest(TreeNode intree) throws Exception + { + doTest(m_xDoc, intree, true); + } + + private void doTest(TreeNode intree, boolean insert) throws Exception + { + doTest(m_xDoc, intree, insert); + } + + private void doTest(XTextDocument xDoc, TreeNode intree, + boolean insert) throws Exception + { + dumpTree(intree, "I: "); + + if (insert) { + new TreeInserter(xDoc).insertTree(intree); + } + +//Thread.sleep(10000); + + XText xText = xDoc.getText(); + XEnumerationAccess xTextEA = (XEnumerationAccess) + UnoRuntime.queryInterface(XEnumerationAccess.class, xText); + XEnumeration xTextEnum = xTextEA.createEnumeration(); + // skip to right paragraph + xTextEnum.nextElement(); // skip first -- always empty! + Object xElement = xTextEnum.nextElement(); // second contains test case + XEnumerationAccess xEA = (XEnumerationAccess) + UnoRuntime.queryInterface(XEnumerationAccess.class, xElement); + XEnumeration xEnum = xEA.createEnumeration(); + TreeNode outtree = new EnumConverter(this).convert(xEnum); + + dumpTree(outtree, "O: "); + + boolean success = new FuzzyTester(log).doTest(intree, outtree); + assure("test failed", success); + } + + private void dumpTree(TreeNode tree) { dumpTree(tree, "> "); } + + private void dumpTree(TreeNode tree, String prefix) + { + log.println(prefix + tree.toString()); + TreeNodeEnum children = tree.createEnumeration(); + while (children.hasNext()) { + TreeNode node = children.next(); + dumpTree(node, prefix + " "); + } + } + + private String mkName(String prefix) + { + return prefix + String.valueOf(m_Count++); + } + + private StringPair mkId(String prefix) + { + return new StringPair("content.xml", mkName(prefix)); + } + + private StringPair mkId_(String id) + { + return new StringPair("content.xml", id); + } + + public void assure(String str, boolean cond) { super.assure(str, cond); } +} + diff --git a/sw/qa/complex/writer/makefile.mk b/sw/qa/complex/writer/makefile.mk index 7bcc7fe934..de5200d471 100755 --- a/sw/qa/complex/writer/makefile.mk +++ b/sw/qa/complex/writer/makefile.mk @@ -41,7 +41,7 @@ PACKAGE = complex$/writer #----- compile .java files ----------------------------------------- JARFILES = mysql.jar sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = CheckIndexedPropertyValues.java CheckNamedPropertyValues.java CheckCrossReferences.java CheckBookmarks.java CheckFlies.java +JAVAFILES = CheckIndexedPropertyValues.java CheckNamedPropertyValues.java CheckCrossReferences.java CheckBookmarks.java CheckFlies.java TextPortionEnumerationTest.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) #----- make a jar from compiled files ------------------------------ @@ -85,7 +85,9 @@ run: \ CheckCrossReferences \ CheckIndexedPropertyValues \ CheckNamedPropertyValues \ - CheckFlies + CheckFlies \ + TextPortionEnumerationTest \ + RUN: run @@ -105,3 +107,6 @@ CheckBookmarks: CheckFlies: +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) -tdoc $(PWD)$/testdocuments $(CT_PACKAGE).CheckFlies +TextPortionEnumerationTest: + +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) -tdoc $(PWD)$/testdocuments $(CT_PACKAGE).TextPortionEnumerationTest + diff --git a/sw/qa/complex/writer/testdocuments/TESTMETA.odt b/sw/qa/complex/writer/testdocuments/TESTMETA.odt Binary files differnew file mode 100755 index 0000000000..004af82e5d --- /dev/null +++ b/sw/qa/complex/writer/testdocuments/TESTMETA.odt diff --git a/sw/sdi/_annotsh.sdi b/sw/sdi/_annotsh.sdi index 6291061b86..d98339ee40 100755 --- a/sw/sdi/_annotsh.sdi +++ b/sw/sdi/_annotsh.sdi @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -36,7 +36,7 @@ interface _Annotation ExecMethod = NoteExec ; StateMethod = GetNoteState ; ] - + FN_DELETE_NOTE [ ExecMethod = NoteExec ; @@ -72,7 +72,7 @@ interface _Annotation ExecMethod = NoteExec ; StateMethod = GetNoteState ; ] - + FN_POSTIT [ ExecMethod = NoteExec ; @@ -88,12 +88,11 @@ interface _Annotation [ ExecMethod = NoteExec ; ] - + SfxVoidItem Cut SID_CUT ( ) // api: [ ExecMethod = ExecClpbrd ; StateMethod = StateClpbrd ; - Volatile ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] @@ -101,7 +100,6 @@ interface _Annotation [ ExecMethod = ExecClpbrd ; StateMethod = StateClpbrd ; - Volatile ; ] SID_PASTE // api: @@ -111,7 +109,7 @@ interface _Annotation DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - FN_PASTESPECIAL // api: + SID_PASTE_SPECIAL // api: [ StateMethod = StateClpbrd ; ExecMethod = ExecClpbrd ; @@ -124,13 +122,13 @@ interface _Annotation ExecMethod = ExecClpbrd ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - + SID_SELECTALL // api: [ ExecMethod = Exec ; StateMethod = NoState ; ] - + SID_UNDO // api: [ ExecMethod = ExecUndo ; @@ -143,7 +141,7 @@ interface _Annotation [ ExecMethod = ExecUndo ; StateMethod = StateUndo ; - + ] SID_REPEAT // api: @@ -167,12 +165,12 @@ interface _Annotation StateMethod = NoState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - + FN_FORMAT_FOOTNOTE_DLG // status() [ ExecMethod = Exec ; ] - + SID_OPEN_XML_FILTERSETTINGS // ole : no, status : ? [ ExecMethod = Exec ; @@ -193,7 +191,7 @@ interface _Annotation ExecMethod = Exec ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - + FN_INSERT_STRING [ ExecMethod = Exec ; diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi index e7c156e3d3..0a37050a4d 100644 --- a/sw/sdi/_basesh.sdi +++ b/sw/sdi/_basesh.sdi @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -95,7 +95,6 @@ interface BaseTextSelection [ ExecMethod = ExecClpbrd ; StateMethod = StateClpbrd ; - Volatile; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] @@ -103,7 +102,6 @@ interface BaseTextSelection [ ExecMethod = ExecClpbrd ; StateMethod = StateClpbrd ; - Volatile; ] SID_PASTE // status(final|play) @@ -127,7 +125,7 @@ interface BaseTextSelection DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - FN_PASTESPECIAL // status(final|play) + SID_PASTE_SPECIAL // status(final|play) [ ExecMethod = ExecClpbrd ; StateMethod = StateClpbrd ; diff --git a/sw/sdi/_docsh.sdi b/sw/sdi/_docsh.sdi index a8c249234e..cf71e18bd8 100644 --- a/sw/sdi/_docsh.sdi +++ b/sw/sdi/_docsh.sdi @@ -132,7 +132,8 @@ interface BaseTextDocument : OfficeDocument [ ExecMethod = Execute; StateMethod = GetState; - ] + ] + FN_PRINT_LAYOUT [ ExecMethod = Execute; diff --git a/sw/sdi/_frmsh.sdi b/sw/sdi/_frmsh.sdi index 62e83bf22d..8081d8e043 100644 --- a/sw/sdi/_frmsh.sdi +++ b/sw/sdi/_frmsh.sdi @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -231,12 +231,12 @@ interface BaseTextFrame StateMethod = GetState ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - + FN_FORMAT_FOOTNOTE_DLG // status() [ ExecMethod = Execute; ] - + SID_OPEN_XML_FILTERSETTINGS // ole : no, status : ? [ ExecMethod = Execute ; @@ -251,8 +251,16 @@ interface BaseTextFrame [ ExecMethod = Execute ; ] + // --> OD 2009-07-08 #i73249# + FN_TITLE_DESCRIPTION_SHAPE + [ + ExecMethod = Execute ; + StateMethod = GetState ; + DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; + ] + // <-- + - /***************************************************** Abfragefunktionen fuer ImageMaps diff --git a/sw/sdi/drwtxtsh.sdi b/sw/sdi/drwtxtsh.sdi index c55ab668b3..cb87291b0d 100644 --- a/sw/sdi/drwtxtsh.sdi +++ b/sw/sdi/drwtxtsh.sdi @@ -43,7 +43,6 @@ interface TextDrawText [ ExecMethod = ExecClpbrd ; StateMethod = StateClpbrd ; - Volatile ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] @@ -51,7 +50,6 @@ interface TextDrawText [ ExecMethod = ExecClpbrd ; StateMethod = StateClpbrd ; - Volatile ; ] SID_PASTE // api: @@ -61,7 +59,7 @@ interface TextDrawText DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] - FN_PASTESPECIAL // api: + SID_PASTE_SPECIAL // api: [ StateMethod = StateClpbrd ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; diff --git a/sw/sdi/makefile.mk b/sw/sdi/makefile.mk index 1a3f17a6c6..25b75feea0 100644 --- a/sw/sdi/makefile.mk +++ b/sw/sdi/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite @@ -38,20 +38,20 @@ PRJNAME=sw TARGET=swslots # --- Settings ----------------------------------------------------- - +.IF "$(L10N_framework)"=="" SVSDIINC=$(PRJ)$/source$/ui$/inc +.ENDIF .INCLUDE : $(PRJ)$/inc$/swpre.mk .INCLUDE : settings.mk .INCLUDE : $(PRJ)$/inc$/sw.mk - +.IF "$(L10N_framework)"=="" SDI1NAME=$(TARGET) SDI1EXPORT=swriter #SIDHRCNAME=swslots.hrc # --- Files -------------------------------------------------------- - SVSDI1DEPEND= \ switems.sdi\ swriter.sdi\ @@ -97,7 +97,9 @@ SVSDI1DEPEND= \ annotsh.sdi\ swslots.hrc \ $(INC)$/globals.hrc \ - $(INC)$/cmdid.h + $(INC)$/cmdid.h \ + $(SOLARINCXDIR)$/svxslots.ilb +.ENDIF # --- Targets ------------------------------------------------------- diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi index 97093e15a0..315d341977 100644 --- a/sw/sdi/swriter.sdi +++ b/sw/sdi/swriter.sdi @@ -821,7 +821,7 @@ SfxVoidItem ChangeDatabaseField FN_CHANGE_DBFIELD [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = TRUE, @@ -1759,7 +1759,7 @@ SfxVoidItem ExecuteMacroField FN_EXECUTE_MACROFIELD [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -1809,7 +1809,7 @@ SfxVoidItem FieldDialog FN_EDIT_FIELD [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = TRUE, @@ -4370,7 +4370,7 @@ SfxVoidItem InsertMultiIndex FN_INSERT_MULTI_TOX [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = TRUE, @@ -6509,12 +6509,12 @@ SfxVoidItem PageUpSel FN_PAGEUP_SEL ] //-------------------------------------------------------------------------- -SfxInt16Item PasteSpecial FN_PASTESPECIAL +SfxVoidItem PreviewPrintOptions FN_PREVIEW_PRINT_OPTIONS () [ /* flags: */ - AutoUpdate = FALSE, - Cachable = Volatile, + AutoUpdate = TRUE, + Cachable = Cachable, FastCall = TRUE, HasCoreId = FALSE, HasDialog = TRUE, @@ -6523,14 +6523,14 @@ SfxInt16Item PasteSpecial FN_PASTESPECIAL Container = FALSE, RecordAbsolute = FALSE, RecordPerSet; - Asynchron; + Synchron; /* config: */ AccelConfig = TRUE, MenuConfig = TRUE, StatusBarConfig = FALSE, ToolBoxConfig = TRUE, - GroupId = GID_EDIT; + GroupId = GID_DOC; ] //-------------------------------------------------------------------------- @@ -6567,7 +6567,7 @@ SfxBoolItem PrintLayout FN_PRINT_LAYOUT [ /* flags: */ AutoUpdate = TRUE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -6848,7 +6848,7 @@ SfxBoolItem Ruler FN_RULER [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -7027,7 +7027,7 @@ SfxUInt16Item SelectionMode FN_STAT_SELMODE [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -7394,7 +7394,7 @@ SfxVoidItem SetOptimalColumnWidth FN_TABLE_ADJUST_CELLS [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = TRUE, HasCoreId = FALSE, HasDialog = FALSE, @@ -7905,7 +7905,7 @@ SfxStringItem StatePageNumber FN_STAT_PAGE [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, @@ -8683,7 +8683,7 @@ SfxBoolItem ViewBounds FN_VIEW_BOUNDS [ /* flags: */ AutoUpdate = FALSE, - Cachable = Volatile, + Cachable = Cachable, FastCall = FALSE, HasCoreId = FALSE, HasDialog = FALSE, diff --git a/sw/sdi/viewsh.sdi b/sw/sdi/viewsh.sdi index 71b27cfecb..df7573e10c 100644 --- a/sw/sdi/viewsh.sdi +++ b/sw/sdi/viewsh.sdi @@ -158,9 +158,17 @@ shell SwView : SfxViewShell interface TextPrintPreview : View [ uuid = "1622A480-111A-101D-9757-6E74207A7520" ] { + SID_BROWSER_MODE + [ + StateMethod = GetState; + ] + FN_PRINT_LAYOUT + [ + ExecMethod = Execute; + StateMethod = GetState; + ] FN_REFRESH_VIEW // status(final|play) [ - ExecMethod = Execute ; StateMethod = GetState ; ] FN_CHAR_LEFT // status(final|play) diff --git a/sw/sdi/wdocsh.sdi b/sw/sdi/wdocsh.sdi index dd61919cfc..478023ac52 100644 --- a/sw/sdi/wdocsh.sdi +++ b/sw/sdi/wdocsh.sdi @@ -38,7 +38,6 @@ interface WebDocument : BaseTextDocument [ ExecMethod = Execute ; StateMethod = GetState ; - Volatile = TRUE; Asynchron = TRUE; ] diff --git a/sw/sdi/wviewsh.sdi b/sw/sdi/wviewsh.sdi index c188822d59..f4b2bb2e91 100644 --- a/sw/sdi/wviewsh.sdi +++ b/sw/sdi/wviewsh.sdi @@ -144,7 +144,6 @@ interface WebSourceView : View [ ExecMethod = Execute ; StateMethod = GetState ; - Volatile; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] @@ -152,7 +151,6 @@ interface WebSourceView : View [ ExecMethod = Execute ; StateMethod = GetState ; - Volatile; ] SID_PASTE // status(final|play) @@ -187,6 +185,14 @@ interface WebSourceView : View [ StateMethod = GetState ; ] + SID_BROWSER_MODE + [ + StateMethod = GetState; + ] + FN_PRINT_LAYOUT + [ + StateMethod = GetState; + ] } shell SwSrcView : SfxViewShell diff --git a/sw/source/core/access/accnotextframe.cxx b/sw/source/core/access/accnotextframe.cxx index 76706019b3..4bb7c73362 100644 --- a/sw/source/core/access/accnotextframe.cxx +++ b/sw/source/core/access/accnotextframe.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -42,6 +42,9 @@ #include <ndnotxt.hxx> #include <flyfrm.hxx> #include <cntfrm.hxx> +// --> OD 2009-07-14 #i73249# +#include <hints.hxx> +// <-- #include "accnotextframe.hxx" using namespace ::com::sun::star; @@ -67,13 +70,25 @@ SwAccessibleNoTextFrame::SwAccessibleNoTextFrame( sal_Int16 nInitRole, const SwFlyFrm* pFlyFrm ) : SwAccessibleFrameBase( pInitMap, nInitRole, pFlyFrm ), - aDepend( this, const_cast < SwNoTxtNode * >( GetNoTxtNode() ) ) + aDepend( this, const_cast < SwNoTxtNode * >( GetNoTxtNode() ) ), + msTitle(), + msDesc() { - const SwNoTxtNode *pNd = GetNoTxtNode(); + const SwNoTxtNode* pNd = GetNoTxtNode(); + // --> OD 2009-07-14 #i73249# + // consider new attributes Title and Description if( pNd ) - sDesc = OUString( pNd->GetAlternateText() ); - if( !sDesc.getLength() ) - sDesc = GetName(); + { + msTitle = pNd->GetTitle(); + + msDesc = pNd->GetDescription(); + if ( msDesc.getLength() == 0 && + msTitle != GetName() ) + { + msDesc = msTitle; + } + } + // <-- } SwAccessibleNoTextFrame::~SwAccessibleNoTextFrame() @@ -82,36 +97,70 @@ SwAccessibleNoTextFrame::~SwAccessibleNoTextFrame() void SwAccessibleNoTextFrame::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) { - SwAccessibleFrameBase::Modify( pOld, pNew ); + const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ; + // --> OD 2009-07-14 #i73249# + // suppress handling of RES_NAME_CHANGED in case that attribute Title is + // used as the accessible name. + if ( nWhich != RES_NAME_CHANGED || + msTitle.getLength() == 0 ) + { + SwAccessibleFrameBase::Modify( pOld, pNew ); + } - sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ; const SwNoTxtNode *pNd = GetNoTxtNode(); ASSERT( pNd == aDepend.GetRegisteredIn(), "invalid frame" ); switch( nWhich ) { - case RES_NAME_CHANGED: - if( pNd->GetAlternateText().Len() ) - break; - case RES_ALT_TEXT_CHANGED: - if( pNd && GetFrm() ) + // --> OD 2009-07-14 #i73249# + case RES_TITLE_CHANGED: { - OUString sOldDesc( sDesc ); - - const String& rDesc = pNd->GetAlternateText(); - sDesc = rDesc; - if( !sDesc.getLength() ) - sDesc = GetName(); - - if( sDesc != sOldDesc ) + const String& sOldTitle( + dynamic_cast<SwStringMsgPoolItem*>(pOld)->GetString() ); + const String& sNewTitle( + dynamic_cast<SwStringMsgPoolItem*>(pNew)->GetString() ); + if ( sOldTitle == sNewTitle ) + { + break; + } + msTitle = sNewTitle; + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::NAME_CHANGED; + aEvent.OldValue <<= OUString( sOldTitle ); + aEvent.NewValue <<= msTitle; + FireAccessibleEvent( aEvent ); + + if ( pNd->GetDescription().Len() != 0 ) + { + break; + } + } + // intentional no break here + case RES_DESCRIPTION_CHANGED: + { + if ( pNd && GetFrm() ) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; - aEvent.OldValue <<= sOldDesc; - aEvent.NewValue <<= sDesc; - FireAccessibleEvent( aEvent ); + const OUString sOldDesc( msDesc ); + + const String& rDesc = pNd->GetDescription(); + msDesc = rDesc; + if ( msDesc.getLength() == 0 && + msTitle != GetName() ) + { + msDesc = msTitle; + } + + if ( msDesc != sOldDesc ) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; + aEvent.OldValue <<= sOldDesc; + aEvent.NewValue <<= msDesc; + FireAccessibleEvent( aEvent ); + } } } break; + // <-- /* case RES_OBJECTDYING: if( aDepend.GetRegisteredIn() == @@ -138,6 +187,23 @@ void SwAccessibleNoTextFrame::Dispose( sal_Bool bRecursive ) SwAccessibleFrameBase::Dispose( bRecursive ); } +// --> OD 2009-07-14 #i73249# +OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleName (void) + throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + CHECK_FOR_DEFUNC( XAccessibleContext ) + + if ( msTitle.getLength() != 0 ) + { + return msTitle; + } + + return SwAccessibleFrameBase::getAccessibleName(); +} +// <-- + OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleDescription (void) throw (uno::RuntimeException) { @@ -145,7 +211,7 @@ OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleDescription (void) CHECK_FOR_DEFUNC( XAccessibleContext ) - return sDesc; + return msDesc; } @@ -154,10 +220,10 @@ OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleDescription (void) // XInterface // -uno::Any SAL_CALL SwAccessibleNoTextFrame::queryInterface( const uno::Type& aType ) - throw (uno::RuntimeException) +uno::Any SAL_CALL SwAccessibleNoTextFrame::queryInterface( const uno::Type& aType ) + throw (uno::RuntimeException) { - if( aType == + if( aType == ::getCppuType( static_cast<uno::Reference<XAccessibleImage>*>( NULL ) ) ) { uno::Reference<XAccessibleImage> xImage = this; @@ -193,19 +259,19 @@ uno::Sequence< uno::Type > SAL_CALL SwAccessibleNoTextFrame::getTypes() throw(un // all releveant information is already accessible through other // methods. So we just delegate to those. -OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageDescription() +OUString SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageDescription() throw ( uno::RuntimeException ) { return getAccessibleDescription(); } -sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageHeight( ) +sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageHeight( ) throw ( uno::RuntimeException ) { return getSize().Height; } -sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageWidth( ) +sal_Int32 SAL_CALL SwAccessibleNoTextFrame::getAccessibleImageWidth( ) throw ( uno::RuntimeException ) { return getSize().Width; diff --git a/sw/source/core/access/accnotextframe.hxx b/sw/source/core/access/accnotextframe.hxx index 7d4d4f4e7b..203f135588 100644 --- a/sw/source/core/access/accnotextframe.hxx +++ b/sw/source/core/access/accnotextframe.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -39,7 +39,10 @@ class SwAccessibleNoTextFrame : public SwAccessibleFrameBase, public ::com::sun::star::accessibility::XAccessibleImage { SwDepend aDepend; - ::rtl::OUString sDesc; + // --> OD 2009-07-14 #i73249# + ::rtl::OUString msTitle; + // <-- + ::rtl::OUString msDesc; protected: @@ -57,7 +60,14 @@ public: //===== XAccessibleContext ============================================== - /// Return this object's description. + // --> OD 2009-07-14 #i73249# + /// Return the object's current name. + virtual ::rtl::OUString SAL_CALL + getAccessibleName (void) + throw (::com::sun::star::uno::RuntimeException); + // <-- + + /// Return this object's description. virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void) throw (com::sun::star::uno::RuntimeException); diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx index 5d786e50bc..a48e36d134 100644 --- a/sw/source/core/access/accpara.cxx +++ b/sw/source/core/access/accpara.cxx @@ -668,8 +668,8 @@ sal_Bool SwAccessibleParagraph::GetWordBoundary( // now ask the Break-Iterator for the word DBG_ASSERT( pBreakIt != NULL, "We always need a break." ); - DBG_ASSERT( pBreakIt->xBreak.is(), "No break-iterator." ); - if( pBreakIt->xBreak.is() ) + DBG_ASSERT( pBreakIt->GetBreakIter().is(), "No break-iterator." ); + if( pBreakIt->GetBreakIter().is() ) { // get locale for this position USHORT nModelPos = GetPortionData().GetModelPosition( nPos ); @@ -681,7 +681,7 @@ sal_Bool SwAccessibleParagraph::GetWordBoundary( const USHORT nWordType = WordType::ANY_WORD; // get word boundary, as the Break-Iterator sees fit. - rBound = pBreakIt->xBreak->getWordBoundary( + rBound = pBreakIt->GetBreakIter()->getWordBoundary( rText, nPos, aLocale, nWordType, sal_True ); // It's a word if the first character is an alpha-numeric character. @@ -748,8 +748,8 @@ sal_Bool SwAccessibleParagraph::GetGlyphBoundary( // ask the Break-Iterator for the glyph by moving one cell // forward, and then one cell back DBG_ASSERT( pBreakIt != NULL, "We always need a break." ); - DBG_ASSERT( pBreakIt->xBreak.is(), "No break-iterator." ); - if( pBreakIt->xBreak.is() ) + DBG_ASSERT( pBreakIt->GetBreakIter().is(), "No break-iterator." ); + if( pBreakIt->GetBreakIter().is() ) { // get locale for this position USHORT nModelPos = GetPortionData().GetModelPosition( nPos ); @@ -759,9 +759,9 @@ sal_Bool SwAccessibleParagraph::GetGlyphBoundary( // get word boundary, as the Break-Iterator sees fit. const USHORT nIterMode = CharacterIteratorMode::SKIPCELL; sal_Int32 nDone = 0; - rBound.endPos = pBreakIt->xBreak->nextCharacters( + rBound.endPos = pBreakIt->GetBreakIter()->nextCharacters( rText, nPos, aLocale, nIterMode, 1, nDone ); - rBound.startPos = pBreakIt->xBreak->previousCharacters( + rBound.startPos = pBreakIt->GetBreakIter()->previousCharacters( rText, rBound.endPos, aLocale, nIterMode, 1, nDone ); DBG_ASSERT( rBound.startPos <= nPos, "start pos too high" ); diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx index fb80f040bd..48f4b23136 100644 --- a/sw/source/core/access/accportions.cxx +++ b/sw/source/core/access/accportions.cxx @@ -489,8 +489,8 @@ void SwAccessiblePortionData::GetSentenceBoundary( if( pSentences == NULL ) { DBG_ASSERT( pBreakIt != NULL, "We always need a break." ); - DBG_ASSERT( pBreakIt->xBreak.is(), "No break-iterator." ); - if( pBreakIt->xBreak.is() ) + DBG_ASSERT( pBreakIt->GetBreakIter().is(), "No break-iterator." ); + if( pBreakIt->GetBreakIter().is() ) { pSentences = new Positions_t(); pSentences->reserve(10); @@ -505,7 +505,7 @@ void SwAccessiblePortionData::GetSentenceBoundary( USHORT nModelPos = GetModelPosition( nCurrent ); - sal_Int32 nNew = pBreakIt->xBreak->endOfSentence( + sal_Int32 nNew = pBreakIt->GetBreakIter()->endOfSentence( sAccessibleString, nCurrent, pBreakIt->GetLocale(pTxtNode->GetLang(nModelPos)) ) + 1; diff --git a/sw/source/core/access/acctextframe.cxx b/sw/source/core/access/acctextframe.cxx index 66303ef027..d91a9ef514 100644 --- a/sw/source/core/access/acctextframe.cxx +++ b/sw/source/core/access/acctextframe.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -46,6 +46,9 @@ #include <flyfrm.hxx> #include <accmap.hxx> #include <unotools/accessiblerelationsethelper.hxx> +// --> OD 2009-07-14 #i73249# +#include <hints.hxx> +// <-- #include "acctextframe.hxx" using namespace ::com::sun::star; @@ -61,8 +64,23 @@ const sal_Char sImplementationName[] = "com.sun.star.comp.Writer.SwAccessibleTex SwAccessibleTextFrame::SwAccessibleTextFrame( SwAccessibleMap* pInitMap, const SwFlyFrm* pFlyFrm ) : - SwAccessibleFrameBase( pInitMap, AccessibleRole::TEXT_FRAME, pFlyFrm ) + SwAccessibleFrameBase( pInitMap, AccessibleRole::TEXT_FRAME, pFlyFrm ), + msTitle(), + msDesc() { + if ( pFlyFrm ) + { + const SwFlyFrmFmt* pFlyFrmFmt = + dynamic_cast<const SwFlyFrmFmt*>( pFlyFrm->GetFmt() ); + msTitle = pFlyFrmFmt->GetObjTitle(); + + msDesc = pFlyFrmFmt->GetObjDescription(); + if ( msDesc.getLength() == 0 && + msTitle != GetName() ) + { + msDesc = msTitle; + } + } } SwAccessibleTextFrame::~SwAccessibleTextFrame() @@ -71,32 +89,92 @@ SwAccessibleTextFrame::~SwAccessibleTextFrame() void SwAccessibleTextFrame::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) { - sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ; + const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0 ; + // --> OD 2009-07-14 #i73249# + // suppress handling of RES_NAME_CHANGED in case that attribute Title is + // used as the accessible name. + if ( nWhich != RES_NAME_CHANGED || + msTitle.getLength() == 0 ) + { + SwAccessibleFrameBase::Modify( pOld, pNew ); + } + const SwFlyFrm *pFlyFrm = static_cast< const SwFlyFrm * >( GetFrm() ); switch( nWhich ) { - case RES_NAME_CHANGED: - if( pFlyFrm ) + // --> OD 2009-07-14 #i73249# + case RES_TITLE_CHANGED: { - OUString sOldDesc( GetName() ); - SwAccessibleFrameBase::Modify( pOld, pNew ); - - if( sOldDesc != GetName() ) + const String& sOldTitle( + dynamic_cast<SwStringMsgPoolItem*>(pOld)->GetString() ); + const String& sNewTitle( + dynamic_cast<SwStringMsgPoolItem*>(pNew)->GetString() ); + if ( sOldTitle == sNewTitle ) { - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; - aEvent.OldValue <<= sOldDesc; - aEvent.NewValue <<= GetName(); - FireAccessibleEvent( aEvent ); + break; + } + msTitle = sNewTitle; + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::NAME_CHANGED; + aEvent.OldValue <<= OUString( sOldTitle ); + aEvent.NewValue <<= msTitle; + FireAccessibleEvent( aEvent ); + + const SwFlyFrmFmt* pFlyFrmFmt = + dynamic_cast<const SwFlyFrmFmt*>( pFlyFrm->GetFmt() ); + if ( pFlyFrmFmt->GetObjDescription().Len() != 0 ) + { + break; + } + } + // intentional no break here + case RES_DESCRIPTION_CHANGED: + { + if ( pFlyFrm ) + { + const OUString sOldDesc( msDesc ); + + const SwFlyFrmFmt* pFlyFrmFmt = + dynamic_cast<const SwFlyFrmFmt*>( pFlyFrm->GetFmt() ); + const String& rDesc = pFlyFrmFmt->GetObjDescription(); + msDesc = rDesc; + if ( msDesc.getLength() == 0 && + msTitle != GetName() ) + { + msDesc = msTitle; + } + + if ( msDesc != sOldDesc ) + { + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::DESCRIPTION_CHANGED; + aEvent.OldValue <<= sOldDesc; + aEvent.NewValue <<= msDesc; + FireAccessibleEvent( aEvent ); + } } } break; - default: - SwAccessibleFrameBase::Modify( pOld, pNew ); - break; + // <-- } } +// --> OD 2009-07-14 #i73249# +OUString SAL_CALL SwAccessibleTextFrame::getAccessibleName (void) + throw (uno::RuntimeException) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + + CHECK_FOR_DEFUNC( XAccessibleContext ) + + if ( msTitle.getLength() != 0 ) + { + return msTitle; + } + + return SwAccessibleFrameBase::getAccessibleName(); +} +// <-- OUString SAL_CALL SwAccessibleTextFrame::getAccessibleDescription (void) throw (uno::RuntimeException) { @@ -104,7 +182,7 @@ OUString SAL_CALL SwAccessibleTextFrame::getAccessibleDescription (void) CHECK_FOR_DEFUNC( XAccessibleContext ) - return GetName(); + return msDesc; } @@ -134,7 +212,7 @@ uno::Sequence< OUString > SAL_CALL SwAccessibleTextFrame::getSupportedServiceNam return aRet; } -uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleTextFrame::getImplementationId() +uno::Sequence< sal_Int8 > SAL_CALL SwAccessibleTextFrame::getImplementationId() throw(uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); diff --git a/sw/source/core/access/acctextframe.hxx b/sw/source/core/access/acctextframe.hxx index 639a7f4bf3..27c84b3fdb 100644 --- a/sw/source/core/access/acctextframe.hxx +++ b/sw/source/core/access/acctextframe.hxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -39,6 +39,11 @@ namespace com { namespace star { class SwAccessibleTextFrame : public SwAccessibleFrameBase { +private: + // --> OD 2009-07-14 #i73249# + ::rtl::OUString msTitle; + ::rtl::OUString msDesc; + // <-- protected: @@ -53,7 +58,13 @@ public: //===== XAccessibleContext ============================================== - /// Return this object's description. + // --> OD 2009-07-14 #i73249# + /// Return the object's current name. + virtual ::rtl::OUString SAL_CALL + getAccessibleName (void) + throw (::com::sun::star::uno::RuntimeException); + // <-- + /// Return this object's description. virtual ::rtl::OUString SAL_CALL getAccessibleDescription (void) throw (com::sun::star::uno::RuntimeException); diff --git a/sw/source/core/bastyp/breakit.cxx b/sw/source/core/bastyp/breakit.cxx index f463c818c6..9541707ea9 100644 --- a/sw/source/core/bastyp/breakit.cxx +++ b/sw/source/core/bastyp/breakit.cxx @@ -32,6 +32,7 @@ #include "precompiled_sw.hxx" #include "breakit.hxx" +#include <unicode/uchar.h> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> @@ -73,18 +74,18 @@ SwBreakIt::SwBreakIt( aForbiddenLang( LANGUAGE_DONTKNOW) { DBG_ASSERT( m_xMSF.is(), "SwBreakIt: no MultiServiceFactory" ); - if ( m_xMSF.is() ) - { - xBreak = uno::Reference< i18n::XBreakIterator >( - m_xMSF->createInstance( - rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ), - uno::UNO_QUERY); - - xCTLDetect = uno::Reference< i18n::XScriptTypeDetector >( - m_xMSF->createInstance( - rtl::OUString::createFromAscii( "com.sun.star.i18n.ScriptTypeDetector" ) ), - uno::UNO_QUERY); - } + //if ( m_xMSF.is() ) + //{ + // xBreak = uno::Reference< i18n::XBreakIterator >( + // m_xMSF->createInstance( + // rtl::OUString::createFromAscii( "com.sun.star.i18n.BreakIterator" ) ), + // uno::UNO_QUERY); + + // xCTLDetect = uno::Reference< i18n::XScriptTypeDetector >( + // m_xMSF->createInstance( + // rtl::OUString::createFromAscii( "com.sun.star.i18n.ScriptTypeDetector" ) ), + // uno::UNO_QUERY); + // } } SwBreakIt::~SwBreakIt() @@ -92,7 +93,16 @@ SwBreakIt::~SwBreakIt() delete m_pLocale; delete m_pForbidden; } - +void SwBreakIt::createBreakIterator() const +{ + if ( m_xMSF.is() && !xBreak.is() ) + xBreak.set(m_xMSF->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.i18n.BreakIterator"))),uno::UNO_QUERY); +} +void SwBreakIt::createScriptTypeDetector() +{ + if ( m_xMSF.is() && !xCTLDetect.is() ) + xCTLDetect.set(m_xMSF->createInstance(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.ScriptTypeDetector" ))),uno::UNO_QUERY); +} void SwBreakIt::_GetLocale( const LanguageType aLang ) { aLast = aLang; @@ -112,6 +122,7 @@ void SwBreakIt::_GetForbidden( const LanguageType aLang ) USHORT SwBreakIt::GetRealScriptOfText( const String& rTxt, xub_StrLen nPos ) const { + createBreakIterator(); USHORT nScript = i18n::ScriptType::WEAK; if( xBreak.is() && rTxt.Len() ) { @@ -119,6 +130,18 @@ USHORT SwBreakIt::GetRealScriptOfText( const String& rTxt, --nPos; nScript = xBreak->getScriptType( rTxt, nPos ); sal_Int32 nChgPos = 0; + if ( i18n::ScriptType::WEAK == nScript && nPos + 1 < rTxt.Len() ) + { + // A weak character followed by a mark may be meant to combine with + // the mark, so prefer the following character's script + switch ( u_charType(rTxt.GetChar(nPos + 1) ) ) { + case U_NON_SPACING_MARK: + case U_ENCLOSING_MARK: + case U_COMBINING_SPACING_MARK: + nScript = xBreak->getScriptType( rTxt, nPos+1 ); + break; + } + } if( i18n::ScriptType::WEAK == nScript && nPos && 0 < (nChgPos = xBreak->beginOfScript( rTxt, nPos, nScript )) ) nScript = xBreak->getScriptType( rTxt, nChgPos-1 ); @@ -138,6 +161,7 @@ USHORT SwBreakIt::GetAllScriptsOfText( const String& rTxt ) const const USHORT coAllScripts = ( SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX ); + createBreakIterator(); USHORT nRet = 0, nScript; if( !xBreak.is() ) nRet = coAllScripts; diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx index 487df0ac87..bb81f9116c 100644 --- a/sw/source/core/bastyp/calc.cxx +++ b/sw/source/core/bastyp/calc.cxx @@ -273,7 +273,7 @@ SwCalc::SwCalc( SwDoc& rD ) : aErrExpr( aEmptyStr, SwSbxValue(), 0 ), rDoc( rD ), - pLclData( &GetAppLocaleData() ), + pLclData( &SvtSysLocale().GetLocaleData() ), pCharClass( &GetAppCharClass() ), nListPor( 0 ), eError( CALC_NOERR ) @@ -422,7 +422,7 @@ SwCalc::~SwCalc() { for( USHORT n = 0; n < TBLSZ; ++n ) delete VarTable[n]; - if( pLclData != &GetAppLocaleData() ) + if( pLclData != &SvtSysLocale().GetLocaleData() ) delete pLclData; if( pCharClass != &GetAppCharClass() ) delete pCharClass; @@ -1622,7 +1622,7 @@ BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, { const LocaleDataWrapper* pLclD = pLclData; if( !pLclD ) - pLclD = &GetAppLocaleData(); + pLclD = &SvtSysLocale().GetLocaleData(); const xub_Unicode nCurrCmdPos = rCommandPos; rtl_math_ConversionStatus eStatus; @@ -1634,7 +1634,7 @@ BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, &eStatus, &pEnd ); rCommandPos = static_cast<xub_StrLen>(pEnd - rCommand.GetBuffer()); - if( !pLclData && pLclD != &GetAppLocaleData() ) + if( !pLclData && pLclD != &SvtSysLocale().GetLocaleData() ) delete (LocaleDataWrapper*)pLclD; return rtl_math_ConversionStatus_Ok == eStatus && nCurrCmdPos != rCommandPos; @@ -1643,7 +1643,7 @@ BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, double& rVal, SwDoc* pDoc ) { - const LocaleDataWrapper* pLclD = &GetAppLocaleData(); + const LocaleDataWrapper* pLclD = &SvtSysLocale().GetLocaleData(); if( pDoc ) { @@ -1664,7 +1664,7 @@ BOOL SwCalc::Str2Double( const String& rCommand, xub_StrLen& rCommandPos, &eStatus, &pEnd ); rCommandPos = static_cast<xub_StrLen>(pEnd - rCommand.GetBuffer()); - if( pLclD != &GetAppLocaleData() ) + if( pLclD != &SvtSysLocale().GetLocaleData() ) delete (LocaleDataWrapper*)pLclD; return rtl_math_ConversionStatus_Ok == eStatus && nCurrCmdPos != rCommandPos; diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx index 9fb6c70b25..84302c65c4 100644 --- a/sw/source/core/bastyp/index.cxx +++ b/sw/source/core/bastyp/index.cxx @@ -328,10 +328,10 @@ SwIndexReg::~SwIndexReg() -void SwIndexReg::Update( const SwIndex& rIdx, xub_StrLen nDiff, BOOL bNeg, - BOOL /* argument is only used in derived class*/ ) +void SwIndexReg::Update( SwIndex const & rIdx, const xub_StrLen nDiff, + const bool bNeg, const bool /* argument is only used in derived class*/ ) { - SwIndex* pStt = (SwIndex*)&rIdx; + SwIndex* pStt = const_cast<SwIndex*>(&rIdx); xub_StrLen nNewVal = rIdx.nIndex; if( bNeg ) { diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx index ca1a599968..05e5659082 100644 --- a/sw/source/core/bastyp/init.cxx +++ b/sw/source/core/bastyp/init.cxx @@ -46,9 +46,7 @@ #include <svx/shaditem.hxx> #include <svx/prntitem.hxx> #include <svx/brkitem.hxx> -#ifndef _SVX_TSTPITEM_HXX #include <svx/tstpitem.hxx> -#endif #include <svx/langitem.hxx> #include <svx/wrlmitem.hxx> #include <svx/kernitem.hxx> @@ -62,13 +60,9 @@ #include <svx/lspcitem.hxx> #include <svx/blnkitem.hxx> #include <svx/akrnitem.hxx> -#ifndef _SVX_EMPHITEM_HXX #include <svx/emphitem.hxx> -#endif #include <svx/twolinesitem.hxx> -#ifndef _SVX_SCRIPSPACEITEM_HXX #include <svx/scriptspaceitem.hxx> -#endif #include <svx/hngpnctitem.hxx> #include <svx/cmapitem.hxx> #include <svx/charscaleitem.hxx> @@ -94,7 +88,6 @@ #include <unotools/transliterationwrapper.hxx> #include <svx/acorrcfg.hxx> #include <vcl/svapp.hxx> -#include <fmthbsh.hxx> #include <fmtanchr.hxx> #include <fmtornt.hxx> #include <fmtsrnd.hxx> @@ -116,9 +109,7 @@ #include <fmtautofmt.hxx> #include <fmtinfmt.hxx> #include <fmtcnct.hxx> -#ifndef _FMTLINE_HXX #include <fmtline.hxx> -#endif #include <fmtftntx.hxx> #include <fmtruby.hxx> #include <fmtautofmt.hxx> @@ -137,9 +128,7 @@ #include <doc.hxx> #include <acmplwrd.hxx> #include <fmtclbl.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <breakit.hxx> #include <checkit.hxx> #include <swcalwrp.hxx> @@ -150,6 +139,9 @@ // OD 2004-05-05 #i28701# #include <fmtwrapinfluenceonobjpos.hxx> +#include <fmtmeta.hxx> + + using namespace ::com::sun::star; extern void _FrmFinit(); @@ -327,14 +319,14 @@ SfxItemInfo __FAR_DATA aSlotTab[] = { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY5 { SID_ATTR_CHAR_CJK_RUBY, 0 }, // RES_TXTATR_CJK_RUBY, { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_UNKNOWN_CONTAINER, - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY6, - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY7, + { 0, 0 }, // RES_TXTATR_META, + { 0, 0 }, // RES_TXTATR_METAFIELD, { 0, 0 }, // RES_TXTATR_FIELD { 0, 0 }, // RES_TXTATR_FLYCNT { 0, 0 }, // RES_TXTATR_FTN - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_SOFTHYPH - { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_HARDBLANK + { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY4 + { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY3 { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY1 { 0, SFX_ITEM_POOLABLE }, // RES_TXTATR_DUMMY2 @@ -467,14 +459,18 @@ SwAutoCompleteWord* SwDoc::pACmpltWords = 0; SwCheckIt* pCheckIt = 0; CharClass* pAppCharClass = 0; -SwCalendarWrapper* pCalendarWrapper = 0; + CollatorWrapper* pCollator = 0, *pCaseCollator = 0; ::utl::TransliterationWrapper* pTransWrp = 0; /****************************************************************************** * void _InitCore() ******************************************************************************/ - +salhelper::SingletonRef<SwCalendarWrapper>* s_getCalendarWrapper() +{ + static salhelper::SingletonRef<SwCalendarWrapper> aCalendarWrapper; + return &aCalendarWrapper; +} void _InitCore() { SfxPoolItem* pItem; @@ -540,19 +536,19 @@ void _InitCore() aAttrTab[ RES_TXTATR_CHARFMT- POOLATTR_BEGIN ] = new SwFmtCharFmt( 0 ); aAttrTab[ RES_TXTATR_CJK_RUBY - POOLATTR_BEGIN ] = new SwFmtRuby( aEmptyStr ); aAttrTab[ RES_TXTATR_UNKNOWN_CONTAINER - POOLATTR_BEGIN ] = new SvXMLAttrContainerItem( RES_TXTATR_UNKNOWN_CONTAINER ); + aAttrTab[ RES_TXTATR_META - POOLATTR_BEGIN ] = SwFmtMeta::CreatePoolDefault(RES_TXTATR_META); + aAttrTab[ RES_TXTATR_METAFIELD - POOLATTR_BEGIN ] = SwFmtMeta::CreatePoolDefault(RES_TXTATR_METAFIELD); aAttrTab[ RES_TXTATR_FIELD- POOLATTR_BEGIN ] = new SwFmtFld; aAttrTab[ RES_TXTATR_FLYCNT - POOLATTR_BEGIN ] = new SwFmtFlyCnt( 0 ); aAttrTab[ RES_TXTATR_FTN - POOLATTR_BEGIN ] = new SwFmtFtn; - aAttrTab[ RES_TXTATR_SOFTHYPH- POOLATTR_BEGIN ] = new SwFmtSoftHyph; - aAttrTab[ RES_TXTATR_HARDBLANK- POOLATTR_BEGIN ] = new SwFmtHardBlank( ' ', FALSE ); // TextAttr - Dummies + aAttrTab[ RES_TXTATR_DUMMY4 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY4 ); + aAttrTab[ RES_TXTATR_DUMMY3 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY3 ); aAttrTab[ RES_TXTATR_DUMMY1 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY1 ); aAttrTab[ RES_TXTATR_DUMMY2 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY2 ); aAttrTab[ RES_TXTATR_DUMMY5 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY5 ); - aAttrTab[ RES_TXTATR_DUMMY6 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY6 ); - aAttrTab[ RES_TXTATR_DUMMY7 - POOLATTR_BEGIN ] = new SfxBoolItem( RES_TXTATR_DUMMY7 ); // TextAttr - Dummies aAttrTab[ RES_PARATR_LINESPACING- POOLATTR_BEGIN ] = new SvxLineSpacingItem( LINE_SPACE_DEFAULT_HEIGHT, RES_PARATR_LINESPACING ); @@ -740,9 +736,9 @@ void _InitCore() SwBreakIt::_Create( xMSF ); pCheckIt = NULL; - pAppCharClass = new CharClass( - xMSF, SwBreakIt::Get()->GetLocale( (LanguageType)GetAppLanguage() )); - pCalendarWrapper = new SwCalendarWrapper( xMSF ); + /*pAppCharClass = new CharClass( + xMSF, SwBreakIt::Get()->GetLocale( (LanguageType)GetAppLanguage() ));*/ + //pCalendarWrapper = new SwCalendarWrapper( xMSF ); _FrmInit(); _TextInit(); @@ -773,7 +769,6 @@ void _FinitCore() SwBreakIt::_Delete(); delete pCheckIt; delete pAppCharClass; - delete pCalendarWrapper; delete pCollator; delete pCaseCollator; @@ -856,16 +851,15 @@ void _FinitCore() // returns the APP - CharClass instance - used for all ToUpper/ToLower/... CharClass& GetAppCharClass() { + if ( !pAppCharClass ) + { + uno::Reference< lang::XMultiServiceFactory > xMSF = ::comphelper::getProcessServiceFactory(); + pAppCharClass = new CharClass( + xMSF, SwBreakIt::Get()->GetLocale( (LanguageType)GetAppLanguage() )); + } return *pAppCharClass; } -LocaleDataWrapper& GetAppLocaleData() -{ - SvtSysLocale aSysLocale; - return (LocaleDataWrapper&)aSysLocale.GetLocaleData(); -} - - void SwCalendarWrapper::LoadDefaultCalendar( USHORT eLang ) { sUniqueId.Erase(); diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 5e9c7aa75d..8918058c31 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -42,8 +42,10 @@ #include <svx/linkmgr.hxx> #include <swtypes.hxx> #include <undobj.hxx> +#include <unoobj.hxx> #include <rtl/random.h> + SV_IMPL_REF( SwServerObject ) using namespace ::sw::mark; @@ -85,9 +87,13 @@ namespace const SwPaM aEndPaM(rEnd); io_pDoc->StartUndo(UNDO_UI_REPLACE, NULL); if(ch_start != aStartMark) - io_pDoc->Insert(aStartPaM, aStartMark); + { + io_pDoc->InsertString(aStartPaM, aStartMark); + } if(aEndMark && ch_end != aEndMark) - io_pDoc->Insert(aEndPaM, aEndMark); + { + io_pDoc->InsertString(aEndPaM, aEndMark); + } io_pDoc->EndUndo(UNDO_UI_REPLACE, NULL); }; } @@ -190,6 +196,7 @@ namespace sw { namespace mark const ::rtl::OUString& rName, const ::rtl::OUString& rShortName) : DdeBookmark(aPaM) + , ::sfx2::Metadatable() , m_aCode(rCode) , m_sShortName(rShortName) { @@ -206,6 +213,54 @@ namespace sw { namespace mark io_pDoc->SetModified(); } + // ::sfx2::Metadatable + ::sfx2::IXmlIdRegistry& Bookmark::GetRegistry() + { + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?"); + return pDoc->GetXmlIdRegistry(); + } + + bool Bookmark::IsInClipboard() const + { + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::IsInClipboard: no doc?"); + return pDoc->IsClipBoard(); + } + + bool Bookmark::IsInUndo() const + { + return false; + } + + bool Bookmark::IsInContent() const + { + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::IsInContent: no doc?"); + return !pDoc->IsInHeaderFooter( SwNodeIndex(GetMarkPos().nNode) ); + } + + ::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > + Bookmark::MakeUnoObject() + { + // re-use existing SwXBookmark + SwClientIter iter( *this ); + SwClient * pClient( iter.First( TYPE( SwXBookmark ) ) ); + while (pClient) { + SwXBookmark *const pBookmark( dynamic_cast<SwXBookmark*>(pClient) ); + if (pBookmark && pBookmark->GetCoreObject() == this) { + return pBookmark; + } + pClient = iter.Next(); + } + + // create new SwXBookmark + SwDoc *const pDoc( GetMarkPos().GetDoc() ); + OSL_ENSURE(pDoc, "Bookmark::MakeUnoObject: no doc?"); + return new SwXBookmark(this, pDoc); + } + + Fieldmark::Fieldmark(const SwPaM& rPaM) : MarkBase(rPaM, MarkBase::GenerateNewName(our_sNamePrefix)) { diff --git a/sw/source/core/crsr/callnk.cxx b/sw/source/core/crsr/callnk.cxx index 8aaa93cf56..8c26aeb6eb 100644 --- a/sw/source/core/crsr/callnk.cxx +++ b/sw/source/core/crsr/callnk.cxx @@ -171,12 +171,12 @@ SwCallLink::~SwCallLink() } } - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { const String& rTxt = ((SwTxtNode*)pCNd)->GetTxt(); if( !nCmp || - pBreakIt->xBreak->getScriptType( rTxt, nCmp ) - != pBreakIt->xBreak->getScriptType( rTxt, nCmp - 1 )) + pBreakIt->GetBreakIter()->getScriptType( rTxt, nCmp ) + != pBreakIt->GetBreakIter()->getScriptType( rTxt, nCmp - 1 )) { rShell.CallChgLnk(); return; diff --git a/sw/source/core/crsr/crossrefbookmark.cxx b/sw/source/core/crsr/crossrefbookmark.cxx index 834d574382..8ae112a783 100644 --- a/sw/source/core/crsr/crossrefbookmark.cxx +++ b/sw/source/core/crsr/crossrefbookmark.cxx @@ -75,11 +75,6 @@ namespace sw { namespace mark return *static_cast<SwPosition*>(NULL); } - bool CrossRefBookmark::IsLegalName(const ::rtl::OUString& rName) - { - return CrossRefNumItemBookmark::IsLegalName(rName) || CrossRefHeadingBookmark::IsLegalName(rName); - } - CrossRefHeadingBookmark::CrossRefHeadingBookmark(const SwPaM& rPaM, const KeyCode& rCode, const OUString& rName, diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index f828bd3542..5c6fc9a21c 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -2569,22 +2569,6 @@ void SwCrsrShell::ParkCrsr( const SwNodeIndex &rIdx ) * Alle Ansichten eines Dokumentes stehen im Ring der Shells. */ -SwOverlayType impGetOverlayType(OutputDevice* pOut) -{ - if(!pOut) - { - pOut = Application::GetDefaultDevice(); - } - - if(pOut->GetSettings().GetStyleSettings().GetHighContrastMode() - || !pOut->supportsOperation( OutDevSupport_TransparentRect )) - { - return SW_OVERLAY_INVERT; - } - - return SW_OVERLAY_TRANSPARENT; -} - SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin ) : ViewShell( rShell, pInitWin ), SwModify( 0 ), pCrsrStk( 0 ), pBlockCrsr( 0 ), pTblCrsr( 0 ), @@ -2592,9 +2576,8 @@ SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin ) eMvState( MV_NONE ), // --> OD 2008-04-02 #refactorlists# sMarkedListId(), - nMarkedListLevel( 0 ), + nMarkedListLevel( 0 ) // <-- - maSwOverlayType(SW_OVERLAY_INVERT) { SET_CURR_SHELL( this ); // Nur die Position vom aktuellen Cursor aus der Copy-Shell uebernehmen @@ -2610,9 +2593,6 @@ SwCrsrShell::SwCrsrShell( SwCrsrShell& rShell, Window *pInitWin ) // UpdateCrsr( 0 ); // OD 11.02.2003 #100556# mbMacroExecAllowed = rShell.IsMacroExecAllowed(); - - // #i88893# init cursor selection type - maSwOverlayType = impGetOverlayType(pInitWin); } @@ -2628,9 +2608,8 @@ SwCrsrShell::SwCrsrShell( SwDoc& rDoc, Window *pInitWin, eMvState( MV_NONE ), // state for crsr-travelling - GetCrsrOfst // --> OD 2008-04-02 #refactorlists# sMarkedListId(), - nMarkedListLevel( 0 ), + nMarkedListLevel( 0 ) // <-- - maSwOverlayType(SW_OVERLAY_INVERT) { SET_CURR_SHELL( this ); /* @@ -2658,9 +2637,6 @@ SwCrsrShell::SwCrsrShell( SwDoc& rDoc, Window *pInitWin, // UpdateCrsr( 0 ); // OD 11.02.2003 #100556# mbMacroExecAllowed = true; - - // #i88893# init cursor selection type - maSwOverlayType = impGetOverlayType(pInitWin); } diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx index 050467217c..d788c1e66e 100644 --- a/sw/source/core/crsr/crstrvl.cxx +++ b/sw/source/core/crsr/crstrvl.cxx @@ -1124,8 +1124,8 @@ BOOL SwCrsrShell::GetContentAtPos( const Point& rPt, if( !bRet && ( SwContentAtPos::SW_FIELD | SwContentAtPos::SW_CLICKFIELD ) & rCntntAtPos.eCntntAtPos && !aTmpState.bFtnNoInfo ) { - pTxtAttr = pTxtNd->GetTxtAttr( aPos.nContent.GetIndex(), - RES_TXTATR_FIELD ); + pTxtAttr = pTxtNd->GetTxtAttrForCharAt( + aPos.nContent.GetIndex(), RES_TXTATR_FIELD ); const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; @@ -1190,7 +1190,7 @@ BOOL SwCrsrShell::GetContentAtPos( const Point& rPt, if( bRet ) rCntntAtPos.eCntntAtPos = SwContentAtPos::SW_FTN; } - else if( 0 != ( pTxtAttr = pTxtNd->GetTxtAttr( + else if ( 0 != ( pTxtAttr = pTxtNd->GetTxtAttrForCharAt( aPos.nContent.GetIndex(), RES_TXTATR_FTN )) ) { bRet = TRUE; @@ -1526,9 +1526,8 @@ const SwPostItField* SwCrsrShell::GetPostItFieldAtCursor() const const SwTxtNode* pTxtNd = pCursorPos->nNode.GetNode().GetTxtNode(); if ( pTxtNd ) { - SwTxtAttr* pTxtAttr = - pTxtNd->GetTxtAttr( pCursorPos->nContent.GetIndex(), - RES_TXTATR_FIELD ); + SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttrForCharAt( + pCursorPos->nContent.GetIndex(), RES_TXTATR_FIELD ); const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; if ( pFld && pFld->Which()== RES_POSTITFLD ) { @@ -1766,7 +1765,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) if( n < aFPos.nColumnCnt ) { *pCurCrsr->GetPoint() = aPos; - GetDoc()->Insert( *pCurCrsr, + GetDoc()->InsertPoolItem( *pCurCrsr, SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0); } } @@ -1792,7 +1791,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) if( SVX_ADJUST_LEFT != rAdj.GetAdjust() ) aSet.Put( SvxAdjustItem( SVX_ADJUST_LEFT, RES_PARATR_ADJUST ) ); - GetDoc()->Insert( *pCurCrsr, aSet, 0 ); + GetDoc()->InsertItemSet( *pCurCrsr, aSet, 0 ); } else { ASSERT( !this, "wo ist mein CntntNode?" ); @@ -1812,7 +1811,9 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) sInsert += sSpace; } if( sInsert.Len() ) - GetDoc()->Insert( *pCurCrsr, sInsert, true ); + { + GetDoc()->InsertString( *pCurCrsr, sInsert ); + } } // kein break - Ausrichtung muss noch gesetzt werden case FILL_MARGIN: @@ -1830,7 +1831,7 @@ BOOL SwCrsrShell::SetShadowCrsrPos( const Point& rPt, SwFillMode eFillMode ) default: break; } - GetDoc()->Insert( *pCurCrsr, aAdj, 0 ); + GetDoc()->InsertPoolItem( *pCurCrsr, aAdj, 0 ); } break; } diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index 981767e30a..61fefca669 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -1189,7 +1189,8 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, if( bReplaceTxt ) { - int bRegExp = SearchAlgorithms_REGEXP == pSearchOpt->algorithmType; + const bool bRegExp( + SearchAlgorithms_REGEXP == pSearchOpt->algorithmType); SwIndex& rSttCntIdx = pCrsr->Start()->nContent; xub_StrLen nSttCnt = rSttCntIdx.GetIndex(); @@ -1202,12 +1203,11 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, ((Ring*)pRegion)->MoveRingTo( &rCursor ); } - String *pRepl = bRegExp ? ReplaceBackReferences( *pSearchOpt, pCrsr ) : 0; - if( pRepl ) - rCursor.GetDoc()->Replace( *pCrsr, *pRepl, bRegExp ); - else - rCursor.GetDoc()->Replace( *pCrsr, pSearchOpt->replaceString, bRegExp ); - delete pRepl; + ::std::auto_ptr<String> pRepl( (bRegExp) ? + ReplaceBackReferences( *pSearchOpt, pCrsr ) : 0 ); + rCursor.GetDoc()->ReplaceRange( *pCrsr, + (pRepl.get()) ? *pRepl : String(pSearchOpt->replaceString), + bRegExp ); rCursor.SaveTblBoxCntnt( pCrsr->GetPoint() ); if( bRegExp ) @@ -1235,7 +1235,9 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, // ReplaceSet angegeben, auf Default zurueck gesetzt if( !pSet->Count() ) - pCrsr->GetDoc()->Insert( *pCrsr, *pReplSet, 0 ); + { + pCrsr->GetDoc()->InsertItemSet( *pCrsr, *pReplSet, 0 ); + } else { SfxItemPool* pPool = pReplSet->GetPool(); @@ -1255,7 +1257,7 @@ int SwFindParaAttr::Find( SwPaM* pCrsr, SwMoveFn fnMove, const SwPaM* pRegion, pItem = aIter.NextItem(); } aSet.Put( *pReplSet ); - pCrsr->GetDoc()->Insert( *pCrsr, aSet, 0 ); + pCrsr->GetDoc()->InsertItemSet( *pCrsr, aSet, 0 ); } #endif return FIND_NO_RING; diff --git a/sw/source/core/crsr/findtxt.cxx b/sw/source/core/crsr/findtxt.cxx index e483aa44a0..ab93dee334 100644 --- a/sw/source/core/crsr/findtxt.cxx +++ b/sw/source/core/crsr/findtxt.cxx @@ -126,7 +126,7 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, if ( bNewHint ) { const SwTxtAttr* pHt = (*pHts)[n]; - if ( !pHt->GetEnd() && nStt >= nStart ) + if ( pHt->HasDummyChar() && (nStt >= nStart) ) { //JP 17.05.00: Task 75806 ask for ">=" and not for ">" switch( pHt->Which() ) @@ -136,7 +136,9 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, case RES_TXTATR_FIELD: case RES_TXTATR_REFMARK: case RES_TXTATR_TOXMARK: - { + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + { // JP 06.05.98: mit Bug 50100 werden sie als Trenner erwuenscht und nicht // mehr zum Wort dazu gehoerend. // MA 23.06.98: mit Bug 51215 sollen sie konsequenterweise auch am @@ -161,9 +163,6 @@ String& lcl_CleanStr( const SwTxtNode& rNd, xub_StrLen nStart, } } break; - case RES_TXTATR_HARDBLANK: - rRet.SetChar( nAkt, ((SwTxtHardBlank*)pHt)->GetChar() ); - break; default: ASSERT( false, "unknown case in lcl_CleanStr" ) break; @@ -456,7 +455,7 @@ bool SwPaM::DoSearch( const SearchOptions& rSearchOpt, utl::TextSearch& rSTxt, USHORT nCurrScript = 0; if ( SearchAlgorithms_APPROXIMATE == rSearchOpt.algorithmType && - pBreakIt->xBreak.is() ) + pBreakIt->GetBreakIter().is() ) { pScriptIter = new SwScriptIterator( sCleanStr, nStart, bSrchForward ); nSearchScript = pBreakIt->GetRealScriptOfText( rSearchOpt.searchString, 0 ); @@ -593,7 +592,7 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove, if( bFnd && bReplace ) // String ersetzen ?? { // Replace-Methode vom SwDoc benutzen - int bRegExp = SearchAlgorithms_REGEXP == rSearchOpt.algorithmType; + const bool bRegExp(SearchAlgorithms_REGEXP == rSearchOpt.algorithmType); SwIndex& rSttCntIdx = pCrsr->Start()->nContent; xub_StrLen nSttCnt = rSttCntIdx.GetIndex(); // damit die Region auch verschoben wird, in den Shell-Cursr-Ring @@ -605,12 +604,11 @@ int SwFindParaText::Find( SwPaM* pCrsr, SwMoveFn fnMove, ((Ring*)pRegion)->MoveRingTo( &rCursor ); } - String *pRepl = bRegExp ? ReplaceBackReferences( rSearchOpt, pCrsr ) : 0; - if( pRepl ) - rCursor.GetDoc()->Replace( *pCrsr, *pRepl, bRegExp ); - else - rCursor.GetDoc()->Replace( *pCrsr, rSearchOpt.replaceString, bRegExp ); - delete pRepl; + ::std::auto_ptr<String> pRepl( (bRegExp) + ? ReplaceBackReferences( rSearchOpt, pCrsr ) : 0 ); + rCursor.GetDoc()->ReplaceRange( *pCrsr, + (pRepl.get()) ? *pRepl : String(rSearchOpt.replaceString), + bRegExp ); rCursor.SaveTblBoxCntnt( pCrsr->GetPoint() ); if( bRegExp ) diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 7a8a83ef38..d80f1a2465 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -198,7 +198,12 @@ SwComparePosition ComparePosition( nRet = POS_INSIDE; } else - nRet = POS_OVERLAP_BEHIND; + { + if (rStt1 == rStt2) + nRet = POS_OUTSIDE; + else + nRet = POS_OVERLAP_BEHIND; + } } else if( rEnd2 == rStt1 ) nRet = POS_COLLIDE_START; @@ -237,7 +242,12 @@ SwComparePosition ComparePosition( nRet = POS_INSIDE; } else - nRet = POS_OVERLAP_BEHIND; + { + if (nStt1 == nStt2) + nRet = POS_OUTSIDE; + else + nRet = POS_OVERLAP_BEHIND; + } } else if( nEnd2 == nStt1 ) nRet = POS_COLLIDE_START; diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index d32eaf667e..749046780b 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1188,10 +1188,10 @@ BOOL SwCursor::IsStartWordWT( sal_Int16 nWordType ) const { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - bRet = pBreakIt->xBreak->isBeginWord( + bRet = pBreakIt->GetBreakIter()->isBeginWord( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos )), nWordType ); @@ -1203,10 +1203,10 @@ BOOL SwCursor::IsEndWordWT( sal_Int16 nWordType ) const { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - bRet = pBreakIt->xBreak->isEndWord( + bRet = pBreakIt->GetBreakIter()->isEndWord( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType ); @@ -1219,10 +1219,10 @@ BOOL SwCursor::IsInWordWT( sal_Int16 nWordType ) const { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - Boundary aBoundary = pBreakIt->xBreak->getWordBoundary( + Boundary aBoundary = pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType, @@ -1261,11 +1261,11 @@ BOOL SwCursor::GoStartWordWT( sal_Int16 nWordType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { SwCrsrSaveState aSave( *this ); xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - nPtPos = (xub_StrLen)pBreakIt->xBreak->getWordBoundary( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType, @@ -1285,11 +1285,11 @@ BOOL SwCursor::GoEndWordWT( sal_Int16 nWordType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { SwCrsrSaveState aSave( *this ); xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - nPtPos = (xub_StrLen)pBreakIt->xBreak->getWordBoundary( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType, @@ -1310,12 +1310,12 @@ BOOL SwCursor::GoNextWordWT( sal_Int16 nWordType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { SwCrsrSaveState aSave( *this ); xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - nPtPos = (xub_StrLen)pBreakIt->xBreak->nextWord( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->nextWord( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos, 1 ) ), nWordType ).startPos; @@ -1334,7 +1334,7 @@ BOOL SwCursor::GoPrevWordWT( sal_Int16 nWordType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { SwCrsrSaveState aSave( *this ); xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); @@ -1342,7 +1342,7 @@ BOOL SwCursor::GoPrevWordWT( sal_Int16 nWordType ) if( nPtPos ) --nPtPos; - nPtPos = (xub_StrLen)pBreakIt->xBreak->previousWord( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->previousWord( pTxtNd->GetTxt(), nPtStart, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos, 1 ) ), nWordType ).startPos; @@ -1373,10 +1373,10 @@ BOOL SwCursor::SelectWordWT( sal_Int16 nWordType, const Point* pPt ) } const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { xub_StrLen nPtPos = GetPoint()->nContent.GetIndex(); - Boundary aBndry( pBreakIt->xBreak->getWordBoundary( + Boundary aBndry( pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), nWordType, @@ -1408,7 +1408,7 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) { BOOL bRet = FALSE; const SwTxtNode* pTxtNd = GetNode()->GetTxtNode(); - if( pTxtNd && pBreakIt->xBreak.is() ) + if( pTxtNd && pBreakIt->GetBreakIter().is() ) { //mask deleted redlines String sNodeText(pTxtNd->GetTxt()); @@ -1438,14 +1438,14 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) switch ( eMoveType ) { case END_SENT: - nPtPos = (xub_StrLen)pBreakIt->xBreak->endOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfSentence( sNodeText, nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); break; case NEXT_SENT: { - nPtPos = (xub_StrLen)pBreakIt->xBreak->endOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfSentence( sNodeText, nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); @@ -1455,20 +1455,20 @@ BOOL SwCursor::GoSentence( SentenceMoveType eMoveType ) break; } case START_SENT: - nPtPos = (xub_StrLen)pBreakIt->xBreak->beginOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( sNodeText, nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); break; case PREV_SENT: - nPtPos = (xub_StrLen)pBreakIt->xBreak->beginOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( sNodeText, nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); if (nPtPos == 0) return FALSE; // the previous sentence is not in this paragraph if (nPtPos > 0) - nPtPos = (xub_StrLen)pBreakIt->xBreak->beginOfSentence( + nPtPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfSentence( sNodeText, nPtPos - 1, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) )); diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx index 5b5277c6cd..8f31456292 100644 --- a/sw/source/core/crsr/viscrs.cxx +++ b/sw/source/core/crsr/viscrs.cxx @@ -59,19 +59,10 @@ #include <comcore.hrc> // ResId fuer Abfrage wenn zu Search & Replaces #endif -// #i75172# #include <svx/sdr/overlay/overlaymanager.hxx> #include <svx/sdrpaintwindow.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> -#include <basegfx/polygon/b2dpolygon.hxx> -#include <basegfx/polygon/b2dpolypolygontools.hxx> -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <vcl/hatch.hxx> - -#include <drawinglayer/primitive2d/invertprimitive2d.hxx> -#include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx> -#include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> +#include <vcl/svapp.hxx> +#include <svx/sdr/overlay/overlayselection.hxx> extern void SwCalcPixStatics( OutputDevice *pOut ); @@ -524,106 +515,6 @@ void SwVisCrsr::_SetPosAndShow() } ////////////////////////////////////////////////////////////////////////////// -// #i75172# - -namespace sdr -{ - namespace overlay - { - class OverlaySwSelPaintRects : public OverlayObject - { - // geometry - std::vector< basegfx::B2DRange > maRanges; - SwOverlayType mePaintType; - - // geometry creation for OverlayObject - virtual drawinglayer::primitive2d::Primitive2DSequence createOverlayObjectPrimitive2DSequence(); - - public: - OverlaySwSelPaintRects(Color aBaseColor, const std::vector< basegfx::B2DRange >& rRanges, SwOverlayType eType); - virtual ~OverlaySwSelPaintRects(); - - // data access - const std::vector< basegfx::B2DRange >& getB2DRanges() const { return maRanges; } - void setB2DRanges(const std::vector< basegfx::B2DRange >& rNew); - }; - - drawinglayer::primitive2d::Primitive2DSequence OverlaySwSelPaintRects::createOverlayObjectPrimitive2DSequence() - { - drawinglayer::primitive2d::Primitive2DSequence aRetval; - const sal_uInt32 nCount(maRanges.size()); - - if(nCount) - { - const basegfx::BColor aRGBColor(getBaseColor().getBColor()); - aRetval.realloc(nCount); - - // create primitives for all ranges - for(sal_uInt32 a(0); a < nCount; a++) - { - const basegfx::B2DRange& rRange(maRanges[a]); - const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(rRange)); - - aRetval[a] = drawinglayer::primitive2d::Primitive2DReference( - new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D( - basegfx::B2DPolyPolygon(aPolygon), - aRGBColor)); - } - - - if( mePaintType == SW_OVERLAY_TRANSPARENT) - { - // embed in 50% transparent paint - const drawinglayer::primitive2d::Primitive2DReference aUnifiedAlpha( - new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D( - aRetval, - 0.5)); - - aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedAlpha, 1); - } - else // SW_OVERLAY_INVERT - { - // embed in invert primitive - const drawinglayer::primitive2d::Primitive2DReference aInvert( - new drawinglayer::primitive2d::InvertPrimitive2D( - aRetval)); - - aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aInvert, 1); - } - } - - return aRetval; - } - - OverlaySwSelPaintRects::OverlaySwSelPaintRects(Color aBaseColor, const std::vector< basegfx::B2DRange >& rRanges, SwOverlayType eType) - : OverlayObject(aBaseColor), - maRanges(rRanges), - mePaintType(eType) - { - // no AA for selection overlays - allowAntiAliase(false); - } - - OverlaySwSelPaintRects::~OverlaySwSelPaintRects() - { - if(getOverlayManager()) - { - getOverlayManager()->remove(*this); - } - } - - void OverlaySwSelPaintRects::setB2DRanges(const std::vector< basegfx::B2DRange >& rNew) - { - if(rNew != maRanges) - { - maRanges = rNew; - objectChange(); - } - } - } // end of namespace overlay -} // end of namespace sdr - -////////////////////////////////////////////////////////////////////////////// SwSelPaintRects::SwSelPaintRects( const SwCrsrShell& rCSh ) : SwRects( 0 ), @@ -671,8 +562,11 @@ void SwSelPaintRects::Show() if(pView && pView->PaintWindowCount()) { + // reset rects SwRects::Remove( 0, SwRects::Count() ); FillRects(); + + // get new rects std::vector< basegfx::B2DRange > aNewRanges; for(sal_uInt16 a(0); a < Count(); a++) @@ -689,7 +583,7 @@ void SwSelPaintRects::Show() { if(aNewRanges.size()) { - static_cast< sdr::overlay::OverlaySwSelPaintRects* >(mpCursorOverlay)->setB2DRanges(aNewRanges); + static_cast< sdr::overlay::OverlaySelection* >(mpCursorOverlay)->setRanges(aNewRanges); } else { @@ -704,20 +598,34 @@ void SwSelPaintRects::Show() if(pTargetOverlay) { - Color aHighlight(COL_BLACK); - const OutputDevice *pOut = GetShell()->GetOut(); - - if(pOut) - { - aHighlight = pOut->GetSettings().GetStyleSettings().GetHighlightColor(); + // #i97672# get the system's hilight color and limit it to the maximum + // allowed luminance. This is needed to react on too bright hilight colors + // which would otherwise vive a bad visualisation + const OutputDevice *pOut = Application::GetDefaultDevice(); + Color aHighlight(pOut->GetSettings().GetStyleSettings().GetHighlightColor()); + const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer; + const basegfx::BColor aSelection(aHighlight.getBColor()); + const double fLuminance(aSelection.luminance()); + const double fMaxLum(aSvtOptionsDrawinglayer.GetSelectionMaximumLuminancePercent() / 100.0); + + if(fLuminance > fMaxLum) + { + const double fFactor(fMaxLum / fLuminance); + const basegfx::BColor aNewSelection( + aSelection.getRed() * fFactor, + aSelection.getGreen() * fFactor, + aSelection.getBlue() * fFactor); + + aHighlight = Color(aNewSelection); } - SwOverlayType aType(GetShell()->getSwOverlayType()); -#ifdef DBG_UTIL - static bool bChange(false); - if(bChange) aType = (SW_OVERLAY_INVERT == aType) ? SW_OVERLAY_TRANSPARENT : SW_OVERLAY_INVERT; -#endif - mpCursorOverlay = new sdr::overlay::OverlaySwSelPaintRects(aHighlight, aNewRanges, aType); + // create correct selection + mpCursorOverlay = new sdr::overlay::OverlaySelection( + sdr::overlay::OVERLAY_TRANSPARENT, + aHighlight, + aNewRanges, + true); + pTargetOverlay->add(*mpCursorOverlay); } } diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx index e37c9c8ba4..fc9effe7cf 100644 --- a/sw/source/core/doc/dbgoutsw.cxx +++ b/sw/source/core/doc/dbgoutsw.cxx @@ -173,13 +173,13 @@ map<USHORT,String,CompareUShort> & GetItemWhichMap() aItemWhichMap[RES_TXTATR_DUMMY5] = String("TXTATR_DUMMY5", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_CJK_RUBY] = String("TXTATR_CJK_RUBY", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_UNKNOWN_CONTAINER] = String("TXTATR_UNKNOWN_CONTAINER", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_DUMMY6] = String("TXTATR_DUMMY6", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_DUMMY7] = String("TXTATR_DUMMY7", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_META] = String("TXTATR_META", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_METAFIELD] = String("TXTATR_METAFIELD", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_FIELD] = String("TXTATR_FIELD", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_FLYCNT] = String("TXTATR_FLYCNT", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_FTN] = String("TXTATR_FTN", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_SOFTHYPH] = String("TXTATR_SOFTHYPH", RTL_TEXTENCODING_ASCII_US); - aItemWhichMap[RES_TXTATR_HARDBLANK] = String("TXTATR_HARDBLANK", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_DUMMY4] = String("TXTATR_DUMMY4", RTL_TEXTENCODING_ASCII_US); + aItemWhichMap[RES_TXTATR_DUMMY3] = String("TXTATR_DUMMY3", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_DUMMY1] = String("TXTATR_DUMMY1", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_TXTATR_DUMMY2] = String("TXTATR_DUMMY2", RTL_TEXTENCODING_ASCII_US); aItemWhichMap[RES_PARATR_LINESPACING] = String("PARATR_LINESPACING", RTL_TEXTENCODING_ASCII_US); @@ -542,7 +542,7 @@ String lcl_dbg_out(const SwNode & rNode) String aTmpStr; aTmpStr += String("<node ", RTL_TEXTENCODING_ASCII_US); - aTmpStr += String("index =\"", RTL_TEXTENCODING_ASCII_US); + aTmpStr += String("index=\"", RTL_TEXTENCODING_ASCII_US); aTmpStr += String::CreateFromInt32(rNode.GetIndex()); aTmpStr += String("\"", RTL_TEXTENCODING_ASCII_US); @@ -552,6 +552,10 @@ String lcl_dbg_out(const SwNode & rNode) aTmpStr += String("\"", RTL_TEXTENCODING_ASCII_US); #endif + aTmpStr += String(" type=\"", RTL_TEXTENCODING_ASCII_US); + aTmpStr += String::CreateFromInt32(sal_Int32( rNode.GetNodeType() ) ); + aTmpStr += String("\"", RTL_TEXTENCODING_ASCII_US); + aTmpStr += String(" pointer=\"", RTL_TEXTENCODING_ASCII_US); char aBuffer[128]; @@ -668,7 +672,15 @@ String lcl_dbg_out(const SwNode & rNode) } } else if (rNode.IsStartNode()) - aTmpStr += String("<start/>", RTL_TEXTENCODING_ASCII_US); + { + aTmpStr += String("<start end=\"", RTL_TEXTENCODING_ASCII_US); + + const SwStartNode * pStartNode = dynamic_cast<const SwStartNode *> (&rNode); + if (pStartNode != NULL) + aTmpStr += String::CreateFromInt32(pStartNode->EndOfSectionNode()->GetIndex()); + + aTmpStr += String("\"/>", RTL_TEXTENCODING_ASCII_US); + } else if (rNode.IsEndNode()) aTmpStr += String("<end/>", RTL_TEXTENCODING_ASCII_US); @@ -718,25 +730,68 @@ BOOL lcl_dbg_add_node(const SwNodePtr & pNode, void * pArgs) return TRUE; } -String lcl_dbg_out(SwNodes & rNodes) +void lcl_dbg_nodes_inner(String & aStr, SwNodes & rNodes, ULONG & nIndex) { - String aStr("<nodes>", RTL_TEXTENCODING_ASCII_US); + SwNode * pNode = rNodes[nIndex]; + SwStartNode * pStartNode = dynamic_cast<SwStartNode *> (pNode); - for (ULONG i = 0; i < rNodes.Count(); i++) - { - SwNode * pNode = rNodes[i]; + SwNode * pEndNode = NULL; + if (pStartNode != NULL) + pEndNode = pStartNode->EndOfSectionNode(); - if (pNode->IsEndNode()) - aStr += String("</nodes>\n", RTL_TEXTENCODING_ASCII_US); - - aStr += lcl_dbg_out(*pNode); - aStr += String("\n", RTL_TEXTENCODING_ASCII_US); + ULONG nCount = rNodes.Count(); + ULONG nStartIndex = nIndex; + + bool bDone = false; + + String aTag; + if (pNode->IsTableNode()) + aTag += String("table", RTL_TEXTENCODING_ASCII_US); + else if (pNode->IsSectionNode()) + aTag += String("section", RTL_TEXTENCODING_ASCII_US); + else + aTag += String("nodes", RTL_TEXTENCODING_ASCII_US); - if (pNode->IsStartNode()) - aStr += String("<nodes>", RTL_TEXTENCODING_ASCII_US); + aStr += String("<", RTL_TEXTENCODING_ASCII_US); + aStr += aTag; + aStr += String(">", RTL_TEXTENCODING_ASCII_US); + + while (! bDone) + { + if (pNode->IsStartNode() && nIndex != nStartIndex) + lcl_dbg_nodes_inner(aStr, rNodes, nIndex); + else + { + aStr += lcl_dbg_out(*pNode); + aStr += String("\n", RTL_TEXTENCODING_ASCII_US); + + nIndex++; + } + + if (pNode == pEndNode || nIndex >= nCount) + bDone = true; + else + pNode = rNodes[nIndex]; } + + aStr += String("</", RTL_TEXTENCODING_ASCII_US); + aStr += aTag; + aStr += String(">\n", RTL_TEXTENCODING_ASCII_US); +} - aStr += String("</nodes>\n", RTL_TEXTENCODING_ASCII_US); +String lcl_dbg_out(SwNodes & rNodes) +{ + String aStr("<nodes-array>", RTL_TEXTENCODING_ASCII_US); + + ULONG nIndex = 0; + ULONG nCount = rNodes.Count(); + + while (nIndex < nCount) + { + lcl_dbg_nodes_inner(aStr, rNodes, nIndex); + } + + aStr += String("</nodes-array>\n", RTL_TEXTENCODING_ASCII_US); return aStr; } @@ -1024,5 +1079,24 @@ SW_DLLPUBLIC const char * dbg_out(const SwFormTokens & rTokens) { return dbg_out(lcl_dbg_out(rTokens)); } + +String lcl_dbg_out(const SwNodeRange & rRange) +{ + String aStr("[", RTL_TEXTENCODING_ASCII_US); + + aStr += lcl_dbg_out(SwPosition(rRange.aStart)); + aStr += String(", ", RTL_TEXTENCODING_ASCII_US); + aStr += lcl_dbg_out(SwPosition(rRange.aEnd)); + + aStr += String("]" , RTL_TEXTENCODING_ASCII_US); + + return aStr; +} + +SW_DLLPUBLIC const char * dbg_out(const SwNodeRange & rRange) +{ + return dbg_out(lcl_dbg_out(rRange)); +} + #endif // DEBUG diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 61c596963f..d45f5ae337 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -637,7 +637,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) { SwCntntNode *pNode = rPos.nNode.GetNode().GetCntntNode(); if(0 == pNode) - return FALSE; + return false; { // Bug 26675: DataChanged vorm loeschen verschicken, dann bekommt @@ -652,7 +652,10 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) ClearRedo(); // einfuegen vom Undo-Object, z.Z. nur beim TextNode if( pNode->IsTxtNode() ) - AppendUndo( pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart )); + { + pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart ); + AppendUndo(pUndo); + } } //JP 28.01.97: Sonderfall fuer SplitNode am Tabellenanfang: @@ -722,7 +725,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) if( pUndo ) pUndo->SetTblFlag(); SetModified(); - return TRUE; + return true; } } } @@ -731,7 +734,10 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) SvULongs aBkmkArr( 15, 15 ); _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), aBkmkArr, SAVEFLY_SPLIT ); - if( 0 != ( pNode = pNode->SplitCntntNode( rPos ) )) + // FIXME: only SwTxtNode has a valid implementation of SplitCntntNode! + ASSERT(pNode->IsTxtNode(), "splitting non-text node?"); + pNode = pNode->SplitCntntNode( rPos ); + if (pNode) { // verschiebe noch alle Bookmarks/TOXMarks/FlyAtCnt if( aBkmkArr.Count() ) @@ -750,7 +756,7 @@ bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart ) } SetModified(); - return TRUE; + return true; } bool SwDoc::AppendTxtNode( SwPosition& rPos ) @@ -793,73 +799,86 @@ bool SwDoc::AppendTxtNode( SwPosition& rPos ) return TRUE; } -bool SwDoc::Insert( const SwPaM &rRg, const String &rStr, bool bHintExpand ) +bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr, + const enum InsertFlags nInsertMode ) { if( DoesUndo() ) + { ClearRedo(); + } - const SwPosition* pPos = rRg.GetPoint(); + const SwPosition& rPos = *rRg.GetPoint(); if( pACEWord ) // Aufnahme in die Autokorrektur { if( 1 == rStr.Len() && pACEWord->IsDeleted() ) - pACEWord->CheckChar( *pPos, rStr.GetChar( 0 ) ); + { + pACEWord->CheckChar( rPos, rStr.GetChar( 0 ) ); + } delete pACEWord, pACEWord = 0; } - SwTxtNode *pNode = pPos->nNode.GetNode().GetTxtNode(); + SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode(); if(!pNode) - return FALSE; + { + return false; + } - const USHORT nInsMode = bHintExpand ? INS_EMPTYEXPAND - : INS_NOHINTEXPAND; SwDataChanged aTmp( rRg, 0 ); if( !DoesUndo() || !DoesGroupUndo() ) { - pNode->Insert( rStr, pPos->nContent, nInsMode ); + pNode->InsertText( rStr, rPos.nContent, nInsertMode ); if( DoesUndo() ) - AppendUndo( new SwUndoInsert( pPos->nNode, - pPos->nContent.GetIndex(), rStr.Len() )); + { + SwUndoInsert * const pUndo( new SwUndoInsert( + rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), nInsertMode)); + AppendUndo(pUndo); + } } else { // ist Undo und Gruppierung eingeschaltet, ist alles anders ! - USHORT nUndoSize = pUndos->Count(); - xub_StrLen nInsPos = pPos->nContent.GetIndex(); SwUndoInsert * pUndo = NULL; // #111827# - CharClass& rCC = GetAppCharClass(); + // don't group the start if hints at the start should be expanded + if (!(nInsertMode & IDocumentContentOperations::INS_FORCEHINTEXPAND)) // -> #111827# - bool bNewUndo = false; - if( 0 == nUndoSize) - bNewUndo = true; - else { - pUndo = (SwUndoInsert*)(*pUndos)[ --nUndoSize ]; - - switch (pUndo->GetId()) + USHORT const nUndoSize = pUndos->Count(); + if (0 != nUndoSize) { - case UNDO_INSERT: - case UNDO_TYPING: - bNewUndo = !pUndo->CanGrouping( *pPos ); + SwUndo * const pLastUndo = (*pUndos)[ nUndoSize - 1 ]; - break; + switch (pLastUndo->GetId()) + { + case UNDO_INSERT: + case UNDO_TYPING: + if (static_cast<SwUndoInsert*>(pLastUndo) + ->CanGrouping( rPos )) + { + pUndo = static_cast<SwUndoInsert*>(pLastUndo); + } + break; - default: - bNewUndo = true; + default: + break; + } } } // <- #111827# - if (bNewUndo) + CharClass const& rCC = GetAppCharClass(); + xub_StrLen nInsPos = rPos.nContent.GetIndex(); + + if (!pUndo) { - pUndo = new SwUndoInsert( pPos->nNode, nInsPos, 0, + pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode, !rCC.isLetterNumeric( rStr, 0 ) ); AppendUndo( pUndo ); } - pNode->Insert( rStr, pPos->nContent, nInsMode ); + pNode->InsertText( rStr, rPos.nContent, nInsertMode ); for( xub_StrLen i = 0; i < rStr.Len(); ++i ) { @@ -867,7 +886,7 @@ bool SwDoc::Insert( const SwPaM &rRg, const String &rStr, bool bHintExpand ) // wenn CanGrouping() TRUE returnt, ist schon alles erledigt if( !pUndo->CanGrouping( rStr.GetChar( i ) )) { - pUndo = new SwUndoInsert( pPos->nNode, nInsPos, 1, + pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 1, nInsertMode, !rCC.isLetterNumeric( rStr, i ) ); AppendUndo( pUndo ); } @@ -876,16 +895,21 @@ bool SwDoc::Insert( const SwPaM &rRg, const String &rStr, bool bHintExpand ) if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) { - SwPaM aPam( pPos->nNode, aTmp.GetCntnt(), - pPos->nNode, pPos->nContent.GetIndex()); + SwPaM aPam( rPos.nNode, aTmp.GetCntnt(), + rPos.nNode, rPos.nContent.GetIndex()); if( IsRedlineOn() ) - AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); + { + AppendRedline( + new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); + } else + { SplitRedline( aPam ); + } } SetModified(); - return TRUE; + return true; } SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode, @@ -2111,7 +2135,7 @@ BOOL SwDoc::RemoveInvisibleContent() ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() && !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) ) { - Delete( aPam ); + DeleteRange( aPam ); } else { @@ -2147,7 +2171,7 @@ BOOL SwDoc::RemoveInvisibleContent() ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() && !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) ) { - Delete( aPam ); + DeleteRange( aPam ); } else { @@ -2233,7 +2257,7 @@ BOOL SwDoc::RemoveInvisibleContent() &aPam.GetPoint()->nNode ); aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() ); - Delete( aPam ); + DeleteRange( aPam ); } else { @@ -2315,11 +2339,14 @@ BOOL SwDoc::ConvertFieldsToText() sText.Erase(); //now remove the field and insert the string - SwPaM aPam(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); - aPam.SetMark(); - aPam.Move(); - DeleteAndJoin(aPam); - Insert( aPam, sText, true ); + SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); + aPam1.Move(); + //insert first to keep the field's attributes + InsertString( aPam1, sText ); + SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart()); + aPam2.SetMark(); + aPam2.Move(); + DeleteAndJoin(aPam2);//remove the field } } ++aBegin; @@ -2521,24 +2548,19 @@ String SwDoc::GetPaMDescr(const SwPaM & rPam) const // -> #111840# SwField * SwDoc::GetField(const SwPosition & rPos) { - SwField * pResult = NULL; - - SwTxtFld * pAttr = rPos.nNode.GetNode().GetTxtNode()-> - GetTxtFld(rPos.nContent); - - if (pAttr) - pResult = (SwField *) pAttr->GetFld().GetFld(); + SwTxtFld * const pAttr = GetTxtFld(rPos); - return pResult; + return (pAttr) ? const_cast<SwField *>( pAttr->GetFld().GetFld() ) : 0; } SwTxtFld * SwDoc::GetTxtFld(const SwPosition & rPos) { - SwTxtNode *pNode = rPos.nNode.GetNode().GetTxtNode(); - if( pNode ) - return pNode->GetTxtFld( rPos.nContent ); - else - return 0; + SwTxtNode * const pNode = rPos.nNode.GetNode().GetTxtNode(); + + return (pNode) + ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt( + rPos.nContent.GetIndex(), RES_TXTATR_FIELD) ) + : 0; } // <- #111840# diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index a71c246c16..80973abeca 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -114,8 +114,8 @@ namespace return pResult; } - // return a position at the begin of rEnd, if it is a CntntNode - // else set it to the begin of the Node after rEnd, if there is one + // return a position at the begin of rEnd, if it is a CntntNode + // else set it to the begin of the Node after rEnd, if there is one // else set it to the end of the node before rStt // else set it to the CntntNode of the Pos outside the Range static inline auto_ptr<SwPosition> lcl_FindExpelPosition(const SwNodeIndex& rStt, @@ -485,7 +485,7 @@ namespace sw { namespace mark // illegal selection? collapse the mark and restore sorting later isSortingNeeded |= lcl_FixCorrectedMark(bChangedPos, bChangedOPos, pMark); } - // restore sorting if needed + // restore sorting if needed if(isSortingNeeded) sortMarks(); #if FALSE @@ -525,7 +525,7 @@ namespace sw { namespace mark // illegal selection? collapse the mark and restore sorting later isSortingNeeded |= lcl_FixCorrectedMark(bChangedPos, bChangedOPos, pMark); } - // restore sorting if needed + // restore sorting if needed if(isSortingNeeded) sortMarks(); #if FALSE @@ -535,11 +535,11 @@ namespace sw { namespace mark } void MarkManager::deleteMarks( - const SwNodeIndex& rStt, - const SwNodeIndex& rEnd, - ::std::vector<SaveBookmark>* pSaveBkmk, - const SwIndex* pSttIdx, - const SwIndex* pEndIdx) + const SwNodeIndex& rStt, + const SwNodeIndex& rEnd, + ::std::vector<SaveBookmark>* pSaveBkmk, + const SwIndex* pSttIdx, + const SwIndex* pEndIdx ) { vector<const_iterator_t> vMarksToDelete; bool isSortingNeeded = false; @@ -561,7 +561,7 @@ namespace sw { namespace mark bool isOtherPosInRange = (pMark->IsExpanded() && lcl_GreaterThan(pMark->GetOtherMarkPos(), rStt, pSttIdx) && lcl_Lower(pMark->GetOtherMarkPos(), rEnd, pEndIdx)); - // special case: completely in range, touching the end? + // special case: completely in range, touching the end? if(pEndIdx && ((isOtherPosInRange && pMark->GetMarkPos().nNode == rEnd @@ -574,12 +574,29 @@ namespace sw { namespace mark isPosInRange = true, isOtherPosInRange = true; } - if(isPosInRange && isOtherPosInRange) + if(isPosInRange && (isOtherPosInRange || !pMark->IsExpanded())) { // completely in range - if(pSaveBkmk) - pSaveBkmk->push_back(SaveBookmark(true, true, *pMark, rStt, pSttIdx)); - vMarksToDelete.push_back(ppMark); + + // --> OD 2009-08-07 #i92125# + bool bKeepCrossRefBkmk( false ); + { + if ( rStt == rEnd && + ( IDocumentMarkAccess::GetType(*pMark) == + IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK || + IDocumentMarkAccess::GetType(*pMark) == + IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK ) ) + { + bKeepCrossRefBkmk = true; + } + } + if ( !bKeepCrossRefBkmk ) + { + if(pSaveBkmk) + pSaveBkmk->push_back(SaveBookmark(true, true, *pMark, rStt, pSttIdx)); + vMarksToDelete.push_back(ppMark); + } + // <-- } else if(isPosInRange ^ isOtherPosInRange) { @@ -596,24 +613,37 @@ namespace sw { namespace mark rEnd, isPosInRange ? pMark->GetOtherMarkPos() : pMark->GetMarkPos()); - if(isPosInRange) - pMark->SetMarkPos(*pNewPos); - else - pMark->SetOtherMarkPos(*pNewPos); + // --> OD 2009-08-06 #i92125# + // no move of position for cross-reference bookmarks, + // if move occurs inside a certain node + if ( ( IDocumentMarkAccess::GetType(*pMark) != + IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK && + IDocumentMarkAccess::GetType(*pMark) != + IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK ) || + pMark->GetMarkPos().nNode != pNewPos->nNode ) + { + if(isPosInRange) + pMark->SetMarkPos(*pNewPos); + else + pMark->SetOtherMarkPos(*pNewPos); - // illegal selection? collapse the mark and restore sorting later - isSortingNeeded |= lcl_FixCorrectedMark(isPosInRange, isOtherPosInRange, pMark); + // illegal selection? collapse the mark and restore sorting later + isSortingNeeded |= lcl_FixCorrectedMark(isPosInRange, isOtherPosInRange, pMark); + } + // <-- } } // we just remembered the iterators to delete, so we do not need to search // for the shared_ptr<> (the entry in m_vMarks) again // reverse iteration, since erasing an entry invalidates iterators - // behind it (the iterators in vMarksToDelete are sorted) + // behind it (the iterators in vMarksToDelete are sorted) for(vector<const_iterator_t>::reverse_iterator pppMark = vMarksToDelete.rbegin(); pppMark != vMarksToDelete.rend(); pppMark++) + { deleteMark(*pppMark); + } if(isSortingNeeded) sortMarks(); #if FALSE @@ -965,6 +995,14 @@ SaveBookmark::SaveBookmark( { m_aShortName = pBookmark->GetShortName(); m_aCode = pBookmark->GetKeyCode(); + + ::sfx2::Metadatable * const pMetadatable( + const_cast< ::sfx2::Metadatable * >( // CreateUndo should be const? + dynamic_cast< ::sfx2::Metadatable const* >(pBookmark))); + if (pMetadatable) + { + m_pMetadataUndo = pMetadatable->CreateUndo(); + } } m_nNode1 = rBkmk.GetMarkPos().nNode.GetIndex(); m_nCntnt1 = rBkmk.GetMarkPos().nContent.GetIndex(); @@ -1043,6 +1081,16 @@ void SaveBookmark::SetInDoc( { pBookmark->SetKeyCode(m_aCode); pBookmark->SetShortName(m_aShortName); + if (m_pMetadataUndo) + { + ::sfx2::Metadatable * const pMeta( + dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); + OSL_ENSURE(pMeta, "metadata undo, but not metadatable?"); + if (pMeta) + { + pMeta->RestoreMetadata(m_pMetadataUndo); + } + } } } } diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 1a80dd6431..5fa7731fcb 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1196,7 +1196,8 @@ BOOL SwCompareLine::ChangesInLine( const SwCompareLine& rLine, SwPaM aCpyPam( rSrcNd, nStt ); aCpyPam.SetMark(); aCpyPam.GetPoint()->nContent = nSEnd; - aCpyPam.GetDoc()->Copy( aCpyPam, *aPam.GetPoint(), false ); + aCpyPam.GetDoc()->CopyRange( aCpyPam, *aPam.GetPoint(), + false ); pDoc->DoUndo( bUndo ); } @@ -1624,7 +1625,9 @@ USHORT _SaveMergeRedlines::InsertRedline( FNInsUndo pFn ) RedlineMode_t eOld = pDoc->GetRedlineMode(); pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); - pSrcRedl->GetDoc()->Copy( *(SwPaM*)pSrcRedl, *pDestRedl->GetPoint(), false ); + pSrcRedl->GetDoc()->CopyRange( + *const_cast<SwPaM*>(static_cast<const SwPaM*>(pSrcRedl)), + *pDestRedl->GetPoint(), false ); pDoc->SetRedlineMode_intern( eOld ); pDoc->DoUndo( bUndo ); diff --git a/sw/source/core/doc/docdde.cxx b/sw/source/core/doc/docdde.cxx index 02edef612c..a6c6d2ab8a 100644 --- a/sw/source/core/doc/docdde.cxx +++ b/sw/source/core/doc/docdde.cxx @@ -62,17 +62,24 @@ using namespace ::com::sun::star; namespace { - static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark(const IDocumentMarkAccess& rMarkAccess, const String& rName) + static ::sw::mark::DdeBookmark* lcl_FindDdeBookmark(const IDocumentMarkAccess& rMarkAccess, const String& rName, bool bCaseSensitive) { //Iterating over all bookmarks, checking DdeBookmarks - const String sNameLc = GetAppCharClass().lower(rName); + const ::rtl::OUString sNameLc = bCaseSensitive ? rName : GetAppCharClass().lower(rName); for(IDocumentMarkAccess::const_iterator_t ppMark = rMarkAccess.getMarksBegin(); ppMark != rMarkAccess.getMarksEnd(); ppMark++) { - ::sw::mark::DdeBookmark* const pBkmk = dynamic_cast< ::sw::mark::DdeBookmark*>(ppMark->get()); - if(pBkmk && GetAppCharClass().lower(pBkmk->GetName()) == sNameLc) - return pBkmk; + if (::sw::mark::DdeBookmark* const pBkmk = dynamic_cast< ::sw::mark::DdeBookmark*>(ppMark->get())) + { + if ( + (bCaseSensitive && (pBkmk->GetName() == sNameLc)) || + (!bCaseSensitive && GetAppCharClass().lower(pBkmk->GetName()) == String(sNameLc)) + ) + { + return pBkmk; + } + } } return NULL; } @@ -80,22 +87,26 @@ namespace struct _FindItem { - const String& rItem; + const String m_Item; SwTableNode* pTblNd; SwSectionNode* pSectNd; _FindItem(const String& rS) - : rItem(rS), pTblNd(0), pSectNd(0) + : m_Item(rS), pTblNd(0), pSectNd(0) {} }; -BOOL lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) +BOOL lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs, bool bCaseSensitive ) { + _FindItem * const pItem( static_cast<_FindItem*>(pArgs) ); SwSection* pSect = rpSectFmt->GetSection(); if( pSect ) { - String sNm( GetAppCharClass().lower( pSect->GetName() )); - if( sNm.Equals( ((_FindItem*)pArgs)->rItem )) + String sNm( bCaseSensitive ? pSect->GetName() : GetAppCharClass().lower( pSect->GetName() )); + String sCompare( (bCaseSensitive) + ? pItem->m_Item + : GetAppCharClass().lower( pItem->m_Item ) ); + if( sNm == sCompare ) { // gefunden, als erfrage die Daten const SwNodeIndex* pIdx; @@ -103,7 +114,7 @@ BOOL lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) &rpSectFmt->GetDoc()->GetNodes() == &pIdx->GetNodes() ) { // eine Tabelle im normalen NodesArr - ((_FindItem*)pArgs)->pSectNd = pIdx->GetNode().GetSectionNode(); + pItem->pSectNd = pIdx->GetNode().GetSectionNode(); return FALSE; } //nein!! // sollte der Namen schon passen, der Rest aber nicht, dann haben wir @@ -112,13 +123,22 @@ BOOL lcl_FindSection( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) } return TRUE; // dann weiter } +BOOL lcl_FindSectionCaseSensitive( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) +{ + return lcl_FindSection( rpSectFmt, pArgs, true ); +} +BOOL lcl_FindSectionCaseInsensitive( const SwSectionFmtPtr& rpSectFmt, void* pArgs ) +{ + return lcl_FindSection( rpSectFmt, pArgs, false ); +} BOOL lcl_FindTable( const SwFrmFmtPtr& rpTableFmt, void* pArgs ) { + _FindItem * const pItem( static_cast<_FindItem*>(pArgs) ); String sNm( GetAppCharClass().lower( rpTableFmt->GetName() )); - if( sNm.Equals( ((_FindItem*)pArgs)->rItem )) + if (sNm.Equals( pItem->m_Item )) { SwTable* pTmpTbl; SwTableBox* pFBox; @@ -128,7 +148,7 @@ BOOL lcl_FindTable( const SwFrmFmtPtr& rpTableFmt, void* pArgs ) &rpTableFmt->GetDoc()->GetNodes() == &pFBox->GetSttNd()->GetNodes() ) { // eine Tabelle im normalen NodesArr - ((_FindItem*)pArgs)->pTblNd = (SwTableNode*) + pItem->pTblNd = (SwTableNode*) pFBox->GetSttNd()->FindTableNode(); return FALSE; } @@ -143,20 +163,30 @@ BOOL lcl_FindTable( const SwFrmFmtPtr& rpTableFmt, void* pArgs ) bool SwDoc::GetData( const String& rItem, const String& rMimeType, uno::Any & rValue ) const { - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem); - if(pBkmk) return SwServerObject(*pBkmk).GetData(rValue, rMimeType); - - // haben wir ueberhaupt das Item vorraetig? - String sItem(GetAppCharClass().lower(rItem)); - _FindItem aPara( sItem ); - ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), - lcl_FindSection, &aPara ); - if( aPara.pSectNd ) + //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive + bool bCaseSensitive = true; + while( true ) { - // gefunden, als erfrage die Daten - return SwServerObject( *aPara.pSectNd ).GetData( rValue, rMimeType ); + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem, bCaseSensitive); + if(pBkmk) + return SwServerObject(*pBkmk).GetData(rValue, rMimeType); + + // haben wir ueberhaupt das Item vorraetig? + String sItem( bCaseSensitive ? rItem : GetAppCharClass().lower(rItem)); + _FindItem aPara( sItem ); + ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), + bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara ); + if( aPara.pSectNd ) + { + // gefunden, als erfrage die Daten + return SwServerObject( *aPara.pSectNd ).GetData( rValue, rMimeType ); + } + if( !bCaseSensitive ) + break; + bCaseSensitive = false; } + _FindItem aPara( GetAppCharClass().lower( rItem )); ((SwFrmFmts*)pTblFrmFmtTbl)->ForEach( 0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara ); if( aPara.pTblNd ) @@ -172,19 +202,30 @@ bool SwDoc::GetData( const String& rItem, const String& rMimeType, bool SwDoc::SetData( const String& rItem, const String& rMimeType, const uno::Any & rValue ) { - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem); - if(pBkmk) return SwServerObject(*pBkmk).SetData(rMimeType, rValue); - - // haben wir ueberhaupt das Item vorraetig? - String sItem(GetAppCharClass().lower(rItem)); - _FindItem aPara( sItem ); - pSectionFmtTbl->ForEach( 0, pSectionFmtTbl->Count(), lcl_FindSection, &aPara ); - if( aPara.pSectNd ) + //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive + bool bCaseSensitive = true; + while( true ) { - // gefunden, als erfrage die Daten - return SwServerObject( *aPara.pSectNd ).SetData( rMimeType, rValue ); + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem, bCaseSensitive); + if(pBkmk) + return SwServerObject(*pBkmk).SetData(rMimeType, rValue); + + // haben wir ueberhaupt das Item vorraetig? + String sItem( bCaseSensitive ? rItem : GetAppCharClass().lower(rItem)); + _FindItem aPara( sItem ); + pSectionFmtTbl->ForEach( 0, pSectionFmtTbl->Count(), bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara ); + if( aPara.pSectNd ) + { + // gefunden, als erfrage die Daten + return SwServerObject( *aPara.pSectNd ).SetData( rMimeType, rValue ); + } + if( !bCaseSensitive ) + break; + bCaseSensitive = false; } + String sItem(GetAppCharClass().lower(rItem)); + _FindItem aPara( sItem ); pTblFrmFmtTbl->ForEach( 0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara ); if( aPara.pTblNd ) { @@ -200,31 +241,42 @@ bool SwDoc::SetData( const String& rItem, const String& rMimeType, { SwServerObject* pObj = NULL; - // bookmarks - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem); - if(pBkmk && pBkmk->IsExpanded() - && (0 == (pObj = pBkmk->GetRefObject()))) - { - // mark found, but no link yet -> create hotlink - pObj = new SwServerObject(*pBkmk); - pBkmk->SetRefObject(pObj); - GetLinkManager().InsertServer(pObj); - } - if(pObj) return pObj; - - _FindItem aPara(GetAppCharClass().lower(rItem)); - // sections - ((SwSectionFmts&)*pSectionFmtTbl).ForEach(0, pSectionFmtTbl->Count(), lcl_FindSection, &aPara); - if(aPara.pSectNd - && (0 == (pObj = aPara.pSectNd->GetSection().GetObject()))) + //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive + bool bCaseSensitive = true; + while( true ) { - // section found, but no link yet -> create hotlink - pObj = new SwServerObject( *aPara.pSectNd ); - aPara.pSectNd->GetSection().SetRefObject( pObj ); - GetLinkManager().InsertServer(pObj); + // bookmarks + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, rItem, bCaseSensitive); + if(pBkmk && pBkmk->IsExpanded() + && (0 == (pObj = pBkmk->GetRefObject()))) + { + // mark found, but no link yet -> create hotlink + pObj = new SwServerObject(*pBkmk); + pBkmk->SetRefObject(pObj); + GetLinkManager().InsertServer(pObj); + } + if(pObj) + return pObj; + + _FindItem aPara(bCaseSensitive ? rItem : GetAppCharClass().lower(rItem)); + // sections + ((SwSectionFmts&)*pSectionFmtTbl).ForEach(0, pSectionFmtTbl->Count(), bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara); + if(aPara.pSectNd + && (0 == (pObj = aPara.pSectNd->GetSection().GetObject()))) + { + // section found, but no link yet -> create hotlink + pObj = new SwServerObject( *aPara.pSectNd ); + aPara.pSectNd->GetSection().SetRefObject( pObj ); + GetLinkManager().InsertServer(pObj); + } + if(pObj) + return pObj; + if( !bCaseSensitive ) + break; + bCaseSensitive = false; } - if(pObj) return pObj; + _FindItem aPara( GetAppCharClass().lower(rItem) ); // tables ((SwFrmFmts*)pTblFrmFmtTbl)->ForEach(0, pTblFrmFmtTbl->Count(), lcl_FindTable, &aPara); if(aPara.pTblNd @@ -329,31 +381,39 @@ BOOL SwDoc::SelectServerObj( const String& rStr, SwPaM*& rpPam, return FALSE; } - ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, sItem); - if(pBkmk) + //search for bookmarks and sections case senstive at first. If nothing is found then try again case insensitive + bool bCaseSensitive = true; + while( true ) { - if(pBkmk->IsExpanded()) - rpPam = new SwPaM( - pBkmk->GetMarkPos(), - pBkmk->GetOtherMarkPos()); - return static_cast<bool>(rpPam); - } + ::sw::mark::DdeBookmark* const pBkmk = lcl_FindDdeBookmark(*pMarkManager, sItem, bCaseSensitive); + if(pBkmk) + { + if(pBkmk->IsExpanded()) + rpPam = new SwPaM( + pBkmk->GetMarkPos(), + pBkmk->GetOtherMarkPos()); + return static_cast<bool>(rpPam); + } - // alte "Mechanik" - rCC.toLower( sItem ); - _FindItem aPara( sItem ); + // + _FindItem aPara( bCaseSensitive ? sItem : rCC.lower( sItem ) ); - if( pSectionFmtTbl->Count() ) - { - ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), - lcl_FindSection, &aPara ); - if( aPara.pSectNd ) + if( pSectionFmtTbl->Count() ) { - rpRange = new SwNodeRange( *aPara.pSectNd, 1, - *aPara.pSectNd->EndOfSectionNode() ); - return TRUE; + ((SwSectionFmts&)*pSectionFmtTbl).ForEach( 0, pSectionFmtTbl->Count(), + bCaseSensitive ? lcl_FindSectionCaseSensitive : lcl_FindSectionCaseInsensitive, &aPara ); + if( aPara.pSectNd ) + { + rpRange = new SwNodeRange( *aPara.pSectNd, 1, + *aPara.pSectNd->EndOfSectionNode() ); + return TRUE; + } } + if( !bCaseSensitive ) + break; + bCaseSensitive = false; } return FALSE; } + diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 44e8e15e3b..56565eb6b6 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -71,7 +71,7 @@ #include <fldbas.hxx> #include <swwait.hxx> #include <GetMetricVal.hxx> - +#include <svtools/syslocale.hxx> #ifndef _STATSTR_HRC #include <statstr.hrc> #endif @@ -112,7 +112,7 @@ static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId, nMinRight = nMinTop = nMinBottom = GetMetricVal( CM_1 ); nMinLeft = nMinRight * 2; } - else if( MEASURE_METRIC == GetAppLocaleData().getMeasurementSystemEnum() ) + else if( MEASURE_METRIC == SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ) { nMinTop = nMinBottom = nMinLeft = nMinRight = 1134; //2 Zentimeter } diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 0c434ecbb8..f741f2fc04 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -163,24 +163,11 @@ SV_DECL_PTRARR_DEL( _SaveRedlines, _SaveRedline*, 0, 4 ) SV_IMPL_VARARR( _SaveFlyArr, _SaveFly ) SV_IMPL_PTRARR( _SaveRedlines, _SaveRedline* ) -sal_Bool lcl_MayOverwrite( const SwTxtNode *pNode, const xub_StrLen nPos ) +bool lcl_MayOverwrite( const SwTxtNode *pNode, const xub_StrLen nPos ) { - sal_Bool bRet = sal_True; - const SwTxtAttr *pHt; sal_Unicode cChr = pNode->GetTxt().GetChar( nPos ); - if( ( CH_TXTATR_BREAKWORD == cChr || CH_TXTATR_INWORD == cChr ) && - 0 != (pHt = pNode->GetTxtAttr( nPos )) ) - switch( pHt->Which() ) - { - case RES_TXTATR_FLYCNT: - case RES_TXTATR_FTN: - case RES_TXTATR_FIELD: - case RES_TXTATR_REFMARK: - case RES_TXTATR_TOXMARK: - bRet = sal_False; - break; - } - return bRet; + return !( ( CH_TXTATR_BREAKWORD == cChr || CH_TXTATR_INWORD == cChr ) && + (0 != pNode->GetTxtAttrForCharAt( nPos ) ) ); } void lcl_SkipAttr( const SwTxtNode *pNode, SwIndex &rIdx, xub_StrLen &rStart ) @@ -421,7 +408,7 @@ bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd, { SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode(); SwIndex aIdx( &rTxtNd, nFtnSttIdx ); - rTxtNd.Erase( aIdx, 1 ); + rTxtNd.EraseText( aIdx, 1 ); } else { @@ -449,7 +436,7 @@ bool lcl_SaveFtn( const SwNodeIndex& rSttNd, const SwNodeIndex& rEndNd, // dann weg damit SwTxtNode& rTxtNd = (SwTxtNode&)pSrch->GetTxtNode(); SwIndex aIdx( &rTxtNd, nFtnSttIdx ); - rTxtNd.Erase( aIdx, 1 ); + rTxtNd.EraseText( aIdx, 1 ); } else { @@ -764,64 +751,6 @@ void SwDoc::DeleteSection( SwNode *pNode ) } - -/************************************************************************* -|* SwDoc::Insert(char) -|* Beschreibung Zeichen einfuegen -*************************************************************************/ - -bool SwDoc::Insert( const SwPaM &rRg, sal_Unicode c ) -{ - if( DoesUndo() ) - ClearRedo(); - - const SwPosition & rPos = *rRg.GetPoint(); - - if( pACEWord ) // Aufnahme in die Autokorrektur - { - if( pACEWord->IsDeleted() ) - pACEWord->CheckChar( rPos, c ); - delete pACEWord, pACEWord = 0; - } - SwTxtNode *pNode = rPos.nNode.GetNode().GetTxtNode(); - if(!pNode) - return sal_False; - sal_Bool bInsOneChar = sal_True; - - SwDataChanged aTmp( rRg, 0 ); - - pNode->Insert( c, rPos.nContent ); - - if ( DoesUndo() ) - { - sal_uInt16 nUndoSize = pUndos->Count(); - SwUndo * pUndo; - if( DoesGroupUndo() && bInsOneChar && nUndoSize-- && - UNDO_INSERT == ( pUndo = (*pUndos)[ nUndoSize ])->GetId() && - ((SwUndoInsert*)pUndo)->CanGrouping( rPos, c )) - ; // wenn CanGrouping() sal_True returnt, ist schon alles erledigt - else - AppendUndo( new SwUndoInsert( rPos.nNode, - rPos.nContent.GetIndex(), 1, - !GetAppCharClass().isLetterNumeric( - pNode->GetTxt(), - rPos.nContent.GetIndex() - 1 ))); - } - - if( IsRedlineOn() || (!IsIgnoreRedline() && pRedlineTbl->Count() )) - { - SwPaM aPam( rPos.nNode, rPos.nContent.GetIndex() - 1, - rPos.nNode, rPos.nContent.GetIndex() ); - if( IsRedlineOn() ) - AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); - else - SplitRedline( aPam ); - } - - SetModified(); - return sal_True; -} - void SwDoc::SetModified(SwPaM &rPaM) { SwDataChanged aTmp( rPaM, 0 ); @@ -829,91 +758,8 @@ void SwDoc::SetModified(SwPaM &rPaM) } /************************************************************************* -|* SwDoc::Overwrite(char) -|* Beschreibung Zeichen ueberschreiben -*************************************************************************/ - -bool SwDoc::Overwrite( const SwPaM &rRg, sal_Unicode c ) -{ - SwPosition& rPt = *(SwPosition*)rRg.GetPoint(); - if( pACEWord ) // Aufnahme in die Autokorrektur - { - pACEWord->CheckChar( rPt, c ); - delete pACEWord, pACEWord = 0; - } - - SwTxtNode *pNode = rPt.nNode.GetNode().GetTxtNode(); - if(!pNode) - return sal_False; - - sal_uInt16 nOldAttrCnt = pNode->GetpSwpHints() - ? pNode->GetpSwpHints()->Count() : 0; - SwDataChanged aTmp( rRg, 0 ); - SwIndex& rIdx = rPt.nContent; - xub_StrLen nStart = rIdx.GetIndex(); - - // hinter das Zeichen (zum aufspannen der Attribute !!) - if( nStart < pNode->GetTxt().Len() ) - lcl_SkipAttr( pNode, rIdx, nStart ); - - if( DoesUndo() ) - { - ClearRedo(); - sal_uInt16 nUndoSize = pUndos->Count(); - SwUndo * pUndo; - if( DoesGroupUndo() && nUndoSize-- && - UNDO_OVERWRITE == ( pUndo = (*pUndos)[ nUndoSize ])->GetId() && - ((SwUndoOverwrite*)pUndo)->CanGrouping( this, rPt, c )) - ;// wenn CanGrouping() sal_True returnt, ist schon alles erledigt - else - AppendUndo( new SwUndoOverwrite( this, rPt, c )); - } - else - { - BOOL bOldExpFlg = pNode->IsIgnoreDontExpand(); - pNode->SetIgnoreDontExpand( TRUE ); - - // hinter das Zeichen (zum aufspannen der Attribute !!) - if( nStart < pNode->GetTxt().Len() ) - rIdx++; - pNode->Insert( c, rIdx ); - if( nStart+1 < rIdx.GetIndex() ) - { - rIdx = nStart; - pNode->Erase( rIdx, 1 ); - rIdx++; - } - pNode->SetIgnoreDontExpand( bOldExpFlg ); - } - - sal_uInt16 nNewAttrCnt = pNode->GetpSwpHints() - ? pNode->GetpSwpHints()->Count() : 0; - if( nOldAttrCnt != nNewAttrCnt ) - { - SwUpdateAttr aHint( 0, 0, 0 ); - SwClientIter aIter( *pNode ); - SwClient* pGTO = aIter.First(TYPE( SwCrsrShell )); - while( pGTO ) - { - pGTO->Modify( 0, &aHint ); - pGTO = aIter.Next(); - } - } - - if( !DoesUndo() && !IsIgnoreRedline() && GetRedlineTbl().Count() ) - { - SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); - DeleteRedline( aPam, true, USHRT_MAX ); - } - else if( IsRedlineOn() ) - { - SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); - AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); - } - - SetModified(); - return sal_True; -} + * SwDoc::Overwrite() + ************************************************************************/ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) { @@ -949,8 +795,11 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) for( xub_StrLen nCnt = 0; nCnt < rStr.Len(); ++nCnt ) { // hinter das Zeichen (zum aufspannen der Attribute !!) - if( (nStart = rIdx.GetIndex()) < pNode->GetTxt().Len() ) + nStart = rIdx.GetIndex(); + if ( nStart < pNode->GetTxt().Len() ) + { lcl_SkipAttr( pNode, rIdx, nStart ); + } c = rStr.GetChar( nCnt ); if( DoesUndo() ) { @@ -969,11 +818,11 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) // hinter das Zeichen (zum Aufspannen der Attribute !!) if( nStart < pNode->GetTxt().Len() ) rIdx++; - pNode->Insert( c, rIdx ); + pNode->InsertText( c, rIdx, INS_EMPTYEXPAND ); if( nStart+1 < rIdx.GetIndex() ) { rIdx = nStart; - pNode->Erase( rIdx, 1 ); + pNode->EraseText( rIdx, 1 ); rIdx++; } } @@ -1001,6 +850,8 @@ bool SwDoc::Overwrite( const SwPaM &rRg, const String &rStr ) } else if( IsRedlineOn() ) { + // FIXME: this redline is WRONG: there is no DELETE, and the skipped + // characters are also included in aPam SwPaM aPam( rPt.nNode, nStart, rPt.nNode, rPt.nContent.GetIndex() ); AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); } @@ -1017,7 +868,7 @@ bool SwDoc::MoveAndJoin( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) sal_Bool bOneNode = rPaM.GetPoint()->nNode == rPaM.GetMark()->nNode; aIdx--; // vor den Move Bereich !! - sal_Bool bRet = Move( rPaM, rPos, eMvFlags ); + bool bRet = MoveRange( rPaM, rPos, eMvFlags ); if( bRet && !bOneNode ) { if( bJoinTxt ) @@ -1036,12 +887,15 @@ bool SwDoc::MoveAndJoin( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) return bRet; } -bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) +// mst: it seems that this is mostly used by SwDoc internals; the only +// way to call this from the outside seems to be the special case in +// SwDoc::CopyRange (but i have not managed to actually hit that case) +bool SwDoc::MoveRange( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) { // keine Moves-Abfangen const SwPosition *pStt = rPaM.Start(), *pEnd = rPaM.End(); if( !rPaM.HasMark() || *pStt >= *pEnd || (*pStt <= rPos && rPos < *pEnd)) - return sal_False; + return false; // sicher die absatzgebundenen Flys, damit sie verschoben werden koennen. _SaveFlyArr aSaveFlyArr; @@ -1088,7 +942,7 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) } sal_Bool bSplit = sal_False; - SwPaM * pSavePam = new SwPaM( rPos, rPos ); + SwPaM aSavePam( rPos, rPos ); // stelle den SPoint an den Anfang vom Bereich (Definition) if( rPaM.GetPoint() == pEnd ) @@ -1116,7 +970,7 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(), aBkmkArr, SAVEFLY_SPLIT ); - pTNd = (SwTxtNode*)pTNd->SplitCntntNode( rPos ); + pTNd = static_cast<SwTxtNode*>(pTNd->SplitCntntNode( rPos )); if( aBkmkArr.Count() ) _RestoreCntntIdx( this, aBkmkArr, rPos.nNode.GetIndex()-1, 0, sal_True ); @@ -1132,9 +986,11 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // setze den Pam um einen "Inhalt" zurueck; dadurch steht er immer // ausserhalb des manipulierten Bereiches. Falls kein Inhalt mehr vor- // handen, dann auf den StartNode (es ist immer einer vorhanden !!!) - sal_Bool bNullCntnt = !pSavePam->Move( fnMoveBackward, fnGoCntnt ); + sal_Bool bNullCntnt = !aSavePam.Move( fnMoveBackward, fnGoCntnt ); if( bNullCntnt ) - pSavePam->GetPoint()->nNode--; + { + aSavePam.GetPoint()->nNode--; + } // kopiere alle Bookmarks, die im Move Bereich stehen in ein // Array, das alle Angaben auf die Position als Offset speichert. @@ -1151,31 +1007,33 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // Bereich mehr existiert, ist das immernoch ein gueltiger Move! if( *rPaM.GetPoint() != *rPaM.GetMark() ) { - // jetzt kommt das eigentliche Verschieben - GetNodes().Move( rPaM, rPos, GetNodes() ); + // now do the actual move + GetNodes().MoveRange( rPaM, rPos, GetNodes() ); - if( rPaM.HasMark() ) // es wurde kein Move ausgefuehrt !! + // after a MoveRange() the Mark is deleted + if ( rPaM.HasMark() ) // => no Move occurred! { - delete pSavePam; delete pUndoMove; - return sal_False; // Nach einem Move() ist der GetMark geloescht + return false; } } else rPaM.DeleteMark(); - ASSERT( *pSavePam->GetMark() == rPos || - ( pSavePam->GetMark()->nNode.GetNode().GetCntntNode() == NULL ), + ASSERT( *aSavePam.GetMark() == rPos || + ( aSavePam.GetMark()->nNode.GetNode().GetCntntNode() == NULL ), "PaM wurde nicht verschoben, am Anfang/Ende keine ContentNodes?" ); - *pSavePam->GetMark() = rPos; + *aSavePam.GetMark() = rPos; rPaM.SetMark(); // um den neuen Bereich eine Sel. aufspannen - pTNd = pSavePam->GetNode()->GetTxtNode(); + pTNd = aSavePam.GetNode()->GetTxtNode(); if( DoesUndo() ) { // korrigiere erstmal den Content vom SavePam if( bNullCntnt ) - pSavePam->GetPoint()->nContent = 0; + { + aSavePam.GetPoint()->nContent = 0; + } // die Methode SwEditShell::Move() fuegt nach dem Move den Text-Node // zusammen, in dem der rPaM steht. Wurde der Inhalt nach hinten @@ -1189,7 +1047,7 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) bCorrSavePam = bCorrSavePam && 0 != ( pPamTxtNd = rPaM.GetNode()->GetTxtNode() ) && pPamTxtNd->CanJoinNext() - && *rPaM.GetPoint() <= *pSavePam->GetPoint(); + && (*rPaM.GetPoint() <= *aSavePam.GetPoint()); // muessen am SavePam 2 Nodes zusammengefasst werden ?? if( bJoin && pTNd->CanJoinNext() ) @@ -1198,16 +1056,20 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) // kein temp. sdbcx::Index bei && // es sollten wohl nur die Indexwerte verglichen werden. if( bCorrSavePam && rPaM.GetPoint()->nNode.GetIndex()+1 == - pSavePam->GetPoint()->nNode.GetIndex() ) - pSavePam->GetPoint()->nContent += pPamTxtNd->Len(); + aSavePam.GetPoint()->nNode.GetIndex() ) + { + aSavePam.GetPoint()->nContent += pPamTxtNd->Len(); + } bJoin = sal_False; } // else if( !bCorrSavePam && !pSavePam->Move( fnMoveForward, fnGoCntnt )) - else if( !pSavePam->Move( fnMoveForward, fnGoCntnt )) - pSavePam->GetPoint()->nNode++; + else if ( !aSavePam.Move( fnMoveForward, fnGoCntnt ) ) + { + aSavePam.GetPoint()->nNode++; + } // zwischen SPoint und GetMark steht jetzt der neu eingefuegte Bereich - pUndoMove->SetDestRange( *pSavePam, *rPaM.GetPoint(), + pUndoMove->SetDestRange( aSavePam, *rPaM.GetPoint(), bJoin, bCorrSavePam ); AppendUndo( pUndoMove ); } @@ -1219,34 +1081,27 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) { if( pTNd->CanJoinNext()) { - SwTxtNode *pNextTNd = 0; - if( !pTNd->Len() ) - { - SwNodeIndex aTmpIdx( *pTNd, 1 ); - pNextTNd = aTmpIdx.GetNode().GetTxtNode(); - } - if( pNextTNd ) - { - if( !bNullCntnt ) - pSavePam->Move( fnMoveForward, fnGoCntnt ); - pNextTNd->JoinPrev(); - } - else - pTNd->JoinNext(); + // --> OD 2009-08-20 #i100466# + // Always join next, because <pTNd> has to stay as it is. + // A join previous from its next would more or less delete <pTNd> + pTNd->JoinNext(); + // <-- bRemove = false; } } if( bNullCntnt ) { - pSavePam->GetPoint()->nNode++; - pSavePam->GetPoint()->nContent.Assign( pSavePam->GetCntntNode(), 0 ); + aSavePam.GetPoint()->nNode++; + aSavePam.GetPoint()->nContent.Assign( aSavePam.GetCntntNode(), 0 ); } else if( bRemove ) // No move forward after joining with next paragraph - pSavePam->Move( fnMoveForward, fnGoCntnt ); + { + aSavePam.Move( fnMoveForward, fnGoCntnt ); + } } // setze jetzt wieder die text::Bookmarks in das Dokument - *rPaM.GetMark() = *pSavePam->Start(); + *rPaM.GetMark() = *aSavePam.Start(); for( ::std::vector< ::sw::mark::SaveBookmark>::iterator pBkmk = aSaveBkmks.begin(); pBkmk != aSaveBkmks.end(); @@ -1255,15 +1110,16 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) this, rPaM.GetMark()->nNode, &rPaM.GetMark()->nContent); - *rPaM.GetPoint() = *pSavePam->End(); + *rPaM.GetPoint() = *aSavePam.End(); // verschiebe die Flys an die neue Position _RestFlyInRange( aSaveFlyArr, rPaM.Start()->nNode, &(rPos.nNode) ); // restore redlines (if DOC_MOVEREDLINES is used) if( aSaveRedl.Count() ) - lcl_RestoreRedlines( this, *pSavePam->Start(), aSaveRedl ); - delete pSavePam; // Better to delete an object _after_ the last use + { + lcl_RestoreRedlines( this, *aSavePam.Start(), aSaveRedl ); + } if( bUpdateFtn ) { @@ -1277,10 +1133,11 @@ bool SwDoc::Move( SwPaM& rPaM, SwPosition& rPos, SwMoveFlags eMvFlags ) } SetModified(); - return sal_True; + return true; } -bool SwDoc::Move( SwNodeRange& rRange, SwNodeIndex& rPos, SwMoveFlags eMvFlags ) +bool SwDoc::MoveNodeRange( SwNodeRange& rRange, SwNodeIndex& rPos, + SwMoveFlags eMvFlags ) { // bewegt alle Nodes an die neue Position. Dabei werden die // text::Bookmarks mit verschoben !! (zur Zeit ohne Undo) @@ -1548,7 +1405,7 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) pOldTxtNd->Len(), aBkmkArr ); SwIndex aAlphaIdx(pTxtNd); - pOldTxtNd->Cut( pTxtNd, aAlphaIdx, SwIndex(pOldTxtNd), + pOldTxtNd->CutText( pTxtNd, aAlphaIdx, SwIndex(pOldTxtNd), pOldTxtNd->Len() ); SwPosition aAlphaPos( aIdx, aAlphaIdx ); pDoc->CorrRel( rPam.GetPoint()->nNode, aAlphaPos, 0, sal_True ); @@ -1602,16 +1459,101 @@ void lcl_JoinText( SwPaM& rPam, sal_Bool bJoinPrev ) } pDoc->CorrRel( aIdx, *rPam.GetPoint(), 0, sal_True ); + // --> OD 2009-08-20 #i100466# + // adjust given <rPam>, if it does not belong to the cursors + if ( pDelNd == rPam.GetBound( sal_True ).nContent.GetIdxReg() ) + { + rPam.GetBound( sal_True ) = SwPosition( SwNodeIndex( *pTxtNd ), SwIndex( pTxtNd ) ); + } + if( pDelNd == rPam.GetBound( sal_False ).nContent.GetIdxReg() ) + { + rPam.GetBound( sal_False ) = SwPosition( SwNodeIndex( *pTxtNd ), SwIndex( pTxtNd ) ); + } + // <-- pTxtNd->JoinNext(); } } } -bool SwDoc::DeleteAndJoin( SwPaM & rPam ) +static void +lcl_CalcBreaks( ::std::vector<xub_StrLen> & rBreaks, SwPaM const & rPam ) { - if( lcl_StrLenOverFlow( rPam ) ) - return sal_False; - if( IsRedlineOn() ) + SwTxtNode const * const pTxtNode( + rPam.End()->nNode.GetNode().GetTxtNode() ); + if (!pTxtNode) + return; // left-overlap only possible at end of selection... + + const xub_StrLen nStart(rPam.Start()->nContent.GetIndex()); + const xub_StrLen nEnd (rPam.End ()->nContent.GetIndex()); + if (nEnd == pTxtNode->Len()) + return; // paragraph selected until the end + + for (xub_StrLen i = nStart; i < nEnd; ++i) + { + const sal_Unicode c(pTxtNode->GetTxt().GetChar(i)); + if ((CH_TXTATR_INWORD == c) || (CH_TXTATR_BREAKWORD == c)) + { + SwTxtAttr const * const pAttr( pTxtNode->GetTxtAttrForCharAt(i) ); + if (pAttr && pAttr->GetEnd() && (*pAttr->GetEnd() > nEnd)) + { + ASSERT(pAttr->HasDummyChar(), "GetTxtAttrForCharAt broken?"); + rBreaks.push_back(i); + } + } + } +} + +bool lcl_DoWithBreaks(SwDoc & rDoc, SwPaM & rPam, + bool (SwDoc::*pFunc)(SwPaM&, bool), const bool bForceJoinNext = false) +{ + ::std::vector<xub_StrLen> Breaks; + + lcl_CalcBreaks(Breaks, rPam); + + if (!Breaks.size()) + { + return (rDoc.*pFunc)(rPam, bForceJoinNext); + } + + // N.B.: deletion must be split into several parts if the text node + // contains a text attribute with end and with dummy character + // and the selection does not contain the text attribute completely, + // but overlaps its start (left), where the dummy character is. + + SwPosition const & rSelectionEnd( *rPam.End() ); + + bool bRet( true ); + // iterate from end to start, to avoid invalidating the offsets! + ::std::vector<xub_StrLen>::reverse_iterator iter( Breaks.rbegin() ); + SwPaM aPam( rSelectionEnd, rSelectionEnd ); // end node! + SwPosition & rEnd( *aPam.End() ); + SwPosition & rStart( *aPam.Start() ); + + while (iter != Breaks.rend()) + { + rStart.nContent = *iter + 1; + if (rEnd.nContent > rStart.nContent) // check if part is empty + { + bRet &= (rDoc.*pFunc)(aPam, bForceJoinNext); + } + rEnd.nContent = *iter; + ++iter; + } + + rStart = *rPam.Start(); // set to original start + if (rEnd.nContent > rStart.nContent) // check if part is empty + { + bRet &= (rDoc.*pFunc)(aPam, bForceJoinNext); + } + + return bRet; +} + + +bool SwDoc::DeleteAndJoinWithRedlineImpl( SwPaM & rPam, const bool ) +{ + ASSERT( IsRedlineOn(), "DeleteAndJoinWithRedline: redline off" ); + { sal_uInt16 nUndoSize = 0; SwUndoRedlineDelete* pUndo = 0; @@ -1651,12 +1593,21 @@ bool SwDoc::DeleteAndJoin( SwPaM & rPam ) //JP 06.01.98: MUSS noch optimiert werden!!! SetRedlineMode( eOld ); } - return sal_True; + return true; } +} +bool SwDoc::DeleteAndJoinImpl( SwPaM & rPam, + const bool bForceJoinNext ) +{ sal_Bool bJoinTxt, bJoinPrev; lcl_GetJoinFlags( rPam, bJoinTxt, bJoinPrev ); - + // --> OD 2009-08-20 #i100466# + if ( bForceJoinNext ) + { + bJoinPrev = sal_False; + } + // <-- { // dann eine Kopie vom Cursor erzeugen um alle Pams aus den // anderen Sichten aus dem Loeschbereich zu verschieben @@ -1664,8 +1615,9 @@ SetRedlineMode( eOld ); SwPaM aDelPam( *rPam.GetMark(), *rPam.GetPoint() ); ::PaMCorrAbs( aDelPam, *aDelPam.GetPoint() ); - if( !Delete( aDelPam ) ) - return sal_False; + const bool bSuccess( DeleteRangeImpl( aDelPam ) ); + if (!bSuccess) + return false; *rPam.GetPoint() = *aDelPam.GetPoint(); } @@ -1675,15 +1627,15 @@ SetRedlineMode( eOld ); lcl_JoinText( rPam, bJoinPrev ); } - return sal_True; + return true; } -bool SwDoc::Delete( SwPaM & rPam ) +bool SwDoc::DeleteRangeImpl( SwPaM & rPam, const bool ) { SwPosition *pStt = (SwPosition*)rPam.Start(), *pEnd = (SwPosition*)rPam.End(); if( !rPam.HasMark() || *pStt >= *pEnd ) - return sal_False; + return false; if( pACEWord ) { @@ -1738,7 +1690,7 @@ bool SwDoc::Delete( SwPaM & rPam ) SetModified(); - return sal_True; + return true; } if( !IsIgnoreRedline() && GetRedlineTbl().Count() ) @@ -1772,7 +1724,7 @@ bool SwDoc::Delete( SwPaM & rPam ) // falls schon leer, dann nicht noch aufrufen if( nLen ) { - pStartTxtNode->Erase( pStt->nContent, nLen ); + pStartTxtNode->EraseText( pStt->nContent, nLen ); if( !pStartTxtNode->Len() ) { @@ -1804,7 +1756,7 @@ bool SwDoc::Delete( SwPaM & rPam ) if( pEnd->nContent.GetIndex() ) { SwIndex aIdx( pCNd, 0 ); - pEndTxtNode->Erase( aIdx, pEnd->nContent.GetIndex() ); + pEndTxtNode->EraseText( aIdx, pEnd->nContent.GetIndex() ); if( !pEndTxtNode->Len() ) { @@ -1849,9 +1801,29 @@ bool SwDoc::Delete( SwPaM & rPam ) CompressRedlines(); SetModified(); - return sal_True; + return true; +} + +// OD 2009-08-20 #i100466# +// Add handling of new optional parameter <bForceJoinNext> +bool SwDoc::DeleteAndJoin( SwPaM & rPam, + const bool bForceJoinNext ) +{ + if ( lcl_StrLenOverFlow( rPam ) ) + return false; + + return lcl_DoWithBreaks( *this, rPam, (IsRedlineOn()) + ? &SwDoc::DeleteAndJoinWithRedlineImpl + : &SwDoc::DeleteAndJoinImpl, + bForceJoinNext ); +} + +bool SwDoc::DeleteRange( SwPaM & rPam ) +{ + return lcl_DoWithBreaks( *this, rPam, &SwDoc::DeleteRangeImpl ); } + void lcl_syncGrammarError( SwTxtNode &rTxtNode, linguistic2::ProofreadingResult& rResult, xub_StrLen /*nBeginGrammarCheck*/, const ModelToViewHelper::ConversionMap* pConversionMap ) { @@ -1881,7 +1853,7 @@ void lcl_syncGrammarError( SwTxtNode &rTxtNode, linguistic2::ProofreadingResult& uno::Any SwDoc::Spell( SwPaM& rPaM, uno::Reference< XSpellChecker1 > &xSpeller, sal_uInt16* pPageCnt, sal_uInt16* pPageSt, - bool bGrammarCheck, + bool bGrammarCheck, SwConversionArgs *pConvArgs ) const { SwPosition* pSttPos = rPaM.Start(), *pEndPos = rPaM.End(); @@ -1897,7 +1869,7 @@ uno::Any SwDoc::Spell( SwPaM& rPaM, else pSpellArgs = new SwSpellArgs( xSpeller, pSttPos->nNode.GetNode().GetTxtNode(), pSttPos->nContent, - pEndPos->nNode.GetNode().GetTxtNode(), pEndPos->nContent, + pEndPos->nNode.GetNode().GetTxtNode(), pEndPos->nContent, bGrammarCheck ); ULONG nCurrNd = pSttPos->nNode.GetIndex(); @@ -1957,11 +1929,11 @@ uno::Any SwDoc::Spell( SwPaM& rPaM, if( aOrigPos != *aCrsr.GetPoint() ) { nBeginGrammarCheck = aCrsr.GetPoint()->nContent.GetIndex(); - } + } } nEndGrammarCheck = pSpellArgs->pEndNode == pNd ? pSpellArgs->pEndIdx->GetIndex() : ((SwTxtNode*)pNd)->GetTxt().Len(); } - + xub_StrLen nSpellErrorPosition = ((SwTxtNode*)pNd)->GetTxt().Len(); if( (!pConvArgs && ((SwTxtNode*)pNd)->Spell( pSpellArgs )) || @@ -1973,12 +1945,12 @@ uno::Any SwDoc::Spell( SwPaM& rPaM, pEndPos->nNode = nCurrNd; nCurrNd = nEndNd; if( pSpellArgs ) - nSpellErrorPosition = pSpellArgs->pStartIdx->GetIndex() > pSpellArgs->pEndIdx->GetIndex() ? - pSpellArgs->pEndIdx->GetIndex() : + nSpellErrorPosition = pSpellArgs->pStartIdx->GetIndex() > pSpellArgs->pEndIdx->GetIndex() ? + pSpellArgs->pEndIdx->GetIndex() : pSpellArgs->pStartIdx->GetIndex(); } - - + + if( pSpellArgs && pSpellArgs->bIsGrammarCheck ) { uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( GetGCIterator() ); @@ -1992,7 +1964,7 @@ uno::Any SwDoc::Spell( SwPaM& rPaM, ((SwTxtNode*)pNd)->BuildConversionMap( aExpandText ); // get XFlatParagraph to use... uno::Reference< text::XFlatParagraph > xFlatPara = new SwXFlatParagraph( *((SwTxtNode*)pNd), aExpandText, pConversionMap ); - + // get error position of cursor in XFlatParagraph sal_Int32 nGrammarErrorPosInText; linguistic2::ProofreadingResult aResult; @@ -2000,11 +1972,11 @@ uno::Any SwDoc::Spell( SwPaM& rPaM, do { nGrammarErrorPosInText = ModelToViewHelper::ConvertToViewPosition( pConversionMap, nBeginGrammarCheck ); - aResult = xGCIterator->checkSentenceAtPosition( + aResult = xGCIterator->checkSentenceAtPosition( xDoc, xFlatPara, aExpandText, lang::Locale(), nBeginGrammarCheck, -1, -1 ); - + lcl_syncGrammarError( *((SwTxtNode*)pNd), aResult, nBeginGrammarCheck, pConversionMap ); - + // get suggestions to use for the specific error position nGrammarErrors = aResult.aErrors.getLength(); // if grammar checking doesn't have any progress then quit @@ -2225,12 +2197,86 @@ sal_Bool lcl_GetTokenToParaBreak( String& rStr, String& rRet, sal_Bool bRegExpRp return bRet; } +bool SwDoc::ReplaceRange( SwPaM& rPam, const String& rStr, + const bool bRegExReplace ) +{ + // unfortunately replace works slightly differently from delete, + // so we cannot use lcl_DoWithBreaks here... + + ::std::vector<xub_StrLen> Breaks; + + SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() ); + aPam.Normalize(FALSE); + if (aPam.GetPoint()->nNode != aPam.GetMark()->nNode) + { + aPam.Move(fnMoveBackward); + } + ASSERT((aPam.GetPoint()->nNode == aPam.GetMark()->nNode), "invalid pam?"); + + lcl_CalcBreaks(Breaks, aPam); + + while (!Breaks.empty() // skip over prefix of dummy chars + && (aPam.GetMark()->nContent.GetIndex() == *Breaks.begin()) ) + { + // skip! + ++aPam.GetMark()->nContent; // always in bounds if Breaks valid + Breaks.erase(Breaks.begin()); + } + *rPam.Start() = *aPam.GetMark(); // update start of original pam w/ prefix + + if (!Breaks.size()) + { + return ReplaceRangeImpl(rPam, rStr, bRegExReplace); // original pam! + } + + // N.B.: deletion must be split into several parts if the text node + // contains a text attribute with end and with dummy character + // and the selection does not contain the text attribute completely, + // but overlaps its start (left), where the dummy character is. + + bool bRet( true ); + // iterate from end to start, to avoid invalidating the offsets! + ::std::vector<xub_StrLen>::reverse_iterator iter( Breaks.rbegin() ); + ASSERT(aPam.GetPoint() == aPam.End(), "wrong!"); + SwPosition & rEnd( *aPam.End() ); + SwPosition & rStart( *aPam.Start() ); + + // set end of temp pam to original end (undo Move backward above) + rEnd = *rPam.End(); + // after first deletion, rEnd will point into the original text node again! + + while (iter != Breaks.rend()) + { + rStart.nContent = *iter + 1; + if (rEnd.nContent != rStart.nContent) // check if part is empty + { + bRet &= (IsRedlineOn()) + ? DeleteAndJoinWithRedlineImpl(aPam) + : DeleteAndJoinImpl(aPam, false); + } + rEnd.nContent = *iter; + ++iter; + } + + rStart = *rPam.Start(); // set to original start + ASSERT(rEnd.nContent > rStart.nContent, "replace part empty!"); + if (rEnd.nContent > rStart.nContent) // check if part is empty + { + bRet &= ReplaceRangeImpl(aPam, rStr, bRegExReplace); + } + + rPam = aPam; // update original pam (is this required?) + + return bRet; +} + // N.B.: it is possible to call Replace with a PaM that spans 2 paragraphs: // search with regex for "$", then replace _all_ -bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) +bool SwDoc::ReplaceRangeImpl( SwPaM& rPam, const String& rStr, + const bool bRegExReplace ) { if( !rPam.HasMark() || *rPam.GetPoint() == *rPam.GetMark() ) - return sal_False; + return false; sal_Bool bJoinTxt, bJoinPrev; lcl_GetJoinFlags( rPam, bJoinTxt, bJoinPrev ); @@ -2247,7 +2293,7 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) ASSERT( pStt->nNode == pEnd->nNode || ( pStt->nNode.GetIndex() + 1 == pEnd->nNode.GetIndex() && !pEnd->nContent.GetIndex() ), - "Point & Mark zeigen auf verschiedene Nodes" ); + "invalid range: Point and Mark on different nodes" ); sal_Bool bOneNode = pStt->nNode == pEnd->nNode; // eigenes Undo ???? @@ -2294,6 +2340,10 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) aSet.ClearItem( RES_TXTATR_REFMARK ); aSet.ClearItem( RES_TXTATR_TOXMARK ); + aSet.ClearItem( RES_TXTATR_CJK_RUBY ); + aSet.ClearItem( RES_TXTATR_INETFMT ); + aSet.ClearItem( RES_TXTATR_META ); + aSet.ClearItem( RES_TXTATR_METAFIELD ); if( aDelPam.GetPoint() != aDelPam.End() ) aDelPam.Exchange(); @@ -2304,9 +2354,9 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) sal_Bool bFirst = sal_True; String sIns; - while( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExpRplc )) + while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) ) { - Insert( aDelPam, sIns, true ); + InsertString( aDelPam, sIns ); if( bFirst ) { SwNodeIndex aMkNd( aDelPam.GetMark()->nNode, -1 ); @@ -2324,7 +2374,9 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) SplitNode( *aDelPam.GetPoint(), false ); } if( sIns.Len() ) - Insert( aDelPam, sIns, true ); + { + InsertString( aDelPam, sIns ); + } SwPaM aTmpRange( *aDelPam.GetPoint() ); aTmpRange.SetMark(); @@ -2336,7 +2388,7 @@ bool SwDoc::Replace( SwPaM& rPam, const String& rStr, bool bRegExpRplc ) *aTmpRange.GetMark() = *aDelPam.GetPoint(); RstTxtAttrs( aTmpRange ); - Insert( aTmpRange, aSet, 0 ); + InsertItemSet( aTmpRange, aSet, 0 ); } if( DoesUndo() ) @@ -2386,7 +2438,7 @@ SetRedlineMode( eOld ); pUndoRpl = new SwUndoReplace(); AppendUndo( pUndoRpl ); } - pUndoRpl->AddEntry( aDelPam, sRepl, bRegExpRplc ); + pUndoRpl->AddEntry( aDelPam, sRepl, bRegExReplace ); DoUndo( sal_False ); } @@ -2404,12 +2456,16 @@ SetRedlineMode( eOld ); sal_Bool bFirst = sal_True; String sIns; - while( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExpRplc )) + while ( lcl_GetTokenToParaBreak( sRepl, sIns, bRegExReplace ) ) { if( !bFirst || nStt == pTxtNd->GetTxt().Len() ) - Insert( aDelPam, sIns, true ); + { + InsertString( aDelPam, sIns ); + } else if( nStt < nEnd || sIns.Len() ) - pTxtNd->Replace( pStt->nContent, nEnd - nStt, sIns ); + { + pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns ); + } SplitNode( *pStt, false); bFirst = sal_False; } @@ -2417,9 +2473,13 @@ SetRedlineMode( eOld ); if( bFirst || sIns.Len() ) { if( !bFirst || nStt == pTxtNd->GetTxt().Len() ) - Insert( aDelPam, sIns, true ); + { + InsertString( aDelPam, sIns ); + } else if( nStt < nEnd || sIns.Len() ) - pTxtNd->Replace( pStt->nContent, nEnd - nStt, sIns ); + { + pTxtNd->ReplaceText( pStt->nContent, nEnd - nStt, sIns ); + } } *rPam.GetMark() = *aDelPam.GetMark(); @@ -2443,7 +2503,7 @@ SetRedlineMode( eOld ); lcl_JoinText( rPam, bJoinPrev ); SetModified(); - return sal_True; + return true; } // speicher die akt. Werte fuer die automatische Aufnahme von Ausnahmen @@ -2609,8 +2669,8 @@ void SwDoc::TransliterateText( const SwPaM& rPaM, if( pStt == pEnd && pTNd ) // no region ? { Boundary aBndry; - if( pBreakIt->xBreak.is() ) - aBndry = pBreakIt->xBreak->getWordBoundary( + if( pBreakIt->GetBreakIter().is() ) + aBndry = pBreakIt->GetBreakIter()->getWordBoundary( pTNd->GetTxt(), nSttCnt, pBreakIt->GetLocale( pTNd->GetLang( nSttCnt ) ), WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/, @@ -2740,7 +2800,7 @@ void SwDoc::RemoveLeadingWhiteSpace(const SwPosition & rPos ) aPam.GetPoint()->nContent = 0; aPam.SetMark(); aPam.GetMark()->nContent = nIdx; - Delete( aPam ); + DeleteRange( aPam ); } } } diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 46ba60ffea..05a3efac0e 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -2721,14 +2721,11 @@ bool SwDoc::UpdateFld(SwTxtFld * pDstTxtFld, SwField & rSrcFld, { if (DoesUndo()) { - SwPosition * pPos = - pDstTxtFld->GetPosition(); + SwPosition aPosition( pDstTxtFld->GetTxtNode() ); + aPosition.nContent = *pDstTxtFld->GetStart(); - ASSERT(pPos, "SwTxtFld not in its SwTxtNode?"); - - AppendUndo(new SwUndoFieldFromDoc(*pPos, *pDstFld, rSrcFld, + AppendUndo(new SwUndoFieldFromDoc(aPosition, *pDstFld, rSrcFld, pMsgHnt, bUpdateFlds)); - delete pPos; } // Das gefundene Feld wird angepasst ... diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx index ffe44a02c8..e0645fcdc1 100644 --- a/sw/source/core/doc/docfly.cxx +++ b/sw/source/core/doc/docfly.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -68,6 +68,10 @@ #include <fmtcnct.hxx> #include <dflyobj.hxx> +// --> OD 2009-07-20 #i73249# +#include <undoflystrattr.hxx> +// <-- + extern USHORT GetHtmlMode( const SwDocShell* ); @@ -270,18 +274,17 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); -#ifndef PRODUCT + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT ); ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == &rFmt, "Wrong TxtFlyCnt-Hint." ); -#endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } //Endlich kann das Attribut gesetzt werden. Es muss das erste Attribut @@ -301,8 +304,8 @@ sal_Int8 SwDoc::SetFlyFrmAnchor( SwFrmFmt& rFmt, SfxItemSet& rSet, BOOL bNewFrms SwTxtNode *pNd = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pNd, "Crsr steht nicht auf TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( (SwFlyFrmFmt*)&rFmt ), - pPos->nContent.GetIndex(), 0 ); + SwFmtFlyCnt aFmt( static_cast<SwFlyFrmFmt*>(&rFmt) ); + pNd->InsertItem( aFmt, pPos->nContent.GetIndex(), 0 ); } if( SFX_ITEM_SET != rSet.GetItemState( RES_VERT_ORIENT, FALSE, &pItem )) @@ -469,6 +472,61 @@ BOOL SwDoc::SetFlyFrmAttr( SwFrmFmt& rFlyFmt, SfxItemSet& rSet ) return aTmpSet.Count() || MAKEFRMS == nMakeFrms; } +// --> OD 2009-07-20 #i73249# +void SwDoc::SetFlyFrmTitle( SwFlyFrmFmt& rFlyFrmFmt, + const String& sNewTitle ) +{ + if ( rFlyFrmFmt.GetObjTitle() == sNewTitle ) + { + return; + } + + const bool bFormerIsNoDrawUndoObj( IsNoDrawUndoObj() ); + SetNoDrawUndoObj( true ); + + if ( DoesUndo() ) + { + ClearRedo(); + AppendUndo( new SwUndoFlyStrAttr( rFlyFrmFmt, + UNDO_FLYFRMFMT_TITLE, + rFlyFrmFmt.GetObjTitle(), + sNewTitle ) ); + } + + rFlyFrmFmt.SetObjTitle( sNewTitle, true ); + + SetNoDrawUndoObj( bFormerIsNoDrawUndoObj ); + + SetModified(); +} + +void SwDoc::SetFlyFrmDescription( SwFlyFrmFmt& rFlyFrmFmt, + const String& sNewDescription ) +{ + if ( rFlyFrmFmt.GetObjDescription() == sNewDescription ) + { + return; + } + + const bool bFormerIsNoDrawUndoObj( IsNoDrawUndoObj() ); + SetNoDrawUndoObj( true ); + + if ( DoesUndo() ) + { + ClearRedo(); + AppendUndo( new SwUndoFlyStrAttr( rFlyFrmFmt, + UNDO_FLYFRMFMT_DESCRIPTION, + rFlyFrmFmt.GetObjDescription(), + sNewDescription ) ); + } + + rFlyFrmFmt.SetObjDescription( sNewDescription, true ); + + SetNoDrawUndoObj( bFormerIsNoDrawUndoObj ); + + SetModified(); +} +// <-- /*************************************************************************** * Methode : BOOL SwDoc::SetFrmFmtToFly( SwFlyFrm&, SwFrmFmt& ) @@ -771,10 +829,10 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, // 'center to baseline' SetAttr( SwFmtVertOrient( 0, text::VertOrientation::CENTER, text::RelOrientation::FRAME ), *pContact->GetFmt() ); SwTxtNode *pNd = aPos.nNode.GetNode().GetTxtNode(); - ASSERT( pNd, "Crsr steht nicht auf TxtNode." ); + ASSERT( pNd, "Cursor not positioned at TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( pContact->GetFmt() ), - aPos.nContent.GetIndex(), 0 ); + SwFmtFlyCnt aFmt( pContact->GetFmt() ); + pNd->InsertItem( aFmt, aPos.nContent.GetIndex(), 0 ); } break; default: @@ -821,12 +879,13 @@ sal_Bool SwDoc::ChgAnchor( const SdrMarkList& _rMrkList, SwTxtNode* pTxtNode( pOldAsCharAnchorPos->nNode.GetNode().GetTxtNode() ); ASSERT( pTxtNode, "<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object" ); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); - SwTxtAttr* pHnt = pTxtNode->GetTxtAttr( nIndx, RES_TXTATR_FLYCNT ); - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIndx, RES_TXTATR_FLYCNT ); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIndx, nIndx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIndx, nIndx ); delete pOldAsCharAnchorPos; } // <-- diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index db943cad23..f885456bfa 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -411,8 +411,8 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, else { Boundary aBndry; - if( pBreakIt->xBreak.is() ) - aBndry = pBreakIt->xBreak->getWordBoundary( + if( pBreakIt->GetBreakIter().is() ) + aBndry = pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/, @@ -461,6 +461,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, const SwPosition *pStt = pPam->Start(), *pEnd = pPam->End(); ParaRstFmt aPara( pStt, pEnd, pHst ); + // mst: not including META here; it seems attrs with CH_TXTATR are omitted USHORT __FAR_DATA aResetableSetRange[] = { RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_CHRATR_BEGIN, RES_CHRATR_END-1, @@ -524,12 +525,15 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { if ( pHst ) { - SwRegHistory( pTNd, aCharSet, 0, pTNd->GetTxt().Len(), nsSetAttrMode::SETATTR_NOFORMATATTR, pHst ); + SwRegHistory history( pTNd, *pTNd, pHst ); + history.InsertItems( aCharSet, 0, pTNd->GetTxt().Len(), + nsSetAttrMode::SETATTR_NOFORMATATTR ); } else { - SwTxtAttr* pNew = pTNd->MakeTxtAttr( aCharSet, 0, pTNd->GetTxt().Len() ); - pTNd->Insert( pNew ); + SwTxtAttr* pNew = + MakeTxtAttr( *this, aCharSet, 0, pTNd->GetTxt().Len() ); + pTNd->InsertHint( pNew ); } } } @@ -550,11 +554,12 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, { if( IsInRange( aCharFmtSetRange, pItem->Which() )) { - SwTxtAttr* pTAttr = pTNd->MakeTxtAttr( *pItem, 0, - pTNd->GetTxt().Len() ); + SwTxtAttr* pTAttr = MakeTxtAttr( *this, + const_cast<SfxPoolItem&>(*pItem), + 0, pTNd->GetTxt().Len() ); SwpHints & rHints = pTNd->GetOrCreateSwpHints(); rHints.SwpHintsArray::Insert( pTAttr ); - if( pHst ) + if ( pHst ) { SwRegHistory aRegH( pTNd, *pTNd, pHst ); pTNd->ResetAttr( pItem->Which() ); @@ -597,8 +602,9 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, // Einfuegen der Hints nach Inhaltsformen; // wird in SwDoc::Insert(..., SwFmtHint &rHt) benutzt -BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, - USHORT nFlags, SwUndoAttr* pUndo ) +static bool +lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, + const SetAttrMode nFlags, SwUndoAttr *const pUndo) { // teil die Sets auf (fuer Selektion in Nodes) const SfxItemSet* pCharSet = 0; @@ -668,7 +674,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, } SwHistory* pHistory = pUndo ? &pUndo->GetHistory() : 0; - BOOL bRet = FALSE; + bool bRet = false; const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End(); SwCntntNode* pNode = pStt->nNode.GetNode().GetCntntNode(); @@ -686,7 +692,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, ASSERT( false, "<InsAttr(..)> - PaM in front of label, but text node has no numbering rule set. This is a serious defect, please inform OD." ); DELETECHARSETS - return FALSE; + return false; } // <-- @@ -704,7 +710,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, } DELETECHARSETS - return TRUE; + return true; } // <- #i27615# @@ -718,12 +724,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, aTxtSet.Put( rChgSet ); if( aTxtSet.Count() ) { - SwRegHistory( (SwTxtNode*)pNode, aTxtSet, rSt.GetIndex(), - rSt.GetIndex(), nFlags, pHistory ); - bRet = TRUE; + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems( + aTxtSet, rSt.GetIndex(), rSt.GetIndex(), nFlags ) || bRet; - if( pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() && - pDoc->GetRedlineTbl().Count() )) + if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() + && pDoc->GetRedlineTbl().Count()))) { SwPaM aPam( pStt->nNode, pStt->nContent.GetIndex()-1, pStt->nNode, pStt->nContent.GetIndex() ); @@ -757,12 +763,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, USHORT nEnd = pStt->nNode == pEnd->nNode ? pEnd->nContent.GetIndex() : pNode->Len(); - SwRegHistory( (SwTxtNode*)pNode, aTxtSet, nInsCnt, - nEnd, nFlags, pHistory ); - bRet = TRUE; + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems( aTxtSet, nInsCnt, nEnd, nFlags ) + || bRet; - if( pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() && - pDoc->GetRedlineTbl().Count() ) ) + if (bRet && (pDoc->IsRedlineOn() || (!pDoc->IsIgnoreRedline() + && pDoc->GetRedlineTbl().Count()))) { // wurde Text-Inhalt eingefuegt? (RefMark/TOXMarks ohne Ende) BOOL bTxtIns = nInsCnt != rSt.GetIndex(); @@ -784,7 +790,6 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, // bei PageDesc's, die am Node gesetzt werden, muss immer das // Auto-Flag gesetzt werden!! - const SvxLRSpaceItem* pLRSpace = 0; if( pOtherSet && pOtherSet->Count() ) { SwTableNode* pTblNd; @@ -811,11 +816,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt(); SwRegHistory aRegH( pFmt, *pTblNd, pHistory ); pFmt->SetFmtAttr( aNew ); + bRet = true; } else { SwRegHistory aRegH( pNode, *pNode, pHistory ); - pNode->SetAttr( aNew ); + bRet = pNode->SetAttr( aNew ) || bRet; } } @@ -823,13 +829,13 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, // we know, that there is only one attribute in pOtherSet. We cannot // perform the following operations, instead we return: if ( bOtherAttr ) - return TRUE; + return bRet; const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_PAGEDESC ); if( !pOtherSet->Count() ) { DELETECHARSETS - return TRUE; + return bRet; } } @@ -848,25 +854,22 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, SwFrmFmt* pFmt = pTblNd->GetTable().GetFrmFmt(); SwRegHistory aRegH( pFmt, *pTblNd, pHistory ); pFmt->SetFmtAttr( *pBreak ); + bRet = true; // bOtherAttr = true means that pOtherSet == rChgSet. In this case // we know, that there is only one attribute in pOtherSet. We cannot // perform the following operations, instead we return: if ( bOtherAttr ) - return TRUE; + return bRet; const_cast<SfxItemSet*>(pOtherSet)->ClearItem( RES_BREAK ); if( !pOtherSet->Count() ) { DELETECHARSETS - return TRUE; + return bRet; } } - // fuer Sonderbehandlung von LR-Space innerhalb einer Numerierung !!! - pOtherSet->GetItemState( RES_LR_SPACE, FALSE, - (const SfxPoolItem**)&pLRSpace ); - { // wenns eine PoolNumRule ist, diese ggfs. anlegen const SwNumRuleItem* pRule; @@ -891,7 +894,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() ) { - SwTxtNode* pTxtNd = (SwTxtNode*)pNode; + SwTxtNode* pTxtNd = static_cast<SwTxtNode*>(pNode); const SwIndex& rSt = pStt->nContent; USHORT nMkPos, nPtPos = rSt.GetIndex(); const String& rStr = pTxtNd->GetTxt(); @@ -909,8 +912,8 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, else { Boundary aBndry; - if( pBreakIt->xBreak.is() ) - aBndry = pBreakIt->xBreak->getWordBoundary( + if( pBreakIt->GetBreakIter().is() ) + aBndry = pBreakIt->GetBreakIter()->getWordBoundary( pTxtNd->GetTxt(), nPtPos, pBreakIt->GetLocale( pTxtNd->GetLang( nPtPos ) ), WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/, @@ -946,10 +949,10 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, pTxtNd->RstAttr( aSt, nPtPos, 0, pCharSet ); } - // eintragen des Attributes im Node erledigt die SwRegHistory !! - SwRegHistory( (SwTxtNode*)pNode, *pCharSet, - nMkPos, nPtPos, nFlags, pHistory ); - bRet = TRUE; + // the SwRegHistory inserts the attribute into the TxtNode! + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems( *pCharSet, nMkPos, nPtPos, nFlags ) + || bRet; if( pDoc->IsRedlineOn() ) { @@ -963,8 +966,7 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if( pOtherSet && pOtherSet->Count() ) { SwRegHistory aRegH( pNode, *pNode, pHistory ); - pNode->SetAttr( *pOtherSet ); - bRet = TRUE; + bRet = pNode->SetAttr( *pOtherSet ) || bRet; } DELETECHARSETS @@ -993,25 +995,26 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, if( pStt->nContent.GetIndex() != 0 || aCntEnd.GetIndex() != nLen ) { - // eintragen des Attributes im Node erledigt die SwRegHistory !! + // the SwRegHistory inserts the attribute into the TxtNode! if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() ) { - SwRegHistory( (SwTxtNode*)pNode, *pCharSet, - pStt->nContent.GetIndex(), aCntEnd.GetIndex(), - nFlags, pHistory ); + SwRegHistory history( pNode, *pNode, pHistory ); + bRet = history.InsertItems(*pCharSet, + pStt->nContent.GetIndex(), aCntEnd.GetIndex(), nFlags) + || bRet; } if( pOtherSet && pOtherSet->Count() ) { SwRegHistory aRegH( pNode, *pNode, pHistory ); - pNode->SetAttr( *pOtherSet ); + bRet = pNode->SetAttr( *pOtherSet ) || bRet; } // lediglich Selektion in einem Node. if( pStt->nNode == pEnd->nNode ) { DELETECHARSETS - return TRUE; + return bRet; } ++nNodes; aSt.Assign( pStt->nNode.GetNode(), +1 ); @@ -1036,11 +1039,12 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, USHORT nLen = pNode->Len(); if( aCntEnd.GetIndex() != nLen ) { - // eintragen des Attributes im Node erledigt die SwRegHistory !! + // the SwRegHistory inserts the attribute into the TxtNode! if( pNode->IsTxtNode() && pCharSet && pCharSet->Count() ) { - SwRegHistory( (SwTxtNode*)pNode, *pCharSet, - 0, aCntEnd.GetIndex(), nFlags, pHistory ); + SwRegHistory history( pNode, *pNode, pHistory ); + history.InsertItems(*pCharSet, + 0, aCntEnd.GetIndex(), nFlags); } if( pOtherSet && pOtherSet->Count() ) @@ -1113,14 +1117,14 @@ BOOL InsAttr( SwDoc *pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, } DELETECHARSETS - return nNodes != 0; + return (nNodes != 0) || bRet; } -bool SwDoc::Insert( const SwPaM &rRg, const SfxPoolItem &rHt, USHORT nFlags ) +bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, + const SetAttrMode nFlags ) { SwDataChanged aTmp( rRg, 0 ); - BOOL bRet; SwUndoAttr* pUndoAttr = 0; if( DoesUndo() ) { @@ -1130,7 +1134,7 @@ bool SwDoc::Insert( const SwPaM &rRg, const SfxPoolItem &rHt, USHORT nFlags ) SfxItemSet aSet( GetAttrPool(), rHt.Which(), rHt.Which() ); aSet.Put( rHt ); - bRet = InsAttr( this, rRg, aSet, nFlags, pUndoAttr ); + bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr ); if( DoesUndo() ) AppendUndo( pUndoAttr ); @@ -1140,17 +1144,18 @@ bool SwDoc::Insert( const SwPaM &rRg, const SfxPoolItem &rHt, USHORT nFlags ) return bRet; } -bool SwDoc::Insert( const SwPaM &rRg, const SfxItemSet &rSet, USHORT nFlags ) +bool SwDoc::InsertItemSet ( const SwPaM &rRg, const SfxItemSet &rSet, + const SetAttrMode nFlags ) { SwDataChanged aTmp( rRg, 0 ); SwUndoAttr* pUndoAttr = 0; if( DoesUndo() ) { ClearRedo(); - pUndoAttr = new SwUndoAttr( rRg, rSet ); + pUndoAttr = new SwUndoAttr( rRg, rSet, nFlags ); } - BOOL bRet = InsAttr( this, rRg, rSet, nFlags, pUndoAttr ); + bool bRet = lcl_InsAttr( this, rRg, rSet, nFlags, pUndoAttr ); if( DoesUndo() ) AppendUndo( pUndoAttr ); @@ -2096,7 +2101,7 @@ void SwDoc::CopyFmtArr( const SvPtrarr& rSourceArr, } } -void SwDoc::_CopyPageDescHeaderFooter( BOOL bCpyHeader, +void SwDoc::CopyPageDescHeaderFooterImpl( bool bCpyHeader, const SwFrmFmt& rSrcFmt, SwFrmFmt& rDestFmt ) { // jetzt noch Header-/Footer-Attribute richtig behandeln @@ -2139,7 +2144,7 @@ void SwDoc::_CopyPageDescHeaderFooter( BOOL bCpyHeader, aTmpIdx = *pSttNd->EndOfSectionNode(); rSrcNds._Copy( aRg, aTmpIdx ); aTmpIdx = *pSttNd; - rSrcFmt.GetDoc()->_CopyFlyInFly( aRg, 0, aTmpIdx ); + rSrcFmt.GetDoc()->CopyFlyInFlyImpl( aRg, 0, aTmpIdx ); pNewFmt->SetFmtAttr( SwFmtCntnt( pSttNd )); } else @@ -2499,7 +2504,7 @@ void SwDoc::SetTxtFmtCollByAutoFmt( const SwPosition& rPos, USHORT nPoolId, { aPam.SetMark(); aPam.GetMark()->nContent.Assign( pTNd, pTNd->GetTxt().Len() ); - Insert( aPam, *pSet, 0 ); + InsertItemSet( aPam, *pSet, 0 ); } } @@ -2541,7 +2546,7 @@ void SwDoc::SetFmtItemByAutoFmt( const SwPaM& rPam, const SfxItemSet& rSet ) SetRedlineMode_intern( (RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); } - Insert( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND ); + InsertItemSet( rPam, rSet, nsSetAttrMode::SETATTR_DONTEXPAND ); SetRedlineMode_intern( eOld ); } diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index 5e77a8596b..1d39e35de2 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -307,7 +307,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, pDoc->GetNodes().Delete( aIdx, 1 ); // alle Flys in dem Bereich - _CopyFlyInFly( aRg, 0, aIdx ); + CopyFlyInFlyImpl( aRg, 0, aIdx ); // und noch alle Bookmarks @@ -653,7 +653,7 @@ BOOL SwDoc::SplitDoc( USHORT eDocType, const String& rPath, int nOutlineLevel ) pDoc->GetNodes().Delete( aIdx, 1 ); // alle Flys in dem Bereich - _CopyFlyInFly( aRg, 0, aIdx ); + CopyFlyInFlyImpl( aRg, 0, aIdx ); // und noch alle Bookmarks diff --git a/sw/source/core/doc/docglos.cxx b/sw/source/core/doc/docglos.cxx index a357946c7b..39b1065201 100644 --- a/sw/source/core/doc/docglos.cxx +++ b/sw/source/core/doc/docglos.cxx @@ -183,7 +183,7 @@ BOOL SwDoc::InsertGlossary( SwTextBlocks& rBlock, const String& rEntry, SwDontExpandItem aACD; aACD.SaveDontExpandItems( rInsPos ); - pGDoc->Copy( aCpyPam, rInsPos, false ); + pGDoc->CopyRange( aCpyPam, rInsPos, false ); aACD.RestoreDontExpandItems( rInsPos ); if( pShell ) diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 7b32161238..fe244d4957 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -362,17 +362,20 @@ void SwDoc::DelLayoutFmt( SwFrmFmt *pFmt ) { const SwPosition* pPos = rAnchor.GetCntntAnchor(); SwTxtNode *pTxtNd = pPos->nNode.GetNode().GetTxtNode(); - SwTxtFlyCnt* pAttr; - // Attribut steht noch im TextNode, loeschen - if( pTxtNd && 0 != ( pAttr = ((SwTxtFlyCnt*)pTxtNd->GetTxtAttr( - pPos->nContent.GetIndex() ))) && - pAttr->GetFlyCnt().GetFrmFmt() == pFmt ) + // attribute is still in text node, delete it + if ( pTxtNd ) { - // Pointer auf 0, nicht loeschen - ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt(); - SwIndex aIdx( pPos->nContent ); - pTxtNd->Erase( aIdx, 1 ); + SwTxtFlyCnt* const pAttr = static_cast<SwTxtFlyCnt*>( + pTxtNd->GetTxtAttrForCharAt( pPos->nContent.GetIndex(), + RES_TXTATR_FLYCNT )); + if ( pAttr && (pAttr->GetFlyCnt().GetFrmFmt() == pFmt) ) + { + // dont delete, set pointer to 0 + const_cast<SwFmtFlyCnt&>(pAttr->GetFlyCnt()).SetFlyFmt(); + SwIndex aIdx( pPos->nContent ); + pTxtNd->EraseText( aIdx, 1 ); + } } } @@ -550,9 +553,10 @@ SwFrmFmt *SwDoc::CopyLayoutFmt( const SwFrmFmt& rSource, if( bSetTxtFlyAtt && FLY_IN_CNTNT == rNewAnchor.GetAnchorId() ) { - SwPosition* pPos = (SwPosition*)rNewAnchor.GetCntntAnchor(); - pPos->nNode.GetNode().GetTxtNode()->InsertItem(SwFmtFlyCnt( pDest ), - pPos->nContent.GetIndex(), 0 ); + const SwPosition* pPos = rNewAnchor.GetCntntAnchor(); + SwFmtFlyCnt aFmt( pDest ); + pPos->nNode.GetNode().GetTxtNode()->InsertItem( + aFmt, pPos->nContent.GetIndex(), 0 ); } if( bMakeFrms ) @@ -694,11 +698,14 @@ SwFlyFrmFmt* SwDoc::_MakeFlySection( const SwPosition& rAnchPos, { xub_StrLen nStt = rAnchPos.nContent.GetIndex(); SwTxtNode * pTxtNode = rAnchPos.nNode.GetNode().GetTxtNode(); - + ASSERT(pTxtNode!= 0, "There should be a SwTxtNode!"); - + if (pTxtNode != NULL) - pTxtNode->InsertItem(SwFmtFlyCnt( pFmt ), nStt, nStt ); + { + SwFmtFlyCnt aFmt( pFmt ); + pTxtNode->InsertItem( aFmt, nStt, nStt ); + } } if( SFX_ITEM_SET != pFmt->GetAttrSet().GetItemState( RES_FRM_SIZE )) @@ -844,7 +851,7 @@ SwFlyFrmFmt* SwDoc::MakeFlyAndMove( const SwPaM& rPam, const SfxItemSet& rSet, GetNodes().MakeTxtNode( aRg.aStart, (SwTxtFmtColl*)GetDfltTxtFmtColl() ); - Move( aRg, aPos.nNode, DOC_MOVEDEFAULT ); + MoveNodeRange( aRg, aPos.nNode, DOC_MOVEDEFAULT ); } else { @@ -885,8 +892,11 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. do { if( pTmp->HasMark() && *pTmp->GetPoint() != *pTmp->GetMark() ) - Copy( *pTmp, aPos, false ); - } while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ) ); + { + CopyRange( *pTmp, aPos, false ); + } + pTmp = static_cast<SwPaM*>(pTmp->GetNext()); + } while ( &rPam != pTmp ); mbCopyIsMove = bOldFlag; mbUndo = bOldUndo; @@ -894,8 +904,11 @@ if( DoesUndo() ) // werden erstmal alle Undo - Objecte geloescht. do { if( pTmp->HasMark() && *pTmp->GetPoint() != *pTmp->GetMark() ) + { DeleteAndJoin( *pTmp ); - } while( &rPam != ( pTmp = (SwPaM*)pTmp->GetNext() ) ); + } + pTmp = static_cast<SwPaM*>(pTmp->GetNext()); + } while ( &rPam != pTmp ); } } while( sal_False ); } @@ -982,8 +995,9 @@ SwDrawFrmFmt* SwDoc::Insert( const SwPaM &rRg, if( FLY_IN_CNTNT == eAnchorId ) { xub_StrLen nStt = rRg.GetPoint()->nContent.GetIndex(); + SwFmtFlyCnt aFmt( pFmt ); rRg.GetPoint()->nNode.GetNode().GetTxtNode()->InsertItem( - SwFmtFlyCnt( pFmt ), nStt, nStt ); + aFmt, nStt, nStt ); } SwDrawContact* pContact = new SwDrawContact( pFmt, &rDrawObj ); @@ -1379,16 +1393,16 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr *pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt(nIdx, RES_TXTATR_FLYCNT); -#ifndef PRODUCT ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); - ASSERT( pHnt && ((SwFmtFlyCnt&)pHnt->GetFlyCnt()). - GetFrmFmt() == pOldFmt, + ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pOldFmt, "Wrong TxtFlyCnt-Hint." ); -#endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt( pNewFmt ); + + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt( + pNewFmt ); } @@ -1466,7 +1480,7 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co //String einfuegen SwIndex aIdx( pNew, 0 ); - pNew->Insert( aTxt, aIdx ); + pNew->InsertText( aTxt, aIdx ); // //Feld einfuegen @@ -1475,7 +1489,8 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co SwSetExpField aFld( (SwSetExpFieldType*)pType, aEmptyStr, SVX_NUM_ARABIC); if( bOrderNumberingFirst ) nIdx = 0; - pNew->InsertItem( SwFmtFld( aFld ), nIdx, nIdx ); + SwFmtFld aFmt( aFld ); + pNew->InsertItem( aFmt, nIdx, nIdx ); if(rCharacterStyle.Len()) { SwCharFmt* pCharFmt = FindCharFmtByName( rCharacterStyle ); @@ -1484,9 +1499,12 @@ SwFlyFrmFmt* SwDoc::InsertLabel( const SwLabelType eType, const String &rTxt, co const USHORT nMyId = SwStyleNameMapper::GetPoolIdFromUIName(rCharacterStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT); pCharFmt = GetCharFmtFromPool( nMyId ); } - if(pCharFmt) - pNew->InsertItem( SwFmtCharFmt( pCharFmt ), 0, - nSepIdx + 1, nsSetAttrMode::SETATTR_DONTEXPAND ); + if (pCharFmt) + { + SwFmtCharFmt aCharFmt( pCharFmt ); + pNew->InsertItem( aCharFmt, 0, + nSepIdx + 1, nsSetAttrMode::SETATTR_DONTEXPAND ); + } } } @@ -1672,7 +1690,8 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr *pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT ); #ifndef PRODUCT ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, @@ -1681,7 +1700,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, GetFrmFmt() == (SwFrmFmt*)pOldFmt, "Wrong TxtFlyCnt-Hint." ); #endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt( pNewFmt ); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt( pNewFmt ); } @@ -1751,7 +1770,7 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, // insert text SwIndex aIdx( pNew, 0 ); - pNew->Insert( aTxt, aIdx ); + pNew->InsertText( aTxt, aIdx ); // insert field if ( pType ) @@ -1759,7 +1778,8 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, SwSetExpField aFld( (SwSetExpFieldType*)pType, aEmptyStr, SVX_NUM_ARABIC ); if( bOrderNumberingFirst ) nIdx = 0; - pNew->InsertItem( SwFmtFld( aFld ), nIdx, nIdx ); + SwFmtFld aFmt( aFld ); + pNew->InsertItem( aFmt, nIdx, nIdx ); if ( rCharacterStyle.Len() ) { SwCharFmt* pCharFmt = FindCharFmtByName( rCharacterStyle ); @@ -1769,7 +1789,11 @@ SwFlyFrmFmt* SwDoc::InsertDrawLabel( const String &rTxt, pCharFmt = GetCharFmtFromPool( nMyId ); } if ( pCharFmt ) - pNew->InsertItem( SwFmtCharFmt( pCharFmt ), 0, nSepIdx + 1, nsSetAttrMode::SETATTR_DONTEXPAND ); + { + SwFmtCharFmt aCharFmt( pCharFmt ); + pNew->InsertItem( aCharFmt, 0, nSepIdx + 1, + nsSetAttrMode::SETATTR_DONTEXPAND ); + } } } } diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 25bad5f871..d5285b0177 100644 --- a/sw/source/core/doc/docnew.cxx +++ b/sw/source/core/doc/docnew.cxx @@ -124,6 +124,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <sfx2/Metadatable.hxx> +#include <fmtmeta.hxx> // MetaFieldManager using namespace ::com::sun::star; @@ -225,6 +226,7 @@ SwDoc::SwDoc() : aUndoNodes( this ), mpAttrPool(new SwAttrPool(this)), pMarkManager(new ::sw::mark::MarkManager(*this)), + m_pMetaFieldManager(new ::sw::MetaFieldManager()), pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ), pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ), pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ), @@ -1058,6 +1060,12 @@ SwDoc::GetXmlIdRegistry() return *m_pXmlIdRegistry; } +::sw::MetaFieldManager & +SwDoc::GetMetaFieldManager() +{ + return *m_pMetaFieldManager; +} + void SwDoc::InitTOXTypes() { ShellResource* pShellRes = ViewShell::GetShellRes(); @@ -1398,7 +1406,7 @@ void SwDoc::Paste( const SwDoc& rSource ) aIndexBefore--; - rSource.Copy( aCpyPam, rInsPos, true ); + rSource.CopyRange( aCpyPam, rInsPos, true ); { aIndexBefore++; diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 30aa235f88..a3bca434cc 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -1031,12 +1031,14 @@ void SwDoc::SetNumRule( const SwPaM& rPam, "<SwDoc::SetNumRule(..)> - could not create new list. Serious defect -> please inform OD." ); sListId = pNewList->GetListId(); } - Insert( rPam, SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); + InsertPoolItem( rPam, + SfxStringItem( RES_PARATR_LIST_ID, sListId ), 0 ); } else if ( sContinuedListId.Len() > 0 ) { // apply given list id - Insert( rPam, SfxStringItem( RES_PARATR_LIST_ID, sContinuedListId ), 0 ); + InsertPoolItem( rPam, + SfxStringItem( RES_PARATR_LIST_ID, sContinuedListId ), 0 ); } } // <-- @@ -1080,13 +1082,11 @@ void SwDoc::SetNumRule( const SwPaM& rPam, // <-- } - // --> OD 2006-01-13 #i60395# - // It's not allowed to apply the outline numbering rule as hard attribute - // to document content - typically paragraphs. - if ( bSetItem && pNew != GetOutlineNumRule() ) + // --> OD 2009-08-18 #i103817# + if ( bSetItem ) // <-- { - Insert( rPam, SwNumRuleItem( pNew->GetName() ), 0 ); + InsertPoolItem( rPam, SwNumRuleItem( pNew->GetName() ), 0 ); } // --> OD 2008-02-08 #newlistlevelattrs# @@ -1126,33 +1126,34 @@ void SwDoc::SetCounted(const SwPaM & rPam, bool bCounted) } else { - Insert( rPam, SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, FALSE ), 0 ); + InsertPoolItem( rPam, + SfxBoolItem( RES_PARATR_LIST_ISCOUNTED, FALSE ), 0 ); } } -void SwDoc::ReplaceNumRule(const SwPaM & rPaM, const SwNumRule & rNumRule) -{ - if (DoesUndo()) - StartUndo(UNDO_START, NULL); +//void SwDoc::ReplaceNumRule(const SwPaM & rPaM, const SwNumRule & rNumRule) +//{ +// if (DoesUndo()) +// StartUndo(UNDO_START, NULL); - ULONG nStt = rPaM.Start()->nNode.GetIndex(); - ULONG nEnd = rPaM.End()->nNode.GetIndex(); +// ULONG nStt = rPaM.Start()->nNode.GetIndex(); +// ULONG nEnd = rPaM.End()->nNode.GetIndex(); - for (ULONG n = nStt; n <= nEnd; n++) - { - SwTxtNode * pCNd = GetNodes()[n]->GetTxtNode(); +// for (ULONG n = nStt; n <= nEnd; n++) +// { +// SwTxtNode * pCNd = GetNodes()[n]->GetTxtNode(); - if (pCNd && NULL != pCNd->GetNumRule()) - { - SwPaM aPam(*pCNd); +// if (pCNd && NULL != pCNd->GetNumRule()) +// { +// SwPaM aPam(*pCNd); - Insert(aPam, SwNumRuleItem(rNumRule.GetName()), 0); - } - } +// InsertPoolItem(aPam, SwNumRuleItem(rNumRule.GetName()), 0); +// } +// } - if (DoesUndo()) - EndUndo(UNDO_START, NULL); -} +// if (DoesUndo()) +// EndUndo(UNDO_START, NULL); +//} void SwDoc::SetNumRuleStart( const SwPosition& rPos, BOOL bFlag ) { @@ -1546,8 +1547,8 @@ void SwDoc::MakeUniqueNumRules(const SwPaM & rPaM) SwPosition aPos(*pCNd); aListStyleData.pReplaceNumRule = const_cast<SwNumRule *> - (SearchNumRule( aPos, FALSE, pCNd->HasNumber(), - FALSE, 0, + (SearchNumRule( aPos, false, pCNd->HasNumber(), + false, 0, aListStyleData.sListId, true )); } @@ -1670,7 +1671,7 @@ void SwDoc::DelNumRules( const SwPaM& rPam ) pTNd->ChkCondColl(); //else if( !pOutlNd && NO_NUMBERING != //#outline level,zhaojianwei // ((SwTxtFmtColl*)pTNd->GetFmtColl())->GetOutlineLevel() ) - else if( !pOutlNd && + else if( !pOutlNd && ((SwTxtFmtColl*)pTNd->GetFmtColl())->IsAssignedToListLevelOfOutlineStyle() )//<-end,zhaojianwei pOutlNd = pTNd; } @@ -1851,13 +1852,13 @@ BOOL SwDoc::GotoNextNum( SwPosition& rPos, BOOL bOverUpper, // -> #i23731# // --> OD 2008-03-18 #refactorlists# - add output parameter <sListId> -const SwNumRule * SwDoc::SearchNumRule(SwPosition & rPos, - BOOL bForward, - BOOL bNum, - BOOL bOutline, +const SwNumRule * SwDoc::SearchNumRule(const SwPosition & rPos, + const bool bForward, + const bool bNum, + const bool bOutline, int nNonEmptyAllowed, String& sListId, - bool _bInvestigateStartNode) + const bool bInvestigateStartNode) { const SwNumRule * pResult = NULL; SwTxtNode * pTxtNd = rPos.nNode.GetNode().GetTxtNode(); @@ -1873,7 +1874,7 @@ const SwNumRule * SwDoc::SearchNumRule(SwPosition & rPos, do { // --> OD 2005-10-20 #i55391# - if ( !_bInvestigateStartNode ) + if ( !bInvestigateStartNode ) { if (bForward) aIdx++; @@ -1888,9 +1889,9 @@ const SwNumRule * SwDoc::SearchNumRule(SwPosition & rPos, const SwNumRule * pNumRule = pTxtNd->GetNumRule(); if (pNumRule) { - if (pNumRule->IsOutlineRule() == bOutline && // #115901# - ( (bNum && pNumRule->Get(0).IsEnumeration()) || - (!bNum && pNumRule->Get(0).IsItemize()) )) // #i22362#, #i29560# + if ( ( pNumRule->IsOutlineRule() == ( bOutline ? TRUE : FALSE ) ) && // #115901# + ( ( bNum && pNumRule->Get(0).IsEnumeration()) || + ( !bNum && pNumRule->Get(0).IsItemize() ) ) ) // #i22362#, #i29560# { pResult = pTxtNd->GetNumRule(); // --> OD 2008-03-18 #refactorlists# @@ -1913,7 +1914,7 @@ const SwNumRule * SwDoc::SearchNumRule(SwPosition & rPos, } // --> OD 2005-10-20 #i55391# - if ( _bInvestigateStartNode ) + if ( bInvestigateStartNode ) { if (bForward) aIdx++; @@ -2277,7 +2278,7 @@ BOOL SwDoc::MoveParagraph( const SwPaM& rPam, long nOffset, BOOL bIsOutlMv ) } } - Copy( aPam, aInsPos, false ); + CopyRange( aPam, aInsPos, false ); if( bDelLastPara ) { // dann muss der letzte leere Node wieder entfernt werden @@ -2363,7 +2364,7 @@ SetRedlineMode( eOld ); } - Move( aMvRg, aIdx, DOC_MOVEREDLINES ); + MoveNodeRange( aMvRg, aIdx, DOC_MOVEREDLINES ); if( pUndo ) { diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index d83860947e..75d0dd1faa 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -1725,7 +1725,7 @@ BOOL lcl_AcceptRedline( SwRedlineTbl& rArr, USHORT& rPos, rDoc.DeleteAndJoin( aPam ); else { - rDoc.Delete( aPam ); + rDoc.DeleteRange( aPam ); if( pCSttNd && !pCEndNd ) { @@ -1835,7 +1835,7 @@ BOOL lcl_RejectRedline( SwRedlineTbl& rArr, USHORT& rPos, rDoc.DeleteAndJoin( aPam ); else { - rDoc.Delete( aPam ); + rDoc.DeleteRange( aPam ); if( pCSttNd && !pCEndNd ) { @@ -2899,10 +2899,12 @@ void SwRedlineExtraData_FmtColl::Reject( SwPaM& rPam ) const // nicht angefasst. SfxItemSet aTmp( *pSet ); aTmp.Differentiate( *pTNd->GetpSwAttrSet() ); - pDoc->Insert( rPam, aTmp, 0 ); + pDoc->InsertItemSet( rPam, aTmp, 0 ); } else - pDoc->Insert( rPam, *pSet, 0 ); + { + pDoc->InsertItemSet( rPam, *pSet, 0 ); + } } rPam.DeleteMark(); } @@ -2964,7 +2966,10 @@ void SwRedlineExtraData_Format::Reject( SwPaM& rPam ) const // eigentlich muesste hier das Attribut zurueck gesetzt werden!!! for( USHORT n = 0, nEnd = aWhichIds.Count(); n < nEnd; ++n ) - pDoc->Insert( rPam, *GetDfltAttr( aWhichIds[ n ] ), nsSetAttrMode::SETATTR_DONTEXPAND ); + { + pDoc->InsertPoolItem( rPam, *GetDfltAttr( aWhichIds[ n ] ), + nsSetAttrMode::SETATTR_DONTEXPAND ); + } pDoc->SetRedlineMode_intern( eOld ); } @@ -3359,7 +3364,8 @@ void SwRedline::MoveToSection() { if( pCSttNd && !pCEndNd ) bDelLastPara = TRUE; - pDoc->Move( aPam, aPos, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveRange( aPam, aPos, + IDocumentContentOperations::DOC_MOVEDEFAULT ); } } else @@ -3368,7 +3374,8 @@ void SwRedline::MoveToSection() SwNormalStartNode ); SwPosition aPos( *pSttNd->EndOfSectionNode() ); - pDoc->Move( aPam, aPos, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveRange( aPam, aPos, + IDocumentContentOperations::DOC_MOVEDEFAULT ); } pCntntSect = new SwNodeIndex( *pSttNd ); @@ -3419,7 +3426,7 @@ void SwRedline::CopyToSection() SwNodeIndex aNdIdx( *pSttNd, 1 ); SwTxtNode* pTxtNd = aNdIdx.GetNode().GetTxtNode(); SwPosition aPos( aNdIdx, SwIndex( pTxtNd )); - pDoc->Copy( *this, aPos, false ); + pDoc->CopyRange( *this, aPos, false ); // JP 08.10.98: die Vorlage vom EndNode ggfs. mit uebernehmen // - ist im Doc::Copy nicht erwuenscht @@ -3444,7 +3451,7 @@ void SwRedline::CopyToSection() if( pCEndNd ) { SwPosition aPos( *pSttNd->EndOfSectionNode() ); - pDoc->Copy( *this, aPos, false ); + pDoc->CopyRange( *this, aPos, false ); } else { @@ -3488,12 +3495,17 @@ void SwRedline::DelCopyOfSection() } if( pCSttNd && pCEndNd ) - pDoc->DeleteAndJoin( aPam ); + { + // --> OD 2009-08-20 #i100466# + // force a <join next> on <delete and join> operation + pDoc->DeleteAndJoin( aPam, true ); + // <-- + } else if( pCSttNd || pCEndNd ) { if( pCSttNd && !pCEndNd ) bDelLastPara = TRUE; - pDoc->Delete( aPam ); + pDoc->DeleteRange( aPam ); if( bDelLastPara ) { @@ -3534,7 +3546,9 @@ void SwRedline::DelCopyOfSection() } } else - pDoc->Delete( aPam ); + { + pDoc->DeleteRange( aPam ); + } if( pStt == GetPoint() ) Exchange(); @@ -3617,7 +3631,10 @@ void SwRedline::MoveFromSection() pDoc->AppendTxtNode( aPos ); } else - pDoc->Move( aPam, aPos, IDocumentContentOperations::DOC_MOVEALLFLYS ); + { + pDoc->MoveRange( aPam, aPos, + IDocumentContentOperations::DOC_MOVEALLFLYS ); + } SetMark(); *GetPoint() = aPos; diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx index 6a03378ff3..37d743c0d3 100644 --- a/sw/source/core/doc/docruby.cxx +++ b/sw/source/core/doc/docruby.cxx @@ -147,16 +147,20 @@ USHORT SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, { // set/reset the attribut if( pEntry->GetRubyAttr().GetText().Len() ) - Insert( aPam, pEntry->GetRubyAttr(), 0 ); + { + InsertPoolItem( aPam, pEntry->GetRubyAttr(), 0 ); + } else + { ResetAttrs( aPam, TRUE, &aDelArr ); + } } if( aCheckEntry.GetText() != pEntry->GetText() && pEntry->GetText().Len() ) { // text is changed, so replace the original - Replace( aPam, pEntry->GetText(), FALSE ); + ReplaceRange( aPam, pEntry->GetText(), false ); } aPam.DeleteMark(); } @@ -176,10 +180,11 @@ USHORT SwDoc::SetRubyList( const SwPaM& rPam, const SwRubyList& rList, if( pEntry->GetRubyAttr().GetText().Len() && pEntry->GetText().Len() ) { - Insert( aPam, pEntry->GetText(), true ); + InsertString( aPam, pEntry->GetText() ); aPam.SetMark(); aPam.GetMark()->nContent -= pEntry->GetText().Len(); - Insert( aPam, pEntry->GetRubyAttr(), nsSetAttrMode::SETATTR_DONTEXPAND ); + InsertPoolItem( aPam, pEntry->GetRubyAttr(), + nsSetAttrMode::SETATTR_DONTEXPAND ); } else break; @@ -246,7 +251,7 @@ BOOL SwDoc::_SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rEntry, USHORT ) if( !bHasMark && nStart && ( !pAttr || nStart != *pAttr->GetStart()) ) { // skip to the word begin! - long nWordStt = pBreakIt->xBreak->getWordBoundary( + long nWordStt = pBreakIt->GetBreakIter()->getWordBoundary( *pTxt, nStart, pBreakIt->GetLocale( pTNd->GetLang( nStart )), WordType::ANYWORD_IGNOREWHITESPACES, @@ -335,10 +340,10 @@ BOOL SwDoc::_SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rEntry, USHORT ) { rPam.SetMark(); bAlphaNum = bIsAlphaNum; - if( bChkNxtWrd && pBreakIt->xBreak.is() ) + if( bChkNxtWrd && pBreakIt->GetBreakIter().is() ) { // search the end of this word - nWordEnd = pBreakIt->xBreak->getWordBoundary( + nWordEnd = pBreakIt->GetBreakIter()->getWordBoundary( *pTxt, nStart, pBreakIt->GetLocale( pTNd->GetLang( nStart )), WordType::ANYWORD_IGNOREWHITESPACES, diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx index d69863980f..5414b72869 100644 --- a/sw/source/core/doc/docsort.cxx +++ b/sw/source/core/doc/docsort.cxx @@ -452,7 +452,8 @@ BOOL SwDoc::SortText(const SwPaM& rPaM, const SwSortOptions& rOpt) aRg.aEnd = aRg.aStart.GetIndex() + 1; // Nodes verschieben - Move( aRg, aStart, IDocumentContentOperations::DOC_MOVEDEFAULT ); + MoveNodeRange( aRg, aStart, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // Undo Verschiebungen einpflegen if(pUndoSort) @@ -777,7 +778,8 @@ void MoveCell(SwDoc* pDoc, const SwTableBox* pSource, const SwTableBox* pTar, // Einfuegen der Source SwNodeIndex aIns( *pTar->GetSttNd()->EndOfSectionNode() ); - pDoc->Move( aRg, aIns, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aRg, aIns, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // Falls erster Node leer -> weg damit if(bDelFirst) diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index 50ba887043..57ce88fec8 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -182,7 +182,7 @@ USHORT SwDoc::GetCurTOXMark( const SwPosition& rPos, Beschreibung: Marke loeschen --------------------------------------------------------------------*/ -void SwDoc::Delete( const SwTOXMark* pTOXMark ) +void SwDoc::DeleteTOXMark( const SwTOXMark* pTOXMark ) { // hole den TextNode und const SwTxtTOXMark* pTxtTOXMark = pTOXMark->GetTxtTOXMark(); @@ -202,12 +202,15 @@ void SwDoc::Delete( const SwTOXMark* pTOXMark ) SwRegHistory aRHst( rTxtNd, &pUndo->GetHistory() ); rTxtNd.GetpSwpHints()->Register( &aRHst ); - rTxtNd.Delete( const_cast<SwTxtTOXMark*>( pTxtTOXMark ), TRUE ); + } + + rTxtNd.DeleteAttribute( const_cast<SwTxtTOXMark*>(pTxtTOXMark) ); + + if ( DoesUndo() ) + { if( rTxtNd.GetpSwpHints() ) rTxtNd.GetpSwpHints()->DeRegister(); } - else - rTxtNd.Delete( const_cast<SwTxtTOXMark*>( pTxtTOXMark ), TRUE ); SetModified(); } @@ -372,7 +375,7 @@ const SwTOXBaseSection* SwDoc::InsertTableOf( const SwPosition& rPos, pNew->SetTOXName(sSectNm); pNew->SwSection::SetName(sSectNm); SwPaM aPam( rPos ); - SwSection* pSect = Insert( aPam, *pNew, pSet, FALSE ); + SwSection* pSect = InsertSwSection( aPam, *pNew, pSet, false ); if( pSect ) { SwSectionNode* pSectNd = pSect->GetFmt()->GetSectionNode(); @@ -956,7 +959,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr, SwTxtNode* pHeadNd = pDoc->GetNodes().MakeTxtNode( aIdx, GetTxtFmtColl( FORM_TITLE ) ); - pHeadNd->Insert( GetTitle(), SwIndex( pHeadNd )); + pHeadNd->InsertText( GetTitle(), SwIndex( pHeadNd ) ); String sNm( GetTOXName() ); // ??Resource @@ -1245,7 +1248,7 @@ void SwTOXBaseSection::UpdateMarks( const SwTOXInternational& rIntl, { // Stichwortverzeichnismarkierung lang::Locale aLocale; - if ( pBreakIt->xBreak.is() ) + if ( pBreakIt->GetBreakIter().is() ) { aLocale = pBreakIt->GetLocale( pTOXSrc->GetLang( *pTxtMark->GetStart() ) ); @@ -1939,9 +1942,12 @@ void SwTOXBaseSection::GenerateText( USHORT nArrayIdx, else pCharFmt = pDoc->FindCharFmtByName( aToken.sCharStyleName); - if(pCharFmt) - pTOXNd->InsertItem( SwFmtCharFmt( pCharFmt ), nStartCharStyle, - rTxt.Len(), nsSetAttrMode::SETATTR_DONTEXPAND ); + if (pCharFmt) + { + SwFmtCharFmt aFmt( pCharFmt ); + pTOXNd->InsertItem( aFmt, nStartCharStyle, + rTxt.Len(), nsSetAttrMode::SETATTR_DONTEXPAND ); + } } aIt++; // #i21237# @@ -2139,7 +2145,7 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, break; } } - pNd->Erase(aPos, nEndPos - nStartPos + 2); + pNd->EraseText(aPos, nEndPos - nStartPos + 2); for( i = 1; i < rNums.Count(); ++i) { @@ -2213,7 +2219,8 @@ void SwTOXBaseSection::_UpdatePageNum( SwTxtNode* pNd, GetNumType() ).GetNumStr( nBeg+nCount ); } } - pNd->Insert( aNumStr, aPos, INS_EMPTYEXPAND ); + pNd->InsertText( aNumStr, aPos, + IDocumentContentOperations::INS_EMPTYEXPAND ); if(pPageNoCharFmt) { SwFmtCharFmt aCharFmt( pPageNoCharFmt ); diff --git a/sw/source/core/doc/extinput.cxx b/sw/source/core/doc/extinput.cxx index 2715f39843..8cd8229f74 100644 --- a/sw/source/core/doc/extinput.cxx +++ b/sw/source/core/doc/extinput.cxx @@ -89,7 +89,7 @@ SwExtTextInput::~SwExtTextInput() if ( bLang ) { SvxLanguageItem aLangItem( eInputLanguage, nWhich ); - pDoc->Insert(*this, aLangItem, 0 ); + pDoc->InsertPoolItem(*this, aLangItem, 0 ); } } rIdx = nSttCnt; @@ -100,9 +100,9 @@ SwExtTextInput::~SwExtTextInput() if( nLen > sOverwriteText.Len() ) { rIdx += sOverwriteText.Len(); - pTNd->Erase( rIdx, nLen - sOverwriteText.Len() ); + pTNd->EraseText( rIdx, nLen - sOverwriteText.Len() ); rIdx = nSttCnt; - pTNd->Replace( rIdx, sOverwriteText.Len(), + pTNd->ReplaceText( rIdx, sOverwriteText.Len(), sOverwriteText ); if( bInsText ) { @@ -110,13 +110,15 @@ SwExtTextInput::~SwExtTextInput() pDoc->StartUndo( UNDO_OVERWRITE, NULL ); pDoc->Overwrite( *this, sTxt.Copy( 0, sOverwriteText.Len() )); - pDoc->Insert( *this, sTxt.Copy( sOverwriteText.Len() ), true); + pDoc->InsertString( *this, + sTxt.Copy( sOverwriteText.Len() ) ); pDoc->EndUndo( UNDO_OVERWRITE, NULL ); } } else { - pTNd->Replace( rIdx, nLen, sOverwriteText.Copy( 0, nLen )); + pTNd->ReplaceText( rIdx, nLen, + sOverwriteText.Copy( 0, nLen )); if( bInsText ) { rIdx = nSttCnt; @@ -126,10 +128,12 @@ SwExtTextInput::~SwExtTextInput() } else { - pTNd->Erase( rIdx, nEndCnt - nSttCnt ); + pTNd->EraseText( rIdx, nEndCnt - nSttCnt ); if( bInsText ) - pDoc->Insert( *this, sTxt, true ); + { + pDoc->InsertString( *this, sTxt ); + } } } } @@ -159,7 +163,7 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData ) // some characters nReplace = nReplace - rNewStr.Len(); aIdx += rNewStr.Len(); - pTNd->Replace( aIdx, nReplace, + pTNd->ReplaceText( aIdx, nReplace, sOverwriteText.Copy( rNewStr.Len(), nReplace )); aIdx = nSttCnt; nReplace = rNewStr.Len(); @@ -168,14 +172,14 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData ) { nReplace = nReplace - sOverwriteText.Len(); aIdx += sOverwriteText.Len(); - pTNd->Erase( aIdx, nReplace ); + pTNd->EraseText( aIdx, nReplace ); aIdx = nSttCnt; nReplace = sOverwriteText.Len(); } else if( (nReplace = sOverwriteText.Len()) > rNewStr.Len() ) nReplace = rNewStr.Len(); - pTNd->Replace( aIdx, nReplace, rNewStr ); + pTNd->ReplaceText( aIdx, nReplace, rNewStr ); if( !HasMark() ) SetMark(); GetMark()->nContent = aIdx; @@ -183,9 +187,12 @@ void SwExtTextInput::SetInputData( const CommandExtTextInputData& rData ) else { if( nSttCnt < nEndCnt ) - pTNd->Erase( aIdx, nEndCnt - nSttCnt ); + { + pTNd->EraseText( aIdx, nEndCnt - nSttCnt ); + } - pTNd->Insert( rNewStr, aIdx, INS_EMPTYEXPAND ); + pTNd->InsertText( rNewStr, aIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( !HasMark() ) SetMark(); } diff --git a/sw/source/core/doc/makefile.mk b/sw/source/core/doc/makefile.mk index 9e01f6ff1e..c7459cd164 100644 --- a/sw/source/core/doc/makefile.mk +++ b/sw/source/core/doc/makefile.mk @@ -49,6 +49,7 @@ EXCEPTIONSFILES = \ $(SLO)$/docbm.obj \ $(SLO)$/doccomp.obj \ $(SLO)$/docdraw.obj \ + $(SLO)$/docedt.obj \ $(SLO)$/docfmt.obj \ $(SLO)$/docglbl.obj \ $(SLO)$/docglos.obj \ @@ -70,7 +71,6 @@ SLOFILES = $(EXCEPTIONSFILES) \ $(SLO)$/doccorr.obj \ $(SLO)$/docdde.obj \ $(SLO)$/docdesc.obj \ - $(SLO)$/docedt.obj \ $(SLO)$/docfld.obj \ $(SLO)$/docfly.obj \ $(SLO)$/docftn.obj \ diff --git a/sw/source/core/doc/notxtfrm.cxx b/sw/source/core/doc/notxtfrm.cxx index 9624e817e0..8784290172 100644 --- a/sw/source/core/doc/notxtfrm.cxx +++ b/sw/source/core/doc/notxtfrm.cxx @@ -36,6 +36,7 @@ #include <tools/urlobj.hxx> #include <vcl/print.hxx> #include <vcl/virdev.hxx> +#include <vcl/svapp.hxx> #include <svtools/imapobj.hxx> #include <svtools/imap.hxx> #include <svtools/urihelper.hxx> @@ -281,7 +282,7 @@ void SwNoTxtFrm::Paint( const SwRect &rRect ) const if ( pSh->GetWin() && !pSh->IsPreView() ) { const SwNoTxtNode* pNd = GetNode()->GetNoTxtNode(); - String aTxt( pNd->GetAlternateText() ); + String aTxt( pNd->GetTitle() ); if ( !aTxt.Len() && pNd->IsGrfNode() ) GetRealURL( *(SwGrfNode*)pNd, aTxt ); if( !aTxt.Len() ) @@ -906,7 +907,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons pGrfNd->TriggerAsyncRetrieveInputStream(); // <-- } - String aTxt( pGrfNd->GetAlternateText() ); + String aTxt( pGrfNd->GetTitle() ); if ( !aTxt.Len() ) GetRealURL( *pGrfNd, aTxt ); ::lcl_PaintReplacement( aAlignedGrfArea, aTxt, *pShell, this, FALSE ); @@ -971,7 +972,7 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons ((SwNoTxtFrm*)this)->nWeight = -1; String aText; if ( !nResId && - !(aText = pGrfNd->GetAlternateText()).Len() && + !(aText = pGrfNd->GetTitle()).Len() && (!GetRealURL( *pGrfNd, aText ) || !aText.Len())) { nResId = STR_COMCORE_READERROR; @@ -1027,8 +1028,9 @@ void SwNoTxtFrm::PaintPicture( OutputDevice* pOut, const SwRect &rGrfArea ) cons //TODO/LATER: is it a problem that the JopSetup isn't used? //xRef->DoDraw( pOut, aAlignedGrfArea.Pos(), aAlignedGrfArea.SSize(), *pJobSetup ); + // get hi-contrast image, but never for printing Graphic* pGraphic = NULL; - if ( pOut && ( pOut->GetDrawMode() & DRAWMODE_SETTINGSFILL ) ) + if (pOut && !bPrn && Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) pGraphic = pOLENd->GetHCGraphic(); // when it is not possible to get HC-representation, the original image should be used diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx index a70fb9a709..a5419368d0 100644 --- a/sw/source/core/doc/poolfmt.cxx +++ b/sw/source/core/doc/poolfmt.cxx @@ -1719,7 +1719,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -1773,7 +1773,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -1876,7 +1876,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 283, 567, 850, 1134, 1417, 1701, 1984, 2268, 2551, 2835 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -1930,7 +1930,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 347, 1194 }; const USHORT* pArr0to2 = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace0to2 : aAbsSpaceInch0to2; #else @@ -2070,7 +2070,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -2131,7 +2131,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 170, 340, 510, 680, 850, 1020, 1191, 1361, 1531, 1701 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -2236,7 +2236,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else @@ -2303,7 +2303,7 @@ SwNumRule* SwDoc::GetNumRuleFromPool( USHORT nId ) 227, 454, 680, 907, 1134, 1361, 1587, 1814, 2041, 2268 }; const USHORT* pArr = MEASURE_METRIC == - GetAppLocaleData().getMeasurementSystemEnum() + SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? aAbsSpace : aAbsSpaceInch; #else diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 39b7f95d92..e07062d5de 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -360,11 +360,18 @@ BOOL lcl_CopyCol( const _FndBox*& rpFndBox, void* pPara ) SwTableBoxFmt* pNewFmt = (SwTableBoxFmt*)pBox->ClaimFrmFmt(); // suche die selektierten Boxen in der Line: - _FndLine* pCmpLine; + _FndLine* pCmpLine = NULL; SwFmtFrmSize aFrmSz( pNewFmt->GetFrmSize() ); - if( pBox->GetTabLines().Count() && - ( pCmpLine = rpFndBox->GetLines()[ 0 ])->GetBoxes().Count() - != pCmpLine->GetLine()->GetTabBoxes().Count() ) + + bool bDiffCount = false; + if( pBox->GetTabLines().Count() ) + { + pCmpLine = rpFndBox->GetLines()[ 0 ]; + if ( pCmpLine->GetBoxes().Count() != pCmpLine->GetLine()->GetTabBoxes().Count() ) + bDiffCount = true; + } + + if( bDiffCount ) { // die erste Line sollte reichen _FndBoxes& rFndBoxes = pCmpLine->GetBoxes(); diff --git a/sw/source/core/docnode/ndcopy.cxx b/sw/source/core/docnode/ndcopy.cxx index dba567c545..60b7fe6287 100644 --- a/sw/source/core/docnode/ndcopy.cxx +++ b/sw/source/core/docnode/ndcopy.cxx @@ -203,6 +203,14 @@ namespace pNewBookmark->SetKeyCode(pOldBookmark->GetKeyCode()); pNewBookmark->SetShortName(pOldBookmark->GetShortName()); } + ::sfx2::Metadatable const*const pMetadatable( + dynamic_cast< ::sfx2::Metadatable const* >(pMark)); + ::sfx2::Metadatable *const pNewMetadatable( + dynamic_cast< ::sfx2::Metadatable * >(pNewMark)); + if (pMetadatable && pNewMetadatable) + { + pNewMetadatable->RegisterAsCopyOf(*pMetadatable); + } } pDestDoc->DoUndo(bDoesUndo); } @@ -271,7 +279,8 @@ SwCntntNode* SwTxtNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const // ??? reicht das ??? was ist mit PostIts/Feldern/FeldTypen ??? // --> OD 2008-11-18 #i96213# - force copy of all attributes - pCpyTxtNd->Copy( pTxtNd, SwIndex( pCpyTxtNd ), pCpyTxtNd->GetTxt().Len(), true ); + pCpyTxtNd->CopyText( pTxtNd, SwIndex( pCpyTxtNd ), + pCpyTxtNd->GetTxt().Len(), true ); // <-- //FEATURE::CONDCOLL @@ -673,7 +682,8 @@ void lcl_DeleteRedlines( const SwNodeRange& rRg, SwNodeRange& rCpyRg ) // Kopieren eines Bereiches im oder in ein anderes Dokument ! -bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const +bool +SwDoc::CopyRange( SwPaM& rPam, SwPosition& rPos, const bool bCopyAll ) const { const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End(); @@ -682,7 +692,7 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const // kein Copy abfangen. if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) ) - return FALSE; + return false; // verhinder das Kopieren in Fly's, die im Bereich verankert sind. if( pDoc == this ) @@ -699,7 +709,9 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const --nEnd, --nDiff; if( nDiff && lcl_ChkFlyFly( pDoc, nStt, nEnd, rPos.nNode.GetIndex() ) ) - return FALSE; + { + return false; + } } SwPaM* pRedlineRange = 0; @@ -709,20 +721,25 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const RedlineMode_t eOld = pDoc->GetRedlineMode(); - BOOL bRet = FALSE; + bool bRet = false; if( pDoc != this ) - bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange ); // nur normales Kopieren + { // ordinary copy + bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange ); + } // Copy in sich selbst (ueber mehrere Nodes wird hier gesondert // behandelt; in einem TextNode wird normal behandelt) else if( ! ( *pStt <= rPos && rPos < *pEnd && ( pStt->nNode != pEnd->nNode || !pStt->nNode.GetNode().IsTxtNode() )) ) - bRet = _Copy( rPam, rPos, TRUE, bCopyAll, pRedlineRange ); // nur normales Kopieren - + { // ordinary copy + bRet = CopyImpl( rPam, rPos, true, bCopyAll, pRedlineRange ); + } else { ASSERT( this == pDoc, " falscher Copy-Zweig!" ); + ASSERT(false, "mst: i thought this could be dead code;" + "please tell me what you did to get here!"); pDoc->SetRedlineMode_intern((RedlineMode_t)(eOld | nsRedlineMode_t::REDLINE_IGNORE)); BOOL bDoUndo = pDoc->DoesUndo(); @@ -742,7 +759,8 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const SwStartNode* pSttNd = pDoc->GetNodes().MakeEmptySection( SwNodeIndex( GetNodes().GetEndOfAutotext() )); aPam.GetPoint()->nNode = *pSttNd->EndOfSectionNode(); - pDoc->_Copy( rPam, *aPam.GetPoint(), FALSE, bCopyAll, 0 ); // kopieren ohne Frames + // copy without Frames + pDoc->CopyImpl( rPam, *aPam.GetPoint(), false, bCopyAll, 0 ); aPam.GetPoint()->nNode = pDoc->GetNodes().GetEndOfAutotext(); aPam.SetMark(); @@ -752,7 +770,8 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const aPam.GetPoint()->nNode = *aPam.GetNode()->StartOfSectionNode(); pNode = pDoc->GetNodes().GoNext( &aPam.GetPoint()->nNode ); pNode->MakeStartIndex( &aPam.GetPoint()->nContent ); - pDoc->Move( aPam, rPos, DOC_MOVEDEFAULT ); // auf gewuenschte Position moven + // move to desired position + pDoc->MoveRange( aPam, rPos, DOC_MOVEDEFAULT ); pNode = aPam.GetCntntNode(); *aPam.GetPoint() = rPos; // Cursor umsetzen fuers Undo ! @@ -776,7 +795,7 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const } pDoc->SetModified(); - bRet = TRUE; + bRet = true; } pDoc->SetRedlineMode_intern( eOld ); @@ -795,42 +814,79 @@ bool SwDoc::Copy( SwPaM& rPam, SwPosition& rPos, bool bCopyAll ) const // Kopieren eines Bereiches im oder in ein anderes Dokument ! // Die Position darf nicht im Bereich liegen !! -BOOL lcl_MarksWholeNode(const SwPaM & rPam) +bool lcl_MarksWholeNode(const SwPaM & rPam) { - BOOL bResult = FALSE; - const SwPosition * pStt = rPam.Start(), * pEnd = rPam.End(); + bool bResult = false; + const SwPosition* pStt = rPam.Start(); + const SwPosition* pEnd = rPam.End(); if (NULL != pStt && NULL != pEnd) { - SwTxtNode * pSttNd = pStt->nNode.GetNode().GetTxtNode(); - SwTxtNode * pEndNd = pEnd->nNode.GetNode().GetTxtNode(); + const SwTxtNode* pSttNd = pStt->nNode.GetNode().GetTxtNode(); + const SwTxtNode* pEndNd = pEnd->nNode.GetNode().GetTxtNode(); if (NULL != pSttNd && NULL != pEndNd && pStt->nContent.GetIndex() == 0 && pEnd->nContent.GetIndex() == pEndNd->Len()) { - bResult = TRUE; + bResult = true; } } return bResult; } -BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, - BOOL bMakeNewFrms, bool bCopyAll, SwPaM* pCpyRange ) const +// --> OD 2009-08-25 #i86492# +bool lcl_ContainsOnlyParagraphsInList( const SwPaM& rPam ) +{ + bool bRet = false; + + const SwTxtNode* pTxtNd = rPam.Start()->nNode.GetNode().GetTxtNode(); + const SwTxtNode* pEndTxtNd = rPam.End()->nNode.GetNode().GetTxtNode(); + if ( pTxtNd && pTxtNd->IsInList() && + pEndTxtNd && pEndTxtNd->IsInList() ) + { + bRet = true; + SwNodeIndex aIdx(rPam.Start()->nNode); + + do + { + aIdx++; + pTxtNd = aIdx.GetNode().GetTxtNode(); + + if ( !pTxtNd || !pTxtNd->IsInList() ) + { + bRet = false; + break; + } + } while ( pTxtNd && pTxtNd != pEndTxtNd ); + } + + + return bRet; +} +// <-- + +bool SwDoc::CopyImpl( SwPaM& rPam, SwPosition& rPos, + const bool bMakeNewFrms, const bool bCopyAll, + SwPaM *const pCpyRange ) const { SwDoc* pDoc = rPos.nNode.GetNode().GetDoc(); - bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection(); + const bool bColumnSel = pDoc->IsClipBoard() && pDoc->IsColumnSelection(); + + SwPosition* pStt = rPam.Start(); + SwPosition* pEnd = rPam.End(); - SwPosition *pStt = rPam.Start(), *pEnd = rPam.End(); // kein Copy abfangen. if( !rPam.HasMark() || ( *pStt >= *pEnd && !bColumnSel ) || //JP 29.6.2001: 88963 - dont copy if inspos is in region of start to end //JP 15.11.2001: don't test inclusive the end, ever exclusive ( pDoc == this && *pStt <= rPos && rPos < *pEnd )) - return FALSE; + { + return false; + } - BOOL bEndEqualIns = pDoc == this && rPos == *pEnd; + const bool bEndEqualIns = pDoc == this && rPos == *pEnd; // falls Undo eingeschaltet, erzeuge das UndoCopy-Objekt SwUndoCpyDoc* pUndo = 0; @@ -858,43 +914,63 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, SwNodeRange aRg( pStt->nNode, pEnd->nNode ); SwNodeIndex aInsPos( rPos.nNode ); - BOOL bOneNode = pStt->nNode == pEnd->nNode; - SwTxtNode* pSttNd = pStt->nNode.GetNode().GetTxtNode(); - SwTxtNode* pEndNd = pEnd->nNode.GetNode().GetTxtNode(); - SwTxtNode* pDestNd = aInsPos.GetNode().GetTxtNode(); - BOOL bCopyCollFmt = !pDoc->IsInsOnlyTextGlossary() && ( - ( pDestNd && !pDestNd->GetTxt().Len() ) || - ( !bOneNode && !rPos.nContent.GetIndex() )); - BOOL bCopyBookmarks = TRUE; - BOOL bStartIsTxtNode = 0 != pSttNd; - - // --> OD 2008-03-18 #refactorlists# - String aDummy; - const SwNumRule * pNumRuleToPropagate = - pDoc->SearchNumRule(rPos, FALSE, FALSE, TRUE, 0, aDummy); + const bool bOneNode = pStt->nNode == pEnd->nNode; + SwTxtNode* pSttTxtNd = pStt->nNode.GetNode().GetTxtNode(); + SwTxtNode* pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode(); + SwTxtNode* pDestTxtNd = aInsPos.GetNode().GetTxtNode(); + bool bCopyCollFmt = !pDoc->IsInsOnlyTextGlossary() && + ( ( pDestTxtNd && !pDestTxtNd->GetTxt().Len() ) || + ( !bOneNode && !rPos.nContent.GetIndex() ) ); + bool bCopyBookmarks = true; + BOOL bStartIsTxtNode = 0 != pSttTxtNd; + + // --> OD 2009-08-25 #i86492# + // Correct the search for a previous list: + // First search for non-outline numbering list. Then search for non-outline + // bullet list. + // Keep also the <ListId> value for possible propagation. + String aListIdToPropagate; + const SwNumRule* pNumRuleToPropagate = + pDoc->SearchNumRule( rPos, false, true, false, 0, aListIdToPropagate, true ); + if ( !pNumRuleToPropagate ) + { + pNumRuleToPropagate = + pDoc->SearchNumRule( rPos, false, false, false, 0, aListIdToPropagate, true ); + } + // <-- + // --> OD 2009-08-25 #i86492# + // Do not propagate previous found list, if + // - destination is an empty paragraph which is not in a list and + // - source contains at least one paragraph which is not in a list + if ( pNumRuleToPropagate && + pDestTxtNd && !pDestTxtNd->GetTxt().Len() && !pDestTxtNd->IsInList() && + !lcl_ContainsOnlyParagraphsInList( rPam ) ) + { + pNumRuleToPropagate = 0; + } // <-- // Block, damit aus diesem gesprungen werden kann !! do { - if( pSttNd ) + if( pSttTxtNd ) { // den Anfang nicht komplett kopieren ? if( !bCopyCollFmt || bColumnSel || pStt->nContent.GetIndex() ) { SwIndex aDestIdx( rPos.nContent ); BOOL bCopyOk = FALSE; - if( !pDestNd ) + if( !pDestTxtNd ) { if( pStt->nContent.GetIndex() || bOneNode ) - pDestNd = pDoc->GetNodes().MakeTxtNode( aInsPos, + pDestTxtNd = pDoc->GetNodes().MakeTxtNode( aInsPos, pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD)); else { - pDestNd = (SwTxtNode*)pSttNd->MakeCopy( pDoc, aInsPos ); + pDestTxtNd = static_cast<SwTxtNode*>(pSttTxtNd->MakeCopy( pDoc, aInsPos )); bCopyOk = TRUE; } - aDestIdx.Assign( pDestNd, 0 ); - bCopyCollFmt = TRUE; + aDestIdx.Assign( pDestTxtNd, 0 ); + bCopyCollFmt = true; } else if( !bOneNode || bColumnSel ) { @@ -911,8 +987,8 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, aCpyPam.Move( fnMoveBackward, fnGoCntnt ); } - pDestNd = pDoc->GetNodes()[ aInsPos.GetIndex()-1 ]->GetTxtNode(); - aDestIdx.Assign( pDestNd, pDestNd->GetTxt().Len() ); + pDestTxtNd = pDoc->GetNodes()[ aInsPos.GetIndex()-1 ]->GetTxtNode(); + aDestIdx.Assign( pDestTxtNd, pDestTxtNd->GetTxt().Len() ); // korrigiere den Bereich wieder !! if( bEndEqualIns ) @@ -925,59 +1001,84 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, rPam.Exchange(); aRg.aEnd = pEnd->nNode; - pEndNd = pEnd->nNode.GetNode().GetTxtNode(); + pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode(); } else if( rPos == *pEnd ) // Wurde das Ende auch verschoben { pEnd->nNode--; - pEnd->nContent.Assign( pDestNd, nCntntEnd ); + pEnd->nContent.Assign( pDestTxtNd, nCntntEnd ); aRg.aEnd = pEnd->nNode; - pEndNd = pEnd->nNode.GetNode().GetTxtNode(); + pEndTxtNd = pEnd->nNode.GetNode().GetTxtNode(); } } - const SfxPoolItem * pItem = NULL; - const SfxItemSet * pAttrSet = pDestNd->GetpSwAttrSet(); - /* #107213#: Safe numrule item at destination. */ - int aState = SFX_ITEM_UNKNOWN; + // --> OD 2009-08-25 #i86492# + // Safe also <ListId> item of destination. + int aNumRuleState = SFX_ITEM_UNKNOWN; SwNumRuleItem aNumRuleItem; - - if (pAttrSet != NULL) + int aListIdState = SFX_ITEM_UNKNOWN; + SfxStringItem aListIdItem( RES_PARATR_LIST_ID, String() ); { - aState = - pAttrSet->GetItemState(RES_PARATR_NUMRULE, FALSE, &pItem); - - if (SFX_ITEM_SET == aState) - aNumRuleItem = *((SwNumRuleItem *) pItem); + const SfxItemSet * pAttrSet = pDestTxtNd->GetpSwAttrSet(); + if (pAttrSet != NULL) + { + const SfxPoolItem * pItem = NULL; + aNumRuleState = pAttrSet->GetItemState(RES_PARATR_NUMRULE, FALSE, &pItem); + if (SFX_ITEM_SET == aNumRuleState) + aNumRuleItem = *((SwNumRuleItem *) pItem); + + aListIdState = + pAttrSet->GetItemState(RES_PARATR_LIST_ID, FALSE, &pItem); + if (SFX_ITEM_SET == aListIdState) + { + aListIdItem.SetValue( static_cast<const SfxStringItem*>(pItem)->GetValue() ); + } + } } + // <-- /* #107213# */ if( !bCopyOk ) { - xub_StrLen nCpyLen = ( bOneNode ? pEnd->nContent.GetIndex() - : pSttNd->GetTxt().Len() ) - - pStt->nContent.GetIndex(); - pSttNd->Copy( pDestNd, aDestIdx, pStt->nContent, nCpyLen ); + const xub_StrLen nCpyLen = ( (bOneNode) + ? pEnd->nContent.GetIndex() + : pSttTxtNd->GetTxt().Len() ) + - pStt->nContent.GetIndex(); + pSttTxtNd->CopyText( pDestTxtNd, aDestIdx, + pStt->nContent, nCpyLen ); if( bEndEqualIns ) pEnd->nContent -= nCpyLen; } if( bOneNode ) { - // ist der DestinationNode leer, kopiere die Vorlage mit if( bCopyCollFmt ) { - pSttNd->CopyCollFmt( *pDestNd ); + pSttTxtNd->CopyCollFmt( *pDestTxtNd ); /* #107213# If only a part of one paragraph is copied restore the numrule at the destination. */ - if (! lcl_MarksWholeNode(rPam)) + // --> OD 2009-08-25 #i86492# + // restore also <ListId> item + if ( !lcl_MarksWholeNode(rPam) ) { - if (SFX_ITEM_SET == aState) - pDestNd->SetAttr(aNumRuleItem); + if (SFX_ITEM_SET == aNumRuleState) + { + pDestTxtNd->SetAttr(aNumRuleItem); + } + else + { + pDestTxtNd->ResetAttr(RES_PARATR_NUMRULE); + } + if (SFX_ITEM_SET == aListIdState) + { + pDestTxtNd->SetAttr(aListIdItem); + } else - pDestNd->ResetAttr(RES_PARATR_NUMRULE); + { + pDestTxtNd->ResetAttr(RES_PARATR_LIST_ID); + } } } @@ -987,13 +1088,13 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, aRg.aStart++; } } - else if( pDestNd ) + else if( pDestTxtNd ) { // Problems with insertion of table selections into "normal" text solved. // We have to set the correct PaM for Undo, if this PaM starts in a textnode, // the undo operation will try to merge this node after removing the table. // If we didn't split a textnode, the PaM should start at the inserted table node - if( rPos.nContent.GetIndex() == pDestNd->Len() ) + if( rPos.nContent.GetIndex() == pDestTxtNd->Len() ) { // Insertion at the last position of a textnode (empty or not) aInsPos++; // The table will be inserted behind the text node } @@ -1040,15 +1141,15 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, } } - pDestNd = aInsPos.GetNode().GetTxtNode(); - if( pEndNd ) + pDestTxtNd = aInsPos.GetNode().GetTxtNode(); + if( pEndTxtNd ) { SwIndex aDestIdx( rPos.nContent ); - if( !pDestNd ) + if( !pDestTxtNd ) { - pDestNd = pDoc->GetNodes().MakeTxtNode( aInsPos, + pDestTxtNd = pDoc->GetNodes().MakeTxtNode( aInsPos, pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD)); - aDestIdx.Assign( pDestNd, 0 ); + aDestIdx.Assign( pDestTxtNd, 0 ); aInsPos--; // #112756# #98130# if we have to insert an extra text node @@ -1060,42 +1161,66 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, bStartIsTxtNode = TRUE; } - const SfxPoolItem * pItem = NULL; - const SfxItemSet* pAttrSet = pDestNd->GetpSwAttrSet(); - /* #107213# Save numrule at destination */ - int aState = SFX_ITEM_UNKNOWN; + // --> OD 2009-08-25 #i86492# + // Safe also <ListId> item of destination. + int aNumRuleState = SFX_ITEM_UNKNOWN; SwNumRuleItem aNumRuleItem; - - if (pAttrSet != NULL) + int aListIdState = SFX_ITEM_UNKNOWN; + SfxStringItem aListIdItem( RES_PARATR_LIST_ID, String() ); { - aState = - pAttrSet->GetItemState(RES_PARATR_NUMRULE, FALSE, &pItem); + const SfxItemSet* pAttrSet = pDestTxtNd->GetpSwAttrSet(); + if (pAttrSet != NULL) + { + const SfxPoolItem * pItem = NULL; - if (SFX_ITEM_SET == aState) - aNumRuleItem = *((SwNumRuleItem *) pItem); + aNumRuleState = + pAttrSet->GetItemState(RES_PARATR_NUMRULE, FALSE, &pItem); + if (SFX_ITEM_SET == aNumRuleState) + aNumRuleItem = *((SwNumRuleItem *) pItem); + + aListIdState = + pAttrSet->GetItemState(RES_PARATR_LIST_ID, FALSE, &pItem); + if (SFX_ITEM_SET == aListIdState) + aListIdItem.SetValue( static_cast<const SfxStringItem*>(pItem)->GetValue() ); + } } + // <-- /* #107213# */ - BOOL bEmptyDestNd = 0 == pDestNd->GetTxt().Len(); - pEndNd->Copy( pDestNd, aDestIdx, SwIndex( pEndNd ), + const bool bEmptyDestNd = 0 == pDestTxtNd->GetTxt().Len(); + pEndTxtNd->CopyText( pDestTxtNd, aDestIdx, SwIndex( pEndTxtNd ), pEnd->nContent.GetIndex() ); // auch alle FormatVorlagen kopieren if( bCopyCollFmt && ( bOneNode || bEmptyDestNd )) { - pEndNd->CopyCollFmt( *pDestNd ); + pEndTxtNd->CopyCollFmt( *pDestTxtNd ); - if (bOneNode) + if ( bOneNode ) { /* #107213# If only a part of one paragraph is copied restore the numrule at the destination. */ - if ( ! lcl_MarksWholeNode(rPam)) + // --> OD 2009-08-25 #i86492# + // restore also <ListId> item + if ( !lcl_MarksWholeNode(rPam) ) { - if (SFX_ITEM_SET == aState) - pDestNd->SetAttr(aNumRuleItem); + if (SFX_ITEM_SET == aNumRuleState) + { + pDestTxtNd->SetAttr(aNumRuleItem); + } else - pDestNd->ResetAttr(RES_PARATR_NUMRULE); + { + pDestTxtNd->ResetAttr(RES_PARATR_NUMRULE); + } + if (SFX_ITEM_SET == aListIdState) + { + pDestTxtNd->SetAttr(aListIdItem); + } + else + { + pDestTxtNd->ResetAttr(RES_PARATR_LIST_ID); + } } } } @@ -1104,13 +1229,13 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, if( bCopyAll || aRg.aStart != aRg.aEnd ) { SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange ); - if( pSttNd && bCopyCollFmt && pDestNd->HasSwAttrSet() ) + if( pSttTxtNd && bCopyCollFmt && pDestTxtNd->HasSwAttrSet() ) { - aBrkSet.Put( *pDestNd->GetpSwAttrSet() ); + aBrkSet.Put( *pDestTxtNd->GetpSwAttrSet() ); if( SFX_ITEM_SET == aBrkSet.GetItemState( RES_BREAK, FALSE ) ) - pDestNd->ResetAttr( RES_BREAK ); + pDestTxtNd->ResetAttr( RES_BREAK ); if( SFX_ITEM_SET == aBrkSet.GetItemState( RES_PAGEDESC, FALSE ) ) - pDestNd->ResetAttr( RES_PAGEDESC ); + pDestTxtNd->ResetAttr( RES_PAGEDESC ); } if( aInsPos == pEnd->nNode ) @@ -1124,13 +1249,13 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, else CopyWithFlyInFly( aRg, pEnd->nContent.GetIndex(), aInsPos, bMakeNewFrms, FALSE ); - bCopyBookmarks = FALSE; + bCopyBookmarks = false; // harte Umbrueche wieder in den ersten Node setzen - if( aBrkSet.Count() && 0 != ( pDestNd = pDoc->GetNodes()[ + if( aBrkSet.Count() && 0 != ( pDestTxtNd = pDoc->GetNodes()[ aCpyPam.GetPoint()->nNode.GetIndex()+1 ]->GetTxtNode() ) ) { - pDestNd->SetAttr( aBrkSet ); + pDestTxtNd->SetAttr( aBrkSet ); } } } while( FALSE ); @@ -1169,19 +1294,25 @@ BOOL SwDoc::_Copy( SwPaM& rPam, SwPosition& rPos, *pCpyRange->GetMark() = *aCpyPam.GetMark(); } - if (pNumRuleToPropagate) - pDoc->ReplaceNumRule(aCpyPam, *pNumRuleToPropagate); + if ( pNumRuleToPropagate ) + { + // --> OD 2009-08-25 #i86492# + // use <SwDoc::SetNumRule(..)>, because it also handles the <ListId> +// pDoc->ReplaceNumRule(aCpyPam, *pNumRuleToPropagate); + pDoc->SetNumRule( aCpyPam, *pNumRuleToPropagate, false, + aListIdToPropagate, sal_True, true ); + } pDoc->SetRedlineMode_intern( eOld ); pDoc->SetModified(); - return TRUE; + return true; } // ----- Copy-Methode vom SwDoc - "kopiere Fly's in Fly's" ------ -void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, +void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, const SwNodeIndex& rInsPos, BOOL bMakeNewFrms, BOOL bDelRedlines, BOOL bCopyFlyAtFly ) const { @@ -1220,7 +1351,7 @@ void SwDoc::CopyWithFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndConte // Undo abschalten BOOL bUndo = pDest->DoesUndo(); pDest->DoUndo( FALSE ); - _CopyFlyInFly( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); + CopyFlyInFlyImpl( rRg, nEndContentIndex, aSavePos, bCopyFlyAtFly ); pDest->DoUndo( bUndo ); SwNodeRange aCpyRange( aSavePos, rInsPos ); @@ -1256,14 +1387,15 @@ void lcl_ChainFmts( SwFlyFrmFmt *pSrc, SwFlyFrmFmt *pDest ) } } -void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentIndex, const SwNodeIndex& rSttIdx, - BOOL bCopyFlyAtFly ) const +void SwDoc::CopyFlyInFlyImpl( const SwNodeRange& rRg, + const xub_StrLen nEndContentIndex, const SwNodeIndex& rStartIdx, + const bool bCopyFlyAtFly ) const { // Bug 22727: suche erst mal alle Flys zusammen, sortiere sie entsprechend // ihrer Ordnungsnummer und kopiere sie erst dann. Damit wird // die Ordnungsnummer (wird nur im DrawModel verwaltet) // beibehalten. - SwDoc* pDest = rSttIdx.GetNode().GetDoc(); + SwDoc *const pDest = rStartIdx.GetNode().GetDoc(); _ZSortFlys aArr; USHORT nArrLen = GetSpzFrmFmts()->Count(); USHORT n; @@ -1324,11 +1456,11 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI { if( bAtCntnt ) bAdd = nEndContentIndex > 0; - else + else bAdd = pAPos->nContent <= nEndContentIndex; } } - if( bAdd ) + if( bAdd ) aArr.Insert( _ZSortFly( pFmt, pAnchor, nArrLen + aArr.Count() )); } } @@ -1380,10 +1512,10 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI nAnchorTxtNdNumInRange = 1; } // Second, search corresponding text node in destination document - // by counting forward from start insert position <rSttIdx> the + // by counting forward from start insert position <rStartIdx> the // determined number of text nodes. - aIdx = rSttIdx; - SwNodeIndex aAnchorNdIdx( rSttIdx ); + aIdx = rStartIdx; + SwNodeIndex aAnchorNdIdx( rStartIdx ); const SwNode& aEndOfContentNd = aIdx.GetNode().GetNodes().GetEndOfContent(); while ( nAnchorTxtNdNumInRange > 0 && @@ -1403,7 +1535,7 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI // text node in the destination document. ASSERT( false, "<SwDoc::_CopyFlyInFly(..)> - found anchor node index isn't a text node" ); - aAnchorNdIdx = rSttIdx; + aAnchorNdIdx = rStartIdx; while ( !aAnchorNdIdx.GetNode().IsTxtNode() ) { ++aAnchorNdIdx; @@ -1415,7 +1547,7 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI else { long nOffset = pNewPos->nNode.GetIndex() - rRg.aStart.GetIndex(); - SwNodeIndex aIdx( rSttIdx, nOffset ); + SwNodeIndex aIdx( rStartIdx, nOffset ); pNewPos->nNode = aIdx; } // <-- @@ -1440,8 +1572,8 @@ void SwDoc::_CopyFlyInFly( const SwNodeRange& rRg, const xub_StrLen nEndContentI const SwStartNode* pSNd; if( rCntnt.GetCntntIdx() && 0 != ( pSNd = rCntnt.GetCntntIdx()->GetNode().GetStartNode() ) && - pSNd->GetIndex() < rSttIdx.GetIndex() && - rSttIdx.GetIndex() < pSNd->EndOfSectionIndex() ) + pSNd->GetIndex() < rStartIdx.GetIndex() && + rStartIdx.GetIndex() < pSNd->EndOfSectionIndex() ) { bMakeCpy = FALSE; aArr.Remove( n, 1 ); diff --git a/sw/source/core/docnode/ndnotxt.cxx b/sw/source/core/docnode/ndnotxt.cxx index b3e5fe72c1..4b94c1bf12 100644 --- a/sw/source/core/docnode/ndnotxt.cxx +++ b/sw/source/core/docnode/ndnotxt.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -48,6 +48,10 @@ #include <istyleaccess.hxx> #include <SwStyleNameMapper.hxx> +// --> OD 2009-07-13 #i73249# +#include <frmfmt.hxx> +// <-- + SwNoTxtNode::SwNoTxtNode( const SwNodeIndex & rWhere, const BYTE nNdType, SwGrfFmtColl *pGrfColl, @@ -250,19 +254,57 @@ Graphic SwNoTxtNode::GetGraphic() const return aRet; } +// --> OD 2009-07-14 #i73249# +void SwNoTxtNode::SetTitle( const String& rTitle, bool bBroadcast ) +{ + // Title attribute of <SdrObject> replaces own AlternateText attribute + SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(GetFlyFmt()); + ASSERT( pFlyFmt, + "<SwNoTxtNode::SetTitle(..)> - missing <SwFlyFrmFmt> instance" ); + if ( !pFlyFmt ) + { + return; + } -void SwNoTxtNode::SetAlternateText( const String& rTxt, sal_Bool bBroadcast ) + pFlyFmt->SetObjTitle( rTitle, bBroadcast ); +} + +const String SwNoTxtNode::GetTitle() const { - if( bBroadcast ) + const SwFlyFrmFmt* pFlyFmt = dynamic_cast<const SwFlyFrmFmt*>(GetFlyFmt()); + ASSERT( pFlyFmt, + "<SwNoTxtNode::GetTitle(..)> - missing <SwFlyFrmFmt> instance" ); + if ( !pFlyFmt ) { - SwStringMsgPoolItem aOld( RES_ALT_TEXT_CHANGED, aAlternateText ); - SwStringMsgPoolItem aNew( RES_ALT_TEXT_CHANGED, rTxt ); - aAlternateText = rTxt; - Modify( &aOld, &aNew ); + return aEmptyStr; } - else + + return pFlyFmt->GetObjTitle(); +} + +void SwNoTxtNode::SetDescription( const String& rDescription, bool bBroadcast ) +{ + SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(GetFlyFmt()); + ASSERT( pFlyFmt, + "<SwNoTxtNode::SetDescription(..)> - missing <SwFlyFrmFmt> instance" ); + if ( !pFlyFmt ) { - aAlternateText = rTxt; + return; } + + pFlyFmt->SetObjDescription( rDescription, bBroadcast ); } +const String SwNoTxtNode::GetDescription() const +{ + const SwFlyFrmFmt* pFlyFmt = dynamic_cast<const SwFlyFrmFmt*>(GetFlyFmt()); + ASSERT( pFlyFmt, + "<SwNoTxtNode::GetDescription(..)> - missing <SwFlyFrmFmt> instance" ); + if ( !pFlyFmt ) + { + return aEmptyStr; + } + + return pFlyFmt->GetObjDescription(); +} +// <-- diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index a6363a209b..5da8c44c3a 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -158,8 +158,8 @@ void lcl_CheckEmptyLayFrm( SwNodes& rNds, SwSection& rSect, } } -SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, - const SfxItemSet* pAttr, BOOL bUpdate ) +SwSection* SwDoc::InsertSwSection( const SwPaM& rRange, const SwSection& rNew, + const SfxItemSet* pAttr, bool bUpdate ) { const SwNode* pPrvNd = 0; USHORT nRegionRet = 0; @@ -178,10 +178,11 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, if( !pStt->nContent.GetIndex() && pEnd->nNode.GetNode().GetCntntNode()->Len() == pEnd->nContent.GetIndex() ) - - ::lcl_CheckEmptyLayFrm( GetNodes(), (SwSection&)rNew, + { + ::lcl_CheckEmptyLayFrm( GetNodes(), const_cast<SwSection&>(rNew), pStt->nNode.GetNode(), pEnd->nNode.GetNode() ); + } } SwUndoInsSection* pUndoInsSect = 0; @@ -193,9 +194,11 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, DoUndo( FALSE ); } - SwSectionFmt* pFmt = MakeSectionFmt( 0 ); - if( pAttr ) + SwSectionFmt* const pFmt = MakeSectionFmt( 0 ); + if ( pAttr ) + { pFmt->SetFmtAttr( *pAttr ); + } SwSectionNode* pNewSectNode = 0; @@ -222,16 +225,27 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, { if( pUndoInsSect ) { - SwTxtNode* pTNd; if( !( pPrvNd && 1 == nRegionRet ) && - pSttPos->nContent.GetIndex() && - 0 != ( pTNd = pSttPos->nNode.GetNode().GetTxtNode() )) - pUndoInsSect->SaveSplitNode( pTNd, TRUE ); - - if( !( pPrvNd && 2 == nRegionRet ) && - 0 != ( pTNd = pEndPos->nNode.GetNode().GetTxtNode() ) && - pTNd->GetTxt().Len() != pEndPos->nContent.GetIndex() ) - pUndoInsSect->SaveSplitNode( pTNd, FALSE ); + pSttPos->nContent.GetIndex() ) + { + SwTxtNode* const pTNd = + pSttPos->nNode.GetNode().GetTxtNode(); + if (pTNd) + { + pUndoInsSect->SaveSplitNode( pTNd, TRUE ); + } + } + + if ( !( pPrvNd && 2 == nRegionRet ) ) + { + SwTxtNode *const pTNd = + pEndPos->nNode.GetNode().GetTxtNode(); + if (pTNd && + (pTNd->GetTxt().Len() != pEndPos->nContent.GetIndex())) + { + pUndoInsSect->SaveSplitNode( pTNd, FALSE ); + } + } } const SwCntntNode* pCNd; @@ -241,7 +255,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, pSttPos->nContent.Assign( pSttPos->nNode.GetNode().GetCntntNode(), 0 ); } else if( pSttPos->nContent.GetIndex() ) + { SplitNode( *pSttPos, false ); + } if( pPrvNd && 2 == nRegionRet ) { @@ -293,7 +309,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, else { if( pUndoInsSect && pCNd->IsTxtNode() ) + { pUndoInsSect->SaveSplitNode( (SwTxtNode*)pCNd, TRUE ); + } SplitNode( *pPos, false ); pNewSectNode = GetNodes().InsertSection( pPos->nNode, *pFmt, rNew, 0, TRUE ); } @@ -309,9 +327,13 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, { SwPaM aPam( *pNewSectNode->EndOfSectionNode(), *pNewSectNode, 1 ); if( IsRedlineOn() ) + { AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true); + } else + { SplitRedline( aPam ); + } } // ist eine Condition gesetzt @@ -320,7 +342,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, // dann berechne bis zu dieser Position SwCalc aCalc( *this ); if( ! IsInReading() ) + { FldsToCalc( aCalc, pNewSectNode->GetIndex(), USHRT_MAX ); + } SwSection& rNewSect = pNewSectNode->GetSection(); rNewSect.SetCondHidden( aCalc.Calculate( rNewSect.GetCondition() ).GetBool() ); } @@ -335,7 +359,9 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, ( FTNEND_ATTXTEND_OWNNUMSEQ == ( nVal = ((SwFmtEndAtTxtEnd&) pAttr->Get( RES_END_AT_TXTEND )).GetValue() ) || FTNEND_ATTXTEND_OWNNUMANDFMT == nVal )) + { bUpdateFtn = TRUE; + } } if( pUndoInsSect ) @@ -346,10 +372,14 @@ SwSection* SwDoc::Insert( const SwPaM& rRange, const SwSection& rNew, } if( rNew.IsLinkType() ) + { pNewSectNode->GetSection().CreateLink( bUpdate ? CREATE_UPDATE : CREATE_CONNECT ); + } if( bUpdateFtn ) + { GetFtnIdxs().UpdateFtn( SwNodeIndex( *pNewSectNode )); + } SetModified(); return &pNewSectNode->GetSection(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 35d7d4e858..8f01680de5 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -1034,7 +1034,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& rRange, sal_Unicode cCh, nChPos + 1 ); // Trennzeichen loeschen und SuchString korrigieren - pTxtNd->Erase( aCntPos.nContent, 1 ); + pTxtNd->EraseText( aCntPos.nContent, 1 ); pTxt = pTxtNd->GetTxt().GetBuffer(); nChPos = 0; --nChPos, --pTxt; // for the ++ in the for loop !!! @@ -1551,7 +1551,8 @@ BOOL lcl_DelBox( const SwTableBox*& rpBox, void* pPara ) { // Inserting the seperator SwIndex aCntIdx( pDelPara->pLastNd, pDelPara->pLastNd->GetTxt().Len()); - pDelPara->pLastNd->Insert( pDelPara->cCh, aCntIdx ); + pDelPara->pLastNd->InsertText( pDelPara->cCh, aCntIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( pDelPara->pUndo ) pDelPara->pUndo->AddBoxPos( *pDoc, nNdIdx, aDelRg.aEnd.GetIndex(), aCntIdx.GetIndex() ); diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index b97eeda74d..69a6f68d90 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1249,13 +1249,13 @@ BOOL SwCntntNode::GoNext(SwIndex * pIdx, USHORT nMode ) const { const SwTxtNode& rTNd = *GetTxtNode(); xub_StrLen nPos = pIdx->GetIndex(); - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { sal_Int32 nDone = 0; sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ? CharacterIteratorMode::SKIPCELL : CharacterIteratorMode::SKIPCONTROLCHARACTER; - nPos = (xub_StrLen)pBreakIt->xBreak->nextCharacters( rTNd.GetTxt(), nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->nextCharacters( rTNd.GetTxt(), nPos, pBreakIt->GetLocale( rTNd.GetLang( nPos ) ), nItrMode, 1, nDone ); @@ -1297,13 +1297,13 @@ BOOL SwCntntNode::GoPrevious(SwIndex * pIdx, USHORT nMode ) const { const SwTxtNode& rTNd = *GetTxtNode(); xub_StrLen nPos = pIdx->GetIndex(); - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { sal_Int32 nDone = 0; sal_uInt16 nItrMode = ( CRSR_SKIP_CELLS & nMode ) ? CharacterIteratorMode::SKIPCELL : CharacterIteratorMode::SKIPCONTROLCHARACTER; - nPos = (xub_StrLen)pBreakIt->xBreak->previousCharacters( rTNd.GetTxt(), nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->previousCharacters( rTNd.GetTxt(), nPos, pBreakIt->GetLocale( rTNd.GetLang( nPos ) ), nItrMode, 1, nDone ); diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 4cefc2dd5a..dd5a91b2ba 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -47,6 +47,7 @@ #include <ddefld.hxx> #include <swddetbl.hxx> #include <frame.hxx> +#include <fmtmeta.hxx> #include <docsh.hxx> #include <svtools/smplhint.hxx> @@ -288,7 +289,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, SwTxtNode* pTxtNd = pCNd->GetTxtNode(); if( pTxtNd ) { - const SwpHints* pHts = pTxtNd->GetpSwpHints(); + SwpHints * const pHts = pTxtNd->GetpSwpHints(); // setze die OultineNodes im neuen Nodes-Array //if( bInsOutlineIdx && NO_NUMBERING != //#outline level,removed by zhaojianwei // pTxtNd->GetTxtColl()->GetOutlineLevel() ) @@ -306,16 +307,17 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, // Sonderbehandlung fuer die Felder! if( pHts && pHts->Count() ) { - const SwTxtAttr* pAttr; int bToUndo = &pDestDoc->GetNodes() != &rNds; for( USHORT i = pHts->Count(); i; ) { USHORT nDelMsg = 0; - switch( (pAttr = (*pHts)[ --i ])->Which() ) + SwTxtAttr * const pAttr = pHts->GetTextHint( --i ); + switch ( pAttr->Which() ) { case RES_TXTATR_FIELD: { - SwTxtFld* pTxtFld = (SwTxtFld*)pAttr; + SwTxtFld* pTxtFld = + static_cast<SwTxtFld*>(pAttr); rNds.GetDoc()->InsDelFldInFldLst( !bToUndo, *pTxtFld ); const SwFieldType* pTyp = pTxtFld->GetFld().GetFld()->GetTyp(); @@ -345,6 +347,15 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, ULONG nSz, case RES_TXTATR_REFMARK: nDelMsg = RES_REFMARK_DELETED; break; + + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + static_cast<SwFmtMeta&>(pAttr->GetAttr()) + .NotifyRemoval(); + break; + + default: + break; } if( nDelMsg && bToUndo ) { @@ -450,7 +461,7 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, ( (pAktNode = &aIndex.GetNode())->GetStartNode() && !pAktNode->StartOfSectionIndex() )) return FALSE; - + SwNodeRange aRg( aRange ); // "einfache" StartNodes oder EndNodes ueberspringen @@ -912,7 +923,7 @@ BOOL SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, ASSERT( FALSE, "was ist das fuer ein Node??" ); break; } - + if( nInsPos ) // kopiere den Rest { // der Rest muesste so stimmen @@ -1762,10 +1773,10 @@ USHORT HighestLevel( SwNodes & rNodes, const SwNodeRange & rRange ) |* Letzte Aenderung JP 09.07.92 |* *************************************************************************/ -void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, - BOOL ) +void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) { - SwPosition *pStt = (SwPosition*)rPam.Start(), *pEnd = (SwPosition*)rPam.End(); + SwPosition * const pStt = rPam.Start(); + SwPosition * const pEnd = rPam.End(); if( !rPam.HasMark() || *pStt >= *pEnd ) return; @@ -1775,10 +1786,9 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, SwNodeIndex aEndIdx( pEnd->nNode ); SwNodeIndex aSttIdx( pStt->nNode ); - SwTxtNode* pSrcNd = (*this)[ aSttIdx ]->GetTxtNode(); + SwTxtNode* const pSrcNd = (*this)[ aSttIdx ]->GetTxtNode(); SwTxtNode* pDestNd = rNodes[ rPos.nNode ]->GetTxtNode(); BOOL bSplitDestNd = TRUE; - BOOL bSttTxtNd = 0 != pSrcNd; BOOL bCopyCollFmt = pDestNd && !pDestNd->GetTxt().Len(); if( pSrcNd ) @@ -1792,67 +1802,74 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, rPos.nContent.Assign( pDestNd, 0 ); bCopyCollFmt = TRUE; } -/*!NOSPLIT bSplitDestNd = !bSplitNd && - ( pDestNd->Len() > rPos.nContent.GetIndex() || - !aEndIdx.GetNode().IsTxtNode() ); -*/ -// ASSERT( bSplitNd, "Move mit bSplitNode = FALSE" ); bSplitDestNd = pDestNd->Len() > rPos.nContent.GetIndex() || pEnd->nNode.GetNode().IsTxtNode(); // verschiebe jetzt noch den Inhalt in den neuen Node BOOL bOneNd = pStt->nNode == pEnd->nNode; - xub_StrLen nLen = ( bOneNd ? pEnd->nContent.GetIndex() : pSrcNd->Len() ) - - pStt->nContent.GetIndex(); + const xub_StrLen nLen = + ( (bOneNd) ? pEnd->nContent.GetIndex() : pSrcNd->Len() ) + - pStt->nContent.GetIndex(); if( !pEnd->nNode.GetNode().IsCntntNode() ) { bOneNd = TRUE; - ULONG nSttNdIdx = pStt->nNode.GetIndex() + 1, - nEndNdIdx = pEnd->nNode.GetIndex(); + ULONG nSttNdIdx = pStt->nNode.GetIndex() + 1; + const ULONG nEndNdIdx = pEnd->nNode.GetIndex(); for( ; nSttNdIdx < nEndNdIdx; ++nSttNdIdx ) + { if( (*this)[ nSttNdIdx ]->IsCntntNode() ) { bOneNd = FALSE; break; } + } } // das kopieren / setzen der Vorlagen darf erst nach // dem Splitten erfolgen -//!NOSPLIT if( !bOneNd && ( bSplitNd || bSplitDestNd )) if( !bOneNd && bSplitDestNd ) { if( !rPos.nContent.GetIndex() ) + { bCopyCollFmt = TRUE; + } if( rNodes.IsDocNodes() ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); pInsDoc->SplitNode( rPos, false ); pInsDoc->DoUndo( bIsUndo ); } else + { pDestNd->SplitCntntNode( rPos ); + } if( rPos.nNode == aEndIdx ) + { aEndIdx--; + } bSplitDestNd = TRUE; pDestNd = rNodes[ rPos.nNode.GetIndex() - 1 ]->GetTxtNode(); if( nLen ) - pSrcNd->Cut( pDestNd, SwIndex( pDestNd, pDestNd->Len()), + { + pSrcNd->CutText( pDestNd, SwIndex( pDestNd, pDestNd->Len()), pStt->nContent, nLen ); + } + } + else if ( nLen ) + { + pSrcNd->CutText( pDestNd, rPos.nContent, pStt->nContent, nLen ); } - else if( nLen ) - pSrcNd->Cut( pDestNd, rPos.nContent, pStt->nContent, nLen ); if( bCopyCollFmt ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); pSrcNd->CopyCollFmt( *pDestNd ); pInsDoc->DoUndo( bIsUndo ); bCopyCollFmt = FALSE; @@ -1865,7 +1882,8 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, // wird aufgehoben ! pEnd->nContent = pStt->nContent; rPam.DeleteMark(); - GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); + GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, + rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); return; } @@ -1875,106 +1893,117 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, { if( rPos.nContent.GetIndex() ) { -//!NOSPLIT if( !bSplitNd && rPos.nContent.GetIndex() == pDestNd->Len() ) if( rPos.nContent.GetIndex() == pDestNd->Len() ) + { rPos.nNode++; + } else if( rPos.nContent.GetIndex() ) { // falls im EndNode gesplittet wird, dann muss der EndIdx // korrigiert werden !! - BOOL bCorrEnde = aEndIdx == rPos.nNode; + const bool bCorrEnd = aEndIdx == rPos.nNode; // es wird kein Text an den TextNode angehaengt, also splitte ihn if( rNodes.IsDocNodes() ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); pInsDoc->SplitNode( rPos, false ); pInsDoc->DoUndo( bIsUndo ); } else + { pDestNd->SplitCntntNode( rPos ); + } pDestNd = rPos.nNode.GetNode().GetTxtNode(); - if( bCorrEnde ) + if ( bCorrEnd ) + { aEndIdx--; + } } } // am Ende steht noch ein leerer Text Node herum. bSplitDestNd = TRUE; } - pSrcNd = (*this)[ aEndIdx ]->GetTxtNode(); - if( pSrcNd ) + SwTxtNode* const pEndSrcNd = (*this)[ aEndIdx ]->GetTxtNode(); + if ( pEndSrcNd ) { -// if( pEnd->nContent.GetIndex() ? TRUE : aEndIdx != pStt->nNode ) { // am Bereichsende entsteht ein neuer TextNode if( !bSplitDestNd ) { if( rPos.nNode < rNodes.GetEndOfContent().GetIndex() ) + { rPos.nNode++; + } - pDestNd = rNodes.MakeTxtNode( rPos.nNode, pSrcNd->GetTxtColl() ); + pDestNd = + rNodes.MakeTxtNode( rPos.nNode, pEndSrcNd->GetTxtColl() ); rPos.nNode--; rPos.nContent.Assign( pDestNd, 0 ); } else + { pDestNd = rNodes[ rPos.nNode ]->GetTxtNode(); + } if( pDestNd && pEnd->nContent.GetIndex() ) { // verschiebe jetzt noch den Inhalt in den neuen Node - SwIndex aIdx( pSrcNd, 0 ); - pSrcNd->Cut( pDestNd, rPos.nContent, aIdx, + SwIndex aIdx( pEndSrcNd, 0 ); + pEndSrcNd->CutText( pDestNd, rPos.nContent, aIdx, pEnd->nContent.GetIndex()); } if( bCopyCollFmt ) { - SwDoc* pInsDoc = pDestNd->GetDoc(); - BOOL bIsUndo = pInsDoc->DoesUndo(); - pInsDoc->DoUndo( FALSE ); - pSrcNd->CopyCollFmt( *pDestNd ); + SwDoc* const pInsDoc = pDestNd->GetDoc(); + const bool bIsUndo = pInsDoc->DoesUndo(); + pInsDoc->DoUndo( false ); + pEndSrcNd->CopyCollFmt( *pDestNd ); pInsDoc->DoUndo( bIsUndo ); } } } else { - if( bSttTxtNd && aEndIdx.GetNode().IsCntntNode() ) + if ( pSrcNd && aEndIdx.GetNode().IsCntntNode() ) + { aEndIdx++; -//!NOSPLIT + } if( !bSplitDestNd ) { rPos.nNode++; rPos.nContent.Assign( rPos.nNode.GetNode().GetCntntNode(), 0 ); } -//!NOSPLIT } if( aEndIdx != aSttIdx ) { // verschiebe jetzt die Nodes in das NodesArary - SwNodeIndex aPrvIdx( rPos.nNode, -1 ); - ULONG nSttDiff = aSttIdx.GetIndex() - pStt->nNode.GetIndex(); + const ULONG nSttDiff = aSttIdx.GetIndex() - pStt->nNode.GetIndex(); SwNodeRange aRg( aSttIdx, aEndIdx ); _MoveNodes( aRg, rNodes, rPos.nNode ); // falls ins gleiche Nodes-Array verschoben wurde, stehen die // Indizies jetzt auch an der neuen Position !!!! // (also alles wieder umsetzen) if( &rNodes == this ) + { pStt->nNode = aRg.aEnd.GetIndex() - nSttDiff; + } } // falls der Start-Node verschoben wurde, in dem der Cursor stand, so // muss der Content im akt. Content angemeldet werden !!! - if( &pStt->nNode.GetNode() == &GetEndOfContent() && - !GoPrevious( &pStt->nNode )) + if ( &pStt->nNode.GetNode() == &GetEndOfContent() ) { - ASSERT( FALSE, "Move() - kein ContentNode mehr vorhanden" ); + const bool bSuccess = GoPrevious( &pStt->nNode ); + ASSERT( bSuccess, "Move() - no ContentNode here" ); + (void) bSuccess; } pStt->nContent.Assign( (*this)[ pStt->nNode ]->GetCntntNode(), pStt->nContent.GetIndex() ); @@ -1983,7 +2012,8 @@ void SwNodes::Move( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes, // wird aufgehoben ! *pEnd = *pStt; rPam.DeleteMark(); - GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); + GetDoc()->GetDocShell()->Broadcast( SwFmtFldHint( 0, + rNodes.IsDocNodes() ? SWFMTFLD_INSERTED : SWFMTFLD_REMOVED ) ); } diff --git a/sw/source/core/docnode/section.cxx b/sw/source/core/docnode/section.cxx index a10833f03b..23dffa13ac 100644 --- a/sw/source/core/docnode/section.cxx +++ b/sw/source/core/docnode/section.cxx @@ -1414,7 +1414,10 @@ void SwIntrnlSectRefLink::DataChanged( const String& rMimeType, if( pSrcDoc != pDoc || pCpyPam->Start()->nNode > rInsPos || rInsPos >= pCpyPam->End()->nNode ) - pSrcDoc->Copy( *pCpyPam, *pPam->GetPoint(), false ); + { + pSrcDoc->CopyRange( *pCpyPam, *pPam->GetPoint(), + false ); + } delete pCpyPam; } if( pCpyRg && pSrcDoc == pDoc && diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index 6712f04080..93f83256a9 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -1653,7 +1653,12 @@ void SwDrawContact::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) { ASSERT( maAnchoredDrawObj.DrawObj(), "SwDrawContact::Modify: no draw object here?" ); if ( maAnchoredDrawObj.DrawObj() ) - maAnchoredDrawObj.DrawObj()->getShapePropertyChangeNotifier().notifyPropertyChange( ::svx::eTextShapeAnchorType ); + { + // --> OD 2009-07-10 #i102752# + // assure that a ShapePropertyChangeNotifier exists + maAnchoredDrawObj.DrawObj()->notifyShapePropertyChange( ::svx::eTextShapeAnchorType ); + // <-- + } } } } diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx index ede1df3978..29b3968c34 100644 --- a/sw/source/core/edit/acorrect.cxx +++ b/sw/source/core/edit/acorrect.cxx @@ -42,7 +42,6 @@ #include <fmtinfmt.hxx> #include <txtatr.hxx> #include <txtinet.hxx> -#include <fmthbsh.hxx> #include <editsh.hxx> #include <doc.hxx> #include <pam.hxx> @@ -125,7 +124,9 @@ void SwAutoCorrDoc::DeleteSel( SwPaM& rDelPam ) pDoc->DeleteAndJoin( rDelPam ); } else - pDoc->Delete( rDelPam ); + { + pDoc->DeleteRange( rDelPam ); + } } BOOL SwAutoCorrDoc::Delete( xub_StrLen nStt, xub_StrLen nEnd ) @@ -143,7 +144,7 @@ BOOL SwAutoCorrDoc::Delete( xub_StrLen nStt, xub_StrLen nEnd ) BOOL SwAutoCorrDoc::Insert( xub_StrLen nPos, const String& rTxt ) { SwPaM aPam( rCrsr.GetPoint()->nNode.GetNode(), nPos ); - rEditSh.GetDoc()->Insert( aPam, rTxt, true ); + rEditSh.GetDoc()->InsertString( aPam, rTxt ); if( !bUndoIdInitialized ) { bUndoIdInitialized = true; @@ -163,23 +164,27 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) pPam->GetPoint()->nContent = nPos; } - BOOL bChg = TRUE; - SwTxtNode* pNd = pPam->GetNode()->GetTxtNode(); - if( pNd ) + SwTxtNode * const pNd = pPam->GetNode()->GetTxtNode(); + if ( !pNd ) { - // TextAttribute ohne Ende duerfen nie ersetzt werden! - sal_Unicode cChr; - for( xub_StrLen n = 0, nLen = rTxt.Len(); n < nLen; ++n ) - if( ( CH_TXTATR_BREAKWORD == (cChr = pNd->GetTxt(). - GetChar( n + nPos )) || CH_TXTATR_INWORD == cChr ) && - pNd->GetTxtAttr( n + nPos ) ) - { - bChg = FALSE; - break; - } + return FALSE; + } + + // text attributes with dummy characters must not be replaced! + bool bDoReplace = true; + xub_StrLen const nLen = rTxt.Len(); + for ( xub_StrLen n = 0; n < nLen; ++n ) + { + sal_Unicode const Char = pNd->GetTxt().GetChar( n + nPos ); + if ( ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char ) + && pNd->GetTxtAttrForCharAt( n + nPos ) ) + { + bDoReplace = false; + break; + } } - if( bChg ) + if ( bDoReplace ) { SwDoc* pDoc = rEditSh.GetDoc(); @@ -190,7 +195,9 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) if( pDoc->IsAutoFmtRedline() ) { if( nPos == pNd->GetTxt().Len() ) // am Ende erfolgt ein Insert - pDoc->Insert( *pPam, rTxt, true ); + { + pDoc->InsertString( *pPam, rTxt ); + } else { _PaMIntoCrsrShellRing aTmp( rEditSh, rCrsr, *pPam ); @@ -198,7 +205,7 @@ BOOL SwAutoCorrDoc::Replace( xub_StrLen nPos, const String& rTxt ) pPam->SetMark(); pPam->GetPoint()->nContent = Min( pNd->GetTxt().Len(), xub_StrLen( nPos + rTxt.Len() )); - pDoc->Replace( *pPam, rTxt, FALSE ); + pDoc->ReplaceRange( *pPam, rTxt, false ); pPam->Exchange(); pPam->DeleteMark(); } @@ -333,7 +340,7 @@ BOOL SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPos, '.' != pFnd->GetLong().GetChar( pFnd->GetLong().Len() - 1 ) ) { // replace the selection - pDoc->Replace( aPam, pFnd->GetLong(), false); + pDoc->ReplaceRange( aPam, pFnd->GetLong(), false); bRet = TRUE; } } @@ -374,7 +381,7 @@ BOOL SwAutoCorrDoc::ChgAutoCorrWord( xub_StrLen & rSttPos, xub_StrLen nEndPos, SwDontExpandItem aExpItem; aExpItem.SaveDontExpandItems( *aPam.GetPoint() ); - pAutoDoc->Copy( aCpyPam, *aPam.GetPoint(), false ); + pAutoDoc->CopyRange( aCpyPam, *aPam.GetPoint(), false ); aExpItem.RestoreDontExpandItems( *aPam.GetPoint() ); diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index 9622075cd1..114ae919a1 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -44,9 +44,7 @@ #include <svx/lrspitem.hxx> #include <svx/brkitem.hxx> #include <svx/adjitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/fontitem.hxx> #include <svx/langitem.hxx> #include <svx/cscoitem.hxx> @@ -74,7 +72,6 @@ #include <acorrect.hxx> #include <shellres.hxx> #include <section.hxx> -#include <fmthbsh.hxx> #include <frmatr.hxx> #include <charatr.hxx> #include <mdiexp.hxx> @@ -645,7 +642,7 @@ BOOL SwAutoFormat::DoUnderline() aBox.SetLine( &aLine, BOX_LINE_BOTTOM ); aBox.SetDistance( 42 ); // ~0,75 mm aSet.Put(aBox); - pDoc->Insert( aDelPam, aSet, 0 ); + pDoc->InsertItemSet( aDelPam, aSet, 0 ); aDelPam.DeleteMark(); } @@ -1300,7 +1297,9 @@ void SwAutoFormat::DelMoreLinesBlanks( BOOL bWithLineBreaks ) BOOL bHasBlnks = HasSelBlanks( *pNxt ); DeleteSel( *pNxt ); if( !bHasBlnks ) - pDoc->Insert( *pNxt, ' ' ); + { + pDoc->InsertString( *pNxt, sal_Unicode(' ') ); + } } if( pNxt == &aDelPam ) @@ -1357,7 +1356,9 @@ void SwAutoFormat::BuildIndent() IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() )) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; pNxtNd = GetNextNode(); @@ -1396,7 +1397,9 @@ void SwAutoFormat::BuildTextIndent() bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; pNxtNd = GetNextNode(); @@ -1430,7 +1433,9 @@ void SwAutoFormat::BuildText() bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; const SwTxtNode* pCurrNode = pNxtNd; @@ -1705,7 +1710,7 @@ void SwAutoFormat::BuildEnum( USHORT nLvl, USHORT nDigitLevel ) String sChgStr( '\t' ); if( bChgBullet ) sChgStr.Insert( aFlags.cBullet, 0 ); - pDoc->Insert( aDelPam, sChgStr, true ); + pDoc->InsertString( aDelPam, sChgStr ); SfxItemSet aSet( pDoc->GetAttrPool(), aTxtNodeSetRange ); if( bChgBullet ) @@ -1745,7 +1750,9 @@ void SwAutoFormat::BuildEnum( USHORT nLvl, USHORT nDigitLevel ) bBreak = !IsFastFullLine( *pNxtNd ) || IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; const SwTxtNode* pCurrNode = pNxtNd; @@ -1813,7 +1820,9 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) aDelPam.GetMark()->nContent = nSpaceStt; DeleteSel( aDelPam ); if( bInsTab ) - pDoc->Insert( aDelPam, '\t' ); + { + pDoc->InsertString( aDelPam, sal_Unicode('\t') ); + } } } @@ -1831,7 +1840,9 @@ void SwAutoFormat::BuildNegIndent( SwTwips nSpaces ) IsBlanksInString( *pNxtNd ) || IsSentenceAtEnd( *pNxtNd ); if( DeleteAktNxtPara( pNxtNd->GetTxt() ) ) - pDoc->Insert( aDelPam, ' ' ); + { + pDoc->InsertString( aDelPam, sal_Unicode(' ') ); + } if( bBreak ) break; pNxtNd = GetNextNode(); @@ -1942,7 +1953,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) sReplace.Erase( 1 ); bSetHardBlank = TRUE; } - pDoc->Replace( aDelPam, sReplace, FALSE ); + pDoc->ReplaceRange( aDelPam, sReplace, false ); if( aFlags.bWithRedlining ) { @@ -1957,7 +1968,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) aDelPam.DeleteMark(); if( bSetHardBlank ) { - pDoc->Insert( aDelPam, CHAR_HARDBLANK ); + pDoc->InsertString( aDelPam, CHAR_HARDBLANK ); ++nPos; } } @@ -1994,7 +2005,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) aDelPam.SetMark(); aDelPam.GetPoint()->nContent = nPos+1; - pDoc->Replace( aDelPam, sReplace, FALSE ); + pDoc->ReplaceRange( aDelPam, sReplace, false ); if( aFlags.bWithRedlining ) { @@ -2012,7 +2023,7 @@ void SwAutoFormat::AutoCorrect( xub_StrLen nPos ) if( bSetHardBlank ) { aDelPam.GetPoint()->nContent = nPos; - pDoc->Insert( aDelPam, CHAR_HARDBLANK ); + pDoc->InsertString( aDelPam, CHAR_HARDBLANK ); aDelPam.GetPoint()->nContent = ++nPos; } } diff --git a/sw/source/core/edit/edatmisc.cxx b/sw/source/core/edit/edatmisc.cxx index 1913da57a9..0c8952ff81 100644 --- a/sw/source/core/edit/edatmisc.cxx +++ b/sw/source/core/edit/edatmisc.cxx @@ -141,7 +141,9 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, USHORT nFlags ) FOREACHPAM_START(this) if( PCURCRSR->HasMark() && ( bIsTblMode || *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() )) - GetDoc()->Insert(*PCURCRSR, rHint, nFlags ); + { + GetDoc()->InsertPoolItem(*PCURCRSR, rHint, nFlags ); + } FOREACHPAM_END() GetDoc()->EndUndo(UNDO_INSATTR, NULL); @@ -150,7 +152,7 @@ void SwEditShell::SetAttr( const SfxPoolItem& rHint, USHORT nFlags ) { if( !HasSelection() ) UpdateAttr(); - GetDoc()->Insert( *pCrsr, rHint, nFlags ); + GetDoc()->InsertPoolItem( *pCrsr, rHint, nFlags ); } EndAllAction(); } @@ -169,7 +171,9 @@ void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags ) FOREACHPAM_START(this) if( PCURCRSR->HasMark() && ( bIsTblMode || *PCURCRSR->GetPoint() != *PCURCRSR->GetMark() )) - GetDoc()->Insert(*PCURCRSR, rSet, nFlags ); + { + GetDoc()->InsertItemSet(*PCURCRSR, rSet, nFlags ); + } FOREACHPAM_END() GetDoc()->EndUndo(UNDO_INSATTR, NULL); @@ -178,7 +182,7 @@ void SwEditShell::SetAttr( const SfxItemSet& rSet, USHORT nFlags ) { if( !HasSelection() ) UpdateAttr(); - GetDoc()->Insert( *pCrsr, rSet, nFlags ); + GetDoc()->InsertItemSet( *pCrsr, rSet, nFlags ); } EndAllAction(); } diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 259cb34f1c..f12766f6ae 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -452,17 +452,21 @@ BOOL lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, } // and fields - const SwTxtAttr* pTFld; - if( CH_TXTATR_BREAKWORD == rTxt.GetChar( nPos ) && - 0 != ( pTFld = rTNd.GetTxtAttr( nPos ) ) ) + if ( CH_TXTATR_BREAKWORD == rTxt.GetChar( nPos ) ) { - bRet = TRUE; // all other then fields can be - // defined as weak-script ? - const SwField* pFld; - if( RES_TXTATR_FIELD == pTFld->Which() && - 0 != (pFld = pTFld->GetFld().GetFld() ) ) + const SwTxtAttr* const pAttr = rTNd.GetTxtAttrForCharAt( nPos ); + if (pAttr) { - sExp += pFld->Expand(); + bRet = TRUE; // all other than fields can be + // defined as weak-script ? + if ( RES_TXTATR_FIELD == pAttr->Which() ) + { + const SwField* const pFld = pAttr->GetFld().GetFld(); + if (pFld) + { + sExp += pFld->Expand(); + } + } } } @@ -474,14 +478,14 @@ BOOL lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, { USHORT nScript; for( n = 0; n < nEnd; n = (xub_StrLen) - pBreakIt->xBreak->endOfScript( sExp, n, nScript )) + pBreakIt->GetBreakIter()->endOfScript( sExp, n, nScript )) { - nScript = pBreakIt->xBreak->getScriptType( sExp, n ); + nScript = pBreakIt->GetBreakIter()->getScriptType( sExp, n ); rScrpt |= lcl_SetScriptFlags( nScript ); } } else - rScrpt |= lcl_SetScriptFlags( pBreakIt->xBreak-> + rScrpt |= lcl_SetScriptFlags( pBreakIt->GetBreakIter()-> getScriptType( sExp, nEnd-1 )); } @@ -493,7 +497,7 @@ BOOL lcl_IsNoEndTxtAttrAtPos( const SwTxtNode& rTNd, xub_StrLen nPos, USHORT SwEditShell::GetScriptType() const { USHORT nRet = 0; - if( pBreakIt->xBreak.is() ) + //if( pBreakIt->GetBreakIter().is() ) { FOREACHPAM_START(this) @@ -525,7 +529,7 @@ USHORT SwEditShell::GetScriptType() const { nScript = pScriptInfo ? pScriptInfo->ScriptType( nPos ) : - pBreakIt->xBreak->getScriptType( pTNd->GetTxt(), nPos ); + pBreakIt->GetBreakIter()->getScriptType( pTNd->GetTxt(), nPos ); } else nScript = GetI18NScriptTypeOfLanguage( (USHORT)GetAppLanguage() ); @@ -534,7 +538,7 @@ USHORT SwEditShell::GetScriptType() const nRet |= lcl_SetScriptFlags( nScript ); } } - else + else if ( pBreakIt->GetBreakIter().is() ) { ULONG nEndIdx = pEnd->nNode.GetIndex(); SwNodeIndex aIdx( pStt->nNode ); @@ -563,7 +567,7 @@ USHORT SwEditShell::GetScriptType() const { nScript = pScriptInfo ? pScriptInfo->ScriptType( nChg ) : - pBreakIt->xBreak->getScriptType( + pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ); if( !lcl_IsNoEndTxtAttrAtPos( *pTNd, nChg, nRet, TRUE, @@ -578,7 +582,7 @@ USHORT SwEditShell::GetScriptType() const nChg = pScriptInfo ? pScriptInfo->NextScriptChg( nChg ) : - (xub_StrLen)pBreakIt->xBreak->endOfScript( + (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rTxt, nChg, nScript ); nFldPos = rTxt.Search( diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index f3942ff6c3..823dee6054 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -249,7 +249,8 @@ long SwEditShell::Copy( SwEditShell* pDestShell ) bFirstMove = FALSE; } - if( !GetDoc()->Copy( *PCURCRSR, *pPos, false )) + const bool bSuccess( GetDoc()->CopyRange( *PCURCRSR, *pPos, false ) ); + if (!bSuccess) continue; SwPaM aInsertPaM(*pPos, SwPosition(aSttNdIdx)); @@ -319,7 +320,8 @@ BOOL SwEditShell::Replace( const String& rNewStr, BOOL bRegExpRplc ) FOREACHPAM_START(this) if( PCURCRSR->HasMark() && *PCURCRSR->GetMark() != *PCURCRSR->GetPoint() ) { - bRet = GetDoc()->Replace( *PCURCRSR, rNewStr, bRegExpRplc ) || bRet; + bRet = GetDoc()->ReplaceRange( *PCURCRSR, rNewStr, bRegExpRplc ) + || bRet; SaveTblBoxCntnt( PCURCRSR->GetPoint() ); } FOREACHPAM_END() diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx index 310def985d..82e915cdfe 100644 --- a/sw/source/core/edit/edfld.cxx +++ b/sw/source/core/edit/edfld.cxx @@ -232,8 +232,8 @@ void SwEditShell::FieldToText( SwFieldType* pType ) String aEntry( pFmtFld->GetFld()->Expand() ); pPaM->SetMark(); pPaM->Move( fnMoveForward ); - GetDoc()->Delete( *pPaM ); - GetDoc()->Insert( *pPaM, aEntry, true ); + GetDoc()->DeleteRange( *pPaM ); + GetDoc()->InsertString( *pPaM, aEntry ); } else if( bDDEFld ) { @@ -258,17 +258,20 @@ void SwEditShell::FieldToText( SwFieldType* pType ) |* Quelle: vgl. SwEditShell::Insert( String ) |* *************************************************************************/ -void SwEditShell::Insert(SwField& rFld) +void SwEditShell::Insert2(SwField& rFld, const bool bForceExpandHints) { SET_CURR_SHELL( this ); StartAllAction(); SwFmtFld aFld( rFld ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + FOREACHPAM_START(this) // fuer jeden PaM - if( !GetDoc()->Insert( *PCURCRSR, aFld, 0 ) ) - { - ASSERT( FALSE, "Doc->Insert(Field) failed") - } + bool bSuccess(GetDoc()->InsertPoolItem(*PCURCRSR, aFld, nInsertFlags)); + ASSERT( bSuccess, "Doc->Insert(Field) failed"); + (void) bSuccess; FOREACHPAM_END() // fuer jeden PaM EndAllAction(); @@ -285,11 +288,11 @@ void SwEditShell::Insert(SwField& rFld) inline SwTxtFld *GetDocTxtFld( const SwPosition* pPos ) { - SwTxtNode *pNode = pPos->nNode.GetNode().GetTxtNode(); - if( pNode ) - return pNode->GetTxtFld( pPos->nContent ); - else - return 0; + SwTxtNode * const pNode = pPos->nNode.GetNode().GetTxtNode(); + return (pNode) + ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt( + pPos->nContent.GetIndex(), RES_TXTATR_FIELD )) + : 0; } SwField* SwEditShell::GetCurFld() const diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx index d26acf1f53..5e87946247 100644 --- a/sw/source/core/edit/edglbldc.cxx +++ b/sw/source/core/edit/edglbldc.cxx @@ -343,7 +343,10 @@ BOOL SwEditShell::MoveGlobalDocContent( const SwGlblDocContents& rArr , else aInsPos = pMyDoc->GetNodes().GetEndOfContent(); - BOOL bRet = pMyDoc->Move( aRg, aInsPos, IDocumentContentOperations::DOC_MOVEALLFLYS ); + bool bRet = pMyDoc->MoveNodeRange( aRg, aInsPos, + static_cast<IDocumentContentOperations::SwMoveFlags>( + IDocumentContentOperations::DOC_MOVEALLFLYS + | IDocumentContentOperations::DOC_CREATEUNDOOBJ )); EndAllAction(); return bRet; diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 0196844442..41879086d0 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -168,7 +168,7 @@ USHORT SwEditShell::SaveGlossaryDoc( SwTextBlocks& rBlock, aStt = pGDoc->GetNodes().GetEndOfExtras(); pCntntNd = pGDoc->GetNodes().GoNext( &aStt ); SwPosition aInsPos( aStt, SwIndex( pCntntNd )); - pMyDoc->Copy( aCpyPam, aInsPos, false ); + pMyDoc->CopyRange( aCpyPam, aInsPos, false ); nRet = rBlock.PutDoc(); } @@ -250,13 +250,16 @@ BOOL SwEditShell::_CopySelToDoc( SwDoc* pInsDoc, SwNodeIndex* pSttNd ) { PCURCRSR->SetMark(); PCURCRSR->Move( fnMoveForward, fnGoCntnt ); - bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet; + bRet = GetDoc()->CopyRange( *PCURCRSR, aPos, false ) + || bRet; PCURCRSR->Exchange(); PCURCRSR->DeleteMark(); } } else - bRet = GetDoc()->Copy( *PCURCRSR, aPos, false ) || bRet; + { + bRet = GetDoc()->CopyRange( *PCURCRSR, aPos, false ) || bRet; + } FOREACHPAM_END() } diff --git a/sw/source/core/edit/editsh.cxx b/sw/source/core/edit/editsh.cxx index 9bed73cfda..8e79603719 100644 --- a/sw/source/core/edit/editsh.cxx +++ b/sw/source/core/edit/editsh.cxx @@ -86,10 +86,9 @@ void SwEditShell::Insert( sal_Unicode c, BOOL bOnlyCurrCrsr ) StartAllAction(); FOREACHPAM_START(this) - if( !GetDoc()->Insert(*PCURCRSR, c) ) - { - ASSERT( FALSE, "Doc->Insert(c) failed." ) - } + const bool bSuccess = GetDoc()->InsertString(*PCURCRSR, c); + ASSERT( bSuccess, "Doc->Insert() failed." ); + (void) bSuccess; SaveTblBoxCntnt( PCURCRSR->GetPoint() ); if( bOnlyCurrCrsr ) @@ -106,17 +105,24 @@ void SwEditShell::Insert( sal_Unicode c, BOOL bOnlyCurrCrsr ) ******************************************************************************/ -void SwEditShell::Insert(const String &rStr) +void SwEditShell::Insert2(const String &rStr, const bool bForceExpandHints ) { StartAllAction(); { + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + SwPaM *_pStartCrsr = getShellCrsr( true ), *__pStartCrsr = _pStartCrsr; do { //OPT: GetSystemCharSet - if( !GetDoc()->Insert( *_pStartCrsr, rStr, true ) ) - { - ASSERT( FALSE, "Doc->Insert(Str) failed." ) - } + const bool bSuccess = + GetDoc()->InsertString(*_pStartCrsr, rStr, nInsertFlags); + ASSERT( bSuccess, "Doc->Insert() failed." ); + (void) bSuccess; SaveTblBoxCntnt( _pStartCrsr->GetPoint() ); @@ -383,27 +389,27 @@ void SwEditShell::GetGrfNms( String* pGrfName, String* pFltName, // alternativen Text abfragen/setzen -const String& SwEditShell::GetAlternateText() const -{ - SwPaM* pCrsr = GetCrsr(); - const SwNoTxtNode* pNd; - if( !pCrsr->HasMark() && 0 != ( pNd = pCrsr->GetNode()->GetNoTxtNode()) ) - return pNd->GetAlternateText(); +//const String& SwEditShell::GetAlternateText() const +//{ +// SwPaM* pCrsr = GetCrsr(); +// const SwNoTxtNode* pNd; +// if( !pCrsr->HasMark() && 0 != ( pNd = pCrsr->GetNode()->GetNoTxtNode()) ) +// return pNd->GetAlternateText(); - return aEmptyStr; -} +// return aEmptyStr; +//} -void SwEditShell::SetAlternateText( const String& rTxt ) -{ - SwPaM* pCrsr = GetCrsr(); - SwNoTxtNode* pNd; - if( !pCrsr->HasMark() && 0 != ( pNd = pCrsr->GetNode()->GetNoTxtNode()) ) - { - pNd->SetAlternateText( rTxt, sal_True ); - GetDoc()->SetModified(); - } -} +//void SwEditShell::SetAlternateText( const String& rTxt ) +//{ +// SwPaM* pCrsr = GetCrsr(); +// SwNoTxtNode* pNd; +// if( !pCrsr->HasMark() && 0 != ( pNd = pCrsr->GetNode()->GetNoTxtNode()) ) +// { +// pNd->SetAlternateText( rTxt, sal_True ); +// GetDoc()->SetModified(); +// } +//} const PolyPolygon *SwEditShell::GetGraphicPolygon() const @@ -778,7 +784,7 @@ BOOL SwEditShell::InsertURL( const SwFmtINetFmt& rFmt, const String& rStr, BOOL if( bInsTxt ) { - Insert( rStr ); + Insert2( rStr ); SetMark(); ExtendSelection( FALSE, rStr.Len() ); } diff --git a/sw/source/core/edit/edlingu.cxx b/sw/source/core/edit/edlingu.cxx index 052937fb5e..c10370979a 100644 --- a/sw/source/core/edit/edlingu.cxx +++ b/sw/source/core/edit/edlingu.cxx @@ -49,7 +49,6 @@ #include <svx/langitem.hxx> #include <svx/SpellPortions.hxx> #include <svx/scripttypeitem.hxx> -#include <fmthbsh.hxx> #include <charatr.hxx> #include <editsh.hxx> #include <doc.hxx> @@ -70,6 +69,8 @@ #include <redline.hxx> // SwRedline #include <docary.hxx> // SwRedlineTbl #include <docsh.hxx> +#include <txatbase.hxx> + using namespace ::svx; using namespace ::com::sun::star; @@ -682,7 +683,7 @@ void SwHyphIter::InsertSoftHyph( const xub_StrLen nHyphPos ) DelSoftHyph( *pCrsr ); pSttPos->nContent += nHyphPos; SwPaM aRg( *pSttPos ); - pDoc->Insert( aRg, CHAR_SOFTHYPHEN ); + pDoc->InsertString( aRg, CHAR_SOFTHYPHEN ); // Durch das Einfuegen des SoftHyphs ist ein Zeichen hinzugekommen //JP 18.07.95: warum, ist doch ein SwIndex, dieser wird doch mitverschoben !! // pSttPos->nContent++; @@ -1342,7 +1343,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, // ... and apply language if necessary if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage) SetAttr( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId), nLangWhichId ); - pDoc->Insert(*pCrsr, aCurrentNewPortion->sText, true); + pDoc->InsertString(*pCrsr, aCurrentNewPortion->sText); } else if(aCurrentNewPortion->eLanguage != aCurrentOldPortion->eLanguage) { @@ -1388,7 +1389,7 @@ void SwEditShell::ApplyChangedSentence(const ::svx::SpellPortions& rNewPortions, if(rLang.GetLanguage() != aCurrentNewPortion->eLanguage) SetAttr( SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId) ); //insert the new string - pDoc->Insert(*pCrsr, aCurrentNewPortion->sText, true); + pDoc->InsertString(*pCrsr, aCurrentNewPortion->sText); //set the cursor to the end of the inserted string *pCrsr->Start() = *pCrsr->End(); @@ -1819,20 +1820,18 @@ void SwSpellIter::AddPortion(uno::Reference< XSpellAlternatives > xAlt, xub_Unicode cChar = pTxtNode->GetTxt().GetChar( pCrsr->GetMark()->nContent.GetIndex() ); if( CH_TXTATR_BREAKWORD == cChar || CH_TXTATR_INWORD == cChar) { - const SwTxtAttr* pTxtAttr = pTxtNode->GetTxtAttr( - pCrsr->GetMark()->nContent.GetIndex(), RES_TXTATR_FIELD ); - bField = 0 != pTxtAttr; - if(!bField) - { - const SwTxtAttr* pTmpTxtAttr = pTxtNode->GetTxtAttr( - pCrsr->GetMark()->nContent.GetIndex(), RES_TXTATR_FTN ); - bField = 0 != pTmpTxtAttr; - } - if(!bField) + const SwTxtAttr* pTxtAttr = pTxtNode->GetTxtAttrForCharAt( + pCrsr->GetMark()->nContent.GetIndex() ); + const USHORT nWhich = pTxtAttr + ? pTxtAttr->Which() + : static_cast<USHORT>(RES_TXTATR_END); + switch (nWhich) { - const SwTxtAttr* pTmpTxtAttr = pTxtNode->GetTxtAttr( - pCrsr->GetMark()->nContent.GetIndex(), RES_TXTATR_FLYCNT ); - bField = 0 != pTmpTxtAttr; + case RES_TXTATR_FIELD: + case RES_TXTATR_FTN: + case RES_TXTATR_FLYCNT: + bField = true; + break; } } diff --git a/sw/source/core/edit/ednumber.cxx b/sw/source/core/edit/ednumber.cxx index ba06e528b4..b9d4523edb 100644 --- a/sw/source/core/edit/ednumber.cxx +++ b/sw/source/core/edit/ednumber.cxx @@ -565,7 +565,7 @@ BOOL SwEditShell::IsProtectedOutlinePara() const // BYTE nTmpLvl = GetRealLevel( pTmpNd->GetTxtNode()-> // GetTxtColl()->GetOutlineLevel() ); // int nTmpLvl = pTmpNd->GetTxtNode()->GetOutlineLevel();//#outline level,zhaojianwei - int nTmpLvl = pTmpNd->GetTxtNode()->GetAttrOutlineLevel(); + int nTmpLvl = pTmpNd->GetTxtNode()->GetAttrOutlineLevel(); // ASSERT( nTmpLvl >= 0 && nTmpLvl < MAXLEVEL, ASSERT( nTmpLvl >= 0 && nTmpLvl <= MAXLEVEL, //<-end,zhaojianwei "<SwEditShell::IsProtectedOutlinePara()>" ); @@ -825,9 +825,9 @@ USHORT SwEditShell::GetNodeNumStart() const -----------------------------------------------------------------------*/ // --> OD 2008-03-18 #refactorlists# -const SwNumRule * SwEditShell::SearchNumRule( BOOL bForward, - BOOL bNum, - BOOL bOutline, +const SwNumRule * SwEditShell::SearchNumRule( const bool bForward, + const bool bNum, + const bool bOutline, int nNonEmptyAllowed, String& sListId ) { diff --git a/sw/source/core/edit/edsect.cxx b/sw/source/core/edit/edsect.cxx index d4d6f2bb61..ad36b898fd 100644 --- a/sw/source/core/edit/edsect.cxx +++ b/sw/source/core/edit/edsect.cxx @@ -56,8 +56,8 @@ const SwSection* SwEditShell::InsertSection( const SwSection& rNew, GetDoc()->StartUndo( UNDO_INSSECTION, NULL ); FOREACHPAM_START(this) - const SwSection* pNew = GetDoc()->Insert( *PCURCRSR, - rNew, pAttr ); + const SwSection* const pNew = + GetDoc()->InsertSwSection( *PCURCRSR, rNew, pAttr ); if( !pRet ) pRet = pNew; FOREACHPAM_END() @@ -72,8 +72,10 @@ const SwSection* SwEditShell::InsertSection( const SwSection& rNew, BOOL SwEditShell::IsInsRegionAvailable() const { - SwPaM* pCrsr; - if( IsTableMode() || ( pCrsr = GetCrsr() )->GetNext() != pCrsr ) + if( IsTableMode() ) + return FALSE; + SwPaM* pCrsr = GetCrsr(); + if( pCrsr->GetNext() != pCrsr ) return FALSE; if( pCrsr->HasMark() ) return 0 != GetDoc()->IsInsRegionAvailable( *pCrsr ); diff --git a/sw/source/core/edit/edtox.cxx b/sw/source/core/edit/edtox.cxx index 0b72c6fcf1..c4b81facd8 100644 --- a/sw/source/core/edit/edtox.cxx +++ b/sw/source/core/edit/edtox.cxx @@ -82,10 +82,13 @@ void SwEditShell::Insert(const SwTOXMark& rMark) if( bInsAtPos ) { SwPaM aTmp( *pStt ); - GetDoc()->Insert( aTmp, rMark, 0 ); + GetDoc()->InsertPoolItem( aTmp, rMark, 0 ); } else if( *pEnd != *pStt ) - GetDoc()->Insert( *PCURCRSR, rMark, nsSetAttrMode::SETATTR_DONTEXPAND ); + { + GetDoc()->InsertPoolItem( *PCURCRSR, rMark, + nsSetAttrMode::SETATTR_DONTEXPAND ); + } FOREACHPAM_END() EndAllAction(); @@ -98,7 +101,7 @@ void SwEditShell::DeleteTOXMark( SwTOXMark* pMark ) SET_CURR_SHELL( this ); StartAllAction(); - pDoc->Delete( pMark ); + pDoc->DeleteTOXMark( pMark ); EndAllAction(); } diff --git a/sw/source/core/edit/edws.cxx b/sw/source/core/edit/edws.cxx index 0e6fbb1926..90dc9a70db 100644 --- a/sw/source/core/edit/edws.cxx +++ b/sw/source/core/edit/edws.cxx @@ -189,13 +189,21 @@ sal_uInt16 SwEditShell::GetCntType() const sal_Bool SwEditShell::HasOtherCnt() const { + if ( GetDoc()->GetSpzFrmFmts()->Count() ) + return sal_True; + const SwNodes &rNds = GetDoc()->GetNodes(); const SwNode *pNd; - return GetDoc()->GetSpzFrmFmts()->Count() || - 1 != (( pNd = &rNds.GetEndOfInserts() )->GetIndex() - - pNd->StartOfSectionIndex() ) || - 1 != (( pNd = &rNds.GetEndOfAutotext() )->GetIndex() - - pNd->StartOfSectionIndex() ); + + pNd = &rNds.GetEndOfInserts(); + if ( 1 != (pNd->GetIndex() - pNd->StartOfSectionIndex()) ) + return sal_True; + + pNd = &rNds.GetEndOfAutotext(); + if ( 1 != (pNd->GetIndex() - pNd->StartOfSectionIndex()) ) + return sal_True; + + return sal_False; } /****************************************************************************** diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx index 41e671ca65..a62957faa5 100644 --- a/sw/source/core/fields/cellfml.cxx +++ b/sw/source/core/fields/cellfml.cxx @@ -159,13 +159,13 @@ double SwTableBox::GetValue( SwTblCalcPara& rCalcPara ) const // beginnt an erster Position ein "RechenFeld", dann erfrage den Wert // von diesem - sal_Unicode cChr; - if( nSttPos < rTxt.Len() && - ( CH_TXTATR_BREAKWORD == ( cChr = rTxt.GetChar(nSttPos)) || - CH_TXTATR_INWORD == cChr )) + sal_Unicode const Char = rTxt.GetChar(nSttPos); + if ( nSttPos < rTxt.Len() && + ( CH_TXTATR_BREAKWORD == Char || CH_TXTATR_INWORD == Char ) ) { SwIndex aIdx( pTxtNd, nSttPos ); - SwTxtFld* pTxtFld = pTxtNd->GetTxtFld( aIdx ); + SwTxtFld * const pTxtFld = static_cast<SwTxtFld*>( + pTxtNd->GetTxtAttrForCharAt(aIdx.GetIndex(), RES_TXTATR_FIELD)); if( !pTxtFld ) break; diff --git a/sw/source/core/fields/ddetbl.cxx b/sw/source/core/fields/ddetbl.cxx index 10d78c6188..ba496601c6 100644 --- a/sw/source/core/fields/ddetbl.cxx +++ b/sw/source/core/fields/ddetbl.cxx @@ -131,8 +131,8 @@ void SwDDETable::ChangeContent() SwTxtNode* pTxtNode = aNdIdx.GetNode().GetTxtNode(); ASSERT( pTxtNode, "Kein Node" ); SwIndex aCntIdx( pTxtNode, 0 ); - pTxtNode->Erase( aCntIdx ); - pTxtNode->Insert( aLine.GetToken( i, '\t' ), aCntIdx ); + pTxtNode->EraseText( aCntIdx ); + pTxtNode->InsertText( aLine.GetToken( i, '\t' ), aCntIdx ); SwTableBoxFmt* pBoxFmt = (SwTableBoxFmt*)pBox->GetFrmFmt(); pBoxFmt->LockModify(); diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx index 21cb381b4a..d5204f1c1d 100644 --- a/sw/source/core/fields/docufld.cxx +++ b/sw/source/core/fields/docufld.cxx @@ -66,6 +66,7 @@ #endif #include <svtools/urihelper.hxx> #include <svtools/useroptions.hxx> +#include <svtools/syslocale.hxx> #include <tools/time.hxx> #include <tools/datetime.hxx> @@ -931,10 +932,11 @@ SwFieldType* SwDocInfoFieldType::Copy() const } void lcl_GetLocalDataWrapper( ULONG nLang, - LocaleDataWrapper **ppAppLocalData, - LocaleDataWrapper **ppLocalData ) + const LocaleDataWrapper **ppAppLocalData, + const LocaleDataWrapper **ppLocalData ) { - *ppAppLocalData = &GetAppLocaleData(); + SvtSysLocale aLocale; + *ppAppLocalData = &aLocale.GetLocaleData(); *ppLocalData = *ppAppLocalData; if( nLang != SvxLocaleToLanguage( (*ppLocalData)->getLocale() ) ) *ppLocalData = new LocaleDataWrapper( @@ -949,7 +951,7 @@ String SwDocInfoFieldType::Expand( sal_uInt16 nSub, sal_uInt32 nFormat, sal_uInt16 nLang, const String& rName ) const { String aStr; - LocaleDataWrapper *pAppLocalData = 0, *pLocalData = 0; + const LocaleDataWrapper *pAppLocalData = 0, *pLocalData = 0; SwDocShell *pDocShell(GetDoc()->GetDocShell()); DBG_ASSERT(pDocShell, "no SwDocShell"); if (!pDocShell) { return aStr; } diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index cf9f61dfd6..930394256f 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -611,7 +611,7 @@ SwFieldType* SwValueField::ChgTyp( SwFieldType* pNewType ) sal_uInt32 SwValueField::GetSystemFormat(SvNumberFormatter* pFormatter, sal_uInt32 nFmt) { const SvNumberformat* pEntry = pFormatter->GetEntry(nFmt); - USHORT nLng = SvxLocaleToLanguage( GetAppLocaleData().getLocale() ); + USHORT nLng = SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() ); if (pEntry && nLng != pEntry->GetLanguage()) { diff --git a/sw/source/core/fields/postithelper.cxx b/sw/source/core/fields/postithelper.cxx index de3fc1f8a9..9a4542b628 100644 --- a/sw/source/core/fields/postithelper.cxx +++ b/sw/source/core/fields/postithelper.cxx @@ -64,8 +64,9 @@ SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLa if( !pTxtFrm->IsFollow() ) { pTxtFrm = ((SwTxtFrm*)pTxtFrm)->GetFrmAtPos( rPos ); - SwPageFrm *pPage = pTxtFrm ? pTxtFrm->FindPageFrm() : 0; - if( pPage ) + SwPageFrm *pPage = pTxtFrm ? pTxtFrm->FindPageFrm() : 0; + // #i103490# + if ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() ) { SwLayoutInfo aInfo; pTxtFrm->GetCharRect( aInfo.mPosition, rPos, 0 ); diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx index 2f2c6c4a26..7204947d1a 100644 --- a/sw/source/core/fields/reffld.cxx +++ b/sw/source/core/fields/reffld.cxx @@ -331,8 +331,8 @@ void SwGetRefField::UpdateField( const SwTxtFld* pFldTxtAttr ) case REF_ONLYCAPTION: { - const SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttr( nStt, - RES_TXTATR_FIELD ); + const SwTxtAttr* const pTxtAttr = + pTxtNd->GetTxtAttrForCharAt(nStt, RES_TXTATR_FIELD); if( pTxtAttr ) nStt = SwGetExpField::GetReferenceTextPos( pTxtAttr->GetFld(), *pDoc ); diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx index bc2467e74c..bc66235cde 100644 --- a/sw/source/core/frmedt/fecopy.cxx +++ b/sw/source/core/frmedt/fecopy.cxx @@ -34,13 +34,7 @@ #include <hintids.hxx> -#ifdef WIN -#define NEEDED_BY_FESHVIEW -#endif - -#ifndef _GRAPH_HXX #include <vcl/graph.hxx> -#endif #include <sot/formats.hxx> #include <sot/storage.hxx> #include <svtools/pathoptions.hxx> @@ -58,9 +52,7 @@ #include <svx/svdogrp.hxx> #include <svx/xoutbmp.hxx> #include <svx/svdoole2.hxx> -#ifndef _FM_FMMODEL_HXX #include <svx/fmmodel.hxx> -#endif #include <svx/unomodel.hxx> // --> OD 2005-08-03 #i50824# #include <svx/svditer.hxx> @@ -93,9 +85,7 @@ #include <dview.hxx> #include <dcontact.hxx> #include <dflyobj.hxx> -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <pagedesc.hxx> #include <mvsave.hxx> #include <vcl/virdev.hxx> @@ -145,7 +135,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) // benutzen. if( pNewClpTxt ) { - pTxtNd->Insert( *pNewClpTxt, SwIndex( pTxtNd ) ); + pTxtNd->InsertText( *pNewClpTxt, SwIndex( pTxtNd ) ); return TRUE; // das wars. } @@ -198,7 +188,7 @@ BOOL SwFEShell::Copy( SwDoc* pClpDoc, const String* pNewClpTxt ) if( pTxtFly ) { ((SwFmtFlyCnt&)pTxtFly->GetFlyCnt()).SetFlyFmt( 0 ); - pTxtNd->Erase( rIdx, 1 ); + pTxtNd->EraseText( rIdx, 1 ); } } bRet = TRUE; @@ -840,7 +830,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) { SwNodeIndex aIndexBefore(rInsPos.nNode); aIndexBefore--; - pClpDoc->Copy( rCopy, rInsPos, false ); + pClpDoc->CopyRange( rCopy, rInsPos, false ); { aIndexBefore++; SwPaM aPaM(SwPosition(aIndexBefore, 0), @@ -1069,7 +1059,7 @@ BOOL SwFEShell::Paste( SwDoc* pClpDoc, BOOL bIncludingPageFrames ) aIndexBefore--; - pClpDoc->Copy( aCpyPam, rInsPos, false ); + pClpDoc->CopyRange( aCpyPam, rInsPos, false ); { aIndexBefore++; diff --git a/sw/source/core/frmedt/fedesc.cxx b/sw/source/core/frmedt/fedesc.cxx index e464536308..1e304cca24 100644 --- a/sw/source/core/frmedt/fedesc.cxx +++ b/sw/source/core/frmedt/fedesc.cxx @@ -127,7 +127,7 @@ void SwFEShell::ChgCurPageDesc( const SwPageDesc& rDesc ) else { SwPaM aPaM( *((SwCntntFrm*)pFlow)->GetNode() ); - GetDoc()->Insert( aPaM, aNew, 0 ); + GetDoc()->InsertPoolItem( aPaM, aNew, 0 ); } EndAllActionAndCall(); } diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx index a1dc1d4de2..640a49f13d 100644 --- a/sw/source/core/frmedt/fefly1.cxx +++ b/sw/source/core/frmedt/fefly1.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -2068,3 +2068,99 @@ void SwFEShell::GetConnectableFrmFmts(SwFrmFmt & rFmt, EndAction(); } + +// --> OD 2009-07-13 #i73249# +const String SwFEShell::GetObjTitle() const +{ + String aTitle; + + if ( Imp()->HasDrawView() ) + { + const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList(); + if ( pMrkList->GetMarkCount() == 1 ) + { + const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj(); + const SwFrmFmt* pFmt = FindFrmFmt( pObj ); + if ( pFmt->Which() == RES_FLYFRMFMT ) + { + aTitle = dynamic_cast<const SwFlyFrmFmt*>(pFmt)->GetObjTitle(); + } + else + { + aTitle = pObj->GetTitle(); + } + } + } + + return aTitle; +} + +void SwFEShell::SetObjTitle( const String& rTitle ) +{ + if ( Imp()->HasDrawView() ) + { + const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList(); + if ( pMrkList->GetMarkCount() == 1 ) + { + SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj(); + SwFrmFmt* pFmt = FindFrmFmt( pObj ); + if ( pFmt->Which() == RES_FLYFRMFMT ) + { + GetDoc()->SetFlyFrmTitle( *(dynamic_cast<SwFlyFrmFmt*>(pFmt)), + rTitle ); + } + else + { + pObj->SetTitle( rTitle ); + } + } + } +} + +const String SwFEShell::GetObjDescription() const +{ + String aDescription; + + if ( Imp()->HasDrawView() ) + { + const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList(); + if ( pMrkList->GetMarkCount() == 1 ) + { + const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj(); + const SwFrmFmt* pFmt = FindFrmFmt( pObj ); + if ( pFmt->Which() == RES_FLYFRMFMT ) + { + aDescription = dynamic_cast<const SwFlyFrmFmt*>(pFmt)->GetObjDescription(); + } + else + { + aDescription = pObj->GetDescription(); + } + } + } + + return aDescription; +} + +void SwFEShell::SetObjDescription( const String& rDescription ) +{ + if ( Imp()->HasDrawView() ) + { + const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList(); + if ( pMrkList->GetMarkCount() == 1 ) + { + SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj(); + SwFrmFmt* pFmt = FindFrmFmt( pObj ); + if ( pFmt->Which() == RES_FLYFRMFMT ) + { + GetDoc()->SetFlyFrmDescription( *(dynamic_cast<SwFlyFrmFmt*>(pFmt)), + rDescription ); + } + else + { + pObj->SetDescription( rDescription ); + } + } + } +} +// <-- diff --git a/sw/source/core/frmedt/feshview.cxx b/sw/source/core/frmedt/feshview.cxx index 72f9ff0796..e8c849cee0 100644 --- a/sw/source/core/frmedt/feshview.cxx +++ b/sw/source/core/frmedt/feshview.cxx @@ -34,7 +34,6 @@ #include "hintids.hxx" #ifdef WIN -#define NEEDED_BY_FESHVIEW #define _FESHVIEW_ONLY_INLINE_NEEDED #endif @@ -1874,7 +1873,8 @@ BOOL SwFEShell::ImpEndCreate() { ASSERT( aAnch.GetAnchorId() == FLY_IN_CNTNT, "wrong AnchorType" ); SwTxtNode *pNd = aAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); - pNd->InsertItem( SwFmtFlyCnt( pFmt ), + SwFmtFlyCnt aFmt( pFmt ); + pNd->InsertItem(aFmt, aAnch.GetCntntAnchor()->nContent.GetIndex(), 0 ); SwFmtVertOrient aVertical( pFmt->GetVertOrient() ); aVertical.SetVertOrient( text::VertOrientation::LINE_CENTER ); diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx index 2140311c3c..4485ba99f6 100644 --- a/sw/source/core/frmedt/fews.cxx +++ b/sw/source/core/frmedt/fews.cxx @@ -411,7 +411,9 @@ void lcl_SetAPageOffset( USHORT nOffset, SwPageFrm* pPage, SwFEShell* pThis ) if ( pFrm->IsInTab() ) pThis->GetDoc()->SetAttr( aDesc, *pFrm->FindTabFrm()->GetFmt() ); else - pThis->GetDoc()->Insert( *pThis->GetCrsr(), aDesc, 0 ); + { + pThis->GetDoc()->InsertPoolItem( *pThis->GetCrsr(), aDesc, 0 ); + } pThis->EndAllAction(); } diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx index 4719448b3e..26eed5bdf8 100644 --- a/sw/source/core/frmedt/tblsel.cxx +++ b/sw/source/core/frmedt/tblsel.cxx @@ -1462,7 +1462,10 @@ void GetMergeSel( const SwPaM& rPam, SwSelBoxes& rBoxes, if( pUndo ) pUndo->MoveBoxCntnt( pDoc, aRg, rInsPosNd ); else - pDoc->Move( aRg, rInsPosNd, IDocumentContentOperations::DOC_MOVEDEFAULT ); + { + pDoc->MoveNodeRange( aRg, rInsPosNd, + IDocumentContentOperations::DOC_MOVEDEFAULT ); + } // wo steht jetzt aInsPos ?? if( bCalcWidth ) diff --git a/sw/source/core/graphic/ndgrf.cxx b/sw/source/core/graphic/ndgrf.cxx index 6041de45eb..6626da2420 100644 --- a/sw/source/core/graphic/ndgrf.cxx +++ b/sw/source/core/graphic/ndgrf.cxx @@ -956,7 +956,8 @@ SwCntntNode* SwGrfNode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const SwGrfNode* pGrfNd = pDoc->GetNodes().MakeGrfNode( rIdx, sFile, sFilter, &aTmpGrf, pColl, (SwAttrSet*)GetpSwAttrSet() ); - pGrfNd->SetAlternateText( GetAlternateText() ); + pGrfNd->SetTitle( GetTitle() ); + pGrfNd->SetDescription( GetDescription() ); pGrfNd->SetContour( HasContour(), HasAutomaticContour() ); return pGrfNd; } diff --git a/sw/source/core/inc/GetMetricVal.hxx b/sw/source/core/inc/GetMetricVal.hxx index 14277471fa..1759e46a23 100644 --- a/sw/source/core/inc/GetMetricVal.hxx +++ b/sw/source/core/inc/GetMetricVal.hxx @@ -39,7 +39,7 @@ inline USHORT GetMetricVal( int n ) { #ifdef USE_MEASUREMENT - USHORT nVal = MEASURE_METRIC == GetAppLocaleData().getMeasurementSystemEnum() + USHORT nVal = MEASURE_METRIC == SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() ? 567 // 1 cm : 770; // 1/2 Inch #else diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx index ef1cc12149..415deffa24 100644 --- a/sw/source/core/inc/bookmrk.hxx +++ b/sw/source/core/inc/bookmrk.hxx @@ -32,6 +32,8 @@ #define _BOOKMRK_HXX #include <IMark.hxx> +#include <sfx2/Metadatable.hxx> + #include <boost/scoped_ptr.hpp> #include <boost/noncopyable.hpp> @@ -144,6 +146,7 @@ namespace sw { namespace mark class Bookmark : virtual public IBookmark , public DdeBookmark + , public ::sfx2::Metadatable { public: Bookmark(const SwPaM& rPaM, @@ -160,6 +163,15 @@ namespace sw { namespace mark { m_sShortName = rShortName; } virtual void SetKeyCode(const KeyCode& rCode) { m_aCode = rCode; } + + // ::sfx2::Metadatable + virtual ::sfx2::IXmlIdRegistry& GetRegistry(); + virtual bool IsInClipboard() const; + virtual bool IsInUndo() const; + virtual bool IsInContent() const; + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable > MakeUnoObject(); + private: KeyCode m_aCode; ::rtl::OUString m_sShortName; diff --git a/sw/source/core/inc/crossrefbookmark.hxx b/sw/source/core/inc/crossrefbookmark.hxx index d4b291661c..d175b2130d 100644 --- a/sw/source/core/inc/crossrefbookmark.hxx +++ b/sw/source/core/inc/crossrefbookmark.hxx @@ -70,8 +70,6 @@ namespace sw { namespace mark "<SwCrossRefBookmark::ClearOtherMarkPos(..)>" " - misusage of CrossRefBookmark: other bookmark position isn't allowed to be set or cleared." ); } - - static bool IsLegalName(const ::rtl::OUString& rName); }; class CrossRefHeadingBookmark diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 584c22ec09..199be26f58 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -518,21 +518,26 @@ inline BOOL SwBorderAttrs::IsLine() const OD 2004-03-10 #i28701# Values only provided for flow frames (table, section or text frames) Note: line spacing value is only determined for text frames + OD 2009-08-28 #i102458# + Add output parameter <obIsLineSpacingProportional> - @param _rFrm + @param rFrm input parameter - frame, for which the spacing values are determined. - @param _roPrevLowerSpacing + @param onPrevLowerSpacing output parameter - lower spacing of the frame in SwTwips - @param _roPrevLineSpacing + @param onPrevLineSpacing output parameter - line spacing of the frame in SwTwips + @param obIsLineSpacingProportional + @author OD */ -void GetSpacingValuesOfFrm( const SwFrm& _rFrm, - SwTwips& _roLowerSpacing, - SwTwips& _roLineSpacing ); +void GetSpacingValuesOfFrm( const SwFrm& rFrm, + SwTwips& onLowerSpacing, + SwTwips& onLineSpacing, + bool& obIsLineSpacingProportional ); /** method to get the content of the table cell diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx index e6c864f93e..dac9783874 100644 --- a/sw/source/core/inc/mvsave.hxx +++ b/sw/source/core/inc/mvsave.hxx @@ -39,6 +39,10 @@ #include <IDocumentMarkAccess.hxx> #include <vector> +namespace sfx2 { + class MetadatableUndo; +} + class SvNumberFormatter; class SvULongs; class SwDoc; @@ -80,6 +84,7 @@ namespace sw { namespace mark ULONG m_nNode2; xub_StrLen m_nCntnt1; xub_StrLen m_nCntnt2; + ::boost::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo; }; }} diff --git a/sw/source/core/inc/pagefrm.hxx b/sw/source/core/inc/pagefrm.hxx index aa207629cc..38f0b8a723 100644 --- a/sw/source/core/inc/pagefrm.hxx +++ b/sw/source/core/inc/pagefrm.hxx @@ -275,7 +275,7 @@ public: void SetFtnPage( BOOL b ) { bFtnPage = b; } void SetEndNotePage( BOOL b ) { bEndNotePage = b; } - inline USHORT GetPhyPageNum() const { return nPhyPageNum;} + inline USHORT GetPhyPageNum() const { return nPhyPageNum;} inline void SetPhyPageNum( USHORT nNum ) { nPhyPageNum = nNum;} inline void DecrPhyPageNum() { --nPhyPageNum; } inline void IncrPhyPageNum() { ++nPhyPageNum; } diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index 7b09d045a8..68d031dab5 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -141,6 +141,7 @@ class SwFont Color aOverColor; // color of the overlining BYTE nToxCnt; // Zaehlt die Schachtelungstiefe der Tox BYTE nRefCnt; // Zaehlt die Schachtelungstiefe der Refs + BYTE m_nMetaCount; // count META/METAFIELD BYTE nActual; // actual font (Latin, CJK or CTL) // Schalter fuer die Font-Extensions @@ -245,6 +246,9 @@ public: inline BYTE &GetRef() { return nRefCnt; } inline BYTE GetRef() const { return nRefCnt; } inline BOOL IsRef() const { return ( 0 != nRefCnt ); } + inline BYTE &GetMeta() { return m_nMetaCount; } + inline BYTE GetMeta() const { return m_nMetaCount; } + inline bool IsMeta() const { return (0 != m_nMetaCount); } inline void SetURL( const BOOL bURL ); inline BOOL IsURL() const { return bURL; } inline void SetGreyWave( const BOOL bNew ); diff --git a/sw/source/core/inc/txttypes.hxx b/sw/source/core/inc/txttypes.hxx index 89bb356aed..eaa9a95a9c 100644 --- a/sw/source/core/inc/txttypes.hxx +++ b/sw/source/core/inc/txttypes.hxx @@ -64,6 +64,7 @@ #define POR_ISOTOX 0x808a #define POR_REF 0x808b #define POR_ISOREF 0x808c +#define POR_META 0x808d #define POR_EXP 0xc080 #define POR_BLANK 0xc081 diff --git a/sw/source/ui/table/insrc.hrc b/sw/source/core/inc/undoflystrattr.hxx index 133bcf70c3..86bffc64bd 100644 --- a/sw/source/ui/table/insrc.hrc +++ b/sw/source/core/inc/undoflystrattr.hxx @@ -1,13 +1,13 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: insrc.hrc,v $ - * $Revision: 1.4 $ + * $RCSfile: SwUndoPageDesc.hxx,v $ + * $Revision: 1.7 $ * * This file is part of OpenOffice.org. * @@ -27,17 +27,34 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#define FT_COUNT 1 -#define ED_COUNT 2 -#define FL_INS 3 +#ifndef _UNDO_FLY_STR_ATTR_HXX +#define _UNDO_FLY_STR_ATTR_HXX + +#include <undobj.hxx> +#include <swundo.hxx> + +class SwFlyFrmFmt; +class String; + +class SwUndoFlyStrAttr : public SwUndo +{ + public: + SwUndoFlyStrAttr( SwFlyFrmFmt& rFlyFrmFmt, + const SwUndoId eUndoId, + const String& sOldStr, + const String& sNewStr ); + virtual ~SwUndoFlyStrAttr(); + + virtual void Undo( SwUndoIter & rIt ); + virtual void Redo( SwUndoIter & rIt ); + virtual void Repeat( SwUndoIter & rIt ); -#define CB_POS_BEFORE 10 -#define CB_POS_AFTER 11 -#define FL_POS 12 + virtual SwRewriter GetRewriter() const; -#define STR_ROW 20 -#define STR_COL 21 + private: + SwFlyFrmFmt& mrFlyFrmFmt; + const String msOldStr; + const String msNewStr; +}; -#define BT_OK 100 -#define BT_CANCEL 101 -#define BT_HELP 102 +#endif // _UNDO_FLY_STR_ATTR_HXX diff --git a/sw/source/core/inc/unometa.hxx b/sw/source/core/inc/unometa.hxx new file mode 100755 index 0000000000..1dc1985f7d --- /dev/null +++ b/sw/source/core/inc/unometa.hxx @@ -0,0 +1,345 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: unometa.hxx,v $ + * $Revision: 1.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_UNOMETA_HXX +#define SW_UNOMETA_HXX + +#include "calbck.hxx" + +#include <sfx2/Metadatable.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase5.hxx> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/container/XEnumerationAccess.hpp> +#include <com/sun/star/text/XTextContent.hpp> +#include <com/sun/star/text/XTextField.hpp> + +#include <deque> + + +typedef ::std::deque< + ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > > + TextRangeList_t; + +class SwXTextRange; +class SwPaM; +class SwTxtMeta; +namespace sw { + class Meta; + class MetaField; +} + +typedef +::cppu::ImplInheritanceHelper5 +< ::sfx2::MetadatableMixin +, ::com::sun::star::lang::XUnoTunnel +, ::com::sun::star::lang::XServiceInfo +, ::com::sun::star::text::XTextContent +, ::com::sun::star::text::XText +, ::com::sun::star::container::XEnumerationAccess +> SwXMetaBaseClass; + +class SwXMeta + : public SwXMetaBaseClass + , public SwClient + , private ::boost::noncopyable +{ +private: + struct Impl; + ::std::auto_ptr<Impl> m_pImpl; + +protected: + virtual ~SwXMeta(); + +public: + SwXMeta(SwDoc *const pDoc, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& + xParentText, + TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + SwXMeta(SwDoc *const pDoc); + + TYPEINFO(); + + static const ::com::sun::star::uno::Sequence< sal_Int8 > & getUnoTunnelId(); + + // XUnoTunnel + virtual sal_Int64 SAL_CALL getSomething( + const ::com::sun::star::uno::Sequence< sal_Int8 >& Identifier ) + throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& rServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XTextRange + virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + SAL_CALL getText() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getStart() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getEnd() + throw (::com::sun::star::uno::RuntimeException); + virtual rtl::OUString SAL_CALL getString() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setString(const rtl::OUString& rString) + throw (::com::sun::star::uno::RuntimeException); + + // XSimpleText + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursor() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextCursor > SAL_CALL + createTextCursorByRange( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextPosition) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertString( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const rtl::OUString& aString, sal_Bool bAbsorb) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL insertControlCharacter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + + // XText + virtual void SAL_CALL insertTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xRange, + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent, + sal_Bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeTextContent( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextContent > & xContent) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + + // XElementAccess + virtual ::com::sun::star::uno::Type SAL_CALL getElementType() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasElements() + throw (::com::sun::star::uno::RuntimeException); + + // XEnumerationAccess + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::container::XEnumeration > SAL_CALL + createEnumeration() + throw (::com::sun::star::uno::RuntimeException); + + // MetadatableMixin + virtual ::sfx2::Metadatable * GetCoreObject(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + GetModel(); + + // SwClient + virtual void Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ); + + /// init params with position of the attribute content (w/out CH_TXTATR) + bool SetContentRange( + SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd) const; + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > + GetParentText() const; + + bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +protected: + virtual void SAL_CALL AttachImpl( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange, + const USHORT nWhich) + throw ( ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException ); + +private: + inline const ::sw::Meta * GetMeta() const; + +}; + + +typedef +::cppu::ImplInheritanceHelper2 +< SwXMeta +, ::com::sun::star::beans::XPropertySet +, ::com::sun::star::text::XTextField +> SwXMetaFieldBaseClass; + +class SwXMetaField + : public SwXMetaFieldBaseClass +{ +private: + virtual ~SwXMetaField(); + +private: + inline const ::sw::MetaField * GetMetaField() const; + +public: + SwXMetaField(SwDoc *const pDoc, + ::com::sun::star::uno::Reference< ::com::sun::star::text::XText> const& + xParentText, + TextRangeList_t * const pPortions, SwTxtMeta * const pHint); + SwXMetaField(SwDoc *const pDoc); + + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getSupportedServiceNames( ) + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener) + throw (::com::sun::star::uno::RuntimeException); + + // XTextContent + virtual void SAL_CALL attach( + const ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > & xTextRange) + throw ( ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > SAL_CALL getAnchor() + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + getPropertySetInfo() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Any& rValue) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL + getPropertyValue(const ::rtl::OUString& rPropertyName) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertyChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& rPropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XVetoableChangeListener >& xListener) + throw (::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException); + + // XTextField + virtual rtl::OUString SAL_CALL getPresentation(sal_Bool bShowCommand) + throw (::com::sun::star::uno::RuntimeException); + +}; + +/// get prefix/suffix from the RDF repository. @throws RuntimeException +void getPrefixAndSuffix( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel>& xModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::rdf::XMetadatable>& xMetaField, + ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix); + +#endif // SW_UNOMETA_HXX + diff --git a/sw/source/core/inc/viewimp.hxx b/sw/source/core/inc/viewimp.hxx index 95e2291348..e4735c0e5c 100644 --- a/sw/source/core/inc/viewimp.hxx +++ b/sw/source/core/inc/viewimp.hxx @@ -254,7 +254,7 @@ public: BOOL IsPaintInScroll() const { return bPaintInScroll; } // neues Interface fuer StarView Drawing - inline BOOL HasDrawView() const { return 0 != pDrawView; } + inline BOOL HasDrawView() const { return 0 != pDrawView; } SwDrawView* GetDrawView() { return pDrawView; } const SwDrawView* GetDrawView() const { return pDrawView; } SdrPageView*GetPageView() { return pSdrPageView; } diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index ec5e3f36b8..e327b0bbdf 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -2880,6 +2880,80 @@ sal_Bool SwFlyFrmFmt::GetInfo( SfxPoolItem& rInfo ) const return sal_True; } +// --> OD 2009-07-14 #i73249# +void SwFlyFrmFmt::SetObjTitle( const String& rTitle, bool bBroadcast ) +{ + SdrObject* pMasterObject = FindSdrObject(); + ASSERT( pMasterObject, + "<SwNoTxtNode::SetObjTitle(..)> - missing <SdrObject> instance" ); + if ( !pMasterObject ) + { + return; + } + + if( bBroadcast ) + { + SwStringMsgPoolItem aOld( RES_TITLE_CHANGED, pMasterObject->GetTitle() ); + SwStringMsgPoolItem aNew( RES_TITLE_CHANGED, rTitle ); + pMasterObject->SetTitle( rTitle ); + Modify( &aOld, &aNew ); + } + else + { + pMasterObject->SetTitle( rTitle ); + } +} + +const String SwFlyFrmFmt::GetObjTitle() const +{ + const SdrObject* pMasterObject = FindSdrObject(); + ASSERT( pMasterObject, + "<SwFlyFrmFmt::GetObjTitle(..)> - missing <SdrObject> instance" ); + if ( !pMasterObject ) + { + return aEmptyStr; + } + + return pMasterObject->GetTitle(); +} + +void SwFlyFrmFmt::SetObjDescription( const String& rDescription, bool bBroadcast ) +{ + SdrObject* pMasterObject = FindSdrObject(); + ASSERT( pMasterObject, + "<SwFlyFrmFmt::SetDescription(..)> - missing <SdrObject> instance" ); + if ( !pMasterObject ) + { + return; + } + + if( bBroadcast ) + { + SwStringMsgPoolItem aOld( RES_DESCRIPTION_CHANGED, pMasterObject->GetDescription() ); + SwStringMsgPoolItem aNew( RES_DESCRIPTION_CHANGED, rDescription ); + pMasterObject->SetDescription( rDescription ); + Modify( &aOld, &aNew ); + } + else + { + pMasterObject->SetDescription( rDescription ); + } +} + +const String SwFlyFrmFmt::GetObjDescription() const +{ + const SdrObject* pMasterObject = FindSdrObject(); + ASSERT( pMasterObject, + "<SwNoTxtNode::GetDescription(..)> - missing <SdrObject> instance" ); + if ( !pMasterObject ) + { + return aEmptyStr; + } + + return pMasterObject->GetDescription(); +} +// <-- + /** SwFlyFrmFmt::IsBackgroundTransparent - for #99657# OD 22.08.2002 - overloading virtual method and its default implementation, diff --git a/sw/source/core/layout/colfrm.cxx b/sw/source/core/layout/colfrm.cxx index c4f8923507..8515889c10 100644 --- a/sw/source/core/layout/colfrm.cxx +++ b/sw/source/core/layout/colfrm.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -213,6 +213,15 @@ void SwLayoutFrm::ChgColumns( const SwFmtCol &rOld, const SwFmtCol &rNew, { if ( rOld.GetNumCols() <= 1 && rNew.GetNumCols() <= 1 && !bChgFtn ) return; + // --> OD 2009-08-12 #i97379# + // If current lower is a no text frame, then columns are not allowed + if ( Lower() && Lower()->IsNoTxtFrm() && + rNew.GetNumCols() > 1 ) + { + return; + } + // <-- + USHORT nNewNum, nOldNum = 1; if( Lower() && Lower()->IsColumnFrm() ) { diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index ba9f0f9b99..4968601e7a 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -1514,7 +1514,12 @@ SwTwips SwFlowFrm::CalcUpperSpace( const SwBorderAttrs *pAttrs, // values of found previous frame and use these values. SwTwips nPrevLowerSpace = 0; SwTwips nPrevLineSpacing = 0; - GetSpacingValuesOfFrm( (*pPrevFrm), nPrevLowerSpace, nPrevLineSpacing ); + // --> OD 2009-08-28 #i102458# + bool bPrevLineSpacingPorportional = false; + GetSpacingValuesOfFrm( (*pPrevFrm), + nPrevLowerSpace, nPrevLineSpacing, + bPrevLineSpacingPorportional ); + // <-- if( pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX) ) { nUpper = nPrevLowerSpace + pAttrs->GetULSpace().GetUpper(); @@ -1539,7 +1544,22 @@ SwTwips SwFlowFrm::CalcUpperSpace( const SwBorderAttrs *pAttrs, // building its maximum. if ( pOwn->IsTxtFrm() ) { - nAdd += static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ); + // --> OD 2009-08-28 #i102458# + // Correction: + // A proportional line spacing of the previous text frame + // is added up to a own leading line spacing. + // Otherwise, the maximum of the leading line spacing + // of the previous text frame and the own leading line + // spacing is built. + if ( bPrevLineSpacingPorportional ) + { + nAdd += static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ); + } + else + { + nAdd = Max( nAdd, static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ) ); + } + // <-- } nUpper += nAdd; } @@ -1571,7 +1591,22 @@ SwTwips SwFlowFrm::CalcUpperSpace( const SwBorderAttrs *pAttrs, SwTwips nAdd = nPrevLineSpacing; if ( pOwn->IsTxtFrm() ) { - nAdd += static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ); + // --> OD 2009-08-28 #i102458# + // Correction: + // A proportional line spacing of the previous text frame + // is added up to a own leading line spacing. + // Otherwise, the maximum of the leading line spacing + // of the previous text frame and the own leading line + // spacing is built. + if ( bPrevLineSpacingPorportional ) + { + nAdd += static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ); + } + else + { + nAdd = Max( nAdd, static_cast<SwTxtFrm&>(rThis).GetLineSpace( true ) ); + } + // <-- } nUpper += nAdd; } @@ -1675,7 +1710,10 @@ SwTwips SwFlowFrm::_GetUpperSpaceAmountConsideredForPrevFrm() const { SwTwips nPrevLowerSpace = 0; SwTwips nPrevLineSpacing = 0; - GetSpacingValuesOfFrm( (*pPrevFrm), nPrevLowerSpace, nPrevLineSpacing ); + // --> OD 2009-08-28 #i102458# + bool bDummy = false; + GetSpacingValuesOfFrm( (*pPrevFrm), nPrevLowerSpace, nPrevLineSpacing, bDummy ); + // <-- if ( nPrevLowerSpace > 0 || nPrevLineSpacing > 0 ) { const IDocumentSettingAccess* pIDSA = rThis.GetUpper()->GetFmt()->getIDocumentSettingAccess(); @@ -2697,8 +2735,3 @@ const SwFlowFrm *SwFlowFrm::CastFlowFrm( const SwFrm *pFrm ) return (SwSectionFrm*)pFrm; return 0; } - - - - - diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index 140e1470e1..8899002e4e 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -250,6 +250,18 @@ void SwFlyFrm::InsertCnt() // OD 2004-02-12 #110582#-2 void SwFlyFrm::InsertColumns() { + // --> OD 2009-08-12 #i97379# + // Check, if column are allowed. + // Columns are not allowed for fly frames, which represent graphics or embedded objects. + const SwFmtCntnt& rCntnt = GetFmt()->GetCntnt(); + ASSERT( rCntnt.GetCntntIdx(), "<SwFlyFrm::InsertColumns()> - no content prepared." ); + SwNodeIndex aFirstCntnt( *(rCntnt.GetCntntIdx()), 1 ); + if ( aFirstCntnt.GetNode().IsNoTxtNode() ) + { + return; + } + // <-- + const SwFmtCol &rCol = GetFmt()->GetCol(); if ( rCol.GetNumCols() > 1 ) { diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 6e96769025..756269cd03 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -3655,30 +3655,37 @@ const SwRect SwPageFrm::PrtWithoutHeaderAndFooter() const /** method to determine the spacing values of a frame OD 2004-03-10 #i28701# + OD 2009-08-28 #i102458# + Add output parameter <obIsLineSpacingProportional> @author OD */ -void GetSpacingValuesOfFrm( const SwFrm& _rFrm, - SwTwips& _roLowerSpacing, - SwTwips& _roLineSpacing ) +void GetSpacingValuesOfFrm( const SwFrm& rFrm, + SwTwips& onLowerSpacing, + SwTwips& onLineSpacing, + bool& obIsLineSpacingProportional ) { - if ( !_rFrm.IsFlowFrm() ) + if ( !rFrm.IsFlowFrm() ) { - _roLowerSpacing = 0L; - _roLineSpacing = 0L; + onLowerSpacing = 0; + onLineSpacing = 0; } else { - const SvxULSpaceItem& rULSpace = _rFrm.GetAttrSet()->GetULSpace(); - _roLowerSpacing = rULSpace.GetLower(); + const SvxULSpaceItem& rULSpace = rFrm.GetAttrSet()->GetULSpace(); + onLowerSpacing = rULSpace.GetLower(); - _roLineSpacing = 0; - if ( _rFrm.IsTxtFrm() ) + onLineSpacing = 0; + obIsLineSpacingProportional = false; + if ( rFrm.IsTxtFrm() ) { - _roLineSpacing = static_cast<const SwTxtFrm&>(_rFrm).GetLineSpace(); + onLineSpacing = static_cast<const SwTxtFrm&>(rFrm).GetLineSpace(); + obIsLineSpacingProportional = + onLineSpacing != 0 && + static_cast<const SwTxtFrm&>(rFrm).GetLineSpace( true ) == 0; } - ASSERT( _roLowerSpacing >= 0 && _roLineSpacing >= 0, + ASSERT( onLowerSpacing >= 0 && onLineSpacing >= 0, "<GetSpacingValuesOfFrm(..)> - spacing values aren't positive!" ); } } diff --git a/sw/source/core/layout/layact.cxx b/sw/source/core/layout/layact.cxx index 68eb0469c9..2718e15a6c 100644 --- a/sw/source/core/layout/layact.cxx +++ b/sw/source/core/layout/layact.cxx @@ -3031,7 +3031,8 @@ SwLayIdle::SwLayIdle( SwRootFrm *pRt, SwViewImp *pI ) : if ( !bInValid ) { pRoot->ResetIdleFormat(); - pImp->GetShell()->GetDoc()->GetDocShell()->Broadcast( SfxEventHint( SW_EVENT_LAYOUT_FINISHED ) ); + SfxObjectShell* pDocShell = pImp->GetShell()->GetDoc()->GetDocShell(); + pDocShell->Broadcast( SfxEventHint( SW_EVENT_LAYOUT_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_LAYOUT_FINISHED), pDocShell ) ); } } diff --git a/sw/source/core/layout/laycache.cxx b/sw/source/core/layout/laycache.cxx index 5822bd21b8..aff3c4e07e 100644 --- a/sw/source/core/layout/laycache.cxx +++ b/sw/source/core/layout/laycache.cxx @@ -727,7 +727,8 @@ void lcl_ApplyWorkaroundForB6375613( SwFrm* p_pFirstFrmOnNewPage ) SwDoc* pDoc( pFirstTextFrmOnNewPage->GetTxtNode()->GetDoc() ); IDocumentContentOperations* pIDCO = pFirstTextFrmOnNewPage->GetTxtNode()->getIDocumentContentOperations(); const SwPaM aTmpPaM( *(pFirstTextFrmOnNewPage->GetTxtNode()) ); - pIDCO->Insert( aTmpPaM, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); + pIDCO->InsertPoolItem( aTmpPaM, + SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0 ); pFirstTextFrmOnNewPage->GetTxtNode()->UnlockModify(); uno::Reference< document::XDocumentInfoSupplier > xDoc( diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx index e1c1055638..cf45cba307 100644 --- a/sw/source/core/layout/pagechg.cxx +++ b/sw/source/core/layout/pagechg.cxx @@ -2062,6 +2062,10 @@ void lcl_MoveAllLowerObjs( SwFrm* pFrm, const Point& rOffset ) pAnchoredDrawObj->DrawObj()->SetAnchorPos( aNewAnchorPos ); pAnchoredDrawObj->SetLastObjRect( pAnchoredDrawObj->GetObjRect().SVRect() ); } + // --> OD 2009-08-20 #i92511# + // cache for object rectangle inclusive spaces has to be invalidated. + pAnchoredObj->InvalidateObjRectWithSpaces(); + // <-- } } diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx index 6f6759f1cf..0ba077e799 100644 --- a/sw/source/core/layout/tabfrm.cxx +++ b/sw/source/core/layout/tabfrm.cxx @@ -2103,6 +2103,11 @@ void SwTabFrm::MakeAll() { bMovedFwd = TRUE; bCalcLowers = TRUE; + // --> OD 2009-08-12 #i99267# + // reset <bSplit> after forward move to assure that follows + // can be joined, if further space is available. + bSplit = FALSE; + // <-- } Point aOldPos( (Frm().*fnRect->fnGetPos)() ); @@ -2148,7 +2153,7 @@ void SwTabFrm::MakeAll() { // HB #i101593# no optimization as it leeds to not layouting certain nested tables // const BOOL bOptLower = (Frm().*fnRect->fnGetHeight)() == 0; - const BOOL bOptLower = FALSE; + const BOOL bOptLower = FALSE; const long nOldPrtWidth = (Prt().*fnRect->fnGetWidth)(); const long nOldFrmWidth = (Frm().*fnRect->fnGetWidth)(); diff --git a/sw/source/core/ole/ndole.cxx b/sw/source/core/ole/ndole.cxx index 2afc408a68..3ed18d128b 100644 --- a/sw/source/core/ole/ndole.cxx +++ b/sw/source/core/ole/ndole.cxx @@ -467,7 +467,8 @@ SwCntntNode* SwOLENode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx ) const (SwAttrSet*)GetpSwAttrSet() ); pOLENd->SetChartTblName( GetChartTblName() ); - pOLENd->SetAlternateText( GetAlternateText() ); + pOLENd->SetTitle( GetTitle() ); + pOLENd->SetDescription( GetDescription() ); pOLENd->SetContour( HasContour(), HasAutomaticContour() ); pOLENd->SetAspect( GetAspect() ); // the replacement image must be already copied diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx b/sw/source/core/swg/SwXMLTextBlocks.cxx index 15e91e7050..8eba626632 100644 --- a/sw/source/core/swg/SwXMLTextBlocks.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks.cxx @@ -641,6 +641,6 @@ void SwXMLTextBlocks::MakeBlockText( const String& rText ) } SwIndex aIdx( pTxtNode ); String sTemp(rText.GetToken( 0, '\015', nPos ) ); - pTxtNode->Insert( sTemp, aIdx ); + pTxtNode->InsertText( sTemp, aIdx ); } while ( STRING_NOTFOUND != nPos ); } diff --git a/sw/source/core/swg/SwXMLTextBlocks1.cxx b/sw/source/core/swg/SwXMLTextBlocks1.cxx index 7567e5c4db..0c329ee5b3 100644 --- a/sw/source/core/swg/SwXMLTextBlocks1.cxx +++ b/sw/source/core/swg/SwXMLTextBlocks1.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/xml/sax/InputSource.hpp> #include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/xml/sax/XParser.hpp> +#include <com/sun/star/document/XStorageBasedDocument.hpp> #include <doc.hxx> #ifndef _DOCSH_HXX #include <docsh.hxx> @@ -81,6 +82,21 @@ ULONG SwXMLTextBlocks::GetDoc( USHORT nIdx ) ReadXML->SetBlockMode( sal_True ); aReader.Read( *ReadXML ); ReadXML->SetBlockMode( sal_False ); + // Ole objects fails to display when inserted into document + // because the ObjectReplacement folder ( and contents are missing ) + rtl::OUString sObjReplacements( RTL_CONSTASCII_USTRINGPARAM( "ObjectReplacements" ) ); + if ( xRoot->hasByName( sObjReplacements ) ) + { + uno::Reference< document::XStorageBasedDocument > xDocStor( pDoc->GetDocShell()->GetModel(), uno::UNO_QUERY_THROW ); + uno::Reference< embed::XStorage > xStr( xDocStor->getDocumentStorage() ); + if ( xStr.is() ) + { + xRoot->copyElementTo( sObjReplacements, xStr, sObjReplacements ); + uno::Reference< embed::XTransactedObject > xTrans( xStr, uno::UNO_QUERY ); + if ( xTrans.is() ) + xTrans->commit(); + } + } } catch( uno::Exception& ) { diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx index d83877130e..587914ae0b 100644 --- a/sw/source/core/table/swnewtable.cxx +++ b/sw/source/core/table/swnewtable.cxx @@ -909,7 +909,10 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes, if( pUndo ) pUndo->MoveBoxCntnt( pDoc, aRg, rInsPosNd ); else - pDoc->Move( aRg, rInsPosNd, IDocumentContentOperations::DOC_NO_DELFRMS ); + { + pDoc->MoveNodeRange( aRg, rInsPosNd, + IDocumentContentOperations::DOC_NO_DELFRMS ); + } } } // Only the cell of the first selected column will stay alive diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx index d78233176b..caffe6edbf 100644 --- a/sw/source/core/table/swtable.cxx +++ b/sw/source/core/table/swtable.cxx @@ -2177,8 +2177,10 @@ void ChgTextToNum( SwTableBox& rBox, const String& rTxt, const Color* pCol, pDoc->DeleteRedline(aTemp, true, USHRT_MAX); } - pTNd->Erase( aIdx, n, INS_EMPTYEXPAND ); - pTNd->Insert( rTxt, aIdx, INS_EMPTYEXPAND ); + pTNd->EraseText( aIdx, n, + IDocumentContentOperations::INS_EMPTYEXPAND ); + pTNd->InsertText( rTxt, aIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( pDoc->IsRedlineOn() ) { @@ -2222,8 +2224,10 @@ void ChgNumToText( SwTableBox& rBox, ULONG nFmt ) // zuruecksetzen, damit sie wieder aufgespannt werden pTNd->DontExpandFmt( aIdx, FALSE, FALSE ); aIdx = 0; - pTNd->Erase( aIdx, STRING_LEN, INS_EMPTYEXPAND ); - pTNd->Insert( sTmp, aIdx, INS_EMPTYEXPAND ); + pTNd->EraseText( aIdx, STRING_LEN, + IDocumentContentOperations::INS_EMPTYEXPAND ); + pTNd->InsertText( sTmp, aIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); } } diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index 617c764dca..d6241c775f 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -698,7 +698,7 @@ void SwTaggedPDFHelper::SetAttributes( vcl::PDFWriter::StructElement eType ) const SwNoTxtFrm* pNoTxtFrm = static_cast<const SwNoTxtFrm*>(pFly->Lower()); const SwNoTxtNode* pNoTxtNode = static_cast<const SwNoTxtNode*>(pNoTxtFrm->GetNode()); - const String aAlternateTxt( pNoTxtNode->GetAlternateText() ); + const String aAlternateTxt( pNoTxtNode->GetTitle() ); mpPDFExtOutDevData->SetAlternateText( aAlternateTxt ); } } diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx index 35fb80bde2..4d9a2909d2 100644 --- a/sw/source/core/text/atrhndl.hxx +++ b/sw/source/core/text/atrhndl.hxx @@ -32,7 +32,7 @@ #define _ATRHNDL_HXX #define INITIAL_NUM_ATTR 3 -#define NUM_ATTRIBUTE_STACKS 39 +#define NUM_ATTRIBUTE_STACKS 40 #include <txatbase.hxx> #include <swfntcch.hxx> diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx index b63cd8776d..641bd51ee3 100644 --- a/sw/source/core/text/atrstck.cxx +++ b/sw/source/core/text/atrstck.cxx @@ -136,8 +136,8 @@ const BYTE StackPos[ static_cast<USHORT>(RES_TXTATR_WITHEND_END) - 0, // RES_TXTATR_DUMMY5 // 46 38, // RES_TXTATR_CJK_RUBY, // 47 0, // RES_TXTATR_UNKNOWN_CONTAINER, // 48 - 0, // RES_TXTATR_DUMMY6, // 49 - 0 // RES_TXTATR_DUMMY7, // 50 + 39, // RES_TXTATR_META, // 49 + 39 // RES_TXTATR_METAFIELD, // 50 }; /************************************************************************* @@ -650,6 +650,10 @@ void SwAttrHandler::ActivateTop( SwFont& rFnt, const USHORT nAttr ) rFnt.GetRef()--; else if ( RES_TXTATR_TOXMARK == nAttr ) rFnt.GetTox()--; + else if ( (RES_TXTATR_META == nAttr) || (RES_TXTATR_METAFIELD == nAttr) ) + { + rFnt.GetMeta()--; + } else if ( RES_TXTATR_CJK_RUBY == nAttr ) { // ruby stack has no more attributes @@ -928,6 +932,13 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, sal_Bool bPu else rFnt.GetTox()--; break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + if ( bPush ) + rFnt.GetMeta()++; + else + rFnt.GetMeta()--; + break; } } diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 5d7b28cdea..049ea79078 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -243,7 +243,7 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, nBreakStart = nCutPos; } - else if( pBreakIt->xBreak.is() ) + else if( pBreakIt->GetBreakIter().is() ) { // New: We should have a look into the last portion, if it was a // field portion. For this, we expand the text of the field portion @@ -366,7 +366,7 @@ sal_Bool SwTxtGuess::Guess( const SwTxtPortion& rPor, SwTxtFormatInfo &rInf, // determines first possible line break from nRightPos to // start index of current line - LineBreakResults aResult = pBreakIt->xBreak->getLineBreak( + LineBreakResults aResult = pBreakIt->GetBreakIter()->getLineBreak( rInf.GetTxt(), nCutPos, aLocale, rInf.GetLineStart(), aHyphOpt, aUserOpt ); @@ -534,7 +534,7 @@ sal_Bool SwTxtGuess::AlternativeSpelling( const SwTxtFormatInfo &rInf, xub_StrLen nWordLen; Boundary aBound = - pBreakIt->xBreak->getWordBoundary( rInf.GetTxt(), nPos, + pBreakIt->GetBreakIter()->getWordBoundary( rInf.GetTxt(), nPos, pBreakIt->GetLocale( rInf.GetFont()->GetLanguage() ), WordType::DICTIONARY_WORD, sal_True ); nBreakStart = (xub_StrLen)aBound.startPos; diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 13a05d1295..b27a551ff7 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -1277,7 +1277,8 @@ void SwTxtPaintInfo::DrawViewOpt( const SwLinePortion &rPor, case POR_URL: case POR_HIDDEN: case POR_TOX: - case POR_REF : + case POR_REF: + case POR_META: case POR_CONTROLCHAR: if ( !GetOpt().IsPagePreview() && !GetOpt().IsReadonly() && diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx index 44ab83e9cd..09be2bd798 100644 --- a/sw/source/core/text/itratr.cxx +++ b/sw/source/core/text/itratr.cxx @@ -45,7 +45,6 @@ #include <fmtflcnt.hxx> #include <fmtcntnt.hxx> #include <fmtftn.hxx> -#include <fmthbsh.hxx> #include <frmatr.hxx> #include <frmfmt.hxx> #include <fmtfld.hxx> @@ -126,19 +125,7 @@ SwAttrIter::~SwAttrIter() SwTxtAttr *SwAttrIter::GetAttr( const xub_StrLen nPosition ) const { - if ( pHints ) - { - for ( USHORT i = 0; i < pHints->Count(); ++i ) - { - SwTxtAttr *pPos = pHints->GetTextHint(i); - xub_StrLen nStart = *pPos->GetStart(); - if( nPosition < nStart ) - return 0; - if( nPosition == nStart && !pPos->GetEnd() ) - return pPos; - } - } - return 0; + return (m_pTxtNode) ? m_pTxtNode->GetTxtAttrForCharAt(nPosition) : 0; } /************************************************************************* @@ -400,10 +387,10 @@ sal_Bool lcl_MinMaxString( SwMinMaxArgs& rArg, SwFont* pFnt, const XubString &rT xub_StrLen nStop = nIdx; sal_Bool bClear; LanguageType eLang = pFnt->GetLanguage(); - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { bClear = CH_BLANK == rTxt.GetChar( nStop ); - Boundary aBndry( pBreakIt->xBreak->getWordBoundary( rTxt, nIdx, + Boundary aBndry( pBreakIt->GetBreakIter()->getWordBoundary( rTxt, nIdx, pBreakIt->GetLocale( eLang ), WordType::DICTIONARY_WORD, TRUE ) ); nStop = (xub_StrLen)aBndry.endPos; @@ -870,7 +857,7 @@ USHORT SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) if ( nStt == nEnd ) { - if ( !pBreakIt->xBreak.is() ) + if ( !pBreakIt->GetBreakIter().is() ) return 100; SwScriptInfo aScriptInfo; @@ -878,7 +865,7 @@ USHORT SwTxtNode::GetScalingOfSelectedText( xub_StrLen nStt, xub_StrLen nEnd ) aIter.SeekAndChgAttrIter( nStt, pOut ); Boundary aBound = - pBreakIt->xBreak->getWordBoundary( GetTxt(), nStt, + pBreakIt->GetBreakIter()->getWordBoundary( GetTxt(), nStt, pBreakIt->GetLocale( aIter.GetFnt()->GetLanguage() ), WordType::DICTIONARY_WORD, sal_True ); diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx index 25ad1a25ca..7fbb6bae55 100644 --- a/sw/source/core/text/itrcrsr.cxx +++ b/sw/source/core/text/itrcrsr.cxx @@ -157,8 +157,10 @@ void SwTxtMargin::CtorInitTxtMargin( SwTxtFrm *pNewFrm, SwTxtSizeInfo *pNewInf ) GetInfo().SetFont( GetFnt() ); const SwTxtNode *pNode = pFrm->GetTxtNode(); - const SvxLRSpaceItem &rSpace = - pFrm->GetTxtNode()->GetSwAttrSet().GetLRSpace(); + const SvxLRSpaceItem &rSpace = pFrm->GetTxtNode()->GetSwAttrSet().GetLRSpace(); + // --> OD 2009-09-02 #i95907# + const bool bListLevelIndentsApplicable = pFrm->GetTxtNode()->AreListLevelIndentsApplicable(); + // <-- // // Carefully adjust the text formatting ranges. @@ -181,8 +183,13 @@ void SwTxtMargin::CtorInitTxtMargin( SwTxtFrm *pNewFrm, SwTxtSizeInfo *pNewInf ) pFrm->Prt().Left() + nLMWithNum - pNode->GetLeftMarginWithNum( sal_False ) - - rSpace.GetLeft() + - rSpace.GetTxtLeft(); + // --> OD 2009-09-02 #i95907# +// rSpace.GetLeft() + +// rSpace.GetTxtLeft(); + ( bListLevelIndentsApplicable + ? 0 + : ( rSpace.GetLeft() - rSpace.GetTxtLeft() ) ); + // <-- } else { @@ -193,8 +200,13 @@ void SwTxtMargin::CtorInitTxtMargin( SwTxtFrm *pNewFrm, SwTxtSizeInfo *pNewInf ) pFrm->Prt().Left() + nLMWithNum - pNode->GetLeftMarginWithNum( sal_False ) - - rSpace.GetLeft() + - rSpace.GetTxtLeft(); + // --> OD 2009-09-02 #i95907# +// rSpace.GetLeft() + +// rSpace.GetTxtLeft(); + ( bListLevelIndentsApplicable + ? 0 + : ( rSpace.GetLeft() - rSpace.GetTxtLeft() ) ); + // <-- } else { diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index d9d69343b0..57dacd703a 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -107,6 +107,7 @@ void SwTxtFormatter::CtorInitTxtFormatter( SwTxtFrm *pNewFrm, SwTxtFormatInfo *p nCntMidHyph = 0; nLeftScanIdx = STRING_LEN; nRightScanIdx = 0; + m_nHintEndIndex = 0; if( nStart > GetInfo().GetTxt().Len() ) { @@ -313,7 +314,14 @@ SwLinePortion *SwTxtFormatter::UnderFlow( SwTxtFormatInfo &rInf ) } } pPor->Truncate(); - delete rInf.GetRest(); + SwLinePortion *const pRest( rInf.GetRest() ); + if (pRest && pRest->InFldGrp() && + static_cast<SwFldPortion*>(pRest)->IsNoLength()) + { + // HACK: decrement again, so we pick up the suffix in next line! + --m_nHintEndIndex; + } + delete pRest; rInf.SetRest(0); return pPor; } @@ -820,6 +828,34 @@ void SwTxtFormatter::CalcAscent( SwTxtFormatInfo &rInf, SwLinePortion *pPor ) } /************************************************************************* + * class SwMetaPortion + *************************************************************************/ + +class SwMetaPortion : public SwTxtPortion +{ +public: + inline SwMetaPortion() { SetWhichPor( POR_META ); } + virtual void Paint( const SwTxtPaintInfo &rInf ) const; +// OUTPUT_OPERATOR +}; + +//CLASSIO( SwMetaPortion ) + +/************************************************************************* + * virtual SwMetaPortion::Paint() + *************************************************************************/ + +void SwMetaPortion::Paint( const SwTxtPaintInfo &rInf ) const +{ + if ( Width() ) + { + rInf.DrawViewOpt( *this, POR_META ); + SwTxtPortion::Paint( rInf ); + } +} + + +/************************************************************************* * SwTxtFormatter::WhichTxtPor() *************************************************************************/ @@ -832,6 +868,10 @@ SwTxtPortion *SwTxtFormatter::WhichTxtPor( SwTxtFormatInfo &rInf ) const { if( GetFnt()->IsRef() ) pPor = new SwRefPortion; + else if (GetFnt()->IsMeta()) + { + pPor = new SwMetaPortion; + } else { // Erst zum Schluss ! @@ -1068,6 +1108,12 @@ SwLinePortion *SwTxtFormatter::WhichFirstPortion(SwTxtFormatInfo &rInf) pPor = NewTabPortion( rInf, true ); } + // 11) suffix of meta-field + if (!pPor) + { + pPor = TryNewNoLengthPortion(rInf); + } + return pPor; } @@ -1973,6 +2019,7 @@ long SwTxtFormatter::CalcOptRepaint( xub_StrLen nOldLineEnd, nReformat -= 2; #ifndef QUARTZ +#ifndef ENABLE_GRAPHITE // --> FME 2004-09-27 #i28795#, #i34607#, #i38388# // step back six(!) more characters for complex scripts // this is required e.g., for Khmer (thank you, Javier!) @@ -1981,6 +2028,10 @@ long SwTxtFormatter::CalcOptRepaint( xub_StrLen nOldLineEnd, if( ::i18n::ScriptType::COMPLEX == rSI.ScriptType( nReformat ) ) nMaxContext = 6; #else + // Some Graphite fonts need context for scripts not marked as complex + static const xub_StrLen nMaxContext = 10; +#endif +#else // some fonts like Quartz's Zapfino need more context // TODO: query FontInfo for maximum unicode context static const xub_StrLen nMaxContext = 8; diff --git a/sw/source/core/text/itrform2.hxx b/sw/source/core/text/itrform2.hxx index f5732ced0b..ec6fce1958 100644 --- a/sw/source/core/text/itrform2.hxx +++ b/sw/source/core/text/itrform2.hxx @@ -60,6 +60,7 @@ class SwTxtFormatter : public SwTxtPainter sal_Bool bChanges : 1; // Flag, fuer die Berechnung des Repaint-Rechtecks sal_Bool bTruncLines : 1; // Flag, Repaint-Rechtecks ggf. erweitern sal_Bool bUnclipped : 1; // Flag, ob Repaint groesser als feste Zeilenhoehe + USHORT m_nHintEndIndex; // HACK for TryNewNoLengthPortion SwLinePortion *NewPortion( SwTxtFormatInfo &rInf ); SwTxtPortion *NewTxtPortion( SwTxtFormatInfo &rInf ); SwLinePortion *NewExtraPortion( SwTxtFormatInfo &rInf ); @@ -75,6 +76,7 @@ class SwTxtFormatter : public SwTxtPainter SwTxtAttr *pHt ) const; SwLinePortion *WhichFirstPortion( SwTxtFormatInfo &rInf ); SwTxtPortion *WhichTxtPor( SwTxtFormatInfo &rInf ) const; + SwExpandPortion * TryNewNoLengthPortion( SwTxtFormatInfo & rInfo ); // Das Herzstueck der Formatierung void BuildPortions( SwTxtFormatInfo &rInf ); diff --git a/sw/source/core/text/itrpaint.cxx b/sw/source/core/text/itrpaint.cxx index fc5ebbf16c..550b8fb291 100644 --- a/sw/source/core/text/itrpaint.cxx +++ b/sw/source/core/text/itrpaint.cxx @@ -48,7 +48,6 @@ #include <fmtftn.hxx> #include <fmtfld.hxx> #include <fldbas.hxx> // SwField -#include <fmthbsh.hxx> #include <rootfrm.hxx> #include <pagefrm.hxx> #include <pagedesc.hxx> // SwPageDesc diff --git a/sw/source/core/text/makefile.mk b/sw/source/core/text/makefile.mk index 5cb00b9588..fbc000002e 100644 --- a/sw/source/core/text/makefile.mk +++ b/sw/source/core/text/makefile.mk @@ -45,6 +45,9 @@ AUTOSEG=true CDEFS+=-Dmydebug .ENDIF +.IF "$(ENABLE_GRAPHITE)" == "TRUE" +CFLAGS+=-DENABLE_GRAPHITE +.ENDIF # --- Files -------------------------------------------------------- .IF "$(product)$(cap)" == "" diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx index 096d863194..8fcdbca8e7 100644 --- a/sw/source/core/text/porfld.cxx +++ b/sw/source/core/text/porfld.cxx @@ -85,6 +85,7 @@ SwFldPortion *SwFldPortion::Clone( const XubString &rExpand ) const pNewFnt = new SwFont( *pFnt ); SwFldPortion* pClone = new SwFldPortion( rExpand, pNewFnt ); pClone->SetNextOffset( nNextOffset ); + pClone->m_bNoLength = this->m_bNoLength; return pClone; } @@ -99,6 +100,7 @@ void SwFldPortion::TakeNextOffset( const SwFldPortion* pFld ) SwFldPortion::SwFldPortion( const XubString &rExpand, SwFont *pFont, sal_Bool bPlaceHold ) : aExpand(rExpand), pFnt(pFont), nNextOffset(0), nNextScriptChg(STRING_LEN), nViewWidth(0), bFollow( sal_False ), bHasFollow( sal_False ), bPlaceHolder( bPlaceHold ) + , m_bNoLength( sal_False ) { SetWhichPor( POR_FLD ); } @@ -114,6 +116,7 @@ SwFldPortion::SwFldPortion( const SwFldPortion& rFld ) bCenter( rFld.IsCenter() ), bHasFollow( rFld.HasFollow() ), bPlaceHolder( rFld.bPlaceHolder ) + , m_bNoLength( rFld.m_bNoLength ) { if ( rFld.HasFont() ) pFnt = new SwFont( *rFld.GetFont() ); @@ -215,25 +218,25 @@ SwFldSlot::~SwFldSlot() void SwFldPortion::CheckScript( const SwTxtSizeInfo &rInf ) { String aTxt; - if( GetExpTxt( rInf, aTxt ) && aTxt.Len() && pBreakIt->xBreak.is() ) + if( GetExpTxt( rInf, aTxt ) && aTxt.Len() && pBreakIt->GetBreakIter().is() ) { BYTE nActual = pFnt ? pFnt->GetActual() : rInf.GetFont()->GetActual(); USHORT nScript; { - nScript = pBreakIt->xBreak->getScriptType( aTxt, 0 ); + nScript = pBreakIt->GetBreakIter()->getScriptType( aTxt, 0 ); xub_StrLen nChg = 0; if( i18n::ScriptType::WEAK == nScript ) { - nChg =(xub_StrLen)pBreakIt->xBreak->endOfScript(aTxt,0,nScript); + nChg =(xub_StrLen)pBreakIt->GetBreakIter()->endOfScript(aTxt,0,nScript); if( nChg < aTxt.Len() ) - nScript = pBreakIt->xBreak->getScriptType( aTxt, nChg ); + nScript = pBreakIt->GetBreakIter()->getScriptType( aTxt, nChg ); } // // nNextScriptChg will be evaluated during SwFldPortion::Format() // if ( nChg < aTxt.Len() ) - nNextScriptChg = (xub_StrLen)pBreakIt->xBreak->endOfScript( aTxt, nChg, nScript ); + nNextScriptChg = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( aTxt, nChg, nScript ); else nNextScriptChg = aTxt.Len(); @@ -378,7 +381,7 @@ sal_Bool SwFldPortion::Format( SwTxtFormatInfo &rInf ) // Das Zeichen wird in der ersten Portion gehalten. // Unbedingt nach Format! - SetLen( nFollow ); + SetLen( (m_bNoLength) ? 0 : nFollow ); if( nRest ) { @@ -1127,12 +1130,12 @@ SwCombinedPortion::SwCombinedPortion( const XubString &rTxt ) aExpand.Erase( 6 ); // Initialization of the scripttype array, // the arrays of width and position are filled by the format function - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { BYTE nScr = SW_SCRIPTS; for( USHORT i = 0; i < rTxt.Len(); ++i ) { - USHORT nScript = pBreakIt->xBreak->getScriptType( rTxt, i ); + USHORT nScript = pBreakIt->GetBreakIter()->getScriptType( rTxt, i ); switch ( nScript ) { case i18n::ScriptType::LATIN : nScr = SW_LATIN; break; case i18n::ScriptType::ASIAN : nScr = SW_CJK; break; diff --git a/sw/source/core/text/porfld.hxx b/sw/source/core/text/porfld.hxx index 084b020672..2292a27b78 100644 --- a/sw/source/core/text/porfld.hxx +++ b/sw/source/core/text/porfld.hxx @@ -61,8 +61,12 @@ protected: sal_Bool bNoPaint : 1; // wird von SwGrfNumPortion benutzt sal_Bool bReplace : 1; // wird von SwGrfNumPortion benutzt sal_Bool bPlaceHolder : 1; + sal_Bool m_bNoLength : 1; // HACK for meta suffix (no CH_TXTATR) inline void SetFont( SwFont *pNew ) { pFnt = pNew; } + inline bool IsNoLength() const { return m_bNoLength; } + inline void SetNoLength() { m_bNoLength = sal_True; } + public: SwFldPortion( const SwFldPortion& rFld ); SwFldPortion( const XubString &rExpand, SwFont *pFnt = 0, sal_Bool bPlaceHolder = sal_False ); diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index b8d3de066a..b0e331db47 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: porlay.cxx,v $ - * $Revision: 1.67.190.1 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -45,6 +42,7 @@ #include <porrst.hxx> // SwHangingPortion #include <pormulti.hxx> // SwMultiPortion #include <breakit.hxx> +#include <unicode/uchar.h> #include <com/sun/star/i18n/ScriptType.hdl> #include <com/sun/star/i18n/CTLScriptType.hdl> #include <com/sun/star/i18n/WordType.hdl> @@ -800,7 +798,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode ) void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) { - if( !pBreakIt->xBreak.is() ) + if( !pBreakIt->GetBreakIter().is() ) return; const String& rTxt = rNode.GetTxt(); @@ -909,13 +907,13 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // we go back in our group until we reach the first character of // type nScript while ( nChg > nGrpStart && - nScript != pBreakIt->xBreak->getScriptType( rTxt, nChg ) ) + nScript != pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ) ) --nChg; // If we are at the start of a group, we do not trust nScript, // we better get nScript from the breakiterator: if ( nChg == nGrpStart ) - nScript = (BYTE)pBreakIt->xBreak->getScriptType( rTxt, nChg ); + nScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ); // // INVALID DATA FROM THE SCRIPT INFO ARRAYS HAS TO BE DELETED: @@ -961,14 +959,14 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // SCRIPT FOR WEAK CHARACTERS AT THE BEGINNING OF A PARAGRAPH // - if( WEAK == pBreakIt->xBreak->getScriptType( rTxt, nChg ) ) + if( WEAK == pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ) ) { // If the beginning of the current group is weak, this means that // all of the characters in this grounp are weak. We have to assign // the scripts to these characters depending on the fonts which are // set for these characters to display them. xub_StrLen nEnd = - (xub_StrLen)pBreakIt->xBreak->endOfScript( rTxt, nChg, WEAK ); + (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rTxt, nChg, WEAK ); if( nEnd > rTxt.Len() ) nEnd = rTxt.Len(); @@ -983,7 +981,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // Get next script type or set to weak in order to exit BYTE nNextScript = ( nEnd < rTxt.Len() ) ? - (BYTE)pBreakIt->xBreak->getScriptType( rTxt, nEnd ) : + (BYTE)pBreakIt->GetBreakIter()->getScriptType( rTxt, nEnd ) : (BYTE)WEAK; if ( nScript != nNextScript ) @@ -1005,7 +1003,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) ASSERT( STRING_LEN != nChg, "65K? Strange length of script section" ); xub_StrLen nSearchStt = nChg; - nChg = (xub_StrLen)pBreakIt->xBreak->endOfScript( rTxt, nSearchStt, nScript ); + nChg = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rTxt, nSearchStt, nScript ); if ( nChg > rTxt.Len() ) nChg = rTxt.Len(); @@ -1013,16 +1011,16 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) // --> FME 2008-09-17 #i28203# // for 'complex' portions, we make sure that a portion does not contain more // than one script: - if( pBreakIt->xCTLDetect.is() && i18n::ScriptType::COMPLEX == nScript ) + if( i18n::ScriptType::COMPLEX == nScript && pBreakIt->GetScriptTypeDetector().is() ) { - const short nScriptType = pBreakIt->xCTLDetect->getCTLScriptType( rTxt, nSearchStt ); + const short nScriptType = pBreakIt->GetScriptTypeDetector()->getCTLScriptType( rTxt, nSearchStt ); xub_StrLen nNextCTLScriptStart = nSearchStt; short nCurrentScriptType = nScriptType; while( com::sun::star::i18n::CTLScriptType::CTL_UNKNOWN == nCurrentScriptType || nScriptType == nCurrentScriptType ) { - nNextCTLScriptStart = (xub_StrLen)pBreakIt->xCTLDetect->endOfCTLScriptType( rTxt, nNextCTLScriptStart ); + nNextCTLScriptStart = (xub_StrLen)pBreakIt->GetScriptTypeDetector()->endOfCTLScriptType( rTxt, nNextCTLScriptStart ); if( nNextCTLScriptStart < rTxt.Len() && nNextCTLScriptStart < nChg ) - nCurrentScriptType = pBreakIt->xCTLDetect->getCTLScriptType( rTxt, nNextCTLScriptStart ); + nCurrentScriptType = pBreakIt->GetScriptTypeDetector()->getCTLScriptType( rTxt, nNextCTLScriptStart ); else break; } @@ -1030,7 +1028,26 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) } // <-- - aScriptChg.Insert( nChg, nCnt ); + // special case for dotted circle since it can be used with complex + // before a mark, so we want it associated with the mark's script + if (nChg < rTxt.Len() && nChg > 0 && (i18n::ScriptType::WEAK == + pBreakIt->GetBreakIter()->getScriptType(rTxt,nChg - 1))) + { + int8_t nType = u_charType(rTxt.GetChar(nChg) ); + if (nType == U_NON_SPACING_MARK || nType == U_ENCLOSING_MARK || + nType == U_COMBINING_SPACING_MARK ) + { + aScriptChg.Insert( nChg - 1, nCnt ); + } + else + { + aScriptChg.Insert( nChg, nCnt ); + } + } + else + { + aScriptChg.Insert( nChg, nCnt ); + } aScriptType.Insert( nScript, nCnt++ ); // if current script is asian, we search for compressable characters @@ -1270,7 +1287,7 @@ void SwScriptInfo::InitScriptInfo( const SwTxtNode& rNode, sal_Bool bRTL ) } if ( nChg < rTxt.Len() ) - nScript = (BYTE)pBreakIt->xBreak->getScriptType( rTxt, nChg ); + nScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( rTxt, nChg ); nLastCompression = nChg; nLastKashida = nChg; @@ -1549,7 +1566,7 @@ void SwScriptInfo::DeleteHiddenRanges( SwTxtNode& rNode ) nHiddenStart = *(rFirst++); SwPaM aPam( rNode, nHiddenStart, rNode, nHiddenEnd ); - rNode.getIDocumentContentOperations()->Delete( aPam ); + rNode.getIDocumentContentOperations()->DeleteRange( aPam ); } } diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 6ff2c0ff7a..ea8b756212 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -34,9 +34,7 @@ #include <hintids.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <svx/twolinesitem.hxx> #include <svx/charrotateitem.hxx> #include <vcl/outdev.hxx> @@ -194,13 +192,11 @@ SwRotatedPortion::SwRotatedPortion( const SwMultiCreator& rCreate, if( !pRot ) { const SwTxtAttr& rAttr = *rCreate.pAttr; - if( RES_CHRATR_ROTATE == rAttr.Which() ) - pRot = &rAttr.GetCharRotate(); - else + const SfxPoolItem *const pItem = + CharFmt::GetItem(rAttr, RES_CHRATR_ROTATE); + if ( pItem ) { - const SfxPoolItem* pItem = CharFmt::GetItem( rAttr, RES_CHRATR_ROTATE ); - if ( pItem ) - pRot = (SvxCharRotateItem*)pItem; + pRot = static_cast<const SvxCharRotateItem*>(pItem); } } if( pRot ) @@ -319,13 +315,11 @@ SwDoubleLinePortion::SwDoubleLinePortion( const SwMultiCreator& rCreate, const SwTxtAttr& rAttr = *rCreate.pAttr; pBracket->nStart = *rAttr.GetStart(); - if( RES_CHRATR_TWO_LINES == rAttr.Which() ) - pTwo = &rAttr.Get2Lines(); - else + const SfxPoolItem * const pItem = + CharFmt::GetItem( rAttr, RES_CHRATR_TWO_LINES ); + if ( pItem ) { - const SfxPoolItem* pItem = CharFmt::GetItem( rAttr, RES_CHRATR_TWO_LINES ); - if ( pItem ) - pTwo = (SvxTwoLinesItem*)pItem; + pTwo = static_cast<const SvxTwoLinesItem*>(pItem); } } if( pTwo ) @@ -916,7 +910,7 @@ SwMultiCreator* SwTxtSizeInfo::GetMultiCreator( xub_StrLen &rPos, // for 99% of all cases XubString aTxt = GetTxtFrm()->GetTxtNode()->GetExpandTxt( rPos, 1 ); - if ( pBreakIt->xBreak.is() && aTxt.Len() ) + if ( pBreakIt->GetBreakIter().is() && aTxt.Len() ) { sal_Bool bFldDir = ( i18n::ScriptType::COMPLEX == pBreakIt->GetRealScriptOfText( aTxt, 0 ) ); diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 1c482fc30e..6eeb5492e2 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -97,8 +97,8 @@ USHORT lcl_AddSpace( const SwTxtSizeInfo &rInf, const XubString* pStr, // first we get the script type if ( pSI ) nScript = pSI->ScriptType( nPos ); - else if ( pBreakIt->xBreak.is() ) - nScript = (BYTE)pBreakIt->xBreak->getScriptType( *pStr, nPos ); + else if ( pBreakIt->GetBreakIter().is() ) + nScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( *pStr, nPos ); // Note: rInf.GetIdx() can differ from nPos, // e.g., when rPor is a field portion. nPos referes to the string passed @@ -198,7 +198,7 @@ USHORT lcl_AddSpace( const SwTxtSizeInfo &rInf, const XubString* pStr, if ( pPor && pPor->IsKernPortion() ) pPor = pPor->GetPortion(); - if ( ! pBreakIt->xBreak.is() || ! pPor || pPor->InFixMargGrp() ) + if ( ! pBreakIt->GetBreakIter().is() || ! pPor || pPor->InFixMargGrp() ) return nCnt; // next character is inside a field? @@ -211,10 +211,10 @@ USHORT lcl_AddSpace( const SwTxtSizeInfo &rInf, const XubString* pStr, pPor->GetExpTxt( rInf, aStr ); ((SwTxtSizeInfo &)rInf).SetOnWin( bOldOnWin ); - nNextScript = (BYTE)pBreakIt->xBreak->getScriptType( aStr, 0 ); + nNextScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( aStr, 0 ); } else - nNextScript = (BYTE)pBreakIt->xBreak->getScriptType( rInf.GetTxt(), nPos ); + nNextScript = (BYTE)pBreakIt->GetBreakIter()->getScriptType( rInf.GetTxt(), nPos ); if( ASIAN == nNextScript ) { diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx index 9ae6b7a74a..3a9a7a1072 100644 --- a/sw/source/core/text/redlnitr.cxx +++ b/sw/source/core/text/redlnitr.cxx @@ -110,7 +110,7 @@ void SwAttrIter::CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, S if ( pScriptInfo->GetInvalidity() != STRING_LEN ) pScriptInfo->InitScriptInfo( rTxtNode, bRTL ); - if ( pBreakIt->xBreak.is() ) + if ( pBreakIt->GetBreakIter().is() ) { pFnt->SetActual( SwScriptInfo::WhichFont( 0, 0, pScriptInfo ) ); @@ -263,7 +263,8 @@ short SwRedlineItr::_Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld ) pSet->ClearItem(); else { - SwAttrPool& rPool = (SwAttrPool& )rDoc.GetAttrPool(); + SwAttrPool& rPool = + const_cast<SwDoc&>(rDoc).GetAttrPool(); pSet = new SfxItemSet(rPool, RES_CHRATR_BEGIN, RES_CHRATR_END-1); } @@ -279,7 +280,9 @@ short SwRedlineItr::_Seek( SwFont& rFnt, xub_StrLen nNew, xub_StrLen nOld ) if( ( nWhich < RES_CHRATR_END ) && ( SFX_ITEM_SET == pSet->GetItemState( nWhich, sal_True, &pItem ) ) ) { - SwTxtAttr* pAttr = ((SwTxtNode&)rNd).MakeRedlineTxtAttr( *pItem ); + SwTxtAttr* pAttr = MakeRedlineTxtAttr( + const_cast<SwDoc&>(rDoc), + *const_cast<SfxPoolItem*>(pItem) ); pAttr->SetPriorityAttr( sal_True ); aHints.C40_INSERT( SwTxtAttr, pAttr, aHints.Count()); rAttrHandler.PushAndChg( *pAttr, rFnt ); @@ -352,7 +355,7 @@ void SwRedlineItr::_Clear( SwFont* pFnt ) rAttrHandler.PopAndChg( *pPos, *pFnt ); else rAttrHandler.Pop( *pPos ); - delete pPos; + SwTxtAttr::Destroy(pPos, const_cast<SwDoc&>(rDoc).GetAttrPool() ); } if( pFnt ) pFnt->SetNoCol( sal_False ); diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index 89e519bcd2..475beaecb3 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -152,19 +152,7 @@ SwDropPortion::~SwDropPortion() sal_Bool SwTxtSizeInfo::_HasHint( const SwTxtNode* pTxtNode, xub_StrLen nPos ) { - const SwpHints *pHints = pTxtNode->GetpSwpHints(); - if( !pHints ) - return sal_False; - for ( USHORT i = 0; i < pHints->Count(); ++i ) - { - const SwTxtAttr *pPos = (*pHints)[i]; - xub_StrLen nStart = *pPos->GetStart(); - if( nPos < nStart ) - return sal_False; - if( nPos == nStart && !pPos->GetEnd() ) - return sal_True; - } - return sal_False; + return 0 != pTxtNode->GetTxtAttrForCharAt(nPos); } /************************************************************************* @@ -179,7 +167,7 @@ MSHORT SwTxtNode::GetDropLen( MSHORT nWishLen ) const if( nWishLen && nWishLen < nEnd ) nEnd = nWishLen; - if ( ! nWishLen && pBreakIt->xBreak.is() ) + if ( ! nWishLen && pBreakIt->GetBreakIter().is() ) { // find first word const SwAttrSet& rAttrSet = GetSwAttrSet(); @@ -201,7 +189,7 @@ MSHORT SwTxtNode::GetDropLen( MSHORT nWishLen ) const } Boundary aBound = - pBreakIt->xBreak->getWordBoundary( GetTxt(), 0, + pBreakIt->GetBreakIter()->getWordBoundary( GetTxt(), 0, pBreakIt->GetLocale( eLanguage ), WordType::DICTIONARY_WORD, sal_True ); nEnd = (xub_StrLen)aBound.endPos; diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx index 202cbb886a..4eae178d3e 100644 --- a/sw/source/core/text/txtfld.cxx +++ b/sw/source/core/text/txtfld.cxx @@ -63,6 +63,7 @@ #include "docufld.hxx" #include "pagedesc.hxx" // NewFldPortion, GetNum() #include <pormulti.hxx> // SwMultiPortion +#include "fmtmeta.hxx" // lcl_NewMetaPortion /************************************************************************* @@ -257,12 +258,65 @@ SwExpandPortion *SwTxtFormatter::NewFldPortion( SwTxtFormatInfo &rInf, return pRet; } +/************************************************************************* + * SwTxtFormatter::TryNewNoLengthPortion() + *************************************************************************/ + +SwFldPortion * lcl_NewMetaPortion(SwTxtAttr & rHint, const bool bPrefix) +{ + ::sw::Meta *const pMeta( + static_cast<SwFmtMeta &>(rHint.GetAttr()).GetMeta() ); + ::rtl::OUString fix; + ::sw::MetaField *const pField( dynamic_cast< ::sw::MetaField * >(pMeta) ); + OSL_ENSURE(pField, "lcl_NewMetaPortion: no meta field?"); + if (pField) + { + pField->GetPrefixAndSuffix((bPrefix) ? &fix : 0, (bPrefix) ? 0 : &fix); + } + return new SwFldPortion( fix ); +} + +/** Try to create a new portion with zero length, for an end of a hint + (where there is no CH_TXTATR). Because there may be multiple hint ends at a + given index, m_nHintEndIndex is used to keep track of the already created + portions. But the portions created here may actually be deleted again, + due to UnderFlow. In that case, m_nHintEndIndex must be decremented, + so the portion will be created again on the next line. + */ +SwExpandPortion * +SwTxtFormatter::TryNewNoLengthPortion(SwTxtFormatInfo & rInfo) +{ + if (pHints) + { + const xub_StrLen nIdx(rInfo.GetIdx()); + while (m_nHintEndIndex < pHints->GetEndCount()) + { + SwTxtAttr & rHint( *pHints->GetEnd(m_nHintEndIndex) ); + xub_StrLen const nEnd( *rHint.GetAnyEnd() ); + if (nEnd > nIdx) + { + break; + } + ++m_nHintEndIndex; + if (nEnd == nIdx) + { + if (RES_TXTATR_METAFIELD == rHint.Which()) + { + SwFldPortion *const pPortion( + lcl_NewMetaPortion(rHint, false)); + pPortion->SetNoLength(); // no CH_TXTATR at hint end! + return pPortion; + } + } + } + } + return 0; +} /************************************************************************* * SwTxtFormatter::NewExtraPortion() *************************************************************************/ - SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) { SwTxtAttr *pHint = GetAttr( rInf.GetIdx() ); @@ -290,16 +344,6 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) pRet = NewFtnPortion( rInf, pHint ); break; } - case RES_TXTATR_SOFTHYPH : - { - pRet = new SwSoftHyphPortion; - break; - } - case RES_TXTATR_HARDBLANK : - { - pRet = new SwBlankPortion( ((SwTxtHardBlank*)pHint)->GetChar() ); - break; - } case RES_TXTATR_FIELD : { pRet = NewFldPortion( rInf, pHint ); @@ -315,6 +359,11 @@ SwLinePortion *SwTxtFormatter::NewExtraPortion( SwTxtFormatInfo &rInf ) pRet = new SwIsoToxPortion; break; } + case RES_TXTATR_METAFIELD: + { + pRet = lcl_NewMetaPortion( *pHint, true ); + break; + } default: ; } if( !pRet ) diff --git a/sw/source/core/text/txtfrm.cxx b/sw/source/core/text/txtfrm.cxx index 64f9fd1c7f..8da2cbf4fb 100644 --- a/sw/source/core/text/txtfrm.cxx +++ b/sw/source/core/text/txtfrm.cxx @@ -500,26 +500,10 @@ bool lcl_HideObj( const SwTxtFrm& _rFrm, _rFrm.GetTxtNode()->GetTxt().GetChar( _nObjAnchorPos ); if ( cAnchorChar == CH_TXTATR_BREAKWORD ) { - SwpHints* pHints = - const_cast<SwTxtFrm&>(_rFrm).GetTxtNode()->GetpSwpHints(); - const SwTxtAttr* pHint( 0 ); - if( pHints ) - { - for ( USHORT i = 0; i < pHints->Count(); ++i ) - { - SwTxtAttr* pPos = pHints->GetTextHint(i); - xub_StrLen nStart = *pPos->GetStart(); - if ( _nObjAnchorPos < nStart ) - break; - if ( _nObjAnchorPos == nStart && !pPos->GetEnd() ) - { - pHint = pPos; - break; - } - } - } - if ( pHint && - pHint->Which() == RES_TXTATR_FLYCNT ) + const SwTxtAttr* const pHint( + _rFrm.GetTxtNode()->GetTxtAttrForCharAt(_nObjAnchorPos, + RES_TXTATR_FLYCNT) ); + if ( pHint ) { const SwFrmFmt* pFrmFmt = static_cast<const SwTxtFlyCnt*>(pHint)->GetFlyCnt().GetFrmFmt(); @@ -1040,7 +1024,7 @@ void SwTxtFrm::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) _InvalidateRange( SwCharRange( nPos, nLen) ); MSHORT nTmp = ((SwUpdateAttr*)pNew)->nWhichAttr; - if( ! nTmp || RES_TXTATR_CHARFMT == nTmp || RES_TXTATR_AUTOFMT || + if( ! nTmp || RES_TXTATR_CHARFMT == nTmp || RES_TXTATR_AUTOFMT == nTmp || RES_FMT_CHG == nTmp || RES_ATTRSET_CHG == nTmp ) { SET_WRONG( nPos, nPos + nLen, false ) diff --git a/sw/source/core/text/txthyph.cxx b/sw/source/core/text/txthyph.cxx index a92b77b11e..602cc4803d 100644 --- a/sw/source/core/text/txthyph.cxx +++ b/sw/source/core/text/txthyph.cxx @@ -89,7 +89,7 @@ sal_Bool SwTxtFrm::Hyphenate( SwInterHyphInfo &rHyphInf ) { ASSERT( ! IsVertical() || ! IsSwapped(),"swapped frame at SwTxtFrm::Hyphenate" ); - if( !pBreakIt->xBreak.is() ) + if( !pBreakIt->GetBreakIter().is() ) return sal_False;; // Wir machen den Laden erstmal dicht: ASSERT( !IsLocked(), "SwTxtFrm::Hyphenate: this is locked" ); @@ -254,7 +254,7 @@ sal_Bool SwTxtFormatter::Hyphenate( SwInterHyphInfo &rHyphInf ) Reference< XHyphenatedWord > xHyphWord; Boundary aBound = - pBreakIt->xBreak->getWordBoundary( rInf.GetTxt(), nWrdStart, + pBreakIt->GetBreakIter()->getWordBoundary( rInf.GetTxt(), nWrdStart, pBreakIt->GetLocale( rInf.GetFont()->GetLanguage() ), WordType::DICTIONARY_WORD, sal_True ); nWrdStart = static_cast<xub_StrLen>(aBound.startPos); nLen = static_cast<xub_StrLen>(aBound.endPos - nWrdStart); diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index e713bc3748..5a128fbf8a 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -223,7 +223,7 @@ void SwTOXSortTabBase::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, GetTxt( sMyTxt, sMyTxtReading ); - rNd.Insert( sMyTxt, rInsPos ); + rNd.InsertText( sMyTxt, rInsPos ); } BOOL SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp ) @@ -459,7 +459,7 @@ void SwTOXIndex::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) cons else GetTxt( sTmp, sTmpReading ); - rNd.Insert( sTmp, rInsPos ); + rNd.InsertText( sTmp, rInsPos ); } @@ -582,7 +582,7 @@ void SwTOXContent::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) co { String sTmp, sTmpReading; GetTxt( sTmp, sTmpReading ); - rNd.Insert( sTmp, rInsPos ); + rNd.InsertText( sTmp, rInsPos ); } } @@ -684,7 +684,7 @@ void SwTOXPara::FillText( SwTxtNode& rNd, const SwIndex& rInsPos, USHORT ) const String sTmp, sTmpReading; GetTxt( sTmp, sTmpReading ); sTmp.SearchAndReplaceAll('\t', ' '); - rNd.Insert( sTmp, rInsPos ); + rNd.InsertText( sTmp, rInsPos ); } } @@ -718,40 +718,49 @@ String SwTOXPara::GetURL() const { const SwTxtNode * pTxtNd = static_cast<const SwTxtNode *>(pNd); - //if( MAXLEVEL >= pTxtNd->GetTxtColl()->GetOutlineLevel()) //#outline level,zhaojianwei - if ( pTxtNd->GetAttrOutlineLevel() > 0) //<-end,zhaojianwei - { - aTxt = '#'; - const SwNumRule * pRule = pTxtNd->GetNumRule(); - if( pRule ) - { - // dann noch die rel. Nummer davor setzen - const USHORT nCurrLevel = static_cast<USHORT>(pTxtNd->GetActualListLevel()); - if(nCurrLevel <= MAXLEVEL) - { - // --> OD 2005-11-02 #i51089 - TUNING# - if ( pTxtNd->GetNum() ) - { - SwNumberTree::tNumberVector aNumVector = - pTxtNd->GetNumberVector(); - - for( USHORT n = 0; n <= nCurrLevel; ++n ) - { - int nNum = aNumVector[ n ]; - nNum -= ( pRule->Get( n ).GetStart() - 1 ); - ( aTxt += String::CreateFromInt32( nNum )) += '.'; - } - } - else - { - ASSERT( false, - "<SwTOXPara::GetURL()> - text node with numbering rule, but without number. This is a serious defect -> inform OD" ); - } - } - } - aTxt += pTxtNd->GetExpandTxt(); - ( aTxt += cMarkSeperator ).AppendAscii( pMarkToOutline ); - } + // --> OD 2009-08-05 #i103265# +// //if( MAXLEVEL >= pTxtNd->GetTxtColl()->GetOutlineLevel()) //#outline level,zhaojianwei +// if ( pTxtNd->GetAttrOutlineLevel() > 0) //<-end,zhaojianwei +// { +// aTxt = '#'; +// const SwNumRule * pRule = pTxtNd->GetNumRule(); +// if( pRule ) +// { +// // dann noch die rel. Nummer davor setzen +// const USHORT nCurrLevel = static_cast<USHORT>(pTxtNd->GetActualListLevel()); +// if(nCurrLevel <= MAXLEVEL) +// { +// // --> OD 2005-11-02 #i51089 - TUNING# +// if ( pTxtNd->GetNum() ) +// { +// SwNumberTree::tNumberVector aNumVector = +// pTxtNd->GetNumberVector(); + +// for( USHORT n = 0; n <= nCurrLevel; ++n ) +// { +// int nNum = aNumVector[ n ]; +// nNum -= ( pRule->Get( n ).GetStart() - 1 ); +// ( aTxt += String::CreateFromInt32( nNum )) += '.'; +// } +// } +// else +// { +// ASSERT( false, +// "<SwTOXPara::GetURL()> - text node with numbering rule, but without number. This is a serious defect -> inform OD" ); +// } +// } +// } +// aTxt += pTxtNd->GetExpandTxt(); +// ( aTxt += cMarkSeperator ).AppendAscii( pMarkToOutline ); +// } + SwDoc* pDoc = const_cast<SwDoc*>( pTxtNd->GetDoc() ); + ::sw::mark::IMark const * const pMark = pDoc->getIDocumentMarkAccess()->getMarkForTxtNode( + *(pTxtNd), + IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK); + aTxt = '#'; + const String aMarkName( pMark->GetName() ); + aTxt += aMarkName; + // <-- } break; @@ -895,7 +904,7 @@ void SwTOXAuthority::FillText( SwTxtNode& rNd, } else sText = (pField->GetFieldText((ToxAuthorityField) nAuthField)); - rNd.Insert( sText, rInsPos ); + rNd.InsertText( sText, rInsPos ); } /* -----------------14.10.99 09:35------------------- @@ -943,4 +952,3 @@ BOOL SwTOXAuthority::operator<( const SwTOXSortTabBase& rBase) } return bRet; } - diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx index 2db1dfa22d..5248100afd 100644 --- a/sw/source/core/txtnode/atrfld.cxx +++ b/sw/source/core/txtnode/atrfld.cxx @@ -166,6 +166,8 @@ void SwFmtFld::Modify( SfxPoolItem* pOld, SfxPoolItem* pNew ) { switch( pNew->Which() ) { + case RES_OBJECTDYING: + return; // don't do anything, especially not expand! case RES_TXTATR_FLDCHG: // "Farbe hat sich geaendert !" // this, this fuer "nur Painten" @@ -261,6 +263,7 @@ SwTxtFld::SwTxtFld( SwFmtFld& rAttr, xub_StrLen nStartPos ) , m_pTxtNode( 0 ) { rAttr.pTxtAttr = this; + SetHasDummyChar(true); } SwTxtFld::~SwTxtFld( ) @@ -386,9 +389,4 @@ void SwTxtFld::NotifyContentChange(SwFmtFld& rFmtFld) } } -// #111840# -SwPosition * SwTxtFld::GetPosition() const -{ - return GetTxtNode().GetPosition(this); -} diff --git a/sw/source/core/txtnode/atrflyin.cxx b/sw/source/core/txtnode/atrflyin.cxx index e9f1debf16..92cbc614d6 100644 --- a/sw/source/core/txtnode/atrflyin.cxx +++ b/sw/source/core/txtnode/atrflyin.cxx @@ -74,6 +74,7 @@ SwTxtFlyCnt::SwTxtFlyCnt( SwFmtFlyCnt& rAttr, xub_StrLen nStartPos ) : SwTxtAttr( rAttr, nStartPos ) { rAttr.pTxtAttr = this; + SetHasDummyChar(true); } diff --git a/sw/source/core/txtnode/atrftn.cxx b/sw/source/core/txtnode/atrftn.cxx index 3edd5758cb..73640e2ba6 100644 --- a/sw/source/core/txtnode/atrftn.cxx +++ b/sw/source/core/txtnode/atrftn.cxx @@ -182,6 +182,7 @@ SwTxtFtn::SwTxtFtn( SwFmtFtn& rAttr, xub_StrLen nStartPos ) , m_nSeqNo( USHRT_MAX ) { rAttr.pTxtAttr = this; + SetHasDummyChar(true); } @@ -291,7 +292,7 @@ void SwTxtFtn::SetNumber( const USHORT nNewNum, const XubString* pStr ) } // Die Fussnoten duplizieren -void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) +void SwTxtFtn::CopyFtn( SwTxtFtn *pDest ) const { if ( m_pStartNode && pDest->GetStartNode() ) { diff --git a/sw/source/core/txtnode/atrref.cxx b/sw/source/core/txtnode/atrref.cxx index 054f5c950a..831d604fb3 100644 --- a/sw/source/core/txtnode/atrref.cxx +++ b/sw/source/core/txtnode/atrref.cxx @@ -91,7 +91,10 @@ SwTxtRefMark::SwTxtRefMark( SwFmtRefMark& rAttr, m_nEnd = *pEnd; m_pEnd = & m_nEnd; } - SetDontMergeAttr( true ); + else + { + SetHasDummyChar(true); + } SetDontMoveAttr( true ); SetOverlapAllowedAttr( true ); } diff --git a/sw/source/core/txtnode/atrtox.cxx b/sw/source/core/txtnode/atrtox.cxx index a7e86ac4b8..4cee6eef1b 100644 --- a/sw/source/core/txtnode/atrtox.cxx +++ b/sw/source/core/txtnode/atrtox.cxx @@ -50,7 +50,10 @@ SwTxtTOXMark::SwTxtTOXMark( SwTOXMark& rAttr, m_nEnd = *pEnd; m_pEnd = & m_nEnd; } - SetDontMergeAttr( true ); + else + { + SetHasDummyChar(true); + } SetDontMoveAttr( true ); SetOverlapAllowedAttr( true ); } diff --git a/sw/source/core/txtnode/fmtatr1.cxx b/sw/source/core/txtnode/fmtatr1.cxx deleted file mode 100644 index f9073335c0..0000000000 --- a/sw/source/core/txtnode/fmtatr1.cxx +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: fmtatr1.cxx,v $ - * $Revision: 1.6 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sw.hxx" - - - -#include <hintids.hxx> -#include <errhdl.hxx> -#include <fmthbsh.hxx> - - -/************************************************************************* -|* -|* class SwFmtHardBlank -|* -|* Beschreibung Dokument 1.20 -|* Ersterstellung JP 23.11.90 -|* Letzte Aenderung JP 20.02.91 -|* -*************************************************************************/ - -SwFmtHardBlank::SwFmtHardBlank( sal_Unicode cCh, BOOL ) - : SfxPoolItem( RES_TXTATR_HARDBLANK ), - cChar( cCh ) -{ -// ASSERT( !bCheck || (' ' != cCh && '-' != cCh), -// "Invalid character for the HardBlank attribute - " -// "must be a normal unicode character" ); -} - -int SwFmtHardBlank::operator==( const SfxPoolItem& rAttr ) const -{ - ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" ); - return cChar == ((SwFmtHardBlank&)rAttr).GetChar(); -} - -SfxPoolItem* SwFmtHardBlank::Clone( SfxItemPool* ) const -{ - return new SwFmtHardBlank( *this ); -} - -/************************************************************************* -|* -|* class SwFmtSoftHyph -|* -|* Beschreibung Dokument 1.20 -|* Ersterstellung JP 23.11.90 -|* Letzte Aenderung JP 20.02.91 -|* -*************************************************************************/ - -SwFmtSoftHyph::SwFmtSoftHyph() - : SfxPoolItem( RES_TXTATR_SOFTHYPH ) -{ -} - -int SwFmtSoftHyph::operator==( const SfxPoolItem& ) const -{ -// ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" ); - return TRUE; -} - -SfxPoolItem* SwFmtSoftHyph::Clone( SfxItemPool* ) const -{ - return new SwFmtSoftHyph( *this ); -} - - diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 9e61c7ca70..3d0a043920 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -31,14 +31,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - #include "hintids.hxx" #include "unomid.h" -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #include <svtools/macitem.hxx> #include <svtools/stritem.hxx> #include <svtools/stylepool.hxx> @@ -51,16 +47,24 @@ #include <hints.hxx> // SwUpdateAttr #include <unostyle.hxx> #include <unoevent.hxx> // SwHyperlinkEventDescriptor -#ifndef _COM_SUN_STAR_TEXT_RUBYADJUST_HDL_ #include <com/sun/star/text/RubyAdjust.hdl> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif #include <com/sun/star/uno/Any.h> #include <SwStyleNameMapper.hxx> +#include <fmtmeta.hxx> +#include <ndtxt.hxx> // for meta +#include <doc.hxx> // for meta +#include <unometa.hxx> +#include <unoobj.hxx> // SwXTextRange +#include <docsh.hxx> +#include <svtools/zforlist.hxx> // GetNumberFormat + +#include <boost/bind.hpp> +#include <algorithm> + + using namespace ::com::sun::star; using ::rtl::OUString; @@ -578,3 +582,328 @@ BOOL SwFmtRuby::PutValue( const uno::Any& rVal, return bRet; } + +/************************************************************************* + class SwFmtMeta + ************************************************************************/ + +SwFmtMeta * SwFmtMeta::CreatePoolDefault(const USHORT i_nWhich) +{ + return new SwFmtMeta(i_nWhich); +} + +SwFmtMeta::SwFmtMeta(const USHORT i_nWhich) + : SfxPoolItem( i_nWhich ) + , m_pMeta() + , m_pTxtAttr( 0 ) +{ + ASSERT((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich), + "ERROR: SwFmtMeta: invalid which id!"); +} + +SwFmtMeta::SwFmtMeta( ::boost::shared_ptr< ::sw::Meta > const & i_pMeta, + const USHORT i_nWhich ) + : SfxPoolItem( i_nWhich ) + , m_pMeta( i_pMeta ) + , m_pTxtAttr( 0 ) +{ + ASSERT((RES_TXTATR_META == i_nWhich) || (RES_TXTATR_METAFIELD == i_nWhich), + "ERROR: SwFmtMeta: invalid which id!"); + ASSERT(m_pMeta, "SwFmtMeta: no Meta ?"); + // DO NOT call m_pMeta->SetFmtMeta(this) here; only from SetTxtAttr! +} + +SwFmtMeta::~SwFmtMeta() +{ + if (m_pMeta && (m_pMeta->GetFmtMeta() == this)) + { + m_pMeta->SetFmtMeta(0); + } +} + +int SwFmtMeta::operator==( const SfxPoolItem & i_rOther ) const +{ + ASSERT( SfxPoolItem::operator==( i_rOther ), "i just copied this assert" ); + return SfxPoolItem::operator==( i_rOther ) + && (m_pMeta == static_cast<SwFmtMeta const &>( i_rOther ).m_pMeta); +} + +SfxPoolItem * SwFmtMeta::Clone( SfxItemPool * /*pPool*/ ) const +{ + // if this is indeed a copy, then DoCopy must be called later! + return (m_pMeta) // #i105148# pool default may be cloned also! + ? new SwFmtMeta( m_pMeta, Which() ) : new SwFmtMeta( Which() ); +} + +void SwFmtMeta::SetTxtAttr(SwTxtMeta * const i_pTxtAttr) +{ + ASSERT(!(m_pTxtAttr && i_pTxtAttr), + "SwFmtMeta::SetTxtAttr: already has text attribute?"); + ASSERT( m_pTxtAttr || i_pTxtAttr , + "SwFmtMeta::SetTxtAttr: no attribute to remove?"); + m_pTxtAttr = i_pTxtAttr; + ASSERT(m_pMeta, "inserted SwFmtMeta has no sw::Meta?"); + // the sw::Meta must be able to find the current text attribute! + if (i_pTxtAttr && m_pMeta) + { + m_pMeta->SetFmtMeta(this); + } +} + +void SwFmtMeta::NotifyRemoval() +{ + // N.B.: do not reset m_pTxtAttr here: see call in nodes.cxx, + // where the hint is not deleted! + ASSERT(m_pMeta, "NotifyRemoval: no meta ?"); + if (m_pMeta) + { + SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, + &static_cast<SwModify&>(*m_pMeta) ); // cast to proper base class! + m_pMeta->Modify(&aMsgHint, &aMsgHint); + } +} + +void SwFmtMeta::DoCopy(SwFmtMeta & rOriginalMeta) +{ + ASSERT(m_pMeta, "DoCopy called for SwFmtMeta with no sw::Meta?"); + if (m_pMeta) + { + const ::boost::shared_ptr< ::sw::Meta> pOriginal( m_pMeta ); + // UGLY: original sw::Meta now points at _this_ due to being already + // inserted via MakeTxtAttr! so fix it up to point at the original item + // (maybe would be better to tell MakeTxtAttr that it creates a copy?) + pOriginal->SetFmtMeta(&rOriginalMeta); + if (RES_TXTATR_META == Which()) + { + m_pMeta.reset( new ::sw::Meta(this) ); + } + else + { + ::sw::MetaField *const pMetaField( + static_cast< ::sw::MetaField* >(pOriginal.get())); + SwDoc * const pTargetDoc( GetTxtAttr()->GetTxtNode()->GetDoc() ); + m_pMeta = pTargetDoc->GetMetaFieldManager().makeMetaField( this, + pMetaField->m_nNumberFormat, pMetaField->IsFixedLanguage() ); + } + m_pMeta->RegisterAsCopyOf(*pOriginal); + } +} + + +namespace sw { + +/************************************************************************* + class sw::Meta + ************************************************************************/ + +Meta::Meta(SwFmtMeta * const i_pFmt) + : ::sfx2::Metadatable() + , SwModify() + , m_pFmt( i_pFmt ) +{ +} + +Meta::~Meta() +{ +} + +SwTxtMeta * Meta::GetTxtAttr() const +{ + return (m_pFmt) ? m_pFmt->GetTxtAttr() : 0; +} + +SwTxtNode * Meta::GetTxtNode() const +{ + SwTxtMeta * const pTxtAttr( GetTxtAttr() ); + return (pTxtAttr) ? pTxtAttr->GetTxtNode() : 0; +} + +// SwClient +void Meta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + SwTxtNode * const pTxtNode( GetTxtNode() ); + if (pTxtNode && (GetRegisteredIn() != pTxtNode)) + { + pTxtNode->Add(this); + } + SwModify::Modify(pOld, pNew); +} + +// sw::Metadatable +::sfx2::IXmlIdRegistry& Meta::GetRegistry() +{ + SwTxtNode * const pTxtNode( GetTxtNode() ); + // GetRegistry may only be called on a meta that is actually in the + // document, which means it has a pointer to its text node + OSL_ENSURE(pTxtNode, "ERROR: GetRegistry: no text node?"); + if (!pTxtNode) + throw uno::RuntimeException(); + return pTxtNode->GetRegistry(); +} + +bool Meta::IsInClipboard() const +{ + const SwTxtNode * const pTxtNode( GetTxtNode() ); +// no text node: in UNDO OSL_ENSURE(pTxtNode, "IsInClipboard: no text node?"); + return (pTxtNode) ? pTxtNode->IsInClipboard() : false; +} + +bool Meta::IsInUndo() const +{ + const SwTxtNode * const pTxtNode( GetTxtNode() ); +// no text node: in UNDO OSL_ENSURE(pTxtNode, "IsInUndo: no text node?"); + return (pTxtNode) ? pTxtNode->IsInUndo() : true; +} + +bool Meta::IsInContent() const +{ + const SwTxtNode * const pTxtNode( GetTxtNode() ); + OSL_ENSURE(pTxtNode, "IsInContent: no text node?"); + return (pTxtNode) ? pTxtNode->IsInContent() : true; +} + +::com::sun::star::uno::Reference< ::com::sun::star::rdf::XMetadatable > +Meta::MakeUnoObject() +{ + // re-use existing SwXMeta + SwClientIter iter( *this ); + SwClient * pClient( iter.First( TYPE( SwXMeta ) ) ); + while (pClient) { + SwXMeta *const pMeta( dynamic_cast<SwXMeta*>(pClient) ); + if (pMeta && pMeta->GetCoreObject() == this) { + return pMeta; + } + pClient = iter.Next(); + } + + // create new SwXMeta + SwTxtMeta * const pTxtAttr( GetTxtAttr() ); + OSL_ENSURE(pTxtAttr, "MakeUnoObject: no text attr?"); + if (!pTxtAttr) return 0; + SwTxtNode * const pTxtNode( pTxtAttr->GetTxtNode() ); + OSL_ENSURE(pTxtNode, "MakeUnoObject: no text node?"); + if (!pTxtNode) return 0; + const SwPosition aPos(*pTxtNode, *pTxtAttr->GetStart()); + const uno::Reference<text::XText> xParentText( + SwXTextRange::CreateParentXText(pTxtNode->GetDoc(), aPos) ); + if (!xParentText.is()) return 0; + return (RES_TXTATR_META == m_pFmt->Which()) + ? new SwXMeta (pTxtNode->GetDoc(), xParentText, 0, pTxtAttr) + : new SwXMetaField(pTxtNode->GetDoc(), xParentText, 0, pTxtAttr); +} + +/************************************************************************* + class sw::MetaField + ************************************************************************/ + +MetaField::MetaField(SwFmtMeta * const i_pFmt, + const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage) + : Meta(i_pFmt) + , m_nNumberFormat( nNumberFormat ) + , m_bIsFixedLanguage( bIsFixedLanguage ) +{ +} + +void MetaField::GetPrefixAndSuffix( + ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix) +{ + try + { + const uno::Reference<rdf::XMetadatable> xMetaField( MakeUnoObject() ); + OSL_ENSURE(dynamic_cast<SwXMetaField*>(xMetaField.get()), + "GetPrefixAndSuffix: no SwXMetaField?"); + if (xMetaField.is()) + { + SwTxtNode * const pTxtNode( GetTxtNode() ); + SwDocShell const * const pShell(pTxtNode->GetDoc()->GetDocShell()); + const uno::Reference<frame::XModel> xModel( + (pShell) ? pShell->GetModel() : 0, uno::UNO_SET_THROW); + getPrefixAndSuffix(xModel, xMetaField, o_pPrefix, o_pSuffix); + } + } catch (uno::Exception) { + OSL_ENSURE(false, "exception?"); + } +} + +sal_uInt32 MetaField::GetNumberFormat(::rtl::OUString const & rContent) const +{ + //TODO: this probably lacks treatment for some special cases + sal_uInt32 nNumberFormat( m_nNumberFormat ); + SwTxtNode * const pTxtNode( GetTxtNode() ); + if (pTxtNode) + { + SvNumberFormatter *const pNumberFormatter( + pTxtNode->GetDoc()->GetNumberFormatter() ); + double number; + (void) pNumberFormatter->IsNumberFormat( + rContent, nNumberFormat, number ); + } + return nNumberFormat; +} + +void MetaField::SetNumberFormat(sal_uInt32 nNumberFormat) +{ + // effectively, the member is only a default: + // GetNumberFormat checks if the text actually conforms + m_nNumberFormat = nNumberFormat; +} + + +/************************************************************************* + class sw::MetaFieldManager + ************************************************************************/ + + +MetaFieldManager::MetaFieldManager() +{ +} + +::boost::shared_ptr<MetaField> +MetaFieldManager::makeMetaField(SwFmtMeta * const i_pFmt, + const sal_uInt32 nNumberFormat, const bool bIsFixedLanguage) +{ + const ::boost::shared_ptr<MetaField> pMetaField( + new MetaField(i_pFmt, nNumberFormat, bIsFixedLanguage) ); + m_MetaFields.push_back(pMetaField); + return pMetaField; +} + +struct IsInUndo +{ + bool operator()(::boost::weak_ptr<MetaField> const & pMetaField) { + return pMetaField.lock()->IsInUndo(); + } +}; + +struct MakeUnoObject +{ + uno::Reference<text::XTextField> + operator()(::boost::weak_ptr<MetaField> const & pMetaField) { + return uno::Reference<text::XTextField>( + pMetaField.lock()->MakeUnoObject(), uno::UNO_QUERY); + } +}; + +::std::vector< uno::Reference<text::XTextField> > +MetaFieldManager::getMetaFields() +{ + // erase deleted fields + const MetaFieldList_t::iterator iter( + ::std::remove_if(m_MetaFields.begin(), m_MetaFields.end(), + ::boost::bind(&::boost::weak_ptr<MetaField>::expired, _1))); + m_MetaFields.erase(iter, m_MetaFields.end()); + // filter out fields in UNDO + MetaFieldList_t filtered(m_MetaFields.size()); + const MetaFieldList_t::iterator iter2( + ::std::remove_copy_if(m_MetaFields.begin(), m_MetaFields.end(), + filtered.begin(), IsInUndo())); + filtered.erase(iter2, filtered.end()); + // create uno objects + ::std::vector< uno::Reference<text::XTextField> > ret(filtered.size()); + ::std::transform(filtered.begin(), filtered.end(), ret.begin(), + MakeUnoObject()); + return ret; +} + +} // namespace sw + diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 1e47e16d45..6b8d098618 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -152,6 +152,7 @@ SwFntObj::SwFntObj( const SwSubFont &rFont, const void *pOwn, ViewShell *pSh ) : || UNDERLINE_NONE != aFont.GetOverline() || STRIKEOUT_NONE != aFont.GetStrikeout() ) && !aFont.IsWordLineMode(); + aFont.SetLanguage(rFont.GetLanguage()); } SwFntObj::~SwFntObj() @@ -2424,7 +2425,7 @@ xub_StrLen SwFntObj::GetCrsrOfst( SwDrawTextInfo &rInf ) // skip character cells for complex scripts if ( rInf.GetFont() && SW_CTL == rInf.GetFont()->GetActual() && - pBreakIt->xBreak.is() ) + pBreakIt->GetBreakIter().is() ) { aLang = rInf.GetFont()->GetLanguage(); bSkipCell = sal_True; @@ -2440,7 +2441,7 @@ xub_StrLen SwFntObj::GetCrsrOfst( SwDrawTextInfo &rInf ) if ( bSkipCell ) { - nIdx = (xub_StrLen)pBreakIt->xBreak->nextCharacters( rInf.GetText(), + nIdx = (xub_StrLen)pBreakIt->GetBreakIter()->nextCharacters( rInf.GetText(), nIdx, pBreakIt->GetLocale( aLang ), nItrMode, 1, nDone ); if ( nIdx <= nLastIdx ) break; @@ -2703,13 +2704,13 @@ xub_StrLen SwFont::GetTxtBreak( SwDrawTextInfo& rInf, long nTextWidth ) const XubString aSnippet( rInf.GetText(), rInf.GetIdx(), nLn ); aTmpText = aSub[nActual].CalcCaseMap( aSnippet ); const bool bTitle = SVX_CASEMAP_TITEL == aSub[nActual].GetCaseMap() && - pBreakIt->xBreak.is(); + pBreakIt->GetBreakIter().is(); // Uaaaaahhhh!!! In title case mode, we would get wrong results if ( bTitle && nLn ) { // check if rInf.GetIdx() is begin of word - if ( !pBreakIt->xBreak->isBeginWord( + if ( !pBreakIt->GetBreakIter()->isBeginWord( rInf.GetText(), rInf.GetIdx(), pBreakIt->GetLocale( aSub[nActual].GetLanguage() ), i18n::WordType::ANYWORD_IGNOREWHITESPACES ) ) diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx index e15f975c83..9f32dd7975 100644 --- a/sw/source/core/txtnode/fntcap.cxx +++ b/sw/source/core/txtnode/fntcap.cxx @@ -102,13 +102,13 @@ xub_StrLen lcl_CalcCaseMap( const SwFont& rFnt, // special case for title case: const bool bTitle = SVX_CASEMAP_TITEL == rFnt.GetCaseMap() && - pBreakIt->xBreak.is(); + pBreakIt->GetBreakIter().is(); for ( xub_StrLen i = nOfst; i < nEnd; ++i ) { XubString aTmp( rOrigString, i, 1 ); if ( !bTitle || - pBreakIt->xBreak->isBeginWord( + pBreakIt->GetBreakIter()->isBeginWord( rOrigString, i, pBreakIt->GetLocale( rFnt.GetLanguage() ), WordType::ANYWORD_IGNOREWHITESPACES ) ) @@ -654,7 +654,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) if( nPos < nMaxPos ) { - nPos = (xub_StrLen)pBreakIt->xBreak->endOfCharBlock( rOldText, nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfCharBlock( rOldText, nPos, pBreakIt->GetLocale( eLng ), CharType::LOWERCASE_LETTER); if( nPos == STRING_LEN ) nPos = nOldPos; @@ -702,7 +702,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) rDo.Do(); nOldPos = nPos; } - nPos = (xub_StrLen)pBreakIt->xBreak->nextCharBlock( rOldText, nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->nextCharBlock( rOldText, nPos, pBreakIt->GetLocale( eLng ), CharType::LOWERCASE_LETTER); if( nPos == STRING_LEN || nPos > nMaxPos ) nPos = nMaxPos; @@ -816,7 +816,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) } } while( nOldPos != nPos ); } - nPos = (xub_StrLen)pBreakIt->xBreak->endOfCharBlock( rOldText, nPos, + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfCharBlock( rOldText, nPos, pBreakIt->GetLocale( eLng ), CharType::LOWERCASE_LETTER); if( nPos == STRING_LEN || nPos > nMaxPos ) nPos = nMaxPos; diff --git a/sw/source/core/txtnode/makefile.mk b/sw/source/core/txtnode/makefile.mk index f4fbf70014..36c6e09d6b 100644 --- a/sw/source/core/txtnode/makefile.mk +++ b/sw/source/core/txtnode/makefile.mk @@ -53,7 +53,6 @@ SLOFILES = \ $(SLO)$/atrref.obj \ $(SLO)$/atrtox.obj \ $(SLO)$/chrfmt.obj \ - $(SLO)$/fmtatr1.obj \ $(SLO)$/fmtatr2.obj \ $(SLO)$/fntcap.obj \ $(SLO)$/fntcache.obj \ @@ -71,6 +70,7 @@ SLOFILES = \ EXCEPTIONSFILES = \ + $(SLO)$/fmtatr2.obj \ $(SLO)$/atrtox.obj \ $(SLO)$/atrflyin.obj \ $(SLO)$/docnew.obj \ @@ -78,7 +78,7 @@ EXCEPTIONSFILES = \ $(SLO)$/ndtxt.obj \ $(SLO)$/thints.obj \ $(SLO)$/txtedt.obj - + .IF "$(dbutil)" != "" OFILES+=$(SLO)$/dbchratr.$(QBJX) diff --git a/sw/source/core/txtnode/ndhints.cxx b/sw/source/core/txtnode/ndhints.cxx index 883251c905..c6a2773db0 100644 --- a/sw/source/core/txtnode/ndhints.cxx +++ b/sw/source/core/txtnode/ndhints.cxx @@ -37,6 +37,11 @@ #include "ndhints.hxx" #include <txtatr.hxx> +#ifndef PRODUCT +#include <pam.hxx> +#endif + + _SV_IMPL_SORTAR_ALG( SwpHtStart, SwTxtAttr* ) _SV_IMPL_SORTAR_ALG( SwpHtEnd, SwTxtAttr* ) @@ -99,15 +104,15 @@ static BOOL lcl_IsLessStart( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) { if ( *rHt1.GetStart() == *rHt2.GetStart() ) { - xub_StrLen nHt1 = *rHt1.GetAnyEnd(); - xub_StrLen nHt2 = *rHt2.GetAnyEnd(); + const xub_StrLen nHt1 = *rHt1.GetAnyEnd(); + const xub_StrLen nHt2 = *rHt2.GetAnyEnd(); if ( nHt1 == nHt2 ) { - nHt1 = rHt1.Which(); - nHt2 = rHt2.Which(); - if ( nHt1 == nHt2 ) + const USHORT nWhich1 = rHt1.Which(); + const USHORT nWhich2 = rHt2.Which(); + if ( nWhich1 == nWhich2 ) { - if ( RES_TXTATR_CHARFMT == nHt1 ) + if ( RES_TXTATR_CHARFMT == nWhich1 ) { const USHORT nS1 = static_cast<const SwTxtCharFmt&>(rHt1).GetSortNumber(); const USHORT nS2 = static_cast<const SwTxtCharFmt&>(rHt2).GetSortNumber(); @@ -118,6 +123,8 @@ static BOOL lcl_IsLessStart( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) return (long)&rHt1 < (long)&rHt2; } + // the order must ensure that META is inside RUBY! + return ( nWhich1 < nWhich2 ); } return ( nHt1 > nHt2 ); } @@ -131,18 +138,17 @@ static BOOL lcl_IsLessStart( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) // Zuerst nach Ende danach nach Ptr static BOOL lcl_IsLessEnd( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) { - xub_StrLen nHt1 = *rHt1.GetAnyEnd(); - xub_StrLen nHt2 = *rHt2.GetAnyEnd(); + const xub_StrLen nHt1 = *rHt1.GetAnyEnd(); + const xub_StrLen nHt2 = *rHt2.GetAnyEnd(); if ( nHt1 == nHt2 ) { if ( *rHt1.GetStart() == *rHt2.GetStart() ) { - nHt1 = rHt1.Which(); - nHt2 = rHt2.Which(); - - if ( nHt1 == nHt2 ) + const USHORT nWhich1 = rHt1.Which(); + const USHORT nWhich2 = rHt2.Which(); + if ( nWhich1 == nWhich2 ) { - if ( RES_TXTATR_CHARFMT == nHt1 ) + if ( RES_TXTATR_CHARFMT == nWhich1 ) { const USHORT nS1 = static_cast<const SwTxtCharFmt&>(rHt1).GetSortNumber(); const USHORT nS2 = static_cast<const SwTxtCharFmt&>(rHt2).GetSortNumber(); @@ -153,7 +159,8 @@ static BOOL lcl_IsLessEnd( const SwTxtAttr &rHt1, const SwTxtAttr &rHt2 ) return (long)&rHt1 > (long)&rHt2; } - // else return nHt1 < nHt2, see below + // the order must ensure that META is inside RUBY! + return ( nWhich1 > nWhich2 ); } else return ( *rHt1.GetStart() > *rHt2.GetStart() ); @@ -375,6 +382,37 @@ bool SwpHintsArray::Check() const ( *pHtThis->GetStart() == *pHtThis->GetEnd() ), "HintsCheck: Portion inconsistency. " "This can be temporarily ok during undo operations" ); + + if (pHtThis->IsNesting()) + { + for ( USHORT j = 0; j < Count(); ++j ) + { + SwTxtAttr const * const pOther( m_HintStarts[j] ); + if ( pOther->IsNesting() && (i != j) ) + { + SwComparePosition cmp = ComparePosition( + *pHtThis->GetStart(), *pHtThis->GetEnd(), + *pOther->GetStart(), *pOther->GetEnd()); + CHECK_ERR( (POS_OVERLAP_BEFORE != cmp) && + (POS_OVERLAP_BEHIND != cmp), + "HintsCheck: overlapping nesting hints!!!" ); + } + } + } + + // 9) dummy char check (unfortunately cannot check SwTxtNode::m_Text) + if (pHtThis->HasDummyChar()) + { + for ( USHORT j = 0; j < i; ++j ) + { + SwTxtAttr const * const pOther( m_HintStarts[j] ); + if (pOther->HasDummyChar()) + { + CHECK_ERR( (*pOther->GetStart() != *pHtThis->GetStart()), + "HintsCheck: multiple hints claim same CH_TXTATR!"); + } + } + } #endif } return true; diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 80e88e673b..a0740a35b0 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -52,7 +52,6 @@ #include <fmtinfmt.hxx> #include <fmtpdsc.hxx> #include <txtatr.hxx> -#include <fmthbsh.hxx> #include <fmtrfmrk.hxx> #include <txttxmrk.hxx> #include <fchrfmt.hxx> @@ -64,6 +63,7 @@ #include <ftnidx.hxx> #include <ftninfo.hxx> #include <fmtftn.hxx> +#include <fmtmeta.hxx> #include <charfmt.hxx> #include <ndtxt.hxx> #include <doc.hxx> @@ -234,7 +234,6 @@ SwTxtNode::SwTxtNode( const SwNodeIndex &rWhere, mpNodeNum( 0 ), m_bLastOutlineState( false ), m_bNotifiable( false ), - //nOutlineLevel( pTxtColl->GetOutlineLevel() )//#outline level, removed by zhaojianwei. // --> OD 2008-11-19 #i70748# mbEmptyListStyleSetDueToSetOutlineLevelAttr( false ), // <-- @@ -253,6 +252,15 @@ SwTxtNode::SwTxtNode( const SwNodeIndex &rWhere, // SyncNumberAndNumRule(); if ( !IsInList() && GetNumRule() && GetListId().Len() > 0 ) { + // --> OD 2009-08-27 #i101516# + // apply paragraph style's assigned outline style list level as + // list level of the paragraph, if it has none set already. + if ( !HasAttrListLevel() && + pTxtColl && pTxtColl->IsAssignedToListLevelOfOutlineStyle() ) + { + SetAttrListLevel( pTxtColl->GetAssignedOutlineStyleLevel() ); + } + // <-- AddToList(); } // <-- @@ -390,9 +398,10 @@ void lcl_ChangeFtnRef( SwTxtNode &rNode ) SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) { // lege den Node "vor" mir an - xub_StrLen nSplitPos = rPos.nContent.GetIndex(); - xub_StrLen nTxtLen = m_Text.Len(); - SwTxtNode* pNode = _MakeNewTxtNode( rPos.nNode, FALSE, nSplitPos==nTxtLen ); + const xub_StrLen nSplitPos = rPos.nContent.GetIndex(); + const xub_StrLen nTxtLen = m_Text.Len(); + SwTxtNode* const pNode = + _MakeNewTxtNode( rPos.nNode, FALSE, nSplitPos==nTxtLen ); // the first paragraph gets the XmlId, // _except_ if it is empty and the second is not empty @@ -444,21 +453,27 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) //Ersten Teil des Inhalts in den neuen Node uebertragen und //im alten Node loeschen. SwIndex aIdx( this ); - Cut( pNode, aIdx, nSplitPos ); + CutText( pNode, aIdx, nSplitPos ); if( GetWrong() ) + { pNode->SetWrong( GetWrong()->SplitList( nSplitPos ) ); + } SetWrongDirty( true ); if( GetGrammarCheck() ) + { pNode->SetGrammarCheck( GetGrammarCheck()->SplitGrammarList( nSplitPos ) ); + } SetGrammarCheckDirty( true ); SetWordCountDirty( true ); // SMARTTAGS if( GetSmartTags() ) + { pNode->SetSmartTags( GetSmartTags()->SplitList( nSplitPos ) ); + } SetSmartTagDirty( true ); if ( pNode->HasHints() ) @@ -479,21 +494,22 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) // Attribute loeschen if ( HasHints() ) { - SwTxtAttr* pHt; - xub_StrLen* pEnd; for ( USHORT j = m_pSwpHints->Count(); j; ) { - pHt = m_pSwpHints->GetTextHint( --j ); + SwTxtAttr* const pHt = m_pSwpHints->GetTextHint( --j ); if ( RES_TXTATR_FLYCNT == pHt ->Which() ) { pHt->GetFlyCnt().GetFrmFmt()->DelFrms(); } - else if( pHt->DontExpand() && 0 != ( pEnd = pHt->GetEnd() ) - && *pHt->GetStart() == *pEnd ) + else if ( pHt->DontExpand() ) { - // delete it! - m_pSwpHints->DeleteAtPos( j ); - DestroyAttr( pHt ); + const xub_StrLen* const pEnd = pHt->GetEnd(); + if (pEnd && *pHt->GetStart() == *pEnd ) + { + // delete it! + m_pSwpHints->DeleteAtPos( j ); + DestroyAttr( pHt ); + } } } } @@ -503,6 +519,7 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) SwClientIter aIter( *this ); SwClient* pLastFrm = aIter.GoStart(); if( pLastFrm ) + { do { SwCntntFrm *pFrm = PTR_CAST( SwCntntFrm, pLastFrm ); if ( pFrm ) @@ -512,7 +529,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) ((SwTxtFrm*)pFrm)->GetOfst() ) ((SwTxtFrm*)pFrm)->SetOfst( 0 ); } - } while( 0 != ( pLastFrm = aIter++ )); + pLastFrm = aIter++; + } while ( pLastFrm ); + } if ( IsInCache() ) { @@ -522,13 +541,12 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) UnlockModify(); // Benachrichtigungen wieder freischalten - const SwRootFrm *pRootFrm; + const SwRootFrm * const pRootFrm = pNode->GetDoc()->GetRootFrm(); // If there is an accessible layout we must call modify even // with length zero, because we have to notify about the changed // text node. - if( nTxtLen != nSplitPos || - ( (pRootFrm = pNode->GetDoc()->GetRootFrm()) != 0 && - pRootFrm->IsAnyShellAccessible() ) ) + if ( (nTxtLen != nSplitPos) || + ( pRootFrm && pRootFrm->IsAnyShellAccessible() ) ) { // dann sage den Frames noch, das am Ende etwas "geloescht" wurde @@ -568,18 +586,16 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) SetSmartTagDirty( true ); SwIndex aIdx( this ); - Cut( pNode, aIdx, rPos.nContent.GetIndex() ); + CutText( pNode, aIdx, nSplitPos ); // JP 01.10.96: alle leeren und nicht zu expandierenden // Attribute loeschen if ( HasHints() ) { - SwTxtAttr* pHt; - xub_StrLen* pEnd; for ( USHORT j = m_pSwpHints->Count(); j; ) { - pHt = m_pSwpHints->GetTextHint( --j ); - pEnd = pHt->GetEnd(); + SwTxtAttr* const pHt = m_pSwpHints->GetTextHint( --j ); + const xub_StrLen* const pEnd = pHt->GetEnd(); if ( pHt->DontExpand() && pEnd && (*pHt->GetStart() == *pEnd) ) { // delete it! @@ -610,7 +626,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) } if ( GetDepends() ) + { MakeFrms( *pNode ); // neue Frames anlegen. + } lcl_ChangeFtnRef( *pNode ); } @@ -622,7 +640,9 @@ SwCntntNode *SwTxtNode::SplitCntntNode( const SwPosition &rPos ) const SfxPoolItem *pItem; if( GetDepends() && SFX_ITEM_SET == pNode->GetSwAttrSet(). GetItemState( RES_PAGEDESC, TRUE, &pItem ) ) + { pNode->Modify( (SfxPoolItem*)pItem, (SfxPoolItem*)pItem ); + } } return pNode; } @@ -727,7 +747,7 @@ SwCntntNode *SwTxtNode::JoinNext() } { // wg. SwIndex - pTxtNode->Cut( this, SwIndex(pTxtNode), pTxtNode->Len() ); + pTxtNode->CutText( this, SwIndex(pTxtNode), pTxtNode->Len() ); } // verschiebe noch alle Bookmarks/TOXMarks if( aBkmkArr.Count() ) @@ -822,7 +842,7 @@ SwCntntNode *SwTxtNode::JoinPrev() } { // wg. SwIndex - pTxtNode->Cut( this, SwIndex( this ), SwIndex(pTxtNode), nLen ); + pTxtNode->CutText( this, SwIndex(this), SwIndex(pTxtNode), nLen ); } // verschiebe noch alle Bookmarks/TOXMarks if( aBkmkArr.Count() ) @@ -869,51 +889,49 @@ void SwTxtNode::NewAttrSet( SwAttrPool& rPool ) } -// Ueberladen der virtuellen Update-Methode von SwIndexReg. Dadurch -// benoetigen die Text-Attribute nur xub_StrLen statt SwIndizies! -void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, - BOOL bNegativ, BOOL bDelete ) +// override SwIndexReg::Update => text hints do not need SwIndex for start/end! +void SwTxtNode::Update( SwIndex const & rPos, const xub_StrLen nChangeLen, + const bool bNegative, const bool bDelete ) { SetAutoCompleteWordDirty( TRUE ); - TmpHints* pCollector = NULL; + ::std::auto_ptr<TmpHints> pCollector; + const xub_StrLen nChangePos = rPos.GetIndex(); + if ( HasHints() ) { - xub_StrLen nPos = aPos.GetIndex(); - xub_StrLen* pIdx; - SwTxtAttr* pHt; - if( bNegativ ) + if ( bNegative ) { - xub_StrLen nMax = nPos + nLen; + const xub_StrLen nChangeEnd = nChangePos + nChangeLen; for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { - BOOL bSttBefore = FALSE; - pHt = m_pSwpHints->GetTextHint(n); - pIdx = pHt->GetStart(); - if( *pIdx >= nPos ) + SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(n); + xub_StrLen * const pStart = pHint->GetStart(); + if ( *pStart > nChangePos ) { - if( *pIdx > nMax ) - *pIdx = *pIdx - nLen; + if ( *pStart > nChangeEnd ) + { + *pStart = *pStart - nChangeLen; + } else { - *pIdx = nPos; + *pStart = nChangePos; } } - else - bSttBefore = TRUE; - - if( 0 == (pIdx = pHt->GetEnd()) ) - continue; - if( *pIdx >= nPos ) + xub_StrLen * const pEnd = pHint->GetEnd(); + if (pEnd) { - if( *pIdx > nMax ) - { - *pIdx = *pIdx - nLen; - } - else if( *pIdx != nPos ) + if ( *pEnd > nChangePos ) { - *pIdx = nPos; + if( *pEnd > nChangeEnd ) + { + *pEnd = *pEnd - nChangeLen; + } + else + { + *pEnd = nChangePos; + } } } } @@ -922,9 +940,8 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } else { - xub_StrLen* pEnd; - BOOL bNoExp = FALSE; - BOOL bResort = FALSE; + bool bNoExp = false; + bool bResort = false; const USHORT coArrSz = static_cast<USHORT>(RES_TXTATR_WITHEND_END) - static_cast<USHORT>(RES_CHRATR_BEGIN) + static_cast<USHORT>(RES_UNKNOWNATR_END) - @@ -935,27 +952,29 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, for ( USHORT n = 0; n < m_pSwpHints->Count(); ++n ) { - pHt = m_pSwpHints->GetTextHint(n); - pIdx = pHt->GetStart(); - pEnd = pHt->GetEnd(); - if ( *pIdx >= nPos ) + SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(n); + xub_StrLen * const pStart = pHint->GetStart(); + xub_StrLen * const pEnd = pHint->GetEnd(); + if ( *pStart >= nChangePos ) { - *pIdx = *pIdx + nLen; + *pStart = *pStart + nChangeLen; if ( pEnd ) { - *pEnd = *pEnd + nLen; + *pEnd = *pEnd + nChangeLen; } } - else if ( pEnd && *pEnd >= nPos ) + else if ( pEnd && (*pEnd >= nChangePos) ) { - if( *pEnd > nPos || IsIgnoreDontExpand() ) + if ( (*pEnd > nChangePos) || IsIgnoreDontExpand() ) { - *pEnd = *pEnd + nLen; + *pEnd = *pEnd + nChangeLen; } - else + else // *pEnd == nChangePos { - USHORT nWhPos, nWhich = pHt->Which(); + USHORT nWhPos; + const USHORT nWhich = pHint->Which(); + ASSERT(!isCHRATR(nWhich), "Update: char attr hint?"); if (isCHRATR(nWhich) || isTXTATR_WITHEND(nWhich)) { nWhPos = static_cast<USHORT>(nWhich - @@ -975,13 +994,13 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, if( aDontExp[ nWhPos ] ) continue; - if( pHt->DontExpand() ) + if ( pHint->DontExpand() ) { - pHt->SetDontExpand( FALSE ); - bResort = TRUE; - if( pHt->IsCharFmtAttr() ) + pHint->SetDontExpand( false ); + bResort = true; + if ( pHint->IsCharFmtAttr() ) { - bNoExp = TRUE; + bNoExp = true; aDontExp[ static_cast<USHORT>(RES_TXTATR_CHARFMT) - static_cast<USHORT>(RES_CHRATR_BEGIN) ] = TRUE; aDontExp[ static_cast<USHORT>(RES_TXTATR_INETFMT) - static_cast<USHORT>(RES_CHRATR_BEGIN) ] @@ -992,8 +1011,10 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } else if( bNoExp ) { - if( !pCollector ) - pCollector = new TmpHints; + if ( !pCollector.get() ) + { + pCollector.reset( new TmpHints ); + } USHORT nCollCnt = pCollector->Count(); for( USHORT i = 0; i < nCollCnt; ++i ) { @@ -1001,22 +1022,24 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, if( nWhich == pTmp->Which() ) { pCollector->Remove( i ); - delete pTmp; + SwTxtAttr::Destroy( pTmp, + GetDoc()->GetAttrPool() ); break; } } - SwTxtAttr *pTmp = MakeTxtAttr( pHt->GetAttr(), - nPos, nPos + nLen ); + SwTxtAttr * const pTmp = MakeTxtAttr( *GetDoc(), + pHint->GetAttr(), + nChangePos, nChangePos + nChangeLen); pCollector->C40_INSERT( SwTxtAttr, pTmp, pCollector->Count() ); } else { - *pEnd = *pEnd + nLen; + *pEnd = *pEnd + nChangeLen; } } } } - if( bResort ) + if ( bResort ) { m_pSwpHints->Resort(); } @@ -1024,45 +1047,51 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, } SwIndexReg aTmpIdxReg; - if( !bNegativ && !bDelete ) + if ( !bNegative && !bDelete ) { - SwIndex* pIdx; const SwRedlineTbl& rTbl = GetDoc()->GetRedlineTbl(); - if( rTbl.Count() ) - for( USHORT i = 0; i < rTbl.Count(); ++i ) + for ( USHORT i = 0; i < rTbl.Count(); ++i ) + { + SwRedline *const pRedl = rTbl[ i ]; + if ( pRedl->HasMark() ) { - SwRedline* pRedl = rTbl[ i ]; - if( pRedl->HasMark() ) + SwPosition* const pEnd = pRedl->End(); + if ( this == &pEnd->nNode.GetNode() && + *pRedl->GetPoint() != *pRedl->GetMark() ) { - SwPosition* pEnd = pRedl->End(); - - if( this == &pEnd->nNode.GetNode() && - *pRedl->GetPoint() != *pRedl->GetMark() && - aPos.GetIndex() == - (pIdx = &pEnd->nContent)->GetIndex() ) - pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); + SwIndex & rIdx = pEnd->nContent; + if (nChangePos == rIdx.GetIndex()) + { + rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() ); + } } - else if( this == &pRedl->GetPoint()->nNode.GetNode() && - aPos.GetIndex() == (pIdx = &pRedl->GetPoint()-> - nContent)->GetIndex() ) + } + else if ( this == &pRedl->GetPoint()->nNode.GetNode() ) + { + SwIndex & rIdx = pRedl->GetPoint()->nContent; + if (nChangePos == rIdx.GetIndex()) { - pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); - if( &pRedl->GetBound( TRUE ) == pRedl->GetPoint() ) + rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() ); + // mst: FIXME: why does this adjust the unused position??? + SwIndex * pIdx; + if ( &pRedl->GetBound( true ) == pRedl->GetPoint() ) { - pRedl->GetBound( FALSE ) = pRedl->GetBound( TRUE ); - pIdx = &pRedl->GetBound( FALSE ).nContent; + pRedl->GetBound( false ) = pRedl->GetBound( true ); + pIdx = &pRedl->GetBound( false ).nContent; } else { - pRedl->GetBound( TRUE ) = pRedl->GetBound( FALSE ); - pIdx = &pRedl->GetBound( TRUE ).nContent; + pRedl->GetBound( true ) = pRedl->GetBound( false ); + pIdx = &pRedl->GetBound( true ).nContent; } pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); } } + } const IDocumentMarkAccess* const pMarkAccess = getIDocumentMarkAccess(); - for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); + for(IDocumentMarkAccess::const_iterator_t ppMark = + pMarkAccess->getMarksBegin(); ppMark != pMarkAccess->getMarksEnd(); ppMark++) { @@ -1072,21 +1101,25 @@ void SwTxtNode::Update( const SwIndex & aPos, xub_StrLen nLen, // to the left of the inserted text (used in XML import). const ::sw::mark::IMark* const pMark = ppMark->get(); const SwPosition* pEnd = &pMark->GetMarkEnd(); - pIdx = (SwIndex*)&pEnd->nContent; + SwIndex & rIdx = const_cast<SwIndex&>(pEnd->nContent); if( this == &pEnd->nNode.GetNode() && - aPos.GetIndex() == pIdx->GetIndex() ) - pIdx->Assign( &aTmpIdxReg, pIdx->GetIndex() ); + rPos.GetIndex() == rIdx.GetIndex() ) + { + rIdx.Assign( &aTmpIdxReg, rIdx.GetIndex() ); + } } } - SwIndexReg::Update( aPos, nLen, bNegativ ); - if( pCollector ) + + // base class + SwIndexReg::Update( rPos, nChangeLen, bNegative, bDelete ); + + if ( pCollector.get() ) { - USHORT nCount = pCollector->Count(); - for( USHORT i = 0; i < nCount; ++i ) + const USHORT nCount = pCollector->Count(); + for ( USHORT i = 0; i < nCount; ++i ) { - m_pSwpHints->Insert( (*pCollector)[ i ], *this, FALSE ); + m_pSwpHints->TryInsertHint( (*pCollector)[ i ], *this ); } - delete pCollector; } aTmpIdxReg.MoveTo( *this ); @@ -1252,8 +1285,8 @@ SwCharFmt* lcl_FindCharFmt( const SwCharFmts* pCharFmts, const XubString& rName return NULL; } -void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, - SwTxtAttr *pNewHt, SwDoc* pOtherDoc, SwTxtNode *pDest ) +void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr * const pHt, + SwTxtAttr *const pNewHt, SwDoc *const pOtherDoc, SwTxtNode *const pDest ) { ASSERT( nWhich == pHt->Which(), "Falsche Hint-Id" ); switch( nWhich ) @@ -1261,7 +1294,8 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, // Wenn wir es mit einem Fussnoten-Attribut zu tun haben, // muessen wir natuerlich auch den Fussnotenbereich kopieren. case RES_TXTATR_FTN : - ((SwTxtFtn*)pHt)->CopyFtn( (SwTxtFtn*)pNewHt ); + static_cast<const SwTxtFtn*>(pHt)->CopyFtn( + static_cast<SwTxtFtn*>(pNewHt)); break; // Beim Kopieren von Feldern in andere Dokumente @@ -1272,19 +1306,24 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, { const SwFmtFld& rFld = pHt->GetFld(); if( pOtherDoc ) - ((SwTxtFld*)pHt)->CopyFld( (SwTxtFld*)pNewHt ); + { + static_cast<const SwTxtFld*>(pHt)->CopyFld( + static_cast<SwTxtFld*>(pNewHt) ); + } // Tabellenformel ?? if( RES_TABLEFLD == rFld.GetFld()->GetTyp()->Which() - && ((SwTblField*)rFld.GetFld())->IsIntrnlName() ) + && static_cast<const SwTblField*>(rFld.GetFld())->IsIntrnlName()) { // wandel die interne in eine externe Formel um - const SwTableNode* pDstTblNd = ((SwTxtFld*)pHt)-> + const SwTableNode* const pDstTblNd = + static_cast<const SwTxtFld*>(pHt)-> GetTxtNode().FindTableNode(); if( pDstTblNd ) { - SwTblField* pTblFld = (SwTblField*) - pNewHt->GetFld().GetFld(); + SwTblField* const pTblFld = const_cast<SwTblField*>( + static_cast<const SwTblField*>( + pNewHt->GetFld().GetFld())); pTblFld->PtrToBoxNm( &pDstTblNd->GetTable() ); } } @@ -1294,9 +1333,11 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, case RES_TXTATR_TOXMARK : if( pOtherDoc && pDest && pDest->GetpSwpHints() && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) + { // Beim Kopieren von TOXMarks(Client) in andere Dokumente // muss der Verzeichnis (Modify) ausgetauscht werden - ((SwTxtTOXMark*)pNewHt)->CopyTOXMark( pOtherDoc ); + static_cast<SwTxtTOXMark*>(pNewHt)->CopyTOXMark( pOtherDoc ); + } break; case RES_TXTATR_CHARFMT : @@ -1305,21 +1346,27 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, if( pDest && pDest->GetpSwpHints() && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) { - SwCharFmt* pFmt = (SwCharFmt*)pHt->GetCharFmt().GetCharFmt(); + SwCharFmt* pFmt = + static_cast<SwCharFmt*>(pHt->GetCharFmt().GetCharFmt()); if( pFmt && pOtherDoc ) + { pFmt = pOtherDoc->CopyCharFmt( *pFmt ); - ((SwFmtCharFmt&)pNewHt->GetCharFmt()).SetCharFmt( pFmt ); + } + const_cast<SwFmtCharFmt&>( static_cast<const SwFmtCharFmt&>( + pNewHt->GetCharFmt() ) ).SetCharFmt( pFmt ); } break; case RES_TXTATR_INETFMT : + { // Wenn wir es mit benutzerdefinierten INet-Zeichenvorlagen // zu tun haben, muessen wir natuerlich auch die Formate kopieren. if( pOtherDoc && pDest && pDest->GetpSwpHints() && USHRT_MAX != pDest->GetpSwpHints()->GetPos( pNewHt ) ) { - const SwDoc* pDoc; - if( 0!=( pDoc = ((SwTxtINetFmt*)pHt)->GetTxtNode().GetDoc() ) ) + const SwDoc* const pDoc = static_cast<const SwTxtINetFmt*>(pHt) + ->GetTxtNode().GetDoc(); + if ( pDoc ) { const SwCharFmts* pCharFmts = pDoc->GetCharFmts(); const SwFmtINetFmt& rFmt = pHt->GetINetFmt(); @@ -1335,11 +1382,27 @@ void lcl_CopyHint( const USHORT nWhich, const SwTxtAttr *pHt, //JP 24.04.98: Bug 49753 - ein TextNode muss am Attribut // gesetzt sein, damit die Vorlagen erzeugt // werden koenne - if( !((SwTxtINetFmt*)pNewHt)->GetpTxtNode() ) - ((SwTxtINetFmt*)pNewHt)->ChgTxtNode( pDest ); + SwTxtINetFmt* const pINetHt = static_cast<SwTxtINetFmt*>(pNewHt); + if ( !pINetHt->GetpTxtNode() ) + { + pINetHt->ChgTxtNode( pDest ); + } //JP 22.10.97: Bug 44875 - Verbindung zum Format herstellen - ((SwTxtINetFmt*)pNewHt)->GetCharFmt(); + pINetHt->GetCharFmt(); + break; + } + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + ASSERT(pNewHt, "copying META should not fail! cannot call DoCopy"); + ASSERT(pDest && (CH_TXTATR_INWORD == + pDest->GetTxt().GetChar(*pNewHt->GetStart())), + "missing CH_TXTATR?"); + if (pNewHt) + { + SwFmtMeta & rMeta(static_cast<SwFmtMeta&>(pNewHt->GetAttr())); + rMeta.DoCopy( const_cast<SwFmtMeta&>(pHt->GetMeta()) ); + } break; } } @@ -1358,40 +1421,41 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, { if ( HasHints() ) // keine Attribute, keine Kekse { - const xub_StrLen *pEndIdx = 0; - const SwTxtAttr *pHt = 0; - SwTxtAttr *pNewHt = 0; - xub_StrLen nAttrStartIdx = 0; - USHORT nWhich; - - SwDoc* pOtherDoc = pDest->GetDoc(); - if( pOtherDoc == GetDoc() ) - pOtherDoc = 0; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? + pDest->GetDoc() : 0; for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { - pHt = (*m_pSwpHints)[i]; - if( nTxtStartIdx < ( nAttrStartIdx = *pHt->GetStart() ) ) + SwTxtAttr *const pHt = m_pSwpHints->GetTextHint(i); + xub_StrLen const nAttrStartIdx = *pHt->GetStart(); + if ( nTxtStartIdx < nAttrStartIdx ) break; // ueber das Textende, da nLen == 0 - pEndIdx = pHt->GetEnd(); - if( pEndIdx ) + const xub_StrLen *const pEndIdx = pHt->GetEnd(); + if ( pEndIdx && !pHt->HasDummyChar() ) { if( ( *pEndIdx > nTxtStartIdx || ( *pEndIdx == nTxtStartIdx && nAttrStartIdx == nTxtStartIdx ) ) ) { - if( RES_TXTATR_REFMARK != ( nWhich = pHt->Which()) ) + USHORT const nWhich = pHt->Which(); + if ( RES_TXTATR_REFMARK != nWhich ) { - // Attribut liegt im Bereich, also kopieren - if( 0 != ( pNewHt = pDest->InsertItem( pHt->GetAttr(), - nOldPos, nOldPos ) ) ) - lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); + // attribute in the area => copy + SwTxtAttr *const pNewHt = pDest->InsertItem( + pHt->GetAttr(), nOldPos, nOldPos ); + if ( pNewHt ) + { + lcl_CopyHint( nWhich, pHt, pNewHt, + pOtherDoc, pDest ); + } } else if( !pOtherDoc ? GetDoc()->IsCopyIsMove() : 0 == pOtherDoc->GetRefMark( pHt->GetRefMark().GetRefName() ) ) + { pDest->InsertItem( pHt->GetAttr(), nOldPos, nOldPos ); + } } } } @@ -1413,19 +1477,19 @@ void SwTxtNode::CopyAttr( SwTxtNode *pDest, const xub_StrLen nTxtStartIdx, // --> OD 2008-11-18 #i96213# // introduction of new optional parameter to control, if all attributes have to be copied. -void SwTxtNode::Copy( SwTxtNode *pDest, +void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rStart, - xub_StrLen nLen, + const xub_StrLen nLen, const bool bForceCopyOfAllAttrs ) { SwIndex aIdx( pDest, pDest->m_Text.Len() ); - Copy( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs ); + CopyText( pDest, aIdx, rStart, nLen, bForceCopyOfAllAttrs ); } // <-- // --> OD 2008-11-18 #i96213# // introduction of new optional parameter to control, if all attributes have to be copied. -void SwTxtNode::Copy( SwTxtNode *pDest, +void SwTxtNode::CopyText( SwTxtNode *const pDest, const SwIndex &rDestStart, const SwIndex &rStart, xub_StrLen nLen, @@ -1460,36 +1524,33 @@ void SwTxtNode::Copy( SwTxtNode *pDest, 0 ); aCharSet.Put( *GetpSwAttrSet() ); if( aCharSet.Count() ) + { pDest->SetAttr( aCharSet, nDestStart, nDestStart ); + } } else + { GetpSwAttrSet()->CopyToModify( *pDest ); + } } return; } // 1. Text kopieren - xub_StrLen i = pDest->m_Text.Len() - nDestStart; + const xub_StrLen oldLen = pDest->m_Text.Len(); //JP 15.02.96: Bug 25537 - Attributbehandlung am Ende fehlt! Darum // ueber die InsertMethode den Text einfuegen und nicht // selbst direkt - pDest->Insert( m_Text.Copy( nTxtStartIdx, nLen ), rDestStart, - INS_EMPTYEXPAND ); + pDest->InsertText( m_Text.Copy( nTxtStartIdx, nLen ), rDestStart, + IDocumentContentOperations::INS_EMPTYEXPAND ); // um reale Groesse Updaten ! - nLen = pDest->m_Text.Len() - nDestStart - i; + nLen = pDest->m_Text.Len() - oldLen; if ( !nLen ) // string not longer? return; - i = 0; - const xub_StrLen *pEndIdx = 0; - xub_StrLen nAttrStartIdx = 0; - const SwTxtAttr *pHt = 0; - SwTxtAttr *pNewHt = 0; - - SwDoc* pOtherDoc = pDest->GetDoc(); - if( pOtherDoc == GetDoc() ) - pOtherDoc = 0; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) ? + pDest->GetDoc() : 0; // harte Absatz umspannende Attribute kopieren if( HasSwAttrSet() ) @@ -1510,26 +1571,27 @@ void SwTxtNode::Copy( SwTxtNode *pDest, 0 ); aCharSet.Put( *GetpSwAttrSet() ); if( aCharSet.Count() ) + { pDest->SetAttr( aCharSet, nDestStart, nDestStart + nLen ); + } } else + { GetpSwAttrSet()->CopyToModify( *pDest ); + } } - - const BOOL bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + const bool bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); // Ende erst jetzt holen, weil beim Kopieren in sich selbst der // Start-Index und alle Attribute vorher aktualisiert werden. nTxtStartIdx = rStart.GetIndex(); - xub_StrLen nEnd = nTxtStartIdx + nLen; + const xub_StrLen nEnd = nTxtStartIdx + nLen; // 2. Attribute kopieren // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu kopierenden Bereich liegt - USHORT nWhich; - USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; - xub_StrLen nAttrStt, nAttrEnd; + const USHORT nSize = m_pSwpHints ? m_pSwpHints->Count() : 0; // wird in sich selbst kopiert, dann kann beim Einfuegen ein // Attribut geloescht werden. Darum erst ins Tmp-Array kopieren und @@ -1540,13 +1602,15 @@ void SwTxtNode::Copy( SwTxtNode *pDest, SwpHts aRefMrkArr; //Achtung: kann ungueltig sein!! - while ( ( i < nSize ) && - ((nAttrStartIdx = *(*m_pSwpHints)[i]->GetStart()) < nEnd) ) + for (USHORT n = 0; ( n < nSize ); ++n) { - pHt = (*m_pSwpHints)[i]; - pNewHt = 0; - pEndIdx = pHt->GetEnd(); - nWhich = pHt->Which(); + const xub_StrLen nAttrStartIdx = *(*m_pSwpHints)[n]->GetStart(); + if (!( nAttrStartIdx < nEnd)) + break; + + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(n); + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + const USHORT nWhich = pHt->Which(); // JP 26.04.94: REFMARK's werden nie kopiert. Hat das Refmark aber // keinen Bereich umspannt, so steht im Text ein 255 @@ -1561,44 +1625,52 @@ void SwTxtNode::Copy( SwTxtNode *pDest, if( pEndIdx && RES_TXTATR_REFMARK == nWhich && !bCopyRefMark ) { - ++i; continue; } + xub_StrLen nAttrStt; + xub_StrLen nAttrEnd; + if( nAttrStartIdx < nTxtStartIdx ) { - // Anfang liegt vor dem Bereich - if( pEndIdx && ( nAttrEnd = *pEndIdx ) > nTxtStartIdx ) + // start is before selection + // copy hints with end and CH_TXTATR only if dummy char is copied + if ( pEndIdx && (*pEndIdx > nTxtStartIdx) && !pHt->HasDummyChar() ) { - // Attribut mit einem Bereich - // und das Ende des Attribut liegt im Bereich + // attribute with extent and the end is in the selection nAttrStt = nDestStart; - nAttrEnd = nAttrEnd > nEnd + nAttrEnd = (*pEndIdx > nEnd) ? rDestStart.GetIndex() - : nDestStart + nAttrEnd - nTxtStartIdx; + : nDestStart + (*pEndIdx) - nTxtStartIdx; } else { - ++i; continue; } } else { - // der Anfang liegt innerhalb des Bereiches + // start is in the selection nAttrStt = nDestStart + ( nAttrStartIdx - nTxtStartIdx ); if( pEndIdx ) + { nAttrEnd = *pEndIdx > nEnd ? rDestStart.GetIndex() : nDestStart + ( *pEndIdx - nTxtStartIdx ); + } else + { nAttrEnd = nAttrStt; + } } + SwTxtAttr * pNewHt = 0; + if( pDest == this ) { // die Daten kopieren - pNewHt = MakeTxtAttr( pHt->GetAttr(), nAttrStt, nAttrEnd ); + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), + nAttrStt, nAttrEnd ); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //JP 23.04.95: erstmal so gesondert hier behandeln. Am Besten ist es @@ -1623,38 +1695,28 @@ void SwTxtNode::Copy( SwTxtNode *pDest, else { pNewHt = pDest->InsertItem( pHt->GetAttr(), nAttrStt, - nAttrEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); - if( pNewHt ) - lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); - else if( !pEndIdx ) - { - // Attribut wurde nicht kopiert, hat seinen Inhalt mitgenommen! - // Damit der rest aber korrekt kopiert werden kann, muss das - // Zeichen wieder an der Position stehen. Darum hier ein - // "Dummy-TextAttribut" einfuegen, wird am Ende wieder entfernt! - pNewHt = pDest->InsertItem( SwFmtHardBlank( 0xB7 ), nAttrStt, 0 - /*???, INS_NOHINTEXPAND*/ ); - aRefMrkArr.C40_INSERT( SwTxtAttr, pNewHt, aRefMrkArr.Count() ); - } + nAttrEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); } if( RES_TXTATR_REFMARK == nWhich && !pEndIdx && !bCopyRefMark ) { aRefMrkArr.C40_INSERT( SwTxtAttr, pNewHt, aRefMrkArr.Count() ); } - - ++i; } // nur falls im Array Attribute stehen (kann nur beim Kopieren // sich selbst passieren!!) - for( i = 0; i < aArr.Count(); ++i ) - Insert( aArr[ i ], nsSetAttrMode::SETATTR_NOTXTATRCHR ); + for ( USHORT i = 0; i < aArr.Count(); ++i ) + { + InsertHint( aArr[ i ], nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } if( pDest->GetpSwpHints() ) - for( i = 0; i < aRefMrkArr.Count(); ++i ) + { + for ( USHORT i = 0; i < aRefMrkArr.Count(); ++i ) { - pNewHt = aRefMrkArr[i]; + SwTxtAttr * const pNewHt = aRefMrkArr[i]; if( pNewHt->GetEnd() ) { pDest->GetpSwpHints()->Delete( pNewHt ); @@ -1663,69 +1725,77 @@ void SwTxtNode::Copy( SwTxtNode *pDest, else { const SwIndex aIdx( pDest, *pNewHt->GetStart() ); - pDest->Erase( aIdx, 1 ); + pDest->EraseText( aIdx, 1 ); } } + } CHECK_SWPHINTS(this); } -/* - * Rudimentaeres Editieren, damit die SwDoc-Insert-Methoden - * funktionieren. - */ - -SwTxtNode& SwTxtNode::Insert( const XubString &rStr, - const SwIndex &rIdx, const USHORT nMode ) +void SwTxtNode::InsertText( const XubString & rStr, const SwIndex & rIdx, + const IDocumentContentOperations::InsertFlags nMode ) { - ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Insert: invalid index." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::InsertText: invalid index." ); ASSERT( (ULONG)m_Text.Len() + (ULONG)rStr.Len() <= STRING_LEN, - "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); + "SwTxtNode::InsertText: node text with insertion > STRING_LEN." ); xub_StrLen aPos = rIdx.GetIndex(); xub_StrLen nLen = m_Text.Len() - aPos; m_Text.Insert( rStr, aPos ); nLen = m_Text.Len() - aPos - nLen; - if( !nLen ) - return *this; - Update( rIdx, nLen ); // um reale Groesse Updaten ! + + if ( !nLen ) return; + + BOOL bOldExpFlg = IsIgnoreDontExpand(); + if (nMode & IDocumentContentOperations::INS_FORCEHINTEXPAND) + { + SetIgnoreDontExpand( TRUE ); + } + + Update( rIdx, nLen ); // text content changed! + + if (nMode & IDocumentContentOperations::INS_FORCEHINTEXPAND) + { + SetIgnoreDontExpand( bOldExpFlg ); + } // analog zu Insert(char) in txtedt.cxx: // 1) bei bHintExp leere Hints an rIdx.GetIndex suchen und aufspannen // 2) bei bHintExp == FALSE mitgezogene Feldattribute zuruecksetzen - USHORT i; - if ( HasHints() ) { - for ( i = 0; i < m_pSwpHints->Count() && + for ( USHORT i = 0; i < m_pSwpHints->Count() && rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i ) { - SwTxtAttr *pHt = m_pSwpHints->GetTextHint( i ); - xub_StrLen* pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint( i ); + xub_StrLen * const pEndIdx = pHt->GetEnd(); if( !pEndIdx ) continue; if( rIdx == *pEndIdx ) { - if( nMode & INS_NOHINTEXPAND || pHt->DontExpand() ) + if ( (nMode & IDocumentContentOperations::INS_NOHINTEXPAND) || + (!(nMode & IDocumentContentOperations::INS_FORCEHINTEXPAND) + && pHt->DontExpand()) ) { // bei leeren Attributen auch Start veraendern if( rIdx == *pHt->GetStart() ) *pHt->GetStart() = *pHt->GetStart() - nLen; *pEndIdx = *pEndIdx - nLen; m_pSwpHints->DeleteAtPos(i); - Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); + InsertHint( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } - // leere Hints an rIdx.GetIndex ? - else if( nMode & INS_EMPTYEXPAND && - *pEndIdx == *pHt->GetStart() ) + // empty hints at insert position? + else if ( (nMode & IDocumentContentOperations::INS_EMPTYEXPAND) + && (*pEndIdx == *pHt->GetStart()) ) { *pHt->GetStart() = *pHt->GetStart() - nLen; const USHORT nAktLen = m_pSwpHints->Count(); m_pSwpHints->DeleteAtPos(i); - Insert( pHt/* AUTOSTYLES:, nsSetAttrMode::SETATTR_NOHINTADJUST*/ ); + InsertHint( pHt/* AUTOSTYLES:, nsSetAttrMode::SETATTR_NOHINTADJUST*/ ); if ( nAktLen > m_pSwpHints->Count() && i ) { --i; @@ -1737,14 +1807,14 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, continue; } } - if ( !(nMode & INS_NOHINTEXPAND) && + if ( !(nMode & IDocumentContentOperations::INS_NOHINTEXPAND) && rIdx == nLen && *pHt->GetStart() == rIdx.GetIndex() && !pHt->IsDontExpandStartAttr() ) { // Kein Feld, am Absatzanfang, HintExpand m_pSwpHints->DeleteAtPos(i); *pHt->GetStart() = *pHt->GetStart() - nLen; - Insert( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); + InsertHint( pHt, nsSetAttrMode::SETATTR_NOHINTADJUST ); } } TryDeleteSwpHints(); @@ -1761,7 +1831,6 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, SetCalcHiddenCharFlags(); CHECK_SWPHINTS(this); - return *this; } /************************************************************************* @@ -1774,32 +1843,41 @@ SwTxtNode& SwTxtNode::Insert( const XubString &rStr, |* *************************************************************************/ -void SwTxtNode::Cut( SwTxtNode *pDest, const SwIndex &rStart, xub_StrLen nLen ) +void SwTxtNode::CutText( SwTxtNode * const pDest, + const SwIndex & rStart, const xub_StrLen nLen ) { if(pDest) { SwIndex aDestStt( pDest, pDest->GetTxt().Len() ); - _Cut( pDest, aDestStt, rStart, nLen, FALSE ); + CutImpl( pDest, aDestStt, rStart, nLen, false ); } else - Erase( rStart, nLen ); + { + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); + EraseText( rStart, nLen ); + } } -void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, - const SwIndex &rStart, xub_StrLen nLen, BOOL bUpdate ) +void SwTxtNode::CutImpl( SwTxtNode * const pDest, const SwIndex & rDestStart, + const SwIndex & rStart, /*const*/ xub_StrLen nLen, const bool bUpdate ) { if(!pDest) { - Erase( rStart, nLen ); + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); + EraseText( rStart, nLen ); return; } // nicht im Dokument verschieben ? if( GetDoc() != pDest->GetDoc() ) { - Copy( pDest, rDestStart, rStart, nLen); - Erase(rStart,nLen); + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); + CopyText( pDest, rDestStart, rStart, nLen); + EraseText(rStart, nLen); return; } @@ -1813,48 +1891,46 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, xub_StrLen nTxtStartIdx = rStart.GetIndex(); xub_StrLen nDestStart = rDestStart.GetIndex(); // alte Pos merken - xub_StrLen nInitSize = pDest->m_Text.Len(); - - xub_StrLen *pEndIdx = 0; - xub_StrLen nAttrStartIdx = 0; - SwTxtAttr *pHt = 0; - SwTxtAttr *pNewHt = 0; + const xub_StrLen nInitSize = pDest->m_Text.Len(); // wird in sich selbst verschoben, muss es gesondert behandelt werden !! if( pDest == this ) { + ASSERT(false, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); m_Text.Insert( m_Text, nTxtStartIdx, nLen, nDestStart ); m_Text.Erase( nTxtStartIdx + (nDestStart<nTxtStartIdx ? nLen : 0), nLen ); - xub_StrLen nEnd = rStart.GetIndex() + nLen; - USHORT n; + const xub_StrLen nEnd = rStart.GetIndex() + nLen; // dann suche mal alle Attribute zusammen, die im verschobenen // Bereich liegen. Diese werden in das extra Array verschoben, // damit sich die Indizies beim Updaten nicht veraendern !!! - SwIndexReg aTmpRegArr; SwpHts aArr( 5 ); // 2. Attribute verschieben // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt - USHORT nAttrCnt = 0, nWhich; - while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && - (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> - GetStart()) < nEnd ) + USHORT nAttrCnt = 0; + while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() ) { - pNewHt = 0; - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + if (!( nAttrStartIdx < nEnd )) + break; + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + const USHORT nWhich = pHt->Which(); + SwTxtAttr *pNewHt = 0; if(nAttrStartIdx < nTxtStartIdx) { // Anfang liegt vor dem Bereich - if( RES_TXTATR_REFMARK != ( nWhich = pHt->Which() ) && + if ( RES_TXTATR_REFMARK != nWhich && !pHt->HasDummyChar() && pEndIdx && *pEndIdx > nTxtStartIdx ) { // Attribut mit einem Bereich // und das Ende des Attribut liegt im Bereich - pNewHt = MakeTxtAttr( pHt->GetAttr(), 0, + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), 0, *pEndIdx > nEnd ? nLen : *pEndIdx - nTxtStartIdx ); @@ -1875,9 +1951,9 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, continue; // while-Schleife weiter, ohne ++ ! } // das Ende liegt dahinter - else if( RES_TXTATR_REFMARK != ( nWhich = pHt->Which() )) + else if (RES_TXTATR_REFMARK != nWhich && !pHt->HasDummyChar()) { - pNewHt = MakeTxtAttr( pHt->GetAttr(), + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), nAttrStartIdx - nTxtStartIdx, !pEndIdx ? 0 : ( *pEndIdx > nEnd @@ -1895,8 +1971,10 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, } if( bUpdate ) + { // Update aller Indizies Update( rDestStart, nLen, FALSE, TRUE ); + } #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben @@ -1904,10 +1982,10 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, { // check if there was the end of an attribute at the insertion // position: if it is not a field, it must be expanded - for ( n = 0; n < m_pSwpHints->Count(); n++ ) + for ( USHORT n = 0; n < m_pSwpHints->Count(); n++ ) { - pHt = m_pSwpHints->GetTextHint(n); - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(n); + const xub_StrLen * const pEndIdx = pHt->GetEnd(); if ( pEndIdx && (*pEndIdx == nInitSize) ) { *pEndIdx = *pEndIdx + nLen; @@ -1923,33 +2001,39 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // dann setze die kopierten/geloeschten Attribute in den Node if( nDestStart <= nTxtStartIdx ) + { nTxtStartIdx = nTxtStartIdx + nLen; + } else + { nDestStart = nDestStart - nLen; + } - for( n = 0; n < aArr.Count(); ++n ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { - pNewHt = aArr[n]; + SwTxtAttr *const pNewHt = aArr[n]; *pNewHt->GetStart() = nDestStart + *pNewHt->GetStart(); - if( 0 != ( pEndIdx = pNewHt->GetEnd() )) + xub_StrLen * const pEndIdx = pNewHt->GetEnd(); + if ( pEndIdx ) + { *pEndIdx = nDestStart + *pEndIdx; - Insert( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR ); + } + InsertHint( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR ); } } else { - xub_StrLen i = nInitSize - nDestStart; pDest->m_Text.Insert( m_Text, nTxtStartIdx, nLen, nDestStart ); m_Text.Erase( nTxtStartIdx, nLen ); - nLen = pDest->m_Text.Len() - nDestStart - i; // update w/ current size! + nLen = pDest->m_Text.Len() - nInitSize; // update w/ current size! if( !nLen ) // String nicht gewachsen ?? return; - i = 0; - if( bUpdate ) + { // Update aller Indizies pDest->Update( rDestStart, nLen, FALSE, TRUE); + } #ifdef CUTNOEXPAND else // wird am Ende eingefuegt, nur die Attribut-Indizies verschieben @@ -1959,8 +2043,8 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, // position: if it is not a field, it must be expanded for ( USHORT n = 0; n < pDest->m_pSwpHints->Count(); n++ ) { - pHt = pDest->m_pSwpHints->GetTextHint(n); - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = pDest->m_pSwpHints->GetTextHint(n); + const xub_StrLen * const pEndIdx = pHt->GetEnd(); if ( pEndIdx && (*pEndIdx == nInitSize) ) { *pEndIdx = *pEndIdx + nLen; @@ -1970,11 +2054,14 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, #endif CHECK_SWPHINTS(pDest); - USHORT nEnd = rStart.GetIndex() + nLen; - SwDoc* pOtherDoc = pDest->GetDoc(); - if( pOtherDoc == GetDoc() ) - pOtherDoc = 0; - const BOOL bUndoNodes = !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + const xub_StrLen nEnd = rStart.GetIndex() + nLen; + SwDoc* const pOtherDoc = (pDest->GetDoc() != GetDoc()) + ? pDest->GetDoc() : 0; + const bool bUndoNodes = + !pOtherDoc && GetDoc()->GetUndoNds() == &GetNodes(); + + ASSERT(!pOtherDoc, + "mst: entering dead and bitrotted code; fasten your seatbelts!"); // harte Absatz umspannende Attribute kopieren if( HasSwAttrSet() ) @@ -1994,30 +2081,37 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, pDest->SetAttr( aCharSet, nDestStart, nDestStart + nLen ); } else + { GetpSwAttrSet()->CopyToModify( *pDest ); + } } // 2. Attribute verschieben // durch das Attribute-Array, bis der Anfang des Geltungsbereiches // des Attributs hinter dem zu verschiebenden Bereich liegt - USHORT nAttrCnt = 0, nWhich; - while ( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() && - ( (nAttrStartIdx = *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))-> - GetStart()) < nEnd ) ) + USHORT nAttrCnt = 0; + while ( m_pSwpHints && (nAttrCnt < m_pSwpHints->Count()) ) { - pNewHt = 0; - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + if (!( nAttrStartIdx < nEnd )) + break; + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + const USHORT nWhich = pHt->Which(); + SwTxtAttr *pNewHt = 0; + // if the hint has a dummy character, then it must not be split! if(nAttrStartIdx < nTxtStartIdx) { // Anfang liegt vor dem Bereich - if( ( RES_TXTATR_REFMARK != ( nWhich = pHt->Which() ) + if( !pHt->HasDummyChar() && ( RES_TXTATR_REFMARK != nWhich || bUndoNodes ) && pEndIdx && *pEndIdx > nTxtStartIdx ) { // Attribut mit einem Bereich // und das Ende des Attribut liegt im Bereich - pNewHt = pDest->MakeTxtAttr( pHt->GetAttr(), nDestStart, - nDestStart + ( + pNewHt = MakeTxtAttr( *pDest->GetDoc(), pHt->GetAttr(), + nDestStart, + nDestStart + ( *pEndIdx > nEnd ? nLen : *pEndIdx - nTxtStartIdx ) ); @@ -2026,33 +2120,40 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, else { // der Anfang liegt vollstaendig im Bereich - nWhich = pHt->Which(); if( !pEndIdx || *pEndIdx < nEnd || - ( !pOtherDoc && !bUndoNodes && RES_TXTATR_REFMARK - == nWhich ) ) + (!pOtherDoc && !bUndoNodes && RES_TXTATR_REFMARK == nWhich) + || pHt->HasDummyChar() ) { // do not delete note and later add it -> sidebar flickering if ( GetDoc()->GetDocShell() ) + { GetDoc()->GetDocShell()->Broadcast( SfxSimpleHint(SFX_HINT_USER04)); + } // Attribut verschieben m_pSwpHints->Delete( pHt ); // die Start/End Indicies neu setzen *pHt->GetStart() = nDestStart + (nAttrStartIdx - nTxtStartIdx); if( pEndIdx ) + { *pHt->GetEnd() = nDestStart + ( *pEndIdx > nEnd ? nLen : *pEndIdx - nTxtStartIdx ); - pDest->Insert( pHt, nsSetAttrMode::SETATTR_NOTXTATRCHR | nsSetAttrMode::SETATTR_DONTREPLACE ); + } + pDest->InsertHint( pHt, + nsSetAttrMode::SETATTR_NOTXTATRCHR + | nsSetAttrMode::SETATTR_DONTREPLACE ); if ( GetDoc()->GetDocShell() ) + { GetDoc()->GetDocShell()->Broadcast( SfxSimpleHint(SFX_HINT_USER04)); + } continue; // while-Schleife weiter, ohne ++ ! } // das Ende liegt dahinter else if( RES_TXTATR_REFMARK != nWhich || bUndoNodes ) { - pNewHt = MakeTxtAttr( pHt->GetAttr(), + pNewHt = MakeTxtAttr( *GetDoc(), pHt->GetAttr(), nDestStart + (nAttrStartIdx - nTxtStartIdx), !pEndIdx ? 0 : nDestStart + ( *pEndIdx > nEnd @@ -2062,8 +2163,13 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, } if ( pNewHt ) { - if( pDest->Insert( pNewHt, nsSetAttrMode::SETATTR_NOTXTATRCHR | nsSetAttrMode::SETATTR_DONTREPLACE )) + const bool bSuccess( pDest->InsertHint( pNewHt, + nsSetAttrMode::SETATTR_NOTXTATRCHR + | nsSetAttrMode::SETATTR_DONTREPLACE ) ); + if (bSuccess) + { lcl_CopyHint( nWhich, pHt, pNewHt, pOtherDoc, pDest ); + } } ++nAttrCnt; } @@ -2074,29 +2180,35 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, if( m_pSwpHints && nAttrCnt < m_pSwpHints->Count() ) { SwpHts aArr( 5 ); - for ( ; nAttrCnt < m_pSwpHints->Count() && - nEnd == *(pHt = m_pSwpHints->GetTextHint(nAttrCnt))->GetStart(); - ++nAttrCnt ) + while ( nAttrCnt < m_pSwpHints->Count() ) { - pEndIdx = pHt->GetEnd(); + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(nAttrCnt); + if ( nEnd != *pHt->GetStart() ) + break; + const xub_StrLen * const pEndIdx = pHt->GetEnd(); if ( pEndIdx && *pEndIdx == nEnd ) { aArr.C40_INSERT( SwTxtAttr, pHt, aArr.Count() ); m_pSwpHints->Delete( pHt ); - --nAttrCnt; + } + else + { + ++nAttrCnt; } } Update( rStart, nLen, TRUE, TRUE ); - for( nAttrCnt = 0; nAttrCnt < aArr.Count(); ++nAttrCnt ) + for ( USHORT n = 0; n < aArr.Count(); ++n ) { - pHt = aArr[ nAttrCnt ]; + SwTxtAttr * const pHt = aArr[ n ]; *pHt->GetStart() = *pHt->GetEnd() = rStart.GetIndex(); - Insert( pHt ); + InsertHint( pHt ); } } else + { Update( rStart, nLen, TRUE, TRUE ); + } CHECK_SWPHINTS(this); } @@ -2111,98 +2223,112 @@ void SwTxtNode::_Cut( SwTxtNode *pDest, const SwIndex& rDestStart, } -SwTxtNode& SwTxtNode::Erase(const SwIndex &rIdx, xub_StrLen nCount, - const USHORT nMode ) +void SwTxtNode::EraseText(const SwIndex &rIdx, const xub_StrLen nCount, + const IDocumentContentOperations::InsertFlags nMode ) { - ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::Erase: invalid index." ); + ASSERT( rIdx <= m_Text.Len(), "SwTxtNode::EraseText: invalid index." ); - const xub_StrLen nCnt = STRING_LEN == nCount - ? m_Text.Len() - rIdx.GetIndex() : nCount; - m_Text.Erase( rIdx.GetIndex(), nCnt ); + const xub_StrLen nStartIdx = rIdx.GetIndex(); + const xub_StrLen nCnt = (STRING_LEN == nCount) + ? m_Text.Len() - nStartIdx : nCount; + const xub_StrLen nEndIdx = nStartIdx + nCnt; + m_Text.Erase( nStartIdx, nCnt ); /* GCAttr(); alle leeren weggwerfen ist zu brutal. * Es duerfen nur die wegggeworfen werden, * die im Bereich liegen und nicht am Ende des Bereiches liegen */ - // check m_pSwpHints because fields and FlyFrames delete text (recursion!) for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); - const xub_StrLen nHtStt = *pHt->GetStart(); + const xub_StrLen nHintStart = *pHt->GetStart(); - if( nHtStt < rIdx.GetIndex() ) + if ( nHintStart < nStartIdx ) continue; - // TextFelder und FlyFrames loeschen Text (Rekursion)!! - const xub_StrLen nEndIdx = rIdx.GetIndex() + nCnt; - if( nHtStt > nEndIdx ) - // die Hints sind nach Ende sortiert, also ist Start - // vom Hint groesser als EndIdx dann Abbrechen - break; + if ( nHintStart > nEndIdx ) + break; // hints are sorted by end, so break here const xub_StrLen* pHtEndIdx = pHt->GetEnd(); const USHORT nWhich = pHt->Which(); if( !pHtEndIdx ) { + ASSERT(pHt->HasDummyChar(), + "attribute with neither end nor CH_TXTATR?"); if (isTXTATR(nWhich) && - (nHtStt >= rIdx.GetIndex()) && (nHtStt < nEndIdx)) + (nHintStart >= nStartIdx) && (nHintStart < nEndIdx)) { m_pSwpHints->DeleteAtPos(i); - // Damit im Dtor der TxtAttr ohne End die CH_TXTATR nicht - // geloescht werden... - *(pHt->GetStart()) = USHRT_MAX; DestroyAttr( pHt ); --i; } continue; } + ASSERT (!( (nHintStart < nEndIdx) && (*pHtEndIdx > nEndIdx) + && pHt->HasDummyChar() ) + // next line: deleting exactly dummy char: DeleteAttributes + || ((nHintStart == nStartIdx) && (nHintStart + 1 == nEndIdx)), + "ERROR: deleting left-overlapped attribute with CH_TXTATR"); + // Delete the hint if: // 1. The hint ends before the deletion end position or // 2. The hint ends at the deletion end position and // we are not in empty expand mode and // the hint is a [toxmark|refmark|ruby] text attribute - if( *pHtEndIdx >= nEndIdx && - !( - *pHtEndIdx == nEndIdx && - !(INS_EMPTYEXPAND & nMode) && - (nWhich == RES_TXTATR_TOXMARK || nWhich == RES_TXTATR_REFMARK || - // --> FME 2006-03-03 #i62668# Ruby text attribute has to be treated - // just like toxmark and refmarks - nWhich == RES_TXTATR_CJK_RUBY) ) + // 3. deleting exactly the dummy char of an hint with end and dummy + // char deletes the hint + if ( (*pHtEndIdx < nEndIdx) + || ( (*pHtEndIdx == nEndIdx) && + !(IDocumentContentOperations::INS_EMPTYEXPAND & nMode) && + ( (RES_TXTATR_TOXMARK == nWhich) || + (RES_TXTATR_REFMARK == nWhich) || + // --> FME 2006-03-03 #i62668# Ruby text attribute must be + // treated just like toxmark and refmarks + (RES_TXTATR_CJK_RUBY == nWhich) ) ) // <-- - ) - continue; - - m_pSwpHints->DeleteAtPos(i); - DestroyAttr( pHt ); - --i; +#if 0 + || ( (nHintStart == nStartIdx) && + (nHintStart + 1 == nEndIdx)&& +#else // generalize this to left-overlapped dummy char hints (see ASSERT) + || ( (nHintStart < nEndIdx) && +#endif + pHt->HasDummyChar() ) + ) + { + m_pSwpHints->DeleteAtPos(i); + DestroyAttr( pHt ); + --i; + } } + ASSERT(rIdx.GetIndex() == nStartIdx, "huh? start index has changed?"); + TryDeleteSwpHints(); Update( rIdx, nCnt, TRUE ); if( 1 == nCnt ) { - SwDelChr aHint( rIdx.GetIndex() ); + SwDelChr aHint( nStartIdx ); SwModify::Modify( 0, &aHint ); } else { - SwDelTxt aHint( rIdx.GetIndex(), nCnt ); + SwDelTxt aHint( nStartIdx, nCnt ); SwModify::Modify( 0, &aHint ); } + ASSERT(rIdx.GetIndex() == nStartIdx, "huh? start index has changed?"); + // By deleting a character, the hidden flags // at the TxtNode can become invalid: SetCalcHiddenCharFlags(); CHECK_SWPHINTS(this); - return *this; } /*********************************************************************** @@ -2221,9 +2347,7 @@ void SwTxtNode::GCAttr() if ( !HasHints() ) return; - const SwTxtAttr *pHt = 0; - const xub_StrLen *pEndIdx = 0; - BOOL bChanged = FALSE; + bool bChanged = false; USHORT nMin = m_Text.Len(), nMax = 0; BOOL bAll = nMin != 0; // Bei leeren Absaetzen werden nur die @@ -2231,21 +2355,23 @@ void SwTxtNode::GCAttr() for ( USHORT i = 0; m_pSwpHints && i < m_pSwpHints->Count(); ++i ) { - pHt = (*m_pSwpHints)[i]; + SwTxtAttr * const pHt = m_pSwpHints->GetTextHint(i); // wenn Ende und Start gleich sind --> loeschen - pEndIdx = pHt->GetEnd(); - if( pEndIdx && (*pEndIdx == *pHt->GetStart()) + const xub_StrLen * const pEndIdx = pHt->GetEnd(); + if (pEndIdx && !pHt->HasDummyChar() && (*pEndIdx == *pHt->GetStart()) && ( bAll || pHt->Which() == RES_TXTATR_INETFMT ) ) { - bChanged = TRUE; + bChanged = true; nMin = Min( nMin, *pHt->GetStart() ); nMax = Max( nMax, *pHt->GetEnd() ); DestroyAttr( m_pSwpHints->Cut(i) ); --i; } else - ((SwTxtAttr*)pHt)->SetDontExpand( FALSE ); + { + pHt->SetDontExpand( false ); + } } TryDeleteSwpHints(); @@ -2258,6 +2384,7 @@ void SwTxtNode::GCAttr() SwModify::Modify( 0, &aNew ); } } + // #i23726# SwNumRule* SwTxtNode::_GetNumRule(BOOL bInParent) const { @@ -2271,17 +2398,6 @@ SwNumRule* SwTxtNode::_GetNumRule(BOOL bInParent) const if (sNumRuleName.Len() > 0) { pRet = GetDoc()->FindNumRulePtr( sNumRuleName ); - // --> OD 2006-01-13 #i60395# - // It's not allowed to apply the outline numbering rule as hard - // attribute to a paragraph. - // Because currently not all situation are known, in which such - // a situation is triggered, it's asserted in order to find these. - ASSERT( !pRet || !HasSwAttrSet() || - pRet != GetDoc()->GetOutlineNumRule() || - SFX_ITEM_SET != - GetpSwAttrSet()->GetItemState( RES_PARATR_NUMRULE, FALSE ), - "<SwTxtNode::_GetNumRule(..)> - found outline numbering rule as hard attribute at a paragraph. This isn't allowed. It's a serious defect, please inform OD" ); - // <-- } else // numbering is turned off bNoNumRule = true; @@ -2556,8 +2672,8 @@ SwTxtNode* SwTxtNode::_MakeNewTxtNode( const SwNodeIndex& rPos, BOOL bNext, return pNode; SwTxtFmtColl *pNextColl = &pColl->GetNextTxtFmtColl(); - ChgFmtColl( pNextColl ); - + // --> OD 2009-08-12 #i101870# + // perform action on different paragraph styles before applying the new paragraph style if (pNextColl != pColl) { // --> OD 2007-07-10 #i75353# @@ -2573,6 +2689,8 @@ SwTxtNode* SwTxtNode::_MakeNewTxtNode( const SwNodeIndex& rPos, BOOL bNext, } // <-- } + // <-- + ChgFmtColl( pNextColl ); return pNode; } @@ -2609,30 +2727,25 @@ SwCntntNode* SwTxtNode::AppendNode( const SwPosition & rPos ) /************************************************************************* * SwTxtNode::GetTxtAttr - * - * Diese Methode liefert nur Textattribute auf der Position nIdx - * zurueck, die kein EndIdx besitzen und denselben Which besitzen. - * Ueblicherweise steht an dieser Position ein CH_TXTATR. - * Bei RES_TXTATR_END entfaellt die Pruefung auf den Which-Wert. *************************************************************************/ -SwTxtAttr *SwTxtNode::GetTxtAttr( const xub_StrLen nIdx, - const USHORT nWhichHt ) const +SwTxtAttr * SwTxtNode::GetTxtAttrForCharAt( const xub_StrLen nIndex, + const RES_TXTATR nWhich ) const { if ( HasHints() ) { for ( USHORT i = 0; i < m_pSwpHints->Count(); ++i ) { - SwTxtAttr *pPos = m_pSwpHints->GetTextHint(i); - const xub_StrLen nStartPos = *pPos->GetStart(); - if( nIdx < nStartPos ) + SwTxtAttr * const pHint = m_pSwpHints->GetTextHint(i); + const xub_StrLen nStartPos = *pHint->GetStart(); + if ( nIndex < nStartPos ) + { return 0; - if( nIdx == nStartPos && !pPos->GetEnd() ) + } + if ( (nIndex == nStartPos) && pHint->HasDummyChar() ) { - if( RES_TXTATR_END == nWhichHt || nWhichHt == pPos->Which() ) - return pPos; - else - return 0; + return ( RES_TXTATR_END == nWhich || nWhich == pHint->Which() ) + ? pHint : 0; } } } @@ -2844,7 +2957,8 @@ void SwTxtNode::Replace0xFF( XubString& rTxt, xub_StrLen& rTxtStt, xub_StrLen nPos = rTxt.Search( cSrchChr ); while( STRING_NOTFOUND != nPos && nPos < nEndPos ) { - const SwTxtAttr* pAttr = GetTxtAttr( rTxtStt + nPos ); + const SwTxtAttr* const pAttr = + GetTxtAttrForCharAt( rTxtStt + nPos ); if( pAttr ) { switch( pAttr->Which() ) @@ -2862,11 +2976,6 @@ void SwTxtNode::Replace0xFF( XubString& rTxt, xub_StrLen& rTxtStt, } ++rTxtStt; break; - case RES_TXTATR_HARDBLANK: - rTxt.SetChar( nPos, ((SwTxtHardBlank*)pAttr)->GetChar() ); - ++nPos; - ++nEndPos; - break; case RES_TXTATR_FTN: rTxt.Erase( nPos, 1 ); if( bExpandFlds ) @@ -2968,7 +3077,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, SwScriptInfo::MaskHiddenRanges( *this, sTmpText, 0, sTmpText.Len(), cChar ); sTmpText = sTmpText.Copy( nIdx, nLen ); - rDestNd.Insert( sTmpText, aDestIdx ); + rDestNd.InsertText( sTmpText, aDestIdx ); nLen = aDestIdx.GetIndex() - nDestStt; // alle FontAttribute mit CHARSET Symbol in dem Bereich setzen @@ -2978,25 +3087,28 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, for ( USHORT i = 0; i < m_pSwpHints->Count(); i++ ) { const SwTxtAttr* pHt = (*m_pSwpHints)[i]; - xub_StrLen nAttrStartIdx; - USHORT nWhich = pHt->Which(); - if( nIdx + nLen <= ( nAttrStartIdx = *pHt->GetStart() ) ) + const xub_StrLen nAttrStartIdx = *pHt->GetStart(); + const USHORT nWhich = pHt->Which(); + if (nIdx + nLen <= nAttrStartIdx) break; // ueber das Textende - const SvxFontItem* pFont; const xub_StrLen *pEndIdx = pHt->GetEnd(); if( pEndIdx && *pEndIdx > nIdx && ( RES_CHRATR_FONT == nWhich || RES_TXTATR_CHARFMT == nWhich || - RES_TXTATR_AUTOFMT == nWhich ) && - 0 != ( pFont = static_cast<const SvxFontItem*>(CharFmt::GetItem( *pHt, RES_CHRATR_FONT )) ) && - RTL_TEXTENCODING_SYMBOL == pFont->GetCharSet() ) + RES_TXTATR_AUTOFMT == nWhich )) { - // Attribut liegt im Bereich, also kopieren - rDestNd.InsertItem( *pFont, nInsPos + nAttrStartIdx, - nInsPos + *pEndIdx ); + const SvxFontItem* const pFont = + static_cast<const SvxFontItem*>( + CharFmt::GetItem( *pHt, RES_CHRATR_FONT )); + if ( pFont && RTL_TEXTENCODING_SYMBOL == pFont->GetCharSet() ) + { + // attribute in area => copy + rDestNd.InsertItem( *const_cast<SvxFontItem*>(pFont), + nInsPos + nAttrStartIdx, nInsPos + *pEndIdx ); + } } - else if( !pEndIdx && nAttrStartIdx >= nIdx ) + else if ( pHt->HasDummyChar() && (nAttrStartIdx >= nIdx) ) { aDestIdx = nInsPos + nAttrStartIdx; switch( nWhich ) @@ -3007,20 +3119,15 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, if( aExpand.Len() ) { aDestIdx++; // dahinter einfuegen; - rDestNd.Insert( aExpand, aDestIdx ); + rDestNd.InsertText( aExpand, aDestIdx ); aDestIdx = nInsPos + nAttrStartIdx; nInsPos = nInsPos + aExpand.Len(); } - rDestNd.Erase( aDestIdx, 1 ); + rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; } break; - case RES_TXTATR_HARDBLANK: - rDestNd.m_Text.SetChar( nInsPos + nAttrStartIdx, - ((SwTxtHardBlank*)pHt)->GetChar() ); - break; - case RES_TXTATR_FTN: { if ( bWithFtn ) @@ -3037,23 +3144,25 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, GetNumStr( rFtn.GetNumber() ); if( sExpand.Len() ) { - aDestIdx++; // dahinter einfuegen; - rDestNd.InsertItem( SvxEscapementItem( - SVX_ESCAPEMENT_SUPERSCRIPT ), + aDestIdx++; // insert behind + SvxEscapementItem aItem( + SVX_ESCAPEMENT_SUPERSCRIPT ); + rDestNd.InsertItem(aItem, aDestIdx.GetIndex(), aDestIdx.GetIndex() ); - rDestNd.Insert( sExpand, aDestIdx, INS_EMPTYEXPAND ); + rDestNd.InsertText( sExpand, aDestIdx, + IDocumentContentOperations::INS_EMPTYEXPAND); aDestIdx = nInsPos + nAttrStartIdx; nInsPos = nInsPos + sExpand.Len(); } } - rDestNd.Erase( aDestIdx, 1 ); + rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; } break; default: - rDestNd.Erase( aDestIdx, 1 ); + rDestNd.EraseText( aDestIdx, 1 ); --nInsPos; } } @@ -3063,7 +3172,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, if( bWithNum ) { aDestIdx = nDestStt; - rDestNd.Insert( GetNumString(), aDestIdx ); + rDestNd.InsertText( GetNumString(), aDestIdx ); } if ( nHiddenChrs > 0 ) @@ -3077,7 +3186,7 @@ BOOL SwTxtNode::GetExpandTxt( SwTxtNode& rDestNd, const SwIndex* pDestIdx, while ( nIndex < rDestNd.GetTxt().Len() && cChar == rDestNd.GetTxt().GetChar( ++nIndex ) ) ; - rDestNd.Erase( aDestIdx, nIndex - aDestIdx.GetIndex() ); + rDestNd.EraseText( aDestIdx, nIndex - aDestIdx.GetIndex() ); } else ++aDestIdx; @@ -3197,55 +3306,35 @@ XubString SwTxtNode::GetRedlineTxt( xub_StrLen nIdx, xub_StrLen nLen, } /************************************************************************* - * SwTxtNode::GetExpandTxt + * SwTxtNode::ReplaceText *************************************************************************/ -// Felder werden expandiert: - -void SwTxtNode::Replace( const SwIndex& rStart, xub_Unicode cCh ) -{ - ASSERT( rStart.GetIndex() < m_Text.Len(), - "SwTxtNode::Replace: invalid index." ); - - SwTxtAttr* pHt; - if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( rStart.GetIndex() ) || - CH_TXTATR_INWORD == m_Text.GetChar( rStart.GetIndex() )) && - 0 != ( pHt = GetTxtAttr( rStart.GetIndex() ) )) - { - Delete( pHt ); - m_Text.Insert( cCh, rStart.GetIndex() ); - } - else - { - m_Text.SetChar( rStart.GetIndex(), cCh ); - } - - SwDelTxt aDelHint( rStart.GetIndex(), 1 ); - SwModify::Modify( 0, &aDelHint ); - SwInsTxt aHint( rStart.GetIndex(), 1 ); - SwModify::Modify( 0, &aHint ); -} - - -void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, - const XubString& rText ) +void SwTxtNode::ReplaceText( const SwIndex& rStart, const xub_StrLen nDelLen, + const XubString& rText ) { ASSERT( rStart.GetIndex() < m_Text.Len() && - rStart.GetIndex() + nLen <= m_Text.Len(), - "ausserhalb des Strings" ); - SwTxtAttr* pHt; + rStart.GetIndex() + nDelLen <= m_Text.Len(), + "SwTxtNode::ReplaceText: index out of bounds" ); const xub_StrLen nStartPos = rStart.GetIndex(); - xub_StrLen nEnde = nStartPos + nLen; - xub_StrLen nDelLen = nLen; - for( xub_StrLen nPos = nStartPos; nPos < nEnde; ++nPos ) + xub_StrLen nEndPos = nStartPos + nDelLen; + xub_StrLen nLen = nDelLen; + for ( xub_StrLen nPos = nStartPos; nPos < nEndPos; ++nPos ) { - if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( nPos ) || - CH_TXTATR_INWORD == m_Text.GetChar( nPos )) && - 0 != ( pHt = GetTxtAttr( nPos ) )) + if ( ( CH_TXTATR_BREAKWORD == m_Text.GetChar( nPos ) ) || + ( CH_TXTATR_INWORD == m_Text.GetChar( nPos ) ) ) { - Delete( pHt ); - --nEnde; - --nLen; + SwTxtAttr *const pHint = GetTxtAttrForCharAt( nPos ); + if (pHint) + { + ASSERT (!( pHint->GetEnd() && pHint->HasDummyChar() + && (*pHint->GetStart() < nEndPos) + && (*pHint->GetEnd() > nEndPos) ), + "ReplaceText: ERROR: " + "deleting left-overlapped attribute with CH_TXTATR"); + DeleteAttribute( pHint ); + --nEndPos; + --nLen; + } } } @@ -3260,20 +3349,21 @@ void SwTxtNode::Replace( const SwIndex& rStart, xub_StrLen nLen, ((SwIndex&)rStart)++; m_Text.Erase( rStart.GetIndex(), nLen - 1 ); - Update( rStart, nLen - 1, TRUE ); + Update( rStart, nLen - 1, true ); XubString aTmpTxt( rText ); aTmpTxt.Erase( 0, 1 ); m_Text.Insert( aTmpTxt, rStart.GetIndex() ); - Update( rStart, aTmpTxt.Len(), FALSE ); + Update( rStart, aTmpTxt.Len(), false ); } else { m_Text.Erase( nStartPos, nLen ); - Update( rStart, nLen, TRUE ); + Update( rStart, nLen, true ); m_Text.Insert( rText, nStartPos ); - Update( rStart, rText.Len(), FALSE ); + Update( rStart, rText.Len(), false ); } + SetIgnoreDontExpand( bOldExpFlg ); SwDelTxt aDelHint( nStartPos, nDelLen ); SwModify::Modify( 0, &aDelHint ); @@ -3581,24 +3671,6 @@ SwFmtColl* SwTxtNode::ChgFmtColl( SwFmtColl *pNewColl ) return pOldColl; } -// #111840# -SwPosition * SwTxtNode::GetPosition(const SwTxtAttr * pAttr) -{ - SwPosition * pResult = NULL; - - for (xub_StrLen i = 0; i < Len(); i++) - { - if (GetTxtAttr(i, pAttr->Which()) == pAttr) - { - pResult = new SwPosition(*this, SwIndex(this, i)); - - break; - } - } - - return pResult; -} - SwNodeNum* SwTxtNode::CreateNum() const { if ( !mpNodeNum ) diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index 49b17b884d..5a4d720489 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -445,7 +445,9 @@ SwFont::SwFont( const SwFont &rFont ) pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL; aUnderColor = rFont.GetUnderColor(); aOverColor = rFont.GetOverColor(); - nToxCnt = nRefCnt = 0; + nToxCnt = 0; + nRefCnt = 0; + m_nMetaCount = 0; bFntChg = rFont.bFntChg; bOrgChg = rFont.bOrgChg; bPaintBlank = rFont.bPaintBlank; @@ -461,7 +463,9 @@ SwFont::SwFont( const SwAttrSet* pAttrSet, const IDocumentSettingAccess* pIDocumentSettingAccess ) { nActual = SW_LATIN; - nToxCnt = nRefCnt = 0; + nToxCnt = 0; + nRefCnt = 0; + m_nMetaCount = 0; bPaintBlank = FALSE; bPaintWrong = FALSE; bURL = FALSE; @@ -590,7 +594,9 @@ SwFont& SwFont::operator=( const SwFont &rFont ) pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL; aUnderColor = rFont.GetUnderColor(); aOverColor = rFont.GetOverColor(); - nToxCnt = nRefCnt = 0; + nToxCnt = 0; + nRefCnt = 0; + m_nMetaCount = 0; bFntChg = rFont.bFntChg; bOrgChg = rFont.bOrgChg; bPaintBlank = rFont.bPaintBlank; diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 7802c1d576..7bd02bf4e4 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -65,6 +65,7 @@ #include <frmfmt.hxx> #include <ftnidx.hxx> #include <fmtruby.hxx> +#include <fmtmeta.hxx> #include <breakit.hxx> #include <doc.hxx> #include <errhdl.hxx> @@ -107,142 +108,497 @@ SwpHints::SwpHints() { } +struct TxtAttrDeleter +{ + SwAttrPool & m_rPool; + TxtAttrDeleter( SwDoc & rDoc ) : m_rPool( rDoc.GetAttrPool() ) { } + void operator() (SwTxtAttr * const pAttr) + { + SwTxtAttr::Destroy( pAttr, m_rPool ); + } +}; -// This function takes care for the following text attribute: -// RES_TXTATR_CHARFMT, RES_TXTATR_INETFMT, RES_TXTATR_AUTOFMT, and -// RES_TXTATR_CJK_RUBY. These attributes have to be handled in a -// special way (Portion building). -// 1. New attribute is RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT: -// The new attribute will be split by any existing RES_TXTATR_AUTOFMT, -// RES_TXTATR_CHARFMT or RES_TXTATR_INETFMT. The new attribute itself will -// split any existing RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT. -// 2. New attribute is RES_TXTATR_INETFMT: -// The new attribute will split any existing RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT. -// The new attribute will suppress any existing RES_TXTATR_INETFMT. -// 3. New attribute is RES_TXTATR_CJK_RUBY: -// The new attribute will suppress any existing RES_TXTATR_CJK_RUBY. +struct TxtAttrContains +{ + xub_StrLen m_nPos; + TxtAttrContains( const xub_StrLen nPos ) : m_nPos( nPos ) { } + bool operator() (SwTxtAttrEnd * const pAttr) + { + return (*pAttr->GetStart() < m_nPos) && (m_nPos < *pAttr->GetEnd()); + } +}; -void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMode ) +// a: |-----| +// b: +// |---| => valid: b before a +// |-----| => valid: start == end; b before a +// |---------| => invalid: overlap (1) +// |-----------| => valid: same end; b around a +// |-----------------| => valid: b around a +// |---| => valid; same start; b within a +// |-----| => valid; same start and end; b around or within a? +// |-----------| => valid: same start: b around a +// |-| => valid: b within a +// |---| => valid: same end; b within a +// |---------| => invalid: overlap (2) +// |-----| => valid: end == start; b after a +// |---| => valid: b after a +// ===> 2 invalid overlap cases +static +bool isOverlap(const xub_StrLen nStart1, const xub_StrLen nEnd1, + const xub_StrLen nStart2, const xub_StrLen nEnd2) { - ASSERT( RES_TXTATR_CHARFMT == rNewHint.Which() || - RES_TXTATR_INETFMT == rNewHint.Which() || - RES_TXTATR_AUTOFMT == rNewHint.Which() || - RES_TXTATR_CJK_RUBY == rNewHint.Which(), - "Expecting CHARFMT or AUTOFMT or INETFMT or RUBY" ) + return + ((nStart1 > nStart2) && (nStart1 < nEnd2) && (nEnd1 > nEnd2)) // (1) + || ((nStart1 < nStart2) && (nStart2 < nEnd1) && (nEnd1 < nEnd2)); // (2) +} - const USHORT nWhich = rNewHint.Which(); +static +bool isNestedAny(const xub_StrLen nStart1, const xub_StrLen nEnd1, + const xub_StrLen nStart2, const xub_StrLen nEnd2) +{ + return (nStart1 == nStart2) // in this case ends do not matter + || ((nStart1 < nStart2) ? (nEnd1 >= nEnd2) : (nEnd1 <= nEnd2)); +} - const xub_StrLen nThisStart = *rNewHint.GetStart(); - const xub_StrLen nThisEnd = *rNewHint.GetEnd(); - const bool bNoLengthAttribute = nThisStart == nThisEnd; +static +bool isSelfNestable(const USHORT nWhich) +{ + if ((RES_TXTATR_INETFMT == nWhich) || + (RES_TXTATR_CJK_RUBY == nWhich)) + return false; + ASSERT((RES_TXTATR_META == nWhich) || + (RES_TXTATR_METAFIELD == nWhich), "???"); + return true; +} - std::vector<SwTxtAttr*> aInsDelHints; - std::vector<SwTxtAttr*>::iterator aIter; +static +bool isSplittable(const USHORT nWhich) +{ + if ((RES_TXTATR_INETFMT == nWhich) || + (RES_TXTATR_CJK_RUBY == nWhich)) + return true; + ASSERT((RES_TXTATR_META == nWhich) || + (RES_TXTATR_METAFIELD == nWhich), "???"); + return false; +} - // - // 1. Some attributes are not allowed to overlap. - // They should displace attributes of the same kind. - // This is a special case for RES_TXTATR_INETFMT and - // RES_TXTATR_CJK_RUBY. - // - if ( RES_TXTATR_INETFMT == nWhich || RES_TXTATR_CJK_RUBY == nWhich ) +enum Split_t { FAIL, SPLIT_NEW, SPLIT_OTHER }; +/** + Calculate splitting policy for overlapping hints, based on what kind of + hint is inserted, and what kind of existing hint overlaps. + */ +static Split_t +splitPolicy(const USHORT nWhichNew, const USHORT nWhichOther) +{ + if (!isSplittable(nWhichOther)) { - for ( USHORT i = 0; i < Count(); ++i ) + if (!isSplittable(nWhichNew)) + return FAIL; + else + return SPLIT_NEW; + } + else + { + if ((RES_TXTATR_INETFMT == nWhichNew) && + (RES_TXTATR_CJK_RUBY == nWhichOther)) + return SPLIT_NEW; + else + return SPLIT_OTHER; + } +} + +static void +lcl_InitINetFmt(SwTxtNode & rNode, SwTxtINetFmt * pNew) +{ + pNew->ChgTxtNode(&rNode); + SwCharFmt * const pFmt( + rNode.GetDoc()->GetCharFmtFromPool(RES_POOLCHR_INET_NORMAL) ); + pFmt->Add( pNew ); +} + +static void +lcl_InitRuby(SwTxtNode & rNode, SwTxtRuby * pNew) +{ + pNew->ChgTxtNode(&rNode); + SwCharFmt * const pFmt( + rNode.GetDoc()->GetCharFmtFromPool(RES_POOLCHR_RUBYTEXT) ); + pFmt->Add( pNew ); +} + +/** + Create a new nesting text hint. + */ +static SwTxtAttrNesting * +MakeTxtAttrNesting(SwTxtNode & rNode, SwTxtAttrNesting & rNesting, + const xub_StrLen nStart, const xub_StrLen nEnd) +{ + SwTxtAttr * const pNew( MakeTxtAttr( + *rNode.GetDoc(), rNesting.GetAttr(), nStart, nEnd ) ); + switch (pNew->Which()) + { + case RES_TXTATR_INETFMT: { - SwTxtAttr* pOther = GetTextHint(i); + lcl_InitINetFmt(rNode, static_cast<SwTxtINetFmt*>(pNew)); + break; + } + case RES_TXTATR_CJK_RUBY: + { + lcl_InitRuby(rNode, static_cast<SwTxtRuby*>(pNew)); + break; + } + default: + ASSERT(false, "MakeTxtAttrNesting: what the hell is that?"); + break; + } + return static_cast<SwTxtAttrNesting*>(pNew); +} - if ( nWhich == pOther->Which() ) - { - xub_StrLen nOtherStart = *pOther->GetStart(); - const xub_StrLen nOtherEnd = *pOther->GetEnd(); +typedef ::std::vector<SwTxtAttrNesting *> NestList_t; - // Check if start of new attribute overlaps with pOther. - // Split pOther if necessary: - if ( nOtherStart < nThisStart && nThisStart < nOtherEnd ) - { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisStart ); - aInsDelHints.push_back( pNewAttr ); +static void +lcl_DoSplitNew(NestList_t & rSplits, SwTxtNode & rNode, + const xub_StrLen nNewStart, + const xub_StrLen nOtherStart, const xub_StrLen nOtherEnd, bool bOtherDummy) +{ + const bool bSplitAtStart(nNewStart < nOtherStart); + const xub_StrLen nSplitPos( (bSplitAtStart) ? nOtherStart : nOtherEnd ); + // first find the portion that is split (not necessarily the last one!) + NestList_t::iterator const iter( + ::std::find_if( rSplits.begin(), rSplits.end(), + TxtAttrContains(nSplitPos) ) ); + if (iter != rSplits.end()) // already split here? + { + const xub_StrLen nStartPos( // skip other's dummy character! + (bSplitAtStart && bOtherDummy) ? nSplitPos + 1 : nSplitPos ); + SwTxtAttrNesting * const pNew( MakeTxtAttrNesting( + rNode, **iter, nStartPos, *(*iter)->GetEnd() ) ); + *(*iter)->GetEnd() = nSplitPos; + rSplits.insert(iter + 1, pNew); + } +} - NoteInHistory( pOther ); - *pOther->GetStart() = nThisStart; - NoteInHistory( pOther, true ); - nOtherStart = nThisStart; - } +/** + Insert nesting hint into the hints array. Also calls NoteInHistory. + @param rNewHint the hint to be inserted (must not overlap existing!) + */ +void SwpHints::InsertNesting(SwTxtAttrNesting & rNewHint) +{ + SwpHintsArray::Insert(& rNewHint); + NoteInHistory( & rNewHint, true ); +} - // Check if end of new attribute overlaps with pOther: - // Split pOther if necessary: - if ( nOtherStart < nThisEnd && nThisEnd < nOtherEnd ) - { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), - nOtherStart, nThisEnd ); - aInsDelHints.push_back( pNewAttr ); +/** + +The following hints correspond to well-formed XML elements in ODF: +RES_TXTATR_INETFMT, RES_TXTATR_CJK_RUBY, RES_TXTATR_META, RES_TXTATR_METAFIELD + +The writer core must ensure that these do not overlap; if they did, +the document would not be storable as ODF. + +Also, a Hyperlink must not be nested within another Hyperlink, +and a Ruby must not be nested within another Ruby. + +The ODF export in xmloff will only put a hyperlink into a ruby, never a ruby +into a hyperlink. + +Unfortunately the UNO API for Hyperlink and Ruby consists of the properties +Hyperlink* and Ruby* of the css.text.CharacterProperties service. In other +words, they are treated as formatting attributes, not as content entites. +Furthermore, for API users it is not possible to easily test whether a certain +range would be overlapping with other nested attributes, and most importantly, +<em>which ones</em>, so we can hardly refuse to insert these in cases of +overlap. + +It is possible to split Hyperlink and Ruby into multiple portions, such that +the result is properly nested. + +meta and meta-field must not be split, because they have xml:id. + +These constraints result in the following design: + +RES_TXTATR_INETFMT: + always succeeds + inserts n attributes split at RES_TXTATR_CJK_RUBY, RES_TXTATR_META, + RES_TXTATR_METAFIELD + may replace existing RES_TXTATR_INETFMT at overlap +RES_TXTATR_CJK_RUBY: + always succeeds + inserts n attributes split at RES_TXTATR_META, RES_TXTATR_METAFIELD + may replace existing RES_TXTATR_CJK_RUBY at overlap + may split existing overlapping RES_TXTATR_INETFMT +RES_TXTATR_META: + may fail if overlapping existing RES_TXTATR_META/RES_TXTATR_METAFIELD + may split existing overlapping RES_TXTATR_INETFMT or RES_TXTATR_CJK_RUBY + inserts 1 attribute +RES_TXTATR_METAFIELD: + may fail if overlapping existing RES_TXTATR_META/RES_TXTATR_METAFIELD + may split existing overlapping RES_TXTATR_INETFMT or RES_TXTATR_CJK_RUBY + inserts 1 attribute + +The nesting is expressed by the position of the hints. +RES_TXTATR_META and RES_TXTATR_METAFIELD have a CH_TXTATR, and there can +only be one such hint starting and ending at a given position. +Only RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY lack a CH_TXTATR. +The interpretation given is that RES_TXTATR_CJK_RUBY is always around +a RES_TXTATR_INETFMT at the same start and end position (which corresponds +with the UNO API). +Both of these are always around a nesting hint with CH_TXTATR at the same +start and end position (if they should be inside, then the start should be +after the CH_TXTATR). +It would probably be a bad idea to add another nesting hint without +CH_TXTATR; on the other hand, it would be difficult adding a CH_TXTATR to +RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY, due to the overwriting and +splitting of exising hints that is necessary for backward compatibility. + + @param rNode the text node + @param rHint the hint to be inserted + @returns true iff hint was successfully inserted +*/ +bool +SwpHints::TryInsertNesting( SwTxtNode & rNode, SwTxtAttrNesting & rNewHint ) +{ +// INVARIANT: the nestable hints in the array are properly nested + const USHORT nNewWhich( rNewHint.Which() ); + const xub_StrLen nNewStart( *rNewHint.GetStart() ); + const xub_StrLen nNewEnd ( *rNewHint.GetEnd() ); +//??? const bool bNoLengthAttribute( nNewStart == nNewEnd ); + const bool bNewSelfNestable( isSelfNestable(nNewWhich) ); + + ASSERT( (RES_TXTATR_INETFMT == nNewWhich) || + (RES_TXTATR_CJK_RUBY == nNewWhich) || + (RES_TXTATR_META == nNewWhich) || + (RES_TXTATR_METAFIELD == nNewWhich), + "TryInsertNesting: Expecting INETFMT or RUBY or META or METAFIELD" ); + + NestList_t OverlappingExisting; // existing hints to be split + NestList_t OverwrittenExisting; // existing hints to be replaced + NestList_t SplitNew; // new hints to be inserted + + SplitNew.push_back(& rNewHint); + + // pass 1: split the inserted hint into fragments if necessary + for ( USHORT i = 0; i < GetEndCount(); ++i ) + { + SwTxtAttr * const pOther = GetEnd(i); - NoteInHistory( pOther ); - *pOther->GetStart() = nThisEnd; - NoteInHistory( pOther, true ); + if (pOther->IsNesting()) + { + const USHORT nOtherWhich( pOther->Which() ); + const xub_StrLen nOtherStart( *(pOther)->GetStart() ); + const xub_StrLen nOtherEnd ( *(pOther)->GetEnd() ); + if (isOverlap(nNewStart, nNewEnd, nOtherStart, nOtherEnd )) + { + switch (splitPolicy(nNewWhich, nOtherWhich)) + { + case FAIL: + OSL_TRACE("cannot insert hint: overlap detected"); + ::std::for_each(SplitNew.begin(), SplitNew.end(), + TxtAttrDeleter(*rNode.GetDoc())); + return false; + case SPLIT_NEW: + lcl_DoSplitNew(SplitNew, rNode, nNewStart, + nOtherStart, nOtherEnd, pOther->HasDummyChar()); + break; + case SPLIT_OTHER: + OverlappingExisting.push_back( + static_cast<SwTxtAttrNesting*>(pOther)); + break; + default: + ASSERT(false, "bad code monkey"); + break; + } + } + else if (isNestedAny(nNewStart, nNewEnd, nOtherStart, nOtherEnd)) + { + if (!bNewSelfNestable && (nNewWhich == nOtherWhich)) + { + // ruby and hyperlink: if there is nesting, _overwrite_ + OverwrittenExisting.push_back( + static_cast<SwTxtAttrNesting*>(pOther)); + } + else if ((nNewStart == nOtherStart) && pOther->HasDummyChar()) + { + if (rNewHint.HasDummyChar()) + { + ASSERT(false, + "ERROR: inserting duplicate CH_TXTATR hint"); + return false; + } else if (nNewEnd < nOtherEnd) { + // other has dummy char, new is inside other, but + // new contains the other's dummy char? + // should be corrected because it may lead to problems + // in SwXMeta::createEnumeration + // SplitNew is sorted, so this is the first split + xub_StrLen *const pStart(SplitNew.front()->GetStart()); + ASSERT(*pStart == nNewStart, "how did that happen?"); + *pStart = nNewStart + 1; + } } } } + } - // Insert the newly created attributes: - const sal_uInt16 nCharFmtID = static_cast<sal_uInt16>( RES_TXTATR_INETFMT == nWhich ? - RES_POOLCHR_INET_NORMAL : - RES_POOLCHR_RUBYTEXT ); - SwCharFmt* pFmt = rNode.GetDoc()->GetCharFmtFromPool( nCharFmtID ); + ASSERT (isSplittable(nNewWhich) || SplitNew.size() == 1, + "splitting the unsplittable ???"); + + // pass 2: split existing hints that overlap/nest with new hint + // do not iterate over hints array, but over remembered set of overlapping + // hints, to keep things simple w.r.t. insertion/removal + // N.B: if there is a hint that splits the inserted hint, then + // that hint would also have already split any hint in OverlappingExisting + // so any hint in OverlappingExisting can be split at most by one hint + // in SplitNew, or even not at all (this is not true for existing hints + // that go _around_ new hint, which is the raison d'^etre for pass 4) + for (NestList_t::iterator itOther = OverlappingExisting.begin(); + itOther != OverlappingExisting.end(); ++itOther) + { + const xub_StrLen nOtherStart( *(*itOther)->GetStart() ); + const xub_StrLen nOtherEnd ( *(*itOther)->GetEnd() ); - for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter ) + for (NestList_t::iterator itNew = SplitNew.begin(); + itNew != SplitNew.end(); ++itNew) { - if ( RES_TXTATR_INETFMT == nWhich ) + const xub_StrLen nSplitNewStart( *(*itNew)->GetStart() ); + const xub_StrLen nSplitNewEnd ( *(*itNew)->GetEnd() ); + // 4 cases: within, around, overlap l, overlap r, (OTHER: no action) + const bool bRemoveOverlap( + !bNewSelfNestable && (nNewWhich == (*itOther)->Which()) ); + + switch (ComparePosition(nSplitNewStart, nSplitNewEnd, + nOtherStart, nOtherEnd)) { - SwTxtINetFmt* pInetAttr = static_cast<SwTxtINetFmt*>(*aIter); - pInetAttr->ChgTxtNode( &rNode ); - pFmt->Add( pInetAttr ); - + case POS_INSIDE: + { + ASSERT(!bRemoveOverlap, + "this one should be in OverwrittenExisting?"); + } + break; + case POS_OUTSIDE: + case POS_EQUAL: + { + ASSERT(false, "existing hint inside new hint: why?"); + } + break; + case POS_OVERLAP_BEFORE: + { + Delete( *itOther ); // this also does NoteInHistory! + *(*itOther)->GetStart() = nSplitNewEnd; + InsertNesting( **itOther ); + if (!bRemoveOverlap) + { + if ( USHRT_MAX == Count() ) + { + ASSERT(false, "hints array full :-("); + return false; + } + SwTxtAttrNesting * const pOtherLeft( + MakeTxtAttrNesting( rNode, **itOther, + nOtherStart, nSplitNewEnd ) ); + InsertNesting( *pOtherLeft ); + } + } + break; + case POS_OVERLAP_BEHIND: + { + Delete( *itOther ); // this also does NoteInHistory! + *(*itOther)->GetEnd() = nSplitNewStart; + InsertNesting( **itOther ); + if (!bRemoveOverlap) + { + if ( USHRT_MAX == Count() ) + { + ASSERT(false, "hints array full :-("); + return false; + } + SwTxtAttrNesting * const pOtherRight( + MakeTxtAttrNesting( rNode, **itOther, + nSplitNewStart, nOtherEnd ) ); + InsertNesting( *pOtherRight ); + } + } + break; + default: + break; // overlap resolved by splitting new: nothing to do } + } + } - else - { - SwTxtRuby* pRubyAttr = static_cast<SwTxtRuby*>(*aIter); - pRubyAttr->ChgTxtNode( &rNode ); - pFmt->Add( pRubyAttr ); - - } + if ( USHRT_MAX - SplitNew.size() <= Count() ) + { + ASSERT(false, "hints array full :-("); + return false; + } - SwpHintsArray::Insert( *aIter ); - NoteInHistory( *aIter, true ); - } + // pass 3: insert new hints + for (NestList_t::iterator iter = SplitNew.begin(); + iter != SplitNew.end(); ++iter) + { + InsertNesting(**iter); + } - aInsDelHints.clear(); + // pass 4: handle overwritten hints + // RES_TXTATR_INETFMT and RES_TXTATR_CJK_RUBY should displace attributes + // of the same kind. + for (NestList_t::iterator itOther = OverwrittenExisting.begin(); + itOther != OverwrittenExisting.end(); ++itOther) + { + const xub_StrLen nOtherStart( *(*itOther)->GetStart() ); + const xub_StrLen nOtherEnd ( *(*itOther)->GetEnd() ); - // Now delete all attributes of the same type as the new one - // which are fully covered by the new attribute: - for ( USHORT i = 0; i < Count(); ++i ) + // overwritten portion is given by start/end of inserted hint + if ((nNewStart <= nOtherStart) && (nOtherEnd <= nNewEnd)) { - SwTxtAttr* pOther = GetTextHint(i); - if ( nWhich == pOther->Which() ) - { - const xub_StrLen nOtherStart = *pOther->GetStart(); - const xub_StrLen nOtherEnd = *pOther->GetEnd(); - - if ( nOtherStart >= nThisStart && nOtherEnd <= nThisEnd ) - aInsDelHints.push_back( pOther ); - } + Delete(*itOther); + rNode.DestroyAttr( *itOther ); } - for ( aIter = aInsDelHints.begin(); aIter != aInsDelHints.end(); ++aIter ) + else { - Delete( *aIter ); - rNode.DestroyAttr( *aIter ); + ASSERT((nOtherStart < nNewStart) && (nNewEnd < nOtherEnd), "huh?"); + // scenario: there is a RUBY, and contained within that a META; + // now a RUBY is inserted within the META => the exising RUBY is split: + // here it is not possible to simply insert the left/right fragment + // of the existing RUBY because they <em>overlap</em> with the META! + Delete( *itOther ); // this also does NoteInHistory! + *(*itOther)->GetEnd() = nNewStart; + bool bSuccess( TryInsertNesting(rNode, **itOther) ); + ASSERT(bSuccess, "recursive call 1 failed?"); + SwTxtAttrNesting * const pOtherRight( + MakeTxtAttrNesting( + rNode, **itOther, nNewEnd, nOtherEnd ) ); + bSuccess = TryInsertNesting(rNode, *pOtherRight); + ASSERT(bSuccess, "recursive call 2 failed?"); } - SwpHintsArray::Insert( &rNewHint ); - NoteInHistory( &rNewHint, true ); - - return; } + return true; +} + + +// This function takes care for the following text attribute: +// RES_TXTATR_CHARFMT, RES_TXTATR_AUTOFMT +// These attributes have to be handled in a special way (Portion building). +// +// The new attribute will be split by any existing RES_TXTATR_AUTOFMT or +// RES_TXTATR_CHARFMT. The new attribute itself will +// split any existing RES_TXTATR_AUTOFMT or RES_TXTATR_CHARFMT. + +void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, + const SetAttrMode nMode ) +{ + const USHORT nWhich = rNewHint.Which(); + + const xub_StrLen nThisStart = *rNewHint.GetStart(); + const xub_StrLen nThisEnd = *rNewHint.GetEnd(); + const bool bNoLengthAttribute = nThisStart == nThisEnd; + + std::vector<SwTxtAttr*> aInsDelHints; + std::vector<SwTxtAttr*>::iterator aIter; + ASSERT( RES_TXTATR_CHARFMT == rNewHint.Which() || RES_TXTATR_AUTOFMT == rNewHint.Which(), - "Expecting CHARFMT or AUTOFMT" ) + "Expecting CHARFMT or AUTOFMT" ); // // 2. Find the hints which cover the start and end position @@ -265,7 +621,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Split pOther if necessary: if ( nOtherStart < nThisStart && nThisStart < nOtherEnd ) { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisStart ); + SwTxtAttr* pNewAttr = MakeTxtAttr( *rNode.GetDoc(), + pOther->GetAttr(), nOtherStart, nThisStart ); if ( RES_TXTATR_CHARFMT == pOther->Which() ) static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); @@ -281,7 +638,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Split pOther if necessary: if ( nOtherStart < nThisEnd && nThisEnd < nOtherEnd ) { - SwTxtAttr* pNewAttr = rNode.MakeTxtAttr( pOther->GetAttr(), nOtherStart, nThisEnd ); + SwTxtAttr* pNewAttr = MakeTxtAttr( *rNode.GetDoc(), + pOther->GetAttr(), nOtherStart, nThisEnd ); if ( RES_TXTATR_CHARFMT == pOther->Which() ) static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( static_cast<SwTxtCharFmt*>(pOther)->GetSortNumber() ); aInsDelHints.push_back( pNewAttr ); @@ -433,8 +791,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Create new AutoStyle if ( aNewSet.Count() ) { - pNewAttr = rNode.MakeTxtAttr( aNewSet, - nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), + aNewSet, nPorStart, nPorEnd ); SwpHintsArray::Insert( pNewAttr ); NoteInHistory( pNewAttr, true ); } @@ -453,7 +811,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod } else { - pNewAttr = rNode.MakeTxtAttr( rNewHint.GetAttr(), nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), rNewHint.GetAttr(), + nPorStart, nPorEnd ); static_cast<SwTxtCharFmt*>(pNewAttr)->SetSortNumber( nCharStyleCount ); } } @@ -510,7 +869,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod // Create new AutoStyle if ( aNewSet.Count() ) - pNewAttr = rNode.MakeTxtAttr( aNewSet, nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), aNewSet, + nPorStart, nPorEnd ); } else { @@ -568,7 +928,8 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod } else if ( pNewStyle.get() ) { - pNewAttr = rNode.MakeTxtAttr( *pNewStyle, nPorStart, nPorEnd ); + pNewAttr = MakeTxtAttr( *rNode.GetDoc(), *pNewStyle, + nPorStart, nPorEnd ); } } } @@ -597,35 +958,66 @@ void SwpHints::BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMod * SwTxtNode::MakeTxtAttr() *************************************************************************/ -// create new text attribute -SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnd, bool bRedlineAttr ) +SwTxtAttr* MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem & rAttr ) { - SwDoc* pDoc = GetDoc(); + // this is intended _only_ for special-purpose redline attributes! + switch (rAttr.Which()) + { + case RES_CHRATR_COLOR: + case RES_CHRATR_WEIGHT: + case RES_CHRATR_CJK_WEIGHT: + case RES_CHRATR_CTL_WEIGHT: + case RES_CHRATR_POSTURE: + case RES_CHRATR_CJK_POSTURE: + case RES_CHRATR_CTL_POSTURE: + case RES_CHRATR_UNDERLINE: + case RES_CHRATR_CROSSEDOUT: + case RES_CHRATR_CASEMAP: + case RES_CHRATR_BACKGROUND: + break; + default: + ASSERT(false, "unsupported redline attribute"); + break; + } + + // Put new attribute into pool + // FIXME: this const_cast is evil! + SfxPoolItem& rNew = + const_cast<SfxPoolItem&>( rDoc.GetAttrPool().Put( rAttr ) ); + return new SwTxtAttrEnd( rNew, 0, 0 ); +} - if ( !bRedlineAttr && isCHRATR(rAttr.Which()) ) +// create new text attribute +SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr, + xub_StrLen nStt, xub_StrLen nEnd ) +{ + if ( isCHRATR(rAttr.Which()) ) { - // Somebody wants to build a SwTxtAttr for a character attribute (and - // this attribute is not meant for redlining). Sorry, this is not allowed - // any longer. You'll get a brand new autostyle attribute: - SfxItemSet aItemSet( pDoc->GetAttrPool(), RES_CHRATR_BEGIN, RES_CHRATR_END ); + // Somebody wants to build a SwTxtAttr for a character attribute. + // Sorry, this is not allowed any longer. + // You'll get a brand new autostyle attribute: + SfxItemSet aItemSet( rDoc.GetAttrPool(), + RES_CHRATR_BEGIN, RES_CHRATR_END ); aItemSet.Put( rAttr ); - return MakeTxtAttr( aItemSet, nStt, nEnd ); + return MakeTxtAttr( rDoc, aItemSet, nStt, nEnd ); } else if ( RES_TXTATR_AUTOFMT == rAttr.Which() && - static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle()->GetPool() != &pDoc->GetAttrPool() ) + static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle()-> + GetPool() != &rDoc.GetAttrPool() ) { - // If the attribut is an autostyle which referes to a pool that is different from - // pDoc's pool, we have to correct this: + // If the attribute is an auto-style which refers to a pool that is + // different from rDoc's pool, we have to correct this: const StylePool::SfxItemSet_Pointer_t pAutoStyle = static_cast<const SwFmtAutoFmt&>(rAttr).GetStyleHandle(); - const SfxItemSet* pNewSet = pAutoStyle->SfxItemSet::Clone( TRUE, &pDoc->GetAttrPool() ); - SwTxtAttr* pNew = MakeTxtAttr( *pNewSet, nStt, nEnd ); - delete pNewSet; + ::std::auto_ptr<const SfxItemSet> pNewSet( + pAutoStyle->SfxItemSet::Clone( TRUE, &rDoc.GetAttrPool() )); + SwTxtAttr* pNew = MakeTxtAttr( rDoc, *pNewSet, nStt, nEnd ); return pNew; } - // Put new attribute into pool unless we are asked to build a redline attribute - const SfxPoolItem& rNew = !bRedlineAttr ? GetDoc()->GetAttrPool().Put( rAttr ) : rAttr; + // Put new attribute into pool + // FIXME: this const_cast is evil! + SfxPoolItem& rNew = + const_cast<SfxPoolItem&>( rDoc.GetAttrPool().Put( rAttr ) ); SwTxtAttr* pNew = 0; switch( rNew.Which() ) @@ -634,7 +1026,9 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, { SwFmtCharFmt &rFmtCharFmt = (SwFmtCharFmt&) rNew; if( !rFmtCharFmt.GetCharFmt() ) - rFmtCharFmt.SetCharFmt( GetDoc()->GetDfltCharFmt() ); + { + rFmtCharFmt.SetCharFmt( rDoc.GetDfltCharFmt() ); + } pNew = new SwTxtCharFmt( rFmtCharFmt, nStt, nEnd ); } @@ -650,9 +1044,11 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, // erst hier wird das Frame-Format kopiert (mit Inhalt) !! pNew = new SwTxtFlyCnt( (SwFmtFlyCnt&)rNew, nStt ); // Kopie von einem Text-Attribut - if( ((SwFmtFlyCnt&)rAttr).GetTxtFlyCnt() ) - // dann muss das Format Kopiert werden - ((SwTxtFlyCnt*)pNew)->CopyFlyFmt( GetDoc() ); + if ( static_cast<const SwFmtFlyCnt &>(rAttr).GetTxtFlyCnt() ) + { + // then the format must be copied + static_cast<SwTxtFlyCnt *>(pNew)->CopyFlyFmt( &rDoc ); + } } break; case RES_TXTATR_FTN: @@ -661,12 +1057,6 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, if( ((SwFmtFtn&)rAttr).GetTxtFtn() ) ((SwTxtFtn*)pNew)->SetSeqNo( ((SwFmtFtn&)rAttr).GetTxtFtn()->GetSeqRefNo() ); break; - case RES_TXTATR_HARDBLANK: - pNew = new SwTxtHardBlank( (SwFmtHardBlank&)rNew, nStt ); - break; - case RES_CHRATR_TWO_LINES: - pNew = new SwTxt2Lines( (SvxTwoLinesItem&)rNew, nStt, nEnd ); - break; case RES_TXTATR_REFMARK: pNew = nStt == nEnd ? new SwTxtRefMark( (SwFmtRefMark&)rNew, nStt ) @@ -683,7 +1073,12 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, case RES_TXTATR_CJK_RUBY: pNew = new SwTxtRuby( (SwFmtRuby&)rNew, nStt, nEnd ); break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + pNew = new SwTxtMeta( static_cast<SwFmtMeta&>(rNew), nStt, nEnd ); + break; default: + ASSERT(RES_TXTATR_AUTOFMT == rNew.Which(), "unknown attribute"); pNew = new SwTxtAttrEnd( rNew, nStt, nEnd ); break; } @@ -691,13 +1086,14 @@ SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxPoolItem& rAttr, return pNew; } -SwTxtAttr* SwTxtNode::MakeTxtAttr( const SfxItemSet& rSet, xub_StrLen nStt, xub_StrLen nEnd ) +SwTxtAttr* MakeTxtAttr( SwDoc & rDoc, const SfxItemSet& rSet, + xub_StrLen nStt, xub_StrLen nEnd ) { - IStyleAccess& rStyleAccess = getIDocumentStyleAccess(); + IStyleAccess& rStyleAccess = rDoc.GetIStyleAccess(); const StylePool::SfxItemSet_Pointer_t pAutoStyle = rStyleAccess.getAutomaticStyle( rSet, IStyleAccess::AUTO_STYLE_CHAR ); SwFmtAutoFmt aNewAutoFmt; aNewAutoFmt.SetStyleHandle( pAutoStyle ); - SwTxtAttr* pNew = MakeTxtAttr( aNewAutoFmt, nStt, nEnd ); + SwTxtAttr* pNew = MakeTxtAttr( rDoc, aNewAutoFmt, nStt, nEnd ); return pNew; } @@ -781,6 +1177,14 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) case RES_TXTATR_REFMARK: nDelMsg = RES_REFMARK_DELETED; break; + + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + static_cast<SwFmtMeta&>(pAttr->GetAttr()).NotifyRemoval(); + break; + + default: + break; } if( nDelMsg && !pDoc->IsInDtor() && GetNodes().IsDocNodes() ) @@ -789,8 +1193,7 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) pDoc->GetUnoCallBack()->Modify( &aMsgHint, &aMsgHint ); } - pAttr->RemoveFromPool( pDoc->GetAttrPool() ); - delete pAttr; + SwTxtAttr::Destroy( pAttr, pDoc->GetAttrPool() ); } } @@ -798,30 +1201,52 @@ void SwTxtNode::DestroyAttr( SwTxtAttr* pAttr ) * SwTxtNode::Insert() *************************************************************************/ -// lege ein neues TextAttribut an und fuege es ins SwpHints-Array ein -SwTxtAttr* SwTxtNode::InsertItem( const SfxPoolItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnd, USHORT nMode ) +SwTxtAttr* +SwTxtNode::InsertItem( SfxPoolItem& rAttr, + const xub_StrLen nStart, const xub_StrLen nEnd, const SetAttrMode nMode ) { // character attributes will be inserted as automatic styles: ASSERT( !isCHRATR(rAttr.Which()), "AUTOSTYLES - " "SwTxtNode::InsertItem should not be called with character attributes"); - SwTxtAttr* pNew = MakeTxtAttr( rAttr, nStt, nEnd ); + SwTxtAttr* const pNew = MakeTxtAttr( *GetDoc(), rAttr, nStart, nEnd ); if ( pNew ) - Insert( pNew, nMode ); + { + const bool bSuccess( InsertHint( pNew, nMode ) ); + // N.B.: also check that the hint is actually in the hints array, + // because hints of certain types may be merged after succesful + // insertion, and thus destroyed! + if (!bSuccess || ( USHRT_MAX == m_pSwpHints->GetPos( pNew ) )) + { + return 0; + } + } return pNew; } -// uebernehme den Pointer auf das Text-Attribut -BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) +// take ownership of pAttr; if insertion fails, delete pAttr +bool SwTxtNode::InsertHint( SwTxtAttr * const pAttr, const SetAttrMode nMode ) { BOOL bHiddenPara = FALSE; - ASSERT( pAttr && *pAttr->GetStart() <= Len(), "StartIdx hinter Len!" ); - - if( !pAttr->GetEnd() ) + ASSERT( pAttr && *pAttr->GetStart() <= Len(), "StartIdx out of bounds!" ); + ASSERT( !pAttr->GetEnd() || (*pAttr->GetEnd() <= Len()), + "EndIdx out of bounds!" ); + + // translate from SetAttrMode to InsertMode (for hints with CH_TXTATR) + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (nMode & nsSetAttrMode::SETATTR_FORCEHINTEXPAND) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + + // need this after TryInsertHint, when pAttr may be deleted + const xub_StrLen nStart( *pAttr->GetStart() ); + const bool bDummyChar( pAttr->HasDummyChar() ); + if (bDummyChar) { USHORT nInsMode = nMode; switch( pAttr->Which() ) @@ -843,7 +1268,8 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) (const SfxPoolItem**)&pAnchor ); SwIndex aIdx( this, *pAttr->GetStart() ); - Insert( GetCharOfTxtAttr(*pAttr), aIdx ); + const sal_Unicode c = GetCharOfTxtAttr(*pAttr); + InsertText( c, aIdx, nInsertFlags ); nInsMode |= nsSetAttrMode::SETATTR_NOTXTATRCHR; if( pAnchor && FLY_IN_CNTNT == pAnchor->GetAnchorId() && @@ -892,7 +1318,7 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) pDoc->DoUndo( FALSE ); DestroyAttr( pAttr ); pDoc->DoUndo( bUndo ); - return FALSE; + return false; } } break; @@ -926,7 +1352,7 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) Update( aTmpIdx, 1, TRUE ); } DestroyAttr( pAttr ); - return FALSE; + return false; } // wird eine neue Fussnote eingefuegt ?? @@ -957,7 +1383,8 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) // entstehen koennen und das Attribut im _SortArr_ am // Dokument nicht eingetrage wird. SwIndex aNdIdx( this, *pAttr->GetStart() ); - Insert( GetCharOfTxtAttr(*pAttr), aNdIdx ); + const sal_Unicode c = GetCharOfTxtAttr(*pAttr); + InsertText( c, aNdIdx, nInsertFlags ); nInsMode |= nsSetAttrMode::SETATTR_NOTXTATRCHR; } @@ -1020,92 +1447,105 @@ BOOL SwTxtNode::Insert( SwTxtAttr *pAttr, USHORT nMode ) if( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nInsMode) ) { SwIndex aIdx( this, *pAttr->GetStart() ); - Insert( GetCharOfTxtAttr(*pAttr), aIdx ); + InsertText( GetCharOfTxtAttr(*pAttr), aIdx, nInsertFlags ); + + // adjust end of hint to account for inserted CH_TXTATR + xub_StrLen * const pEnd(pAttr->GetEnd()); + if (pEnd) + { + *pEnd = *pEnd + 1; + } } } - else { - ASSERT( *pAttr->GetEnd() <= Len(), "EndIdx hinter Len!" ); - } GetOrCreateSwpHints(); // 4263: AttrInsert durch TextInsert => kein Adjust - m_pSwpHints->Insert( pAttr, *this, nMode ); + const bool bRet = m_pSwpHints->TryInsertHint( pAttr, *this, nMode ); - // 47375: In pSwpHints->Insert wird u.a. Merge gerufen und das Hints-Array - // von ueberfluessigen Hints befreit, dies kann u.U. sogar der frisch - // eingefuegte Hint pAttr sein, der dann zerstoert wird!! - if ( USHRT_MAX == m_pSwpHints->GetPos( pAttr ) ) + if (!bRet && bDummyChar) { - return FALSE; + // undo insertion of dummy character + // N.B. cannot insert the dummy character after inserting the hint, + // because if the hint has no extent it will be moved in InsertText, + // resulting in infinite recursion + if ( !(nsSetAttrMode::SETATTR_NOTXTATRCHR & nMode) ) + { + ASSERT( ( CH_TXTATR_BREAKWORD == m_Text.GetChar(nStart) || + CH_TXTATR_INWORD == m_Text.GetChar(nStart) ), + "where is my attribute character?" ); + SwIndex aIdx( this, nStart ); + EraseText( aIdx, 1 ); + } } - if( bHiddenPara ) + if ( bHiddenPara ) + { SetCalcHiddenParaField(); + } - return TRUE; + return bRet; } /************************************************************************* - * SwTxtNode::Delete() + * SwTxtNode::DeleteAttribute() *************************************************************************/ -void SwTxtNode::Delete( SwTxtAttr *pAttr, BOOL bThisOnly ) +void SwTxtNode::DeleteAttribute( SwTxtAttr * const pAttr ) { if ( !HasHints() ) + { + ASSERT(false, "DeleteAttribute called, but text node without hints?"); return; + } - if( bThisOnly ) + if ( pAttr->HasDummyChar() ) { - xub_StrLen* pEndIdx = pAttr->GetEnd(); - if( !pEndIdx ) - { - // hat es kein Ende kann es nur das sein, was hier steht! - // Unbedingt Copy-konstruieren! - const SwIndex aIdx( this, *pAttr->GetStart() ); - Erase( aIdx, 1 ); - } - else - { - // den MsgHint jetzt fuettern, weil gleich sind - // Start und End weg. - SwUpdateAttr aHint( *pAttr->GetStart(), *pEndIdx, pAttr->Which() ); - m_pSwpHints->Delete( pAttr ); - pAttr->RemoveFromPool( GetDoc()->GetAttrPool() ); - delete pAttr; - SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen - - TryDeleteSwpHints(); - } - - return; + // Unbedingt Copy-konstruieren! + const SwIndex aIdx( this, *pAttr->GetStart() ); + // erase the CH_TXTATR, which will also delete pAttr + EraseText( aIdx, 1 ); + } + else + { + // create MsgHint before start/end become invalid + SwUpdateAttr aHint( + *pAttr->GetStart(), *pAttr->GetEnd(), pAttr->Which() ); + m_pSwpHints->Delete( pAttr ); + SwTxtAttr::Destroy( pAttr, GetDoc()->GetAttrPool() ); + SwModify::Modify( 0, &aHint ); // notify Frames + + TryDeleteSwpHints(); } - Delete( pAttr->Which(), *pAttr->GetStart(), *pAttr->GetAnyEnd() ); } /************************************************************************* - * SwTxtNode::Delete() + * SwTxtNode::DeleteAttributes() *************************************************************************/ -void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) +//FIXME: this does NOT respect SORT NUMBER (for CHARFMT)! +void SwTxtNode::DeleteAttributes( const USHORT nWhich, + const xub_StrLen nStart, const xub_StrLen nEnd ) { if ( !HasHints() ) return; - const xub_StrLen *pEndIdx; - const xub_StrLen *pSttIdx; - SwTxtAttr* pTxtHt; - for ( USHORT nPos = 0; m_pSwpHints && nPos < m_pSwpHints->Count(); nPos++ ) { - pTxtHt = m_pSwpHints->GetTextHint( nPos ); - const USHORT nWhich = pTxtHt->Which(); - if( nWhich == nTxtWhich && - *( pSttIdx = pTxtHt->GetStart()) == nStt ) + SwTxtAttr * const pTxtHt = m_pSwpHints->GetTextHint( nPos ); + const xub_StrLen nHintStart = *(pTxtHt->GetStart()); + if (nStart < nHintStart) + { + break; // sorted by start + } + else if ( (nStart == nHintStart) && (nWhich == pTxtHt->Which()) ) { if ( nWhich == RES_CHRATR_HIDDEN ) + { + ASSERT(false, "hey, that's a CHRATR! how did that get in?"); SetCalcHiddenCharFlags(); + } else if ( nWhich == RES_TXTATR_CHARFMT ) { // Check if character format contains hidden attribute: @@ -1124,16 +1564,14 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) } // <-- - pEndIdx = pTxtHt->GetEnd(); + xub_StrLen const * const pEndIdx = pTxtHt->GetEnd(); - // Text-Attribute sind voellig dynamisch, so dass diese nur - // mit ihrer Start-Position verglichen werden. - if( !pEndIdx ) + if ( pTxtHt->HasDummyChar() ) { // Unbedingt Copy-konstruieren! - const SwIndex aIdx( this, *pSttIdx ); - Erase( aIdx, 1 ); - break; + const SwIndex aIdx( this, nStart ); + // erase the CH_TXTATR, which will also delete pTxtHt + EraseText( aIdx, 1 ); } else if( *pEndIdx == nEnd ) { @@ -1141,12 +1579,10 @@ void SwTxtNode::Delete( USHORT nTxtWhich, xub_StrLen nStt, xub_StrLen nEnd ) // Start und End weg. // Das CalcVisibleFlag bei HiddenParaFields entfaellt, // da dies das Feld im Dtor selbst erledigt. - SwUpdateAttr aHint( *pSttIdx, *pEndIdx, nTxtWhich ); + SwUpdateAttr aHint( nStart, *pEndIdx, nWhich ); m_pSwpHints->DeleteAtPos( nPos ); // gefunden, loeschen, - pTxtHt->RemoveFromPool( GetDoc()->GetAttrPool() ); - delete pTxtHt; + SwTxtAttr::Destroy( pTxtHt, GetDoc()->GetAttrPool() ); SwModify::Modify( 0, &aHint ); // die Frames benachrichtigen - break; } } } @@ -1165,7 +1601,7 @@ void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) nFndPos < nEndPos ) { const SwIndex aIdx( this, nFndPos ); - Erase( aIdx, 1 ); + EraseText( aIdx, 1 ); --nEndPos; } } @@ -1173,7 +1609,7 @@ void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) // setze diese Attribute am TextNode. Wird der gesamte Bereich umspannt, // dann setze sie nur im AutoAttrSet (SwCntntNode:: SetAttr) BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, - xub_StrLen nEnd, USHORT nMode ) + xub_StrLen nEnd, const SetAttrMode nMode ) { if( !rSet.Count() ) return FALSE; @@ -1262,7 +1698,8 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, } else { - pNew = MakeTxtAttr( *pItem, nStt, nEnd ); + pNew = MakeTxtAttr( *GetDoc(), + const_cast<SfxPoolItem&>(*pItem), nStt, nEnd ); if ( pNew ) { if ( nEnd != nStt && !pNew->GetEnd() ) @@ -1271,7 +1708,7 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, "Attribut without end, but area marked"); DestroyAttr( pNew ); // do not insert } - else if ( Insert( pNew, nMode ) ) + else if ( InsertHint( pNew, nMode ) ) { ++nCount; } @@ -1287,9 +1724,11 @@ BOOL SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, if ( aCharSet.Count() ) { - SwTxtAttr* pTmpNew = MakeTxtAttr( aCharSet, nStt, nEnd ); - if ( Insert( pTmpNew, nMode ) ) + SwTxtAttr* pTmpNew = MakeTxtAttr( *GetDoc(), aCharSet, nStt, nEnd ); + if ( InsertHint( pTmpNew, nMode ) ) + { ++nCount; + } } TryDeleteSwpHints(); @@ -1669,7 +2108,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) if (lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() )) { m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); + MakeTxtAttr( *GetDoc(), + const_cast<SfxPoolItem&>(*pItem), + 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } @@ -1701,8 +2142,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) &pNdItem ) || *pItem != *pNdItem ) && lcl_IsNewAttrInSet( *m_pSwpHints, *pItem, GetTxt().Len() ) ) { - m_pSwpHints->SwpHintsArray::Insert( - MakeTxtAttr( *pItem, 0, GetTxt().Len() ) ); + m_pSwpHints->SwpHintsArray::Insert( MakeTxtAttr( *GetDoc(), + const_cast<SfxPoolItem&>(*pItem), + 0, GetTxt().Len() ) ); aClearWhichIds.push_back( pItem->Which() ); } aNdSet.ClearItem( pItem->Which() ); @@ -1726,7 +2168,9 @@ void SwTxtNode::FmtToTxtAttr( SwTxtNode* pNd ) pNd->GetTxt().Len() ) ) { pNd->m_pSwpHints->SwpHintsArray::Insert( - pNd->MakeTxtAttr( *pItem, 0, pNd->GetTxt().Len() ) ); + MakeTxtAttr( *pNd->GetDoc(), + const_cast<SfxPoolItem&>(*pItem), + 0, pNd->GetTxt().Len() ) ); } aClearWhichIds.push_back( pItem->Which() ); @@ -1979,18 +2423,20 @@ void lcl_CheckSortNumber( const SwpHints& rHints, SwTxtCharFmt& rNewCharFmt ) *************************************************************************/ /* - * Insert: Der neue Hint wird immer eingefuegt. Wenn dabei ein - * ueberlappender oder gleicher Hintbereich mit gleichem Attribut - * und Wert gefunden, wird der neue Hint entsprechend veraendert - * und der alte herausgenommen (und zerstoert: - * SwpHints::Destroy()). + * Try to insert the new hint. + * Depending on the type of the hint, this either always succeeds, or may fail. + * Depending on the type of the hint, other hints may be deleted or + * overwritten. + * The return value indicates successful insertion. */ - -void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) +bool SwpHints::TryInsertHint( SwTxtAttr* const pHint, SwTxtNode &rNode, + const SetAttrMode nMode ) { - // Irgendwann ist immer Schluss - if( USHRT_MAX == Count() ) - return; + if ( USHRT_MAX == Count() ) // we're sorry, this flight is overbooked... + { + ASSERT(false, "hints array full :-("); + return false; + } // Felder bilden eine Ausnahme: // 1) Sie koennen nie ueberlappen @@ -2025,11 +2471,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) } // <-- case RES_TXTATR_INETFMT: - { - ((SwTxtINetFmt*)pHint)->ChgTxtNode( &rNode ); - SwCharFmt* pFmt = rNode.GetDoc()->GetCharFmtFromPool( RES_POOLCHR_INET_NORMAL ); - pFmt->Add( (SwTxtINetFmt*)pHint ); - } + lcl_InitINetFmt(rNode, static_cast<SwTxtINetFmt*>(pHint)); break; case RES_TXTATR_FIELD: { @@ -2163,12 +2605,12 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) break; case RES_TXTATR_CJK_RUBY: - { - ((SwTxtRuby*)pHint)->ChgTxtNode( &rNode ); - SwCharFmt* pFmt = rNode.GetDoc()->GetCharFmtFromPool( - RES_POOLCHR_RUBYTEXT ); - pFmt->Add( (SwTxtRuby*)pHint ); - } + lcl_InitRuby(rNode, static_cast<SwTxtRuby*>(pHint)); + break; + + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + static_cast<SwTxtMeta *>(pHint)->ChgTxtNode( &rNode ); break; case RES_CHRATR_HIDDEN: @@ -2198,7 +2640,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) SwUpdateAttr aHint( nHtStart, nHtStart, nWhich ); rNode.Modify( 0, &aHint ); } - return; + return true; } // ---------------------------------------------------------------- @@ -2219,18 +2661,24 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) const xub_StrLen nHintEnd = *pHtEnd; const bool bNoHintAdjustMode = (nsSetAttrMode::SETATTR_NOHINTADJUST & nMode); + // handle nesting attributes: inserting may fail due to overlap! + if (pHint->IsNesting()) + { + const bool bRet( + TryInsertNesting(rNode, *static_cast<SwTxtAttrNesting*>(pHint))); + if (!bRet) return false; + } // Currently REFMARK and TOXMARK have OverlapAllowed set to true. // These attributes may be inserted directly. // Also attributes without length may be inserted directly. // SETATTR_NOHINTADJUST is set e.g., during undo. // Portion building in not necessary during XML import. + else if ( !bNoHintAdjustMode && !pHint->IsOverlapAllowedAttr() && !rNode.GetDoc()->IsInXMLImport() && ( RES_TXTATR_AUTOFMT == nWhich || - RES_TXTATR_INETFMT == nWhich || - RES_TXTATR_CHARFMT == nWhich || - RES_TXTATR_CJK_RUBY == nWhich ) ) + RES_TXTATR_CHARFMT == nWhich ) ) { ASSERT( nWhich != RES_TXTATR_AUTOFMT || static_cast<const SwFmtAutoFmt&>(pHint->GetAttr()).GetStyleHandle()->GetPool() == @@ -2252,10 +2700,10 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) // multiple times // FME 2007-11-08 #i82989# in NOHINTADJUST mode, we want to insert // character attributes directly - if ( ( RES_TXTATR_CHARFMT == nWhich && !bNoHintAdjustMode ) || - RES_TXTATR_CJK_RUBY == nWhich || - RES_TXTATR_INETFMT == nWhich ) + if ( ( RES_TXTATR_CHARFMT == nWhich && !bNoHintAdjustMode ) ) + { BuildPortions( rNode, *pHint, nMode ); + } else { // --> FME 2007-11-08 #i82989# Check sort numbers in NoHintAdjustMode @@ -2280,7 +2728,7 @@ void SwpHints::Insert( SwTxtAttr* pHint, SwTxtNode &rNode, USHORT nMode ) CHECK; #endif - return; + return true; } /************************************************************************* @@ -2348,7 +2796,6 @@ void SwTxtNode::ClearSwpHintsArr( bool bDelFields ) break; case RES_TXTATR_FIELD: - case RES_TXTATR_HARDBLANK: if( bDelFields ) bDel = true; break; @@ -2435,20 +2882,22 @@ sal_Unicode GetCharOfTxtAttr( const SwTxtAttr& rAttr ) sal_Unicode cRet = CH_TXTATR_BREAKWORD; switch ( rAttr.Which() ) { - case RES_TXTATR_REFMARK: - case RES_TXTATR_TOXMARK: - -// case RES_TXTATR_FIELD: ?????? -// case RES_TXTATR_FLYCNT, // 29 + case RES_TXTATR_FTN: + case RES_TXTATR_REFMARK: + case RES_TXTATR_TOXMARK: + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + cRet = CH_TXTATR_INWORD; + break; - case RES_TXTATR_FTN: - cRet = CH_TXTATR_INWORD; - break; + case RES_TXTATR_FIELD: + case RES_TXTATR_FLYCNT: + cRet = CH_TXTATR_BREAKWORD; + break; - // depends on the character ?? -// case RES_TXTATR_HARDBLANK: -// cRet = CH_TXTATR_INWORD; -// break; + default: + ASSERT(false, "GetCharOfTxtAttr: unknown attr"); + break; } return cRet; } diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index 5b5f81a065..61b425ccce 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -37,17 +37,18 @@ #include <fmtfld.hxx> #include <docufld.hxx> -SwTxtAttr::SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStart ) +SwTxtAttr::SwTxtAttr( SfxPoolItem& rAttr, xub_StrLen nStart ) : m_pAttr( &rAttr ) , m_nStart( nStart ) , m_bDontExpand( false ) , m_bLockExpandFlag( false ) - , m_bDontMergeAttr( false ) , m_bDontMoveAttr( false ) , m_bCharFmtAttr( false ) , m_bOverlapAllowedAttr( false ) , m_bPriorityAttr( false ) , m_bDontExpandStart( false ) + , m_bNesting( false ) + , m_bHasDummyChar( false ) { } @@ -60,11 +61,12 @@ xub_StrLen* SwTxtAttr::GetEnd() return 0; } -// RemoveFromPool must be called before destructor! -void SwTxtAttr::RemoveFromPool( SfxItemPool& rPool ) +void SwTxtAttr::Destroy( SwTxtAttr * pToDestroy, SfxItemPool& rPool ) { - rPool.Remove( GetAttr() ); - m_pAttr = 0; + if (!pToDestroy) return; + SfxPoolItem * const pAttr = pToDestroy->m_pAttr; + delete pToDestroy; + rPool.Remove( *pAttr ); } int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const @@ -72,7 +74,7 @@ int SwTxtAttr::operator==( const SwTxtAttr& rAttr ) const return GetAttr() == rAttr.GetAttr(); } -SwTxtAttrEnd::SwTxtAttrEnd( const SfxPoolItem& rAttr, +SwTxtAttrEnd::SwTxtAttrEnd( SfxPoolItem& rAttr, xub_StrLen nStart, xub_StrLen nEnd ) : SwTxtAttr( rAttr, nStart ), m_nEnd( nEnd ) { diff --git a/sw/source/core/txtnode/txatritr.cxx b/sw/source/core/txtnode/txatritr.cxx index f6afc22c84..cb3c9e4666 100644 --- a/sw/source/core/txtnode/txatritr.cxx +++ b/sw/source/core/txtnode/txatritr.cxx @@ -55,50 +55,50 @@ SwScriptIterator::SwScriptIterator( const String& rStr, xub_StrLen nStt, sal_Boo nCurScript( ScriptType::WEAK ), bForward( bFrwrd ) { - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { if ( ! bFrwrd && nStt ) --nStt; xub_StrLen nPos = nStt; - nCurScript = pBreakIt->xBreak->getScriptType( rText, nPos ); + nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText, nPos ); if( ScriptType::WEAK == nCurScript ) { if( nPos ) { - nPos = (xub_StrLen)pBreakIt->xBreak->beginOfScript( + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfScript( rText, nPos, nCurScript ); if( nPos && nPos < rText.Len() ) { nStt = --nPos; - nCurScript = pBreakIt->xBreak->getScriptType( rText,nPos); + nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText,nPos); } } } nChgPos = bForward ? - (xub_StrLen)pBreakIt->xBreak->endOfScript( rText, nStt, nCurScript ) : - (xub_StrLen)pBreakIt->xBreak->beginOfScript( rText, nStt, nCurScript ); + (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rText, nStt, nCurScript ) : + (xub_StrLen)pBreakIt->GetBreakIter()->beginOfScript( rText, nStt, nCurScript ); } } sal_Bool SwScriptIterator::Next() { sal_Bool bRet = sal_False; - if( pBreakIt->xBreak.is() ) + if( pBreakIt->GetBreakIter().is() ) { if ( bForward && nChgPos < rText.Len() ) { - nCurScript = pBreakIt->xBreak->getScriptType( rText, nChgPos ); - nChgPos = (xub_StrLen)pBreakIt->xBreak->endOfScript( + nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText, nChgPos ); + nChgPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rText, nChgPos, nCurScript ); bRet = sal_True; } else if ( ! bForward && nChgPos ) { --nChgPos; - nCurScript = pBreakIt->xBreak->getScriptType( rText, nChgPos ); - nChgPos = (xub_StrLen)pBreakIt->xBreak->beginOfScript( + nCurScript = pBreakIt->GetBreakIter()->getScriptType( rText, nChgPos ); + nChgPos = (xub_StrLen)pBreakIt->GetBreakIter()->beginOfScript( rText, nChgPos, nCurScript ); bRet = sal_True; } diff --git a/sw/source/core/txtnode/txtatr2.cxx b/sw/source/core/txtnode/txtatr2.cxx index 0253beba8d..f500d28596 100644 --- a/sw/source/core/txtnode/txtatr2.cxx +++ b/sw/source/core/txtnode/txtatr2.cxx @@ -46,24 +46,19 @@ #include <poolfmt.hxx> // RES_POOLCHR_INET_... #include <doc.hxx> // SwDoc #include <fmtruby.hxx> -#include <fmthbsh.hxx> +#include <fmtmeta.hxx> + TYPEINIT1(SwTxtINetFmt,SwClient); TYPEINIT1(SwTxtRuby,SwClient); -/************************************************************************* - * class SwTxtHardBlank - *************************************************************************/ - -SwTxtHardBlank::SwTxtHardBlank( const SwFmtHardBlank& rAttr, xub_StrLen nStt ) - : SwTxtAttr( rAttr, nStt ) - , m_Char( rAttr.GetChar() ) -{ - ASSERT( ' ' != m_Char && '-' != m_Char, - "Invalid character for the HardBlank attribute - " - "must be a normal unicode character" ); -} +// ATT_XMLCONTAINERITEM ****************************** +SwTxtXMLAttrContainer::SwTxtXMLAttrContainer( + SvXMLAttrContainerItem& rAttr, + xub_StrLen nStt, xub_StrLen nEnde ) + : SwTxtAttrEnd( rAttr, nStt, nEnde ) +{} /************************************************************************* * class SwTxtCharFmt @@ -110,20 +105,42 @@ BOOL SwTxtCharFmt::GetInfo( SfxPoolItem& rInfo ) const return FALSE; } + +/************************************************************************* + * class SwTxtAttrNesting + *************************************************************************/ + +SwTxtAttrNesting::SwTxtAttrNesting( SfxPoolItem & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ) + : SwTxtAttrEnd( i_rAttr, i_nStart, i_nEnd ) +{ + SetDontExpand( true ); // never expand this attribute + // lock the expand flag: simple guarantee that nesting will not be + // invalidated by expand operations + SetLockExpandFlag( true ); + SetDontExpandStartAttr( true ); + SetNesting( true ); +} + +SwTxtAttrNesting::~SwTxtAttrNesting() +{ +} + + /************************************************************************* * class SwTxtINetFmt *************************************************************************/ SwTxtINetFmt::SwTxtINetFmt( SwFmtINetFmt& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) + xub_StrLen nStart, xub_StrLen nEnd ) + : SwTxtAttrNesting( rAttr, nStart, nEnd ) , SwClient( 0 ) , m_pTxtNode( 0 ) , m_bVisited( false ) , m_bVisitedValid( false ) { rAttr.pTxtAttr = this; - SetCharFmtAttr( TRUE ); + SetCharFmtAttr( true ); } SwTxtINetFmt::~SwTxtINetFmt( ) @@ -212,30 +229,17 @@ BOOL SwTxtINetFmt::IsProtect( ) const return m_pTxtNode && m_pTxtNode->IsProtect(); } -// ATT_XNLCONTAINERITEM ****************************** - -SwTxtXMLAttrContainer::SwTxtXMLAttrContainer( - const SvXMLAttrContainerItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) -{} - - /************************************************************************* * class SwTxtRuby *************************************************************************/ SwTxtRuby::SwTxtRuby( SwFmtRuby& rAttr, xub_StrLen nStart, xub_StrLen nEnd ) - : SwTxtAttrEnd( rAttr, nStart, nEnd ) + : SwTxtAttrNesting( rAttr, nStart, nEnd ) , SwClient( 0 ) , m_pTxtNode( 0 ) { rAttr.pTxtAttr = this; - SetDontExpand( true ); // never expand this attribute - SetLockExpandFlag( true ); - SetDontMergeAttr( true ); - SetDontExpandStartAttr( true ); } SwTxtRuby::~SwTxtRuby() @@ -310,11 +314,26 @@ SwCharFmt* SwTxtRuby::GetCharFmt() return pRet; } -// ****************************** -SwTxt2Lines::SwTxt2Lines( const SvxTwoLinesItem& rAttr, - xub_StrLen nStt, xub_StrLen nEnde ) - : SwTxtAttrEnd( rAttr, nStt, nEnde ) +/************************************************************************* + * class SwTxtMeta + *************************************************************************/ + +SwTxtMeta::SwTxtMeta( SwFmtMeta & i_rAttr, + const xub_StrLen i_nStart, const xub_StrLen i_nEnd ) + : SwTxtAttrNesting( i_rAttr, i_nStart, i_nEnd ) + , m_pTxtNode( 0 ) { + i_rAttr.SetTxtAttr( this ); + SetHasDummyChar(true); +} + +SwTxtMeta::~SwTxtMeta() +{ + SwFmtMeta & rFmtMeta( static_cast<SwFmtMeta &>(GetAttr()) ); + if (rFmtMeta.GetTxtAttr() == this) + { + rFmtMeta.SetTxtAttr(0); + } } diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 95fcac2e60..db2743218f 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -368,56 +368,6 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& rStyleAccess, return bRet; } -/* - * Ein Zeichen wurde eingefuegt. - */ - -SwTxtNode& SwTxtNode::Insert( xub_Unicode c, const SwIndex &rIdx ) -{ - xub_StrLen nOrigLen = m_Text.Len(); - - ASSERT( rIdx <= nOrigLen, "SwTxtNode::Insert: invalid index." ); - ASSERT( nOrigLen < STRING_LEN, - "SwTxtNode::Insert: node text with insertion > STRING_LEN." ); - - if ( nOrigLen == m_Text.Insert( c, rIdx.GetIndex() ).Len() ) - return *this; - - Update(rIdx,1); - - // leere Hints und Feldattribute an rIdx.GetIndex suchen - if ( HasHints() ) - { - USHORT* pEndIdx; - for ( USHORT i=0; i < m_pSwpHints->Count() && - rIdx >= *(*m_pSwpHints)[i]->GetStart(); ++i) - { - SwTxtAttr *pHt = m_pSwpHints->GetTextHint(i); - pEndIdx = pHt->GetEnd(); - if ( pEndIdx ) - { - // leere Hints an rIdx.GetIndex ? - BOOL bEmpty = *pEndIdx == *pHt->GetStart() - && rIdx == *pHt->GetStart(); - - if( bEmpty ) - { - m_pSwpHints->DeleteAtPos(i); - if( bEmpty ) - *pHt->GetStart() -= 1; - else - *pEndIdx -= 1; - Insert(pHt); - } - } - } - TryDeleteSwpHints(); - } - // den Frames Bescheid sagen - SwInsChr aHint( rIdx.GetIndex()-1 ); - SwModify::Modify( 0, &aHint ); - return *this; -} inline BOOL InRange(xub_StrLen nIdx, xub_StrLen nStart, xub_StrLen nEnd) { return ((nIdx >=nStart) && (nIdx <= nEnd)); @@ -454,7 +404,6 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, USHORT i = 0; xub_StrLen nStt = rIdx.GetIndex(); xub_StrLen nEnd = nStt + nLen; - xub_StrLen *pAttrEnd; xub_StrLen nAttrStart; SwTxtAttr *pHt; @@ -479,8 +428,8 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, pHt = m_pSwpHints->GetTextHint(i); // attributes without end stay in! - pAttrEnd = pHt->GetEnd(); - if ( !pAttrEnd ) + xub_StrLen * const pAttrEnd = pHt->GetEnd(); + if ( !pAttrEnd /*|| pHt->HasDummyChar()*/ ) // see bInclRefToxMark { i++; continue; @@ -514,8 +463,12 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, else if ( !bInclRefToxMark ) { // 3. case: Reset all attributes except from ref/toxmarks: - bSkipAttr = RES_TXTATR_REFMARK == pHt->Which() || - RES_TXTATR_TOXMARK == pHt->Which(); + // skip hints with CH_TXTATR here + // (deleting those is ONLY allowed for UNDO!) + bSkipAttr = RES_TXTATR_REFMARK == pHt->Which() + || RES_TXTATR_TOXMARK == pHt->Which() + || RES_TXTATR_META == pHt->Which() + || RES_TXTATR_METAFIELD == pHt->Which(); } if ( bSkipAttr ) @@ -547,8 +500,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nAttrStart, nAttrEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nAttrStart, nAttrEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } // if the last attribute is a Field, the HintsArray is @@ -574,8 +528,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() && nAttrStart < nEnd ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nAttrStart, nEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nAttrStart, nEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } bChanged = TRUE; @@ -601,8 +556,9 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nStt, nAttrEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nStt, nAttrEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } } else if( nLen ) // Fall: 4 @@ -620,20 +576,23 @@ void SwTxtNode::RstAttr(const SwIndex &rIdx, xub_StrLen nLen, USHORT nWhich, if ( pStyleHandle.get() && nStt < nEnd ) { - SwTxtAttr* pNew = MakeTxtAttr( *pStyleHandle, nStt, nEnd ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + *pStyleHandle, nStt, nEnd ); + InsertHint( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); } if( nEnd < nTmpEnd ) { - SwTxtAttr* pNew = MakeTxtAttr( pHt->GetAttr(), nEnd, nTmpEnd ); + SwTxtAttr* pNew = MakeTxtAttr( *GetDoc(), + pHt->GetAttr(), nEnd, nTmpEnd ); if ( pNew ) { SwTxtCharFmt* pCharFmt = dynamic_cast<SwTxtCharFmt*>(pHt); if ( pCharFmt ) static_cast<SwTxtCharFmt*>(pNew)->SetSortNumber( pCharFmt->GetSortNumber() ); - Insert( pNew, nsSetAttrMode::SETATTR_NOHINTADJUST ); + InsertHint( pNew, + nsSetAttrMode::SETATTR_NOHINTADJUST ); } @@ -682,7 +641,7 @@ XubString SwTxtNode::GetCurWord( xub_StrLen nPos ) const return m_Text; Boundary aBndry; - const uno::Reference< XBreakIterator > &rxBreak = pBreakIt->xBreak; + const uno::Reference< XBreakIterator > &rxBreak = pBreakIt->GetBreakIter(); if (rxBreak.is()) { sal_Int16 nWordType = WordType::DICTIONARY_WORD; @@ -750,7 +709,7 @@ BOOL SwScanner::NextWord() { if ( !pLanguage ) { - const USHORT nNextScriptType = pBreakIt->xBreak->getScriptType( rText, nBegin ); + const USHORT nNextScriptType = pBreakIt->GetBreakIter()->getScriptType( rText, nBegin ); ModelToViewHelper::ModelPosition aModelBeginPos = ModelToViewHelper::ConvertToModelPosition( pConversionMap, nBegin ); const xub_StrLen nBeginModelPos = (xub_StrLen)aModelBeginPos.mnPos; aCurrLang = rNode.GetLang( nBeginModelPos, 1, nNextScriptType ); @@ -772,7 +731,7 @@ BOOL SwScanner::NextWord() return FALSE; // get the word boundaries - aBound = pBreakIt->xBreak->getWordBoundary( rText, nBegin, + aBound = pBreakIt->GetBreakIter()->getWordBoundary( rText, nBegin, pBreakIt->GetLocale( aCurrLang ), nWordType, sal_True ); //no word boundaries could be found @@ -795,11 +754,11 @@ BOOL SwScanner::NextWord() // restrict boundaries to script boundaries and nEndPos const USHORT nCurrScript = - pBreakIt->xBreak->getScriptType( rText, nBegin ); + pBreakIt->GetBreakIter()->getScriptType( rText, nBegin ); XubString aTmpWord = rText.Copy( nBegin, static_cast<xub_StrLen>(aBound.endPos - nBegin) ); const sal_Int32 nScriptEnd = nBegin + - pBreakIt->xBreak->endOfScript( aTmpWord, 0, nCurrScript ); + pBreakIt->GetBreakIter()->endOfScript( aTmpWord, 0, nCurrScript ); const sal_Int32 nEnd = Min( aBound.endPos, nScriptEnd ); // restrict word start to last script change position @@ -810,7 +769,7 @@ BOOL SwScanner::NextWord() aTmpWord = rText.Copy( static_cast<xub_StrLen>(aBound.startPos), static_cast<xub_StrLen>(nBegin - aBound.startPos + 1) ); nScriptBegin = aBound.startPos + - pBreakIt->xBreak->beginOfScript( aTmpWord, nBegin - aBound.startPos, + pBreakIt->GetBreakIter()->beginOfScript( aTmpWord, nBegin - aBound.startPos, nCurrScript ); } @@ -820,11 +779,11 @@ BOOL SwScanner::NextWord() else { const USHORT nCurrScript = - pBreakIt->xBreak->getScriptType( rText, aBound.startPos ); + pBreakIt->GetBreakIter()->getScriptType( rText, aBound.startPos ); XubString aTmpWord = rText.Copy( static_cast<xub_StrLen>(aBound.startPos), static_cast<xub_StrLen>(aBound.endPos - aBound.startPos) ); const sal_Int32 nScriptEnd = aBound.startPos + - pBreakIt->xBreak->endOfScript( aTmpWord, 0, nCurrScript ); + pBreakIt->GetBreakIter()->endOfScript( aTmpWord, 0, nCurrScript ); const sal_Int32 nEnd = Min( aBound.endPos, nScriptEnd ); nBegin = (xub_StrLen)aBound.startPos; nLen = (xub_StrLen)(nEnd - nBegin); @@ -1003,7 +962,7 @@ void SwTxtNode::SetLanguageAndFont( const SwPaM &rPaM, aSet.Put( aFontItem ); } - GetDoc()->Insert( rPaM, aSet, 0 ); + GetDoc()->InsertItemSet( rPaM, aSet, 0 ); // SetAttr( aSet ); <- Does not set language attribute of empty paragraphs correctly, // <- because since there is no selection the flag to garbage // <- collect all attributes is set, and therefore attributes spanned @@ -1196,7 +1155,7 @@ SwRect SwTxtFrm::_AutoSpell( const SwCntntNode* pActNode, const SwViewOption& rV LanguageType eActLang = pNode->GetLang( nBegin ); Boundary aBound = - pBreakIt->xBreak->getWordBoundary( pNode->GetTxt(), nBegin, + pBreakIt->GetBreakIter()->getWordBoundary( pNode->GetTxt(), nBegin, pBreakIt->GetLocale( eActLang ), WordType::DICTIONARY_WORD, TRUE ); nBegin = xub_StrLen(aBound.startPos); @@ -1352,8 +1311,8 @@ SwRect SwTxtFrm::SmartTagScan( SwCntntNode* /*pActNode*/, xub_StrLen /*nActPos*/ { const LanguageType aCurrLang = pNode->GetLang( nBegin ); const com::sun::star::lang::Locale aCurrLocale = pBreakIt->GetLocale( aCurrLang ); - nBegin = static_cast< xub_StrLen >(pBreakIt->xBreak->beginOfSentence( rText, nBegin, aCurrLocale )); - nEnd = static_cast< xub_StrLen >(Min( rText.getLength(), pBreakIt->xBreak->endOfSentence( rText, nEnd, aCurrLocale ) )); + nBegin = static_cast< xub_StrLen >(pBreakIt->GetBreakIter()->beginOfSentence( rText, nBegin, aCurrLocale )); + nEnd = static_cast< xub_StrLen >(Min( rText.getLength(), pBreakIt->GetBreakIter()->endOfSentence( rText, nEnd, aCurrLocale ) )); } } } @@ -1753,7 +1712,7 @@ void SwTxtNode::CountWords( SwDocStat& rStat, const bool bCount = aExpandText.getLength() > 0; // count words in 'regular' text: - if( bCount && pBreakIt->xBreak.is() ) + if( bCount && pBreakIt->GetBreakIter().is() ) { const String aScannerText( aExpandText ); SwScanner aScanner( *this, aScannerText, 0, pConversionMap, diff --git a/sw/source/core/undo/makefile.mk b/sw/source/core/undo/makefile.mk index 12665cf26d..4c7a332eec 100644 --- a/sw/source/core/undo/makefile.mk +++ b/sw/source/core/undo/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2008 by Sun Microsystems, Inc. # # OpenOffice.org - a multi-platform office productivity suite @@ -68,6 +68,7 @@ SLOFILES = \ $(SLO)$/undel.obj \ $(SLO)$/undobj.obj \ $(SLO)$/undobj1.obj \ + $(SLO)$/undoflystrattr.obj \ $(SLO)$/undraw.obj \ $(SLO)$/unfmco.obj \ $(SLO)$/unins.obj \ diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx index 1957c9cea3..44ac5f49c4 100644 --- a/sw/source/core/undo/rolbck.cxx +++ b/sw/source/core/undo/rolbck.cxx @@ -352,7 +352,7 @@ void SwHistorySetRefMark::SetInDoc( SwDoc* pDoc, bool ) // if a reference mark without an end already exists here: must not insert! if ( m_nStart != m_nEnd || - !pTxtNd->GetTxtAttr( m_nStart, RES_TXTATR_REFMARK ) ) + !pTxtNd->GetTxtAttrForCharAt( m_nStart, RES_TXTATR_REFMARK ) ) { pTxtNd->InsertItem( aRefMark, m_nStart, m_nEnd, nsSetAttrMode::SETATTR_NOTXTATRCHR ); @@ -433,7 +433,7 @@ void SwHistoryResetTxt::SetInDoc( SwDoc* pDoc, bool ) ASSERT( pTxtNd, "SwHistoryResetTxt: no TextNode" ); if ( pTxtNd ) { - pTxtNd->Delete( m_nAttr, m_nStart, m_nEnd ); + pTxtNd->DeleteAttributes( m_nAttr, m_nStart, m_nEnd ); } } @@ -514,12 +514,13 @@ void SwHistorySetFootnote::SetInDoc( SwDoc* pDoc, bool ) m_pUndo->GetHistory()->Rollback( pDoc ); } - pTxtNd->Insert( pTxtFtn ); + pTxtNd->InsertHint( pTxtFtn ); } else { - SwTxtFtn *pFtn = const_cast<SwTxtFtn*>( - static_cast<const SwTxtFtn*>(pTxtNd->GetTxtAttr( m_nStart ))); + SwTxtFtn * const pFtn = + const_cast<SwTxtFtn*>( static_cast<const SwTxtFtn*>( + pTxtNd->GetTxtAttrForCharAt( m_nStart ))); SwFmtFtn &rFtn = const_cast<SwFmtFtn&>(pFtn->GetFtn()); rFtn.SetNumStr( m_FootnoteNumber ); if ( rFtn.IsEndNote() != m_bEndNote ) @@ -615,6 +616,14 @@ SwHistoryBookmark::SwHistoryBookmark( { m_aKeycode = pBookmark->GetKeyCode(); m_aShortName = pBookmark->GetShortName(); + + ::sfx2::Metadatable * const pMetadatable( + const_cast< ::sfx2::Metadatable * >( // CreateUndo should be const? + dynamic_cast< ::sfx2::Metadatable const* >(pBookmark))); + if (pMetadatable) + { + m_pMetadataUndo = pMetadatable->CreateUndo(); + } } } @@ -681,6 +690,16 @@ void SwHistoryBookmark::SetInDoc( SwDoc* pDoc, bool ) { pBookmark->SetKeyCode(m_aKeycode); pBookmark->SetShortName(m_aShortName); + if (m_pMetadataUndo) + { + ::sfx2::Metadatable * const pMeta( + dynamic_cast< ::sfx2::Metadatable* >(pBookmark)); + OSL_ENSURE(pMeta, "metadata undo, but not metadatable?"); + if (pMeta) + { + pMeta->RestoreMetadata(m_pMetadataUndo); + } + } } } pDoc->DoUndo(bDoesUndo); @@ -819,6 +838,25 @@ SwHistoryResetAttrSet::SwHistoryResetAttrSet( const SfxItemSet& rSet, while( TRUE ) { const USHORT nWhich = aIter.GetCurItem()->Which(); + +#ifndef PRODUCT + switch (nWhich) + { + case RES_TXTATR_REFMARK: + case RES_TXTATR_TOXMARK: + if (m_nStart != m_nEnd) break; // else: fall through! + case RES_TXTATR_FIELD: + case RES_TXTATR_FLYCNT: + case RES_TXTATR_FTN: + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + ASSERT(rSet.Count() == 1, + "text attribute with CH_TXTATR, but not the only one:" + "\nnot such a good idea"); + break; + } +#endif + // Character attribute cannot be inserted into the hints array // anymore. Therefore we have to treat them as one RES_TXTATR_AUTOFMT: if (isCHRATR(nWhich)) @@ -868,7 +906,7 @@ void SwHistoryResetAttrSet::SetInDoc( SwDoc* pDoc, bool ) for ( USHORT n = m_Array.Count(); n; --n, ++pArr ) { static_cast<SwTxtNode*>(pCntntNd)-> - Delete( *pArr, m_nStart, m_nEnd ); + DeleteAttributes( *pArr, m_nStart, m_nEnd ); } } } @@ -1292,7 +1330,6 @@ void SwHistory::CopyAttr( SwpHints* pHts, ULONG nNodeIdx, switch( pHt->Which() ) { case RES_TXTATR_FIELD: - case RES_TXTATR_HARDBLANK: // keine Felder, .. kopieren ?? if( !bFields ) bNextAttr = TRUE; @@ -1397,40 +1434,45 @@ void SwRegHistory::AddHint( SwTxtAttr* pHt, const bool bNew ) } -SwRegHistory::SwRegHistory( SwTxtNode* pTxtNode, const SfxItemSet& rSet, - xub_StrLen nStart, xub_StrLen nEnd, USHORT nFlags, - SwHistory* pHst ) - : SwClient( pTxtNode ) - , m_pHistory( pHst ) - , m_nNodeIndex( pTxtNode->GetIndex() ) +bool SwRegHistory::InsertItems( const SfxItemSet& rSet, + xub_StrLen const nStart, xub_StrLen const nEnd, SetAttrMode const nFlags ) { if( !rSet.Count() ) - return; + return false; - BOOL bInsert; + SwTxtNode * const pTxtNode = + dynamic_cast<SwTxtNode *>(const_cast<SwModify *>(GetRegisteredIn())); - if( pTxtNode->GetpSwpHints() && pHst ) + ASSERT(pTxtNode, "SwRegHistory not registered at text node?"); + if (!pTxtNode) + return false; + + if ( pTxtNode->GetpSwpHints() && m_pHistory ) { pTxtNode->GetpSwpHints()->Register( this ); - bInsert = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags ); + } + + const bool bInserted = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags ); + // Achtung: Durch das Einfuegen eines Attributs kann das Array // geloescht werden!!! Wenn das einzufuegende zunaechst ein vorhandenes // loescht, selbst aber nicht eingefuegt werden braucht, weil die // Absatzattribute identisch sind( -> bForgetAttr in SwpHints::Insert ) - if ( pTxtNode->GetpSwpHints() ) - pTxtNode->GetpSwpHints()->DeRegister(); + if ( pTxtNode->GetpSwpHints() && m_pHistory ) + { + pTxtNode->GetpSwpHints()->DeRegister(); } - else - bInsert = pTxtNode->SetAttr( rSet, nStart, nEnd, nFlags ); - if( pHst && bInsert ) + if ( m_pHistory && bInserted ) { SwHistoryHint* pNewHstr = new SwHistoryResetAttrSet( rSet, pTxtNode->GetIndex(), nStart, nEnd ); // der NodeIndex kann verschoben sein !! - pHst->m_SwpHstry.Insert( pNewHstr, pHst->Count() ); + m_pHistory->m_SwpHstry.Insert( pNewHstr, m_pHistory->Count() ); } + + return bInserted; } void SwRegHistory::RegisterInModify( SwModify* pRegIn, const SwNode& rNd ) diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index fd5b1ee676..512c7c1afe 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -560,18 +560,17 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) SwTxtNode *pTxtNode = (SwTxtNode*)&pPos->nNode.GetNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); -#ifndef PRODUCT + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( nIdx, RES_TXTATR_FLYCNT ); ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt, "Wrong TxtFlyCnt-Hint." ); -#endif const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); //Die Verbindung ist geloest, jetzt muss noch das Attribut vernichtet //werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } { @@ -618,8 +617,9 @@ bool SwUndoFmtAttr::RestoreFlyAnchor( SwUndoIter& rIter ) { const SwPosition* pPos = aNewAnchor.GetCntntAnchor(); SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); - ASSERT( pTxtNd, "Kein Textnode an dieser Position" ); - pTxtNd->InsertItem( SwFmtFlyCnt( pFrmFmt ), pPos->nContent.GetIndex(), 0 ); + ASSERT( pTxtNd, "no Text Node at position." ); + SwFmtFlyCnt aFmt( pFrmFmt ); + pTxtNd->InsertItem( aFmt, pPos->nContent.GetIndex(), 0 ); } @@ -767,7 +767,9 @@ void SwUndoResetAttr::Redo( SwUndoIter& rUndoIter ) } // gefunden, also loeschen if( nCnt-- ) - rDoc.Delete( aArr[ nCnt ] ); + { + rDoc.DeleteTOXMark( aArr[ nCnt ] ); + } } } break; @@ -815,7 +817,7 @@ void SwUndoResetAttr::SetAttrs( const SvUShortsSort& rArr ) SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr, - USHORT nFlags ) + const SetAttrMode nFlags ) : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) , m_AttrSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() ) , m_pHistory( new SwHistory ) @@ -828,7 +830,7 @@ SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr, } SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet, - USHORT nFlags ) + const SetAttrMode nFlags ) : SwUndo( UNDO_INSATTR ), SwUndRng( rRange ) , m_AttrSet( rSet ) , m_pHistory( new SwHistory ) @@ -899,7 +901,7 @@ void SwUndoAttr::Undo( SwUndoIter& rUndoIter ) const bool bToLast = (1 == m_AttrSet.Count()) && (RES_TXTATR_FIELD <= *m_AttrSet.GetRanges()) - && (*m_AttrSet.GetRanges() <= RES_TXTATR_HARDBLANK); + && (*m_AttrSet.GetRanges() <= RES_TXTATR_FTN); // restore old values m_pHistory->TmpRollback( pDoc, 0, !bToLast ); @@ -948,15 +950,15 @@ void SwUndoAttr::Repeat( SwUndoIter& rUndoIter ) // RefMarks are not repeat capable if ( SFX_ITEM_SET != m_AttrSet.GetItemState( RES_TXTATR_REFMARK, FALSE ) ) { - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, - m_AttrSet, m_nInsertFlags ); + rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam, + m_AttrSet, m_nInsertFlags ); } else if ( 1 < m_AttrSet.Count() ) { SfxItemSet aTmpSet( m_AttrSet ); aTmpSet.ClearItem( RES_TXTATR_REFMARK ); - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, - aTmpSet, m_nInsertFlags ); + rUndoIter.GetDoc().InsertItemSet( *rUndoIter.pAktPam, + aTmpSet, m_nInsertFlags ); } rUndoIter.pLastUndoObj = this; } @@ -974,7 +976,7 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) RedlineMode_t eOld = rDoc.GetRedlineMode(); rDoc.SetRedlineMode_intern(static_cast<RedlineMode_t>( eOld & ~nsRedlineMode_t::REDLINE_IGNORE)); - rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); + rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags ); if ( ULONG_MAX != m_nNodeIndex ) { @@ -995,7 +997,7 @@ void SwUndoAttr::Redo( SwUndoIter& rUndoIter ) } else { - rDoc.Insert( rPam, m_AttrSet, m_nInsertFlags ); + rDoc.InsertItemSet( rPam, m_AttrSet, m_nInsertFlags ); } rUndoIter.pLastUndoObj = 0; diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 458266bde6..1ebc3a084f 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -386,7 +386,7 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, // loesche jetzt noch den Text (alle Attribut-Aenderungen kommen in // die Undo-History pSttStr = (String*)new String( pSttTxtNd->GetTxt().Copy( nSttCntnt, nLen )); - pSttTxtNd->Erase( pStt->nContent, nLen ); + pSttTxtNd->EraseText( pStt->nContent, nLen ); if( pSttTxtNd->GetpSwpHints() ) pSttTxtNd->GetpSwpHints()->DeRegister(); @@ -422,7 +422,7 @@ BOOL SwUndoDelete::SaveCntnt( const SwPosition* pStt, const SwPosition* pEnd, // die Undo-History pEndStr = (String*)new String( pEndTxtNd->GetTxt().Copy( 0, pEnd->nContent.GetIndex() )); - pEndTxtNd->Erase( aEndIdx, pEnd->nContent.GetIndex() ); + pEndTxtNd->EraseText( aEndIdx, pEnd->nContent.GetIndex() ); if( pEndTxtNd->GetpSwpHints() ) pEndTxtNd->GetpSwpHints()->DeRegister(); @@ -511,7 +511,7 @@ BOOL SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam ) nUChrPos++; } pSttStr->Insert( cDelChar, nUChrPos ); - pDelTxtNd->Erase( pStt->nContent, 1 ); + pDelTxtNd->EraseText( pStt->nContent, 1 ); bGroup = TRUE; return TRUE; @@ -711,7 +711,8 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) } if( pTxtNd ) { - pTxtNd->Insert( *pEndStr, aPos.nContent, INS_NOHINTEXPAND ); + pTxtNd->InsertText( *pEndStr, aPos.nContent, + IDocumentContentOperations::INS_NOHINTEXPAND ); // METADATA: restore pTxtNd->RestoreMetadata(m_pMetadataUndoEnd); } @@ -804,7 +805,8 @@ void SwUndoDelete::Undo( SwUndoIter& rUndoIter ) // SectionNode-Modus und von oben nach unten selektiert: // -> im StartNode steht noch der Rest vom Join => loeschen aPos.nContent.Assign( pTxtNd, nSttCntnt ); - pTxtNd->Insert( *pSttStr, aPos.nContent, INS_NOHINTEXPAND ); + pTxtNd->InsertText( *pSttStr, aPos.nContent, + IDocumentContentOperations::INS_NOHINTEXPAND ); // METADATA: restore pTxtNd->RestoreMetadata(m_pMetadataUndoStart); } diff --git a/sw/source/core/undo/undo.hrc b/sw/source/core/undo/undo.hrc index 03900f4c24..2b96ba202a 100644 --- a/sw/source/core/undo/undo.hrc +++ b/sw/source/core/undo/undo.hrc @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -126,14 +126,14 @@ #define STR_UNDO_SETFLYFRMFMT (CORE_REPEAT_END +39) #define STR_UNDO_SETRUBYATTR (CORE_REPEAT_END +40) // #102505# -#define STR_UNDO_TMPAUTOCORR (CORE_REPEAT_END +41) +#define STR_UNDO_TMPAUTOCORR (CORE_REPEAT_END +41) #define STR_TOXCHANGE (CORE_REPEAT_END +42) #define STR_UNDO_PAGEDESC_CREATE (CORE_REPEAT_END +43) #define STR_UNDO_PAGEDESC (CORE_REPEAT_END +44) #define STR_UNDO_PAGEDESC_DELETE (CORE_REPEAT_END +45) -#define STR_UNDO_HEADER_FOOTER (CORE_REPEAT_END +46) // #i7983# -#define STR_UNDO_FIELD (CORE_REPEAT_END +47) // #111840# +#define STR_UNDO_HEADER_FOOTER (CORE_REPEAT_END +46) // #i7983# +#define STR_UNDO_FIELD (CORE_REPEAT_END +47) // #111840# #define STR_UNDO_TXTFMTCOL_CREATE (CORE_REPEAT_END +48) #define STR_UNDO_TXTFMTCOL_DELETE (CORE_REPEAT_END +49) #define STR_UNDO_TXTFMTCOL_RENAME (CORE_REPEAT_END +50) @@ -153,9 +153,11 @@ #define STR_UNDO_ROW_DELETE (CORE_REPEAT_END +64) #define STR_UNDO_PAGEDESC_RENAME (CORE_REPEAT_END +65) #define STR_NUMDOWN (CORE_REPEAT_END +66) +#define STR_UNDO_FLYFRMFMT_TITLE (CORE_REPEAT_END +67) +#define STR_UNDO_FLYFRMFMT_DESCRITPTION (CORE_REPEAT_END +68) // !!!!!! umsetzen !!!!!!!!!!! umsetzen !!!!!!!!!!! umsetzen !!!! -#define CORE_UNDO_END STR_NUMDOWN// !!!! umsetzen !!! +#define CORE_UNDO_END STR_UNDO_FLYFRMFMT_DESCRITPTION// !!!! umsetzen !!! // UI-Undo Klammerungen #define UI_UNDO_BEGIN (CORE_UNDO_END + 1) diff --git a/sw/source/core/undo/undo.src b/sw/source/core/undo/undo.src index ed3b75e7c8..2cf91da28b 100644 --- a/sw/source/core/undo/undo.src +++ b/sw/source/core/undo/undo.src @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -54,7 +54,7 @@ String STR_SPLITNODE_UNDO }; String STR_MOVE_UNDO { - Text [ en-US ] = "Move: $1" ; + Text [ en-US ] = "Move" ; }; String STR_INSATTR_UNDO { @@ -612,7 +612,7 @@ String STR_CHART }; String STR_NOTE { - Text [ en-US ] = "note"; + Text [ en-US ] = "comment"; }; String STR_REFERENCE { @@ -650,3 +650,11 @@ String STR_PARAGRAPH_UNDO { Text[ en-US ] = "paragraph"; }; +String STR_UNDO_FLYFRMFMT_TITLE +{ + Text[ en-US ] = "Change object title of $1"; +}; +String STR_UNDO_FLYFRMFMT_DESCRITPTION +{ + Text[ en-US ] = "Change object description of $1"; +}; diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index e17dbe12e0..38a83445c5 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -330,7 +330,7 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, } else { - rDoc.GetNodes().Move( rPaM, aPos, rNds, FALSE ); + rDoc.GetNodes().MoveRange( rPaM, aPos, rNds ); SwTxtNode* pTxtNd = aPos.nNode.GetNode().GetTxtNode(); if( pTxtNd ) // fuege einen Trenner fuer die Attribute ein ! @@ -350,7 +350,10 @@ void SwUndoSaveCntnt::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, ++aPos.nContent; } else - pTxtNd->Insert( ' ', aPos.nContent, INS_NOHINTEXPAND); + { + pTxtNd->InsertText( sal_Unicode(' '), aPos.nContent, + IDocumentContentOperations::INS_NOHINTEXPAND ); + } } } if( pEndNdIdx ) @@ -404,7 +407,7 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, if( pTxtNd->GetTxt().Len() ) { GoInCntnt( aPaM, fnMoveBackward ); - pTxtNd->Erase( aPaM.GetPoint()->nContent, 1 ); + pTxtNd->EraseText( aPaM.GetPoint()->nContent, 1 ); } aPaM.SetMark(); @@ -413,7 +416,7 @@ void SwUndoSaveCntnt::MoveFromUndoNds( SwDoc& rDoc, ULONG nNodeIdx, _SaveRedlEndPosForRestore aRedlRest( rInsPos.nNode, rInsPos.nContent.GetIndex() ); - rNds.Move( aPaM, rInsPos, rDoc.GetNodes() ); + rNds.MoveRange( aPaM, rInsPos, rDoc.GetNodes() ); // noch den letzen Node loeschen. if( !aPaM.GetPoint()->nContent.GetIndex() || @@ -537,11 +540,12 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtNode* pTxtNd = (SwTxtNode*)pFtnNd; if( !pHistory ) pHistory = new SwHistory; - SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); + SwTxtAttr* const pFtnHnt = + pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } while( nPos-- && ( pFtnNd = &( pSrch = rFtnArr[ nPos ] )-> @@ -560,11 +564,12 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, SwTxtNode* pTxtNd = (SwTxtNode*)pFtnNd; if( !pHistory ) pHistory = new SwHistory; - SwTxtAttr* pFtnHnt = pTxtNd->GetTxtAttr( nFtnSttIdx ); + SwTxtAttr* const pFtnHnt = + pTxtNd->GetTxtAttrForCharAt( nFtnSttIdx ); ASSERT( pFtnHnt, "kein FtnAttribut" ); SwIndex aIdx( pTxtNd, nFtnSttIdx ); pHistory->Add( pFtnHnt, pTxtNd->GetIndex(), false ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } } } @@ -598,7 +603,8 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, if( !pHistory ) pHistory = new SwHistory; SwTxtNode* pTxtNd = pDoc->GetNodes()[ pAPos->nNode]->GetTxtNode(); - SwTxtAttr* pFlyHnt = pTxtNd->GetTxtAttr( pAPos->nContent.GetIndex()); + SwTxtAttr* const pFlyHnt = pTxtNd->GetTxtAttrForCharAt( + pAPos->nContent.GetIndex()); ASSERT( pFlyHnt, "kein FlyAttribut" ); pHistory->Add( pFlyHnt, 0, false ); // n wieder zurueck, damit nicht ein Format uebesprungen wird ! @@ -734,28 +740,43 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, } else { - bool bMaybe = false; - if( *pStt <= pBkmk->GetMarkPos() && pBkmk->GetMarkPos() <= *pEnd ) + // --> OD 2009-08-06 #i92125# + bool bKeepCrossRefBkmk( false ); { - if( pBkmk->GetMarkPos() == *pEnd || - ( *pStt == pBkmk->GetMarkPos() && pBkmk->IsExpanded() ) ) - bMaybe = true; - else - bSavePos = true; + if ( rMark.nNode == rPoint.nNode && + ( IDocumentMarkAccess::GetType(*pBkmk) == + IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK || + IDocumentMarkAccess::GetType(*pBkmk) == + IDocumentMarkAccess::CROSSREF_NUMITEM_BOOKMARK ) ) + { + bKeepCrossRefBkmk = true; + } } - if( pBkmk->IsExpanded() && - *pStt <= pBkmk->GetOtherMarkPos() && pBkmk->GetOtherMarkPos() <= *pEnd ) + if ( !bKeepCrossRefBkmk ) { - if( bSavePos || bSaveOtherPos || - ( pBkmk->GetOtherMarkPos() < *pEnd && pBkmk->GetOtherMarkPos() > *pStt ) ) + bool bMaybe = false; + if ( *pStt <= pBkmk->GetMarkPos() && pBkmk->GetMarkPos() <= *pEnd ) { - if( bMaybe ) + if( pBkmk->GetMarkPos() == *pEnd || + ( *pStt == pBkmk->GetMarkPos() && pBkmk->IsExpanded() ) ) + bMaybe = true; + else bSavePos = true; - bSaveOtherPos = true; + } + if( pBkmk->IsExpanded() && + *pStt <= pBkmk->GetOtherMarkPos() && pBkmk->GetOtherMarkPos() <= *pEnd ) + { + if( bSavePos || bSaveOtherPos || + ( pBkmk->GetOtherMarkPos() < *pEnd && pBkmk->GetOtherMarkPos() > *pStt ) ) + { + if( bMaybe ) + bSavePos = true; + bSaveOtherPos = true; + } } } - // delete cross-reference bookmark at <pStt>, if only part of - // <pEnd> text node content is deleted. + // <-- + // --> OD 2007-10-17 #i81002# const bool bDifferentTxtNodesAtMarkAndPoint( rMark.nNode != rPoint.nNode && @@ -765,6 +786,8 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, if( !bSavePos && !bSaveOtherPos && bDifferentTxtNodesAtMarkAndPoint && dynamic_cast< const ::sw::mark::CrossRefBookmark* >(pBkmk)) { + // delete cross-reference bookmark at <pStt>, if only part of + // <pEnd> text node content is deleted. if( pStt->nNode == pBkmk->GetMarkPos().nNode && pEnd->nContent.GetIndex() != pEnd->nNode.GetNode().GetTxtNode()->Len() ) @@ -788,8 +811,8 @@ void SwUndoSaveCntnt::DelCntntIndex( const SwPosition& rMark, pHistory = new SwHistory; pHistory->Add( *pBkmk, bSavePos, bSaveOtherPos ); - if(bSavePos && - (bSaveOtherPos || !pBkmk->IsExpanded())) + if(bSavePos && + (bSaveOtherPos || !pBkmk->IsExpanded())) { pMarkAccess->deleteMark(pMarkAccess->getMarksBegin()+n); n--; diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx index 81c0f3661c..d9ce9b12a8 100644 --- a/sw/source/core/undo/undobj1.cxx +++ b/sw/source/core/undo/undobj1.cxx @@ -123,9 +123,9 @@ void SwUndoFlyBase::InsFly( SwUndoIter& rUndoIter, BOOL bShowSelFrm ) { // es muss mindestens das Attribut im TextNode stehen SwCntntNode* pCNd = aAnchor.GetCntntAnchor()->nNode.GetNode().GetCntntNode(); - ASSERT( pCNd->IsTxtNode(), "Kein Textnode an dieser Position" ); - ((SwTxtNode*)pCNd)->InsertItem( SwFmtFlyCnt( - (SwFlyFrmFmt*)pFrmFmt ), nCntPos, nCntPos ); + ASSERT( pCNd->IsTxtNode(), "no Text Node at position." ); + SwFmtFlyCnt aFmt( pFrmFmt ); + static_cast<SwTxtNode*>(pCNd)->InsertItem( aFmt, nCntPos, nCntPos ); } pFrmFmt->MakeFrms(); @@ -199,14 +199,15 @@ void SwUndoFlyBase::DelFly( SwDoc* pDoc ) nCntPos = pPos->nContent.GetIndex(); SwTxtNode *pTxtNd = pDoc->GetNodes()[ pPos->nNode ]->GetTxtNode(); ASSERT( pTxtNd, "Kein Textnode gefunden" ); - SwTxtFlyCnt* pAttr = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( nCntPos ); + SwTxtFlyCnt* const pAttr = static_cast<SwTxtFlyCnt*>( + pTxtNd->GetTxtAttrForCharAt( nCntPos, RES_TXTATR_FLYCNT ) ); // Attribut steht noch im TextNode, loeschen if( pAttr && pAttr->GetFlyCnt().GetFrmFmt() == pFrmFmt ) { // Pointer auf 0, nicht loeschen ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt(); SwIndex aIdx( pPos->nContent ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } } else if( FLY_AUTO_CNTNT == nRndId ) @@ -558,18 +559,17 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); -#ifndef PRODUCT + SwTxtAttr * pHnt = pTxtNode->GetTxtAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFrmFmt, "Wrong TxtFlyCnt-Hint." ); -#endif - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()).SetFlyFmt(); // Die Verbindung ist geloest, jetzt muss noch das Attribut // vernichtet werden. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } // Anker umsetzen @@ -580,8 +580,9 @@ void SwUndoSetFlyFmt::Undo( SwUndoIter& rIter ) if( FLY_IN_CNTNT == aNewAnchor.GetAnchorId() ) { SwPosition* pPos = (SwPosition*)aNewAnchor.GetCntntAnchor(); - pPos->nNode.GetNode().GetTxtNode()->InsertItem( - SwFmtFlyCnt( (SwFlyFrmFmt*)pFrmFmt ), nOldCntnt, 0 ); + SwFmtFlyCnt aFmt( pFrmFmt ); + pPos->nNode.GetNode().GetTxtNode()->InsertItem( aFmt, + nOldCntnt, 0 ); } pFrmFmt->MakeFrms(); diff --git a/sw/source/core/undo/undoflystrattr.cxx b/sw/source/core/undo/undoflystrattr.cxx new file mode 100644 index 0000000000..767f300a53 --- /dev/null +++ b/sw/source/core/undo/undoflystrattr.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SwUndoPageDesc.cxx,v $ + * $Revision: 1.12 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_sw.hxx" + +#include <undoflystrattr.hxx> +#include <frmfmt.hxx> + +SwUndoFlyStrAttr::SwUndoFlyStrAttr( SwFlyFrmFmt& rFlyFrmFmt, + const SwUndoId eUndoId, + const String& sOldStr, + const String& sNewStr ) + : SwUndo( eUndoId ), + mrFlyFrmFmt( rFlyFrmFmt ), + msOldStr( sOldStr ), + msNewStr( sNewStr ) +{ + ASSERT( eUndoId == UNDO_FLYFRMFMT_TITLE || + eUndoId == UNDO_FLYFRMFMT_DESCRIPTION, + "<SwUndoFlyStrAttr::SwUndoFlyStrAttr(..)> - unexpected undo id --> Undo will not work" ); +} + +SwUndoFlyStrAttr::~SwUndoFlyStrAttr() +{ +} + +void SwUndoFlyStrAttr::Undo( SwUndoIter& ) +{ + switch ( GetId() ) + { + case UNDO_FLYFRMFMT_TITLE: + { + mrFlyFrmFmt.SetObjTitle( msOldStr, true ); + } + break; + case UNDO_FLYFRMFMT_DESCRIPTION: + { + mrFlyFrmFmt.SetObjDescription( msOldStr, true ); + } + break; + default: + { + } + } +} + +void SwUndoFlyStrAttr::Redo( SwUndoIter& ) +{ + switch ( GetId() ) + { + case UNDO_FLYFRMFMT_TITLE: + { + mrFlyFrmFmt.SetObjTitle( msNewStr, true ); + } + break; + case UNDO_FLYFRMFMT_DESCRIPTION: + { + mrFlyFrmFmt.SetObjDescription( msNewStr, true ); + } + break; + default: + { + } + } +} + +void SwUndoFlyStrAttr::Repeat( SwUndoIter& ) +{ + // no repeat +} + +SwRewriter SwUndoFlyStrAttr::GetRewriter() const +{ + SwRewriter aResult; + + aResult.AddRule( UNDO_ARG1, mrFlyFrmFmt.GetName() ); + + return aResult; +} diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx index e8a2259438..2b89cb1e7c 100644 --- a/sw/source/core/undo/undraw.cxx +++ b/sw/source/core/undo/undraw.cxx @@ -157,14 +157,15 @@ void lcl_SaveAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) // TextAttribut zerstoeren SwTxtNode *pTxtNd = pFmt->GetDoc()->GetNodes()[ rNodePos ]->GetTxtNode(); ASSERT( pTxtNd, "Kein Textnode gefunden" ); - SwTxtFlyCnt* pAttr = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( nCntntPos ); + SwTxtFlyCnt* pAttr = static_cast<SwTxtFlyCnt*>( + pTxtNd->GetTxtAttrForCharAt( nCntntPos, RES_TXTATR_FLYCNT )); // Attribut steht noch im TextNode, loeschen if( pAttr && pAttr->GetFlyCnt().GetFrmFmt() == pFmt ) { // Pointer auf 0, nicht loeschen ((SwFmtFlyCnt&)pAttr->GetFlyCnt()).SetFlyFmt(); SwIndex aIdx( pTxtNd, nCntntPos ); - pTxtNd->Erase( aIdx, 1 ); + pTxtNd->EraseText( aIdx, 1 ); } } else if( FLY_AUTO_CNTNT == rAnchor.GetAnchorId() ) @@ -198,9 +199,9 @@ void lcl_RestoreAnchor( SwFrmFmt* pFmt, ULONG& rNodePos ) if( FLY_IN_CNTNT == rAnchor.GetAnchorId() ) { SwTxtNode *pTxtNd = aIdx.GetNode().GetTxtNode(); - ASSERT( pTxtNd, "Kein Textnode gefunden" ); - pTxtNd->InsertItem( SwFmtFlyCnt( (SwFrmFmt*)pFmt ), - nCntntPos, nCntntPos ); + ASSERT( pTxtNd, "no Text Node" ); + SwFmtFlyCnt aFmt( pFmt ); + pTxtNd->InsertItem( aFmt, nCntntPos, nCntntPos ); } } } diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 9362785ce3..36fc9bde50 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -142,10 +142,13 @@ void SwUndoInsert::Init(const SwNodeIndex & rNd) // #111827# SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, xub_StrLen nCnt, - xub_StrLen nL, BOOL bWDelim ) + xub_StrLen nL, + const IDocumentContentOperations::InsertFlags nInsertFlags, + BOOL bWDelim ) : SwUndo(UNDO_TYPING), pPos( 0 ), pTxt( 0 ), pRedlData( 0 ), nNode( rNd.GetIndex() ), nCntnt(nCnt), nLen(nL), bIsWordDelim( bWDelim ), bIsAppend( FALSE ) + , m_nInsertFlags(nInsertFlags) { Init(rNd); } @@ -155,6 +158,7 @@ SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd ) : SwUndo(UNDO_SPLITNODE), pPos( 0 ), pTxt( 0 ), pRedlData( 0 ), nNode( rNd.GetIndex() ), nCntnt(0), nLen(1), bIsWordDelim( FALSE ), bIsAppend( TRUE ) + , m_nInsertFlags(IDocumentContentOperations::INS_EMPTYEXPAND) { Init(rNd); } @@ -247,7 +251,7 @@ SwUndoInsert::~SwUndoInsert() { SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNd, "kein TextNode, aus dem geloescht werden soll" ); - pTxtNd->Erase( pPos->nContent ); + pTxtNd->EraseText( pPos->nContent ); pPos->nNode++; } pPos->nContent.Assign( 0, 0 ); @@ -295,15 +299,15 @@ void SwUndoInsert::Undo( SwUndoIter& rUndoIter ) aPaM.SetMark(); - if( pCNd->IsTxtNode() ) // Text !! + SwTxtNode * const pTxtNode( pCNd->GetTxtNode() ); + if ( pTxtNode ) { aPaM.GetPoint()->nContent -= nLen; if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineMode() )) pTmpDoc->DeleteRedline( aPaM, true, USHRT_MAX ); RemoveIdxFromRange( aPaM, FALSE ); - pTxt = new String( ((SwTxtNode*)pCNd)->GetTxt().Copy( - nCntnt-nLen, nLen ) ); - ((SwTxtNode*)pCNd)->Erase( aPaM.GetPoint()->nContent, nLen ); + pTxt = new String( pTxtNode->GetTxt().Copy(nCntnt-nLen, nLen) ); + pTxtNode->EraseText( aPaM.GetPoint()->nContent, nLen ); } else // ansonsten Grafik/OLE/Text/... { @@ -379,9 +383,10 @@ void SwUndoInsert::Redo( SwUndoIter& rUndoIter ) if( pTxt ) { - ASSERT( pCNd->IsTxtNode(), "wo ist mein Textnode ??" ); - ((SwTxtNode*)pCNd)->Insert( *pTxt, pPam->GetMark()->nContent, - INS_EMPTYEXPAND ); + SwTxtNode *const pTxtNode = pCNd->GetTxtNode(); + ASSERT( pTxtNode, "where is my textnode ?" ); + pTxtNode->InsertText( *pTxt, pPam->GetMark()->nContent, + m_nInsertFlags ); DELETEZ( pTxt ); } else @@ -445,7 +450,8 @@ void SwUndoInsert::Repeat( SwUndoIter& rUndoIter ) String aTxt( ((SwTxtNode*)pCNd)->GetTxt() ); BOOL bGroupUndo = rDoc.DoesGroupUndo(); rDoc.DoGroupUndo( FALSE ); - rDoc.Insert( *rUndoIter.pAktPam, aTxt.Copy( nCntnt - nLen, nLen ), true); + rDoc.InsertString( *rUndoIter.pAktPam, + aTxt.Copy( nCntnt - nLen, nLen ) ); rDoc.DoGroupUndo( bGroupUndo ); } break; @@ -712,7 +718,7 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) SwIndex aIdx( pNd, m_nSttCnt ); if( m_nSttNd == m_nEndNd ) { - pNd->Erase( aIdx, m_sIns.Len() ); + pNd->EraseText( aIdx, m_sIns.Len() ); } else { @@ -741,7 +747,9 @@ void _UnReplaceData::Undo( SwUndoIter& rIter ) } if( m_sOld.Len() ) - pNd->Insert( m_sOld, aIdx ); + { + pNd->InsertText( m_sOld, aIdx ); + } if( pHistory ) { @@ -813,7 +821,7 @@ void _UnReplaceData::Redo( SwUndoIter& rIter ) delete pHistory, pHistory = 0; } - rDoc.Replace( rPam, m_sIns, m_bRegExp ); + rDoc.ReplaceRange( rPam, m_sIns, m_bRegExp ); rPam.DeleteMark(); rDoc.DoUndo( bUndo ); } diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx index 0482e59233..a7491da0c8 100644 --- a/sw/source/core/undo/unmove.cxx +++ b/sw/source/core/undo/unmove.cxx @@ -207,7 +207,9 @@ void SwUndoMove::Undo( SwUndoIter& rUndoIter ) SwNodeRange aRg( aIdx, aIdx ); aRg.aEnd = nDestEndNode; aIdx = nInsPosNode; - if( !pDoc->Move( aRg, aIdx, IDocumentContentOperations::DOC_MOVEDEFAULT ) ) + bool bSuccess = pDoc->MoveNodeRange( aRg, aIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT ); + if (!bSuccess) break; } else @@ -231,7 +233,10 @@ void SwUndoMove::Undo( SwUndoIter& rUndoIter ) ((SwTxtNode*)pCNd)->ClearSwpHintsArr( false ); // an der InsertPos erstmal alle Attribute entfernen, - if( !pDoc->Move( aPam, aPos, ( bMoveRedlines ? IDocumentContentOperations::DOC_MOVEREDLINES : IDocumentContentOperations::DOC_MOVEDEFAULT ) ) ) + const bool bSuccess = pDoc->MoveRange( aPam, aPos, (bMoveRedlines) + ? IDocumentContentOperations::DOC_MOVEREDLINES + : IDocumentContentOperations::DOC_MOVEDEFAULT ); + if (!bSuccess) break; aPam.Exchange(); @@ -294,7 +299,9 @@ void SwUndoMove::Redo( SwUndoIter& rUndoIter ) { // nur ein Move mit SwRange SwNodeRange aRg( rNds, nSttNode, rNds, nEndNode ); - rDoc.Move( aRg, aIdx, ( bMoveRedlines ? IDocumentContentOperations::DOC_MOVEREDLINES : IDocumentContentOperations::DOC_MOVEDEFAULT ) ); + rDoc.MoveNodeRange( aRg, aIdx, (bMoveRedlines) + ? IDocumentContentOperations::DOC_MOVEREDLINES + : IDocumentContentOperations::DOC_MOVEDEFAULT ); } else { @@ -310,7 +317,8 @@ void SwUndoMove::Redo( SwUndoIter& rUndoIter ) BOOL bJoinTxt = aIdx.GetNode().IsTxtNode(); aIdx--; - rDoc.Move( aPam, aMvPos, IDocumentContentOperations::DOC_MOVEDEFAULT ); + rDoc.MoveRange( aPam, aMvPos, + IDocumentContentOperations::DOC_MOVEDEFAULT ); if( nSttNode != nEndNode && bJoinTxt ) { diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx index d445612539..d91db0515e 100644 --- a/sw/source/core/undo/unovwr.cxx +++ b/sw/source/core/undo/unovwr.cxx @@ -105,13 +105,14 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc* pDoc, SwPosition& rPos, BOOL bOldExpFlg = pTxtNd->IsIgnoreDontExpand(); pTxtNd->SetIgnoreDontExpand( TRUE ); - pTxtNd->Insert( cIns, rPos.nContent ); + pTxtNd->InsertText( cIns, rPos.nContent, + IDocumentContentOperations::INS_EMPTYEXPAND ); aInsStr.Insert( cIns ); if( !bInsChar ) { const SwIndex aTmpIndex( rPos.nContent, -2 ); - pTxtNd->Erase( aTmpIndex, 1 ); + pTxtNd->EraseText( aTmpIndex, 1 ); } pTxtNd->SetIgnoreDontExpand( bOldExpFlg ); @@ -143,7 +144,7 @@ BOOL SwUndoOverwrite::CanGrouping( SwDoc* pDoc, SwPosition& rPos, CharClass& rCC = GetAppCharClass(); // befrage das einzufuegende Charakter - if( ( CH_TXTATR_BREAKWORD == cIns && CH_TXTATR_INWORD == cIns ) || + if (( CH_TXTATR_BREAKWORD == cIns || CH_TXTATR_INWORD == cIns ) || rCC.isLetterNumeric( String( cIns ), 0 ) != rCC.isLetterNumeric( aInsStr, aInsStr.Len()-1 ) ) return FALSE; @@ -183,13 +184,14 @@ BOOL SwUndoOverwrite::CanGrouping( SwDoc* pDoc, SwPosition& rPos, BOOL bOldExpFlg = pDelTxtNd->IsIgnoreDontExpand(); pDelTxtNd->SetIgnoreDontExpand( TRUE ); - pDelTxtNd->Insert( cIns, rPos.nContent ); + pDelTxtNd->InsertText( cIns, rPos.nContent, + IDocumentContentOperations::INS_EMPTYEXPAND ); aInsStr.Insert( cIns ); if( !bInsChar ) { const SwIndex aTmpIndex( rPos.nContent, -2 ); - pDelTxtNd->Erase( aTmpIndex, 1 ); + pDelTxtNd->EraseText( aTmpIndex, 1 ); } pDelTxtNd->SetIgnoreDontExpand( bOldExpFlg ); @@ -225,7 +227,7 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) if( aInsStr.Len() > aDelStr.Len() ) { rIdx += aDelStr.Len(); - pTxtNd->Erase( rIdx, aInsStr.Len() - aDelStr.Len() ); + pTxtNd->EraseText( rIdx, aInsStr.Len() - aDelStr.Len() ); rIdx = nSttCntnt; } @@ -242,9 +244,9 @@ void SwUndoOverwrite::Undo( SwUndoIter& rUndoIter ) { // einzeln, damit die Attribute stehen bleiben !!! *pTmpStr = aDelStr.GetChar( n ); - pTxtNd->Insert( aTmpStr, rIdx /*???, SETATTR_NOTXTATRCHR*/ ); + pTxtNd->InsertText( aTmpStr, rIdx /*???, SETATTR_NOTXTATRCHR*/ ); rIdx -= 2; - pTxtNd->Erase( rIdx, 1 ); + pTxtNd->EraseText( rIdx, 1 ); rIdx += 2; } pTxtNd->SetIgnoreDontExpand( bOldExpFlg ); @@ -312,11 +314,12 @@ void SwUndoOverwrite::Redo( SwUndoIter& rUndoIter ) for( xub_StrLen n = 0; n < aInsStr.Len(); n++ ) { // einzeln, damit die Attribute stehen bleiben !!! - pTxtNd->Insert( aInsStr.GetChar( n ), rIdx ); + pTxtNd->InsertText( aInsStr.GetChar( n ), rIdx, + IDocumentContentOperations::INS_EMPTYEXPAND ); if( n < aDelStr.Len() ) { rIdx -= 2; - pTxtNd->Erase( rIdx, 1 ); + pTxtNd->EraseText( rIdx, 1 ); rIdx += n+1 < aDelStr.Len() ? 2 : 1; } } diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx index b43ec4eeb2..76f8efa306 100644 --- a/sw/source/core/undo/unsect.cxx +++ b/sw/source/core/undo/unsect.cxx @@ -192,7 +192,9 @@ void SwUndoInsSection::Redo( SwUndoIter& rUndoIter ) rBase, pAttr, TRUE ); } else - rDoc.Insert( *rUndoIter.pAktPam, *pSection, pAttr, TRUE ); + { + rDoc.InsertSwSection( *rUndoIter.pAktPam, *pSection, pAttr, true ); + } if( pHistory ) pHistory->SetTmpEnd( pHistory->Count() ); @@ -236,7 +238,10 @@ void SwUndoInsSection::Repeat( SwUndoIter& rUndoIter ) rBase, pAttr, TRUE ); } else - rUndoIter.GetDoc().Insert( *rUndoIter.pAktPam, *pSection, pAttr ); + { + rUndoIter.GetDoc().InsertSwSection( *rUndoIter.pAktPam, + *pSection, pAttr ); + } } @@ -255,7 +260,7 @@ void SwUndoInsSection::Join( SwDoc& rDoc, ULONG nNode ) if( pHistory ) { SwIndex aCntIdx( pTxtNd, 0 ); - pTxtNd->RstAttr( aCntIdx, pTxtNd->GetTxt().Len() ); + pTxtNd->RstAttr( aCntIdx, pTxtNd->Len(), 0, 0, true ); } } diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx index a368362173..e5f4a1c25c 100644 --- a/sw/source/core/undo/unsort.cxx +++ b/sw/source/core/undo/unsort.cxx @@ -166,7 +166,8 @@ void SwUndoSort::Undo( SwUndoIter& rIter) { SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i ); SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); - rDoc.Move(aRg, aIdx, IDocumentContentOperations::DOC_MOVEDEFAULT); + rDoc.MoveNodeRange(aRg, aIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT); } // Indixes loeschen aIdxList.DeleteAndDestroy(0, aIdxList.Count()); @@ -238,7 +239,8 @@ void SwUndoSort::Redo( SwUndoIter& rIter) { SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i); SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); - rDoc.Move(aRg, aIdx, IDocumentContentOperations::DOC_MOVEDEFAULT); + rDoc.MoveNodeRange(aRg, aIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT); } // Indixes loeschen aIdxList.DeleteAndDestroy(0, aIdxList.Count()); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index f08e8b3cc5..ab501f9558 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -591,7 +591,7 @@ SwTableNode* SwNodes::UndoTableToText( ULONG nSttNd, ULONG nEndNd, ASSERT( pTxtNd, "Wo ist der TextNode geblieben?" ); SwIndex aCntPos( pTxtNd, pSave->m_nCntnt - 1 ); - pTxtNd->Erase( aCntPos, 1 ); + pTxtNd->EraseText( aCntPos, 1 ); SwCntntNode* pNewNd = pTxtNd->SplitCntntNode( SwPosition( aSttIdx, aCntPos )); if( aBkmkArr.Count() ) @@ -2121,7 +2121,7 @@ CHECKTABLE(pTblNd->GetTable()) pTxtNd->RstAttr( aTmpIdx, pTxtNd->GetTxt().Len() - nDelPos + 1 ); // das Trennzeichen loeschen - pTxtNd->Erase( aTmpIdx, 1 ); + pTxtNd->EraseText( aTmpIdx, 1 ); } // delete pUndo; DUMPDOC( &rDoc, String( "d:\\tmp\\tab_") + String( aNewSttNds.Count() - i ) + @@ -2198,7 +2198,7 @@ void SwUndoTblMerge::MoveBoxCntnt( SwDoc* pDoc, SwNodeRange& rRg, SwNodeIndex& r SwUndoMove* pUndo = new SwUndoMove( pDoc, rRg, rPos ); sal_Bool bDoesUndo = pDoc->DoesUndo(); pDoc->DoUndo( sal_False ); - pDoc->Move( rRg, rPos, pSaveTbl->IsNewModel() ? + pDoc->MoveNodeRange( rRg, rPos, (pSaveTbl->IsNewModel()) ? IDocumentContentOperations::DOC_NO_DELFRMS : IDocumentContentOperations::DOC_MOVEDEFAULT ); if( bDoesUndo ) @@ -2349,8 +2349,9 @@ void SwUndoTblNumFmt::Undo( SwUndoIter& rIter ) SwIndex aIdx( pTxtNd, 0 ); if( aStr.Len() ) { - pTxtNd->Erase( aIdx ); - pTxtNd->Insert( aStr, aIdx, INS_NOHINTEXPAND ); + pTxtNd->EraseText( aIdx ); + pTxtNd->InsertText( aStr, aIdx, + IDocumentContentOperations::INS_NOHINTEXPAND ); } } diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx index 05f7afb921..e6aad03906 100644 --- a/sw/source/core/undo/untblk.cxx +++ b/sw/source/core/undo/untblk.cxx @@ -158,7 +158,9 @@ SwUndoInserts::~SwUndoInserts() SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNd, "kein TextNode, aus dem geloescht werden soll" ); if( pTxtNd ) // Robust - pTxtNd->Erase( pPos->nContent ); + { + pTxtNd->EraseText( pPos->nContent ); + } pPos->nNode++; } pPos->nContent.Assign( 0, 0 ); @@ -247,7 +249,6 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) } else { - pDoc->RstTxtAttrs( *pPam, TRUE ); if( bJoinNext && pTxtNode->CanJoinNext()) { { @@ -256,6 +257,9 @@ void SwUndoInserts::Undo( SwUndoIter& rUndoIter ) } pTxtNode->JoinNext(); } + // reset all text attributes in the paragraph! + pTxtNode->RstAttr( SwIndex(pTxtNode, 0), pTxtNode->Len(), + 0, 0, true ); // setze alle Attribute im Node zurueck pTxtNode->ResetAllAttr(); @@ -288,7 +292,6 @@ void SwUndoInserts::Redo( SwUndoIter& rUndoIter ) pSavTxtFmtColl = ((SwTxtNode*)pCNd)->GetTxtColl(); pHistory->SetTmpEnd( nSetPos ); - pHistory->TmpRollback( pDoc, 0, false ); // alte Anfangs-Position fuers Rollback zurueckholen if( ( nSttNode != nEndNode || nSttCntnt != nEndCntnt ) && pPos ) @@ -346,7 +349,7 @@ void SwUndoInserts::Repeat( SwUndoIter& rUndoIter ) SwPaM aPam( *rUndoIter.pAktPam->GetPoint() ); SetPaM( aPam ); - aPam.GetDoc()->Copy( aPam, *rUndoIter.pAktPam->GetPoint(), false ); + aPam.GetDoc()->CopyRange( aPam, *rUndoIter.pAktPam->GetPoint(), false ); rUndoIter.pLastUndoObj = this; } diff --git a/sw/source/core/unocore/unobkm.cxx b/sw/source/core/unocore/unobkm.cxx index ca27062014..11ea44de5f 100644 --- a/sw/source/core/unocore/unobkm.cxx +++ b/sw/source/core/unocore/unobkm.cxx @@ -46,6 +46,8 @@ #include <comcore.hrc> #endif #include <undobj.hxx> +#include <docsh.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::lang; @@ -280,6 +282,23 @@ void SwXBookmark::Modify(SfxPoolItem *pOld, SfxPoolItem *pNew) } } +// MetadatableMixin +::sfx2::Metadatable* SwXBookmark::GetCoreObject() +{ + return dynamic_cast< ::sfx2::Metadatable* >( GetBookmark() ); +} + +uno::Reference<frame::XModel> SwXBookmark::GetModel() +{ + if (GetDoc()) + { + SwDocShell const * const pShell( GetDoc()->GetDocShell() ); + return (pShell) ? pShell->GetModel() : 0; + } + return 0; +} + + uno::Reference< beans::XPropertySetInfo > SwXBookmark::getPropertySetInfo(void) throw( uno::RuntimeException ) { diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index dfbc42fb7b..06bbca43e0 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -76,8 +76,10 @@ #include <slist> #include <iterator> +#include "unometa.hxx" #include "docsh.hxx" + using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::document; @@ -174,11 +176,11 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] = { "com.sun.star.text.TextField.Bibliography", SW_SERVICE_FIELDTYPE_BIBLIOGRAPHY }, { "com.sun.star.text.TextField.CombinedCharacters", SW_SERVICE_FIELDTYPE_COMBINED_CHARACTERS }, { "com.sun.star.text.TextField.DropDown", SW_SERVICE_FIELDTYPE_DROPDOWN }, + { "com.sun.star.text.textfield.MetadataField", SW_SERVICE_FIELDTYPE_METAFIELD }, { "", SW_SERVICE_FIELDTYPE_DUMMY_4 }, { "", SW_SERVICE_FIELDTYPE_DUMMY_5 }, { "", SW_SERVICE_FIELDTYPE_DUMMY_6 }, { "", SW_SERVICE_FIELDTYPE_DUMMY_7 }, - { "", SW_SERVICE_FIELDTYPE_DUMMY_8 }, { "com.sun.star.text.FieldMaster.User", SW_SERVICE_FIELDMASTER_USER }, { "com.sun.star.text.FieldMaster.DDE", SW_SERVICE_FIELDMASTER_DDE }, { "com.sun.star.text.FieldMaster.SetExpression", SW_SERVICE_FIELDMASTER_SET_EXP }, @@ -207,6 +209,7 @@ const ProvNamesId_Type __FAR_DATA aProvNamesId[] = { "com.sun.star.chart2.data.DataProvider", SW_SERVICE_CHART2_DATA_PROVIDER }, { "com.sun.star.text.Fieldmark", SW_SERVICE_TYPE_FIELDMARK }, { "com.sun.star.text.FormFieldmark", SW_SERVICE_TYPE_FORMFIELDMARK }, + { "com.sun.star.text.InContentMetadata", SW_SERVICE_TYPE_META }, // case-correct versions of the service names (see #i67811) { CSS_TEXT_TEXTFIELD_DATE_TIME, SW_SERVICE_FIELDTYPE_DATETIME }, @@ -604,6 +607,12 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 if( pDoc->GetDocShell()->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) xRet = (cppu::OWeakObject*) pDoc->GetChartDataProvider( true /* create - if not yet available */ ); break; + case SW_SERVICE_TYPE_META: + xRet = static_cast< ::cppu::OWeakObject* >( new SwXMeta(pDoc) ); + break; + case SW_SERVICE_FIELDTYPE_METAFIELD: + xRet = static_cast< ::cppu::OWeakObject* >(new SwXMetaField(pDoc)); + break; default: throw uno::RuntimeException(); } @@ -806,10 +815,10 @@ XTextTable* SwXTextTables::GetObject( SwFrmFmt& rFmt ) ******************************************************************/ namespace { - template<FlyCntType T> struct SwXFrameEnumeration_traits {}; + template<FlyCntType T> struct UnoFrameWrap_traits {}; template<> - struct SwXFrameEnumeration_traits<FLYCNTTYPE_FRM> + struct UnoFrameWrap_traits<FLYCNTTYPE_FRM> { typedef SwXTextFrame core_frame_t; typedef XTextFrame uno_frame_t; @@ -817,7 +826,7 @@ namespace }; template<> - struct SwXFrameEnumeration_traits<FLYCNTTYPE_GRF> + struct UnoFrameWrap_traits<FLYCNTTYPE_GRF> { typedef SwXTextGraphicObject core_frame_t; typedef XTextContent uno_frame_t; @@ -825,7 +834,7 @@ namespace }; template<> - struct SwXFrameEnumeration_traits<FLYCNTTYPE_OLE> + struct UnoFrameWrap_traits<FLYCNTTYPE_OLE> { typedef SwXTextEmbeddedObject core_frame_t; typedef XEmbeddedObjectSupplier uno_frame_t; @@ -833,6 +842,33 @@ namespace }; template<FlyCntType T> + static uno::Any lcl_UnoWrapFrame(SwFrmFmt* pFmt) + { + SwXFrame* pFrm = static_cast<SwXFrame*>(SwClientIter(*pFmt).First(TYPE(SwXFrame))); + if(!pFrm) + pFrm = new typename UnoFrameWrap_traits<T>::core_frame_t(*pFmt); + Reference< typename UnoFrameWrap_traits<T>::uno_frame_t > xFrm = + static_cast< typename UnoFrameWrap_traits<T>::core_frame_t* >(pFrm); + return uno::makeAny(xFrm); + } + + // runtime adapter for lcl_UnoWrapFrame + static uno::Any lcl_UnoWrapFrame(SwFrmFmt* pFmt, FlyCntType eType) throw(uno::RuntimeException()) + { + switch(eType) + { + case FLYCNTTYPE_FRM: + return lcl_UnoWrapFrame<FLYCNTTYPE_FRM>(pFmt); + case FLYCNTTYPE_GRF: + return lcl_UnoWrapFrame<FLYCNTTYPE_GRF>(pFmt); + case FLYCNTTYPE_OLE: + return lcl_UnoWrapFrame<FLYCNTTYPE_OLE>(pFmt); + default: + throw uno::RuntimeException(); + } + } + + template<FlyCntType T> class SwXFrameEnumeration : public SwSimpleEnumerationBaseClass { private: @@ -844,12 +880,12 @@ namespace SwXFrameEnumeration(const SwDoc* const pDoc); //XEnumeration - virtual BOOL SAL_CALL hasMoreElements(void) throw( RuntimeException ); + virtual sal_Bool SAL_CALL hasMoreElements(void) throw( RuntimeException ); virtual Any SAL_CALL nextElement(void) throw( NoSuchElementException, WrappedTargetException, RuntimeException ); //XServiceInfo virtual OUString SAL_CALL getImplementationName(void) throw( RuntimeException ); - virtual BOOL SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException ); + virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw( RuntimeException ); virtual Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw( RuntimeException ); }; } @@ -860,31 +896,35 @@ SwXFrameEnumeration<T>::SwXFrameEnumeration(const SwDoc* const pDoc) { vos::OGuard aGuard(Application::GetSolarMutex()); const SwSpzFrmFmts* const pFmts = pDoc->GetSpzFrmFmts(); + if(!pFmts->Count()) + return; + // --> OD 2009-09-10 #i104937# +// const SwFrmFmt* const pFmtsEnd = (*pFmts)[pFmts->Count()]; const USHORT nSize = pFmts->Count(); + // <-- ::std::insert_iterator<frmcontainer_t> pInserter = ::std::insert_iterator<frmcontainer_t>(m_aFrames, m_aFrames.begin()); - for( USHORT i=0; i < nSize; ++i ) + // --> OD 2009-09-10 #i104937# + SwFrmFmt* pFmt( 0 ); + for( USHORT i = 0; i < nSize; ++i ) +// for(SwFrmFmt* pFmt = (*pFmts)[0]; pFmt < pFmtsEnd; ++pFmt) + // <-- { - SwFrmFmt* pFmt = (*pFmts)[i]; + // --> OD 2009-09-10 #i104937# + pFmt = (*pFmts)[i]; + // <-- if(pFmt->Which() != RES_FLYFRMFMT) continue; const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); if(!pIdx || !pIdx->GetNodes().IsDocNodes()) continue; const SwNode* pNd = pDoc->GetNodes()[ pIdx->GetIndex() + 1 ]; - if(SwXFrameEnumeration_traits<T>::filter(pNd)) - { - SwXFrame* pFrm = (SwXFrame*)SwClientIter( *pFmt ).First( TYPE( SwXFrame )); - if( !pFrm ) - pFrm = new typename SwXFrameEnumeration_traits<T>::core_frame_t(*pFmt); - Reference< typename SwXFrameEnumeration_traits<T>::uno_frame_t > xFrm = - static_cast< typename SwXFrameEnumeration_traits<T>::core_frame_t* >(pFrm); - *pInserter++ = uno::makeAny(xFrm); - } + if(UnoFrameWrap_traits<T>::filter(pNd)) + *pInserter++ = lcl_UnoWrapFrame<T>(pFmt); } } template<FlyCntType T> -BOOL SwXFrameEnumeration<T>::hasMoreElements(void) throw( RuntimeException ) +sal_Bool SwXFrameEnumeration<T>::hasMoreElements(void) throw( RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); return !m_aFrames.empty(); @@ -908,7 +948,7 @@ OUString SwXFrameEnumeration<T>::getImplementationName(void) throw( RuntimeExcep } template<FlyCntType T> -BOOL SwXFrameEnumeration<T>::supportsService(const OUString& ServiceName) throw( RuntimeException ) +sal_Bool SwXFrameEnumeration<T>::supportsService(const OUString& ServiceName) throw( RuntimeException ) { return C2U("com.sun.star.container.XEnumeration") == ServiceName; } @@ -971,54 +1011,51 @@ sal_Int32 SwXFrames::getCount(void) throw(uno::RuntimeException) vos::OGuard aGuard(Application::GetSolarMutex()); if(!IsValid()) throw uno::RuntimeException(); - const Reference<XEnumeration> xEnum = createEnumeration(); - sal_Int32 nCount = 0; - while(xEnum->hasMoreElements()) - { - xEnum->nextElement(); - ++nCount; - } - return nCount; + return GetDoc()->GetFlyCount(eType); } uno::Any SwXFrames::getByIndex(sal_Int32 nIndex) throw(IndexOutOfBoundsException, WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()) throw uno::RuntimeException(); - if(nIndex < 0 || nIndex >= USHRT_MAX) throw IndexOutOfBoundsException(); - const Reference<XEnumeration> xEnum = createEnumeration(); - while(xEnum->hasMoreElements()) - { - uno::Any aCurrent = xEnum->nextElement(); - if(nIndex-- == 0) - return aCurrent; - } - throw IndexOutOfBoundsException(); + if(nIndex < 0 || nIndex >= USHRT_MAX) + throw IndexOutOfBoundsException(); + SwFrmFmt* pFmt = GetDoc()->GetFlyNum(static_cast<sal_uInt16>(nIndex), eType); + if(!pFmt) + throw IndexOutOfBoundsException(); + return lcl_UnoWrapFrame(pFmt, eType); } + uno::Any SwXFrames::getByName(const OUString& rName) throw(NoSuchElementException, WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()) throw uno::RuntimeException(); - const Reference<XEnumeration> xEnum = createEnumeration(); - while(xEnum->hasMoreElements()) + const SwFrmFmt* pFmt; + switch(eType) { - uno::Any aCurrent = xEnum->nextElement(); - Reference<container::XNamed> xNamed; - aCurrent >>= xNamed; - if(xNamed.is() && xNamed->getName() == rName) - return aCurrent; + case FLYCNTTYPE_GRF: + pFmt = GetDoc()->FindFlyByName(rName, ND_GRFNODE); + break; + case FLYCNTTYPE_OLE: + pFmt = GetDoc()->FindFlyByName(rName, ND_OLENODE); + break; + default: + pFmt = GetDoc()->FindFlyByName(rName, ND_TEXTNODE); + break; } - throw NoSuchElementException(); + if(!pFmt) + throw NoSuchElementException(); + return lcl_UnoWrapFrame(const_cast<SwFrmFmt*>(pFmt), eType); } uno::Sequence<OUString> SwXFrames::getElementNames(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()) throw uno::RuntimeException(); const Reference<XEnumeration> xEnum = createEnumeration(); ::std::vector<OUString> vNames; @@ -1035,16 +1072,17 @@ uno::Sequence<OUString> SwXFrames::getElementNames(void) throw( uno::RuntimeExce sal_Bool SwXFrames::hasByName(const OUString& rName) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) throw uno::RuntimeException(); - const Reference<XEnumeration> xEnum = createEnumeration(); - while(xEnum->hasMoreElements()) + if(!IsValid()) + throw uno::RuntimeException(); + switch(eType) { - Reference<XNamed> xNamed; - xEnum->nextElement() >>= xNamed; - if(xNamed.is() && xNamed->getName() == rName) - return true; + case FLYCNTTYPE_GRF: + return GetDoc()->FindFlyByName(rName, ND_GRFNODE) != NULL; + case FLYCNTTYPE_OLE: + return GetDoc()->FindFlyByName(rName, ND_OLENODE) != NULL; + default: + return GetDoc()->FindFlyByName(rName, ND_TEXTNODE) != NULL; } - return false; } uno::Type SAL_CALL SwXFrames::getElementType() throw(uno::RuntimeException) @@ -1066,9 +1104,9 @@ uno::Type SAL_CALL SwXFrames::getElementType() throw(uno::RuntimeException) sal_Bool SwXFrames::hasElements(void) throw(uno::RuntimeException) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!IsValid()) + if(!IsValid()) throw uno::RuntimeException(); - return createEnumeration()->hasMoreElements(); + return GetDoc()->GetFlyCount(eType) > 0; } SwXFrame* SwXFrames::GetObject(SwFrmFmt& rFmt, FlyCntType eType) @@ -1556,10 +1594,10 @@ SwXBookmark* SwXBookmarks::GetObject( ::sw::mark::IMark& rBkmk, SwDoc* pDoc) SwXBookmark* pXBkmk = (SwXBookmark*)SwClientIter(*pModify).First(TYPE(SwXBookmark)); if(!pXBkmk) { - // FIXME: These belong in XTextFieldsSupplier - //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk)) + // FIXME: These belong in XTextFieldsSupplier + //if (dynamic_cast< ::sw::mark::TextFieldmark* >(&rBkmk)) // pXBkmk = new SwXFieldmark(false, &rBkmk, pDoc); - //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk)) + //else if (dynamic_cast< ::sw::mark::CheckboxFieldmark* >(&rBkmk)) // pXBkmk = new SwXFieldmark(true, &rBkmk, pDoc); //else OSL_ENSURE( diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx index 2aacded41e..b3d17e83a4 100644 --- a/sw/source/core/unocore/unocrsrhelper.cxx +++ b/sw/source/core/unocore/unocrsrhelper.cxx @@ -343,20 +343,9 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry { if( pAny ) { - const SwFmtFld& rFld = pTxtAttr->GetFld(); - SwClientIter aIter(*rFld.GetFld()->GetTyp()); - SwXTextField* pFld = 0; - SwXTextField* pTemp = (SwXTextField*)aIter.First(TYPE(SwXTextField)); - while(pTemp && !pFld) - { - if(pTemp->GetFldFmt() == &rFld) - pFld = pTemp; - pTemp = (SwXTextField*)aIter.Next(); - } - if(!pFld) - pFld = new SwXTextField( rFld, rPam.GetDoc()); - uno::Reference< XTextField > xRet = pFld; - pAny->setValue(&xRet, ::getCppuType((uno::Reference<XTextField>*)0)); + SwXTextField* pField = CreateSwXTextField(*rPam.GetDoc(), + pTxtAttr->GetFld()); + *pAny <<= uno::Reference< XTextField >( pField ); } } else @@ -527,8 +516,8 @@ sal_Bool getCrsrPropertyValue(const SfxItemPropertySimpleEntry& rEntry } } - eNewState = - aCharStyles.getLength() ? + eNewState = + aCharStyles.getLength() ? PropertyState_DIRECT_VALUE : PropertyState_DEFAULT_VALUE;;
if(pAny) (*pAny) <<= aCharStyles; @@ -585,9 +574,9 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) if(pSwNum) { + SwDoc* pDoc = rPam.GetDoc(); if(pSwNum->GetNumRule()) { - SwDoc* pDoc = rPam.GetDoc(); SwNumRule aRule(*pSwNum->GetNumRule()); const String* pNewCharStyles = pSwNum->GetNewCharStyleNames(); const String* pBulletFontNames = pSwNum->GetBulletFontNames(); @@ -680,7 +669,6 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) } else if(pSwNum->GetCreatedNumRuleName().Len()) { - SwDoc* pDoc = rPam.GetDoc(); UnoActionContext aAction(pDoc); SwNumRule* pRule = pDoc->FindNumRulePtr( pSwNum->GetCreatedNumRuleName() ); if(!pRule) @@ -690,6 +678,17 @@ void setNumberingProperty(const Any& rValue, SwPaM& rPam) pDoc->SetNumRule( rPam, *pRule, false ); // <-- } + // --> OD 2009-08-18 #i103817# + // outline numbering + else + { + UnoActionContext aAction(pDoc); + SwNumRule* pRule = pDoc->GetOutlineNumRule(); + if(!pRule) + throw RuntimeException(); + pDoc->SetNumRule( rPam, *pRule, false ); + } + // <-- } } else if(rValue.getValueType() == ::getVoidCppuType()) @@ -933,25 +932,37 @@ void InsertFile(SwUnoCrsr* pUnoCrsr, // paragraph breaks at those positions by calling SplitNode sal_Bool DocInsertStringSplitCR( SwDoc &rDoc, - const SwPaM &rNewCursor, const String &rText ) + const SwPaM &rNewCursor, const String &rText, + const bool bForceExpandHints ) { sal_Bool bOK = sal_True; + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + OUString aTxt; xub_StrLen nStartIdx = 0; - xub_StrLen nMaxLength = STRING_LEN; - SwTxtNode* pTxtNd = rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode(); - if( pTxtNd ) - nMaxLength = STRING_LEN - pTxtNd->GetTxt().Len(); + SwTxtNode* const pTxtNd = + rNewCursor.GetPoint()->nNode.GetNode().GetTxtNode(); + const xub_StrLen nMaxLength = ( pTxtNd ) + ? STRING_LEN - pTxtNd->GetTxt().Len() + : STRING_LEN; xub_StrLen nIdx = rText.Search( '\r', nStartIdx ); if( ( nIdx == STRING_NOTFOUND && nMaxLength < rText.Len() ) || ( nIdx != STRING_NOTFOUND && nMaxLength < nIdx ) ) + { nIdx = nMaxLength; + } while (nIdx != STRING_NOTFOUND ) { DBG_ASSERT( nIdx - nStartIdx >= 0, "index negative!" ); aTxt = rText.Copy( nStartIdx, nIdx - nStartIdx ); - if (aTxt.getLength() && !rDoc.Insert( rNewCursor, aTxt, true )) + if (aTxt.getLength() && + !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags )) { DBG_ERROR( "Doc->Insert(Str) failed." ); bOK = sal_False; @@ -965,7 +976,8 @@ sal_Bool DocInsertStringSplitCR( nIdx = rText.Search( '\r', nStartIdx ); } aTxt = rText.Copy( nStartIdx ); - if (aTxt.getLength() && !rDoc.Insert( rNewCursor, aTxt, true )) + if (aTxt.getLength() && + !rDoc.InsertString( rNewCursor, aTxt, nInsertFlags )) { DBG_ERROR( "Doc->Insert(Str) failed." ); bOK = sal_False; @@ -1037,7 +1049,7 @@ SwAnyMapHelper::~SwAnyMapHelper() { delete ( aIt->second ); ++aIt; - } + } } /*-- 19.02.2009 09:27:26--------------------------------------------------- diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index 7269af7d71..0abfc6844e 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -1297,20 +1297,25 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFmt, "Wrong TxtFlyCnt-Hint." ); - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()) + .SetFlyFmt(); //The connection is removed now the attribute can be deleted. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( + RES_TXTATR_FLYCNT, nIdx ); //create a new one SwTxtNode *pNd = pInternalPam->GetNode()->GetTxtNode(); - DBG_ASSERT( pNd, "Crsr steht nicht auf TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( pFmt ), - pInternalPam->GetPoint()->nContent.GetIndex(), 0 ); + DBG_ASSERT( pNd, "Cursor not at TxtNode." ); + SwFmtFlyCnt aFmt( pFmt ); + pNd->InsertItem(aFmt, pInternalPam->GetPoint() + ->nContent.GetIndex(), 0 ); } else { @@ -1379,15 +1384,18 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode(); ASSERT( pTxtNode->HasHints(), "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx = pPos->nContent.GetIndex(); - SwTxtAttr * pHnt = pTxtNode->GetTxtAttr( nIdx, RES_TXTATR_FLYCNT ); + SwTxtAttr * const pHnt = + pTxtNode->GetTxtAttrForCharAt( + nIdx, RES_TXTATR_FLYCNT ); DBG_ASSERT( pHnt && pHnt->Which() == RES_TXTATR_FLYCNT, "Missing FlyInCnt-Hint." ); DBG_ASSERT( pHnt && pHnt->GetFlyCnt().GetFrmFmt() == pFlyFmt, "Wrong TxtFlyCnt-Hint." ); - ((SwFmtFlyCnt&)pHnt->GetFlyCnt()).SetFlyFmt(); + const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt()) + .SetFlyFmt(); //The connection is removed now the attribute can be deleted. - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes(RES_TXTATR_FLYCNT, nIdx); } else if( text::TextContentAnchorType_AT_PAGE != eNewAnchor && FLY_PAGE == eOldAnchorId ) @@ -1418,8 +1426,9 @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName, const uno::A //the RES_TXTATR_FLYCNT needs to be added now SwTxtNode *pNd = aPam.GetNode()->GetTxtNode(); DBG_ASSERT( pNd, "Crsr is not in a TxtNode." ); - pNd->InsertItem( SwFmtFlyCnt( pFlyFmt ), - aPam.GetPoint()->nContent.GetIndex(), 0 ); + SwFmtFlyCnt aFmt( pFlyFmt ); + pNd->InsertItem(aFmt, + aPam.GetPoint()->nContent.GetIndex(), 0 ); //aPam.GetPoint()->nContent--; } @@ -2124,8 +2133,10 @@ void SwXShape::attach(const uno::Reference< text::XTextRange > & xTextRange) pDoc = pText->GetDoc(); else if (!pDoc && pCursor) pDoc = pCursor->GetDoc(); - else if ( !pDoc && pPortion && pPortion->GetCrsr() ) - pDoc = pPortion->GetCrsr()->GetDoc(); + else if ( !pDoc && pPortion && pPortion->GetCursor() ) + { + pDoc = pPortion->GetCursor()->GetDoc(); + } } @@ -2213,7 +2224,7 @@ void SwXShape::dispose(void) throw( uno::RuntimeException ) const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); const xub_StrLen nIdx = rPos.nContent.GetIndex(); - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx ); } else pFmt->GetDoc()->DelLayoutFmt( pFmt ); diff --git a/sw/source/core/unocore/unoevent.cxx b/sw/source/core/unocore/unoevent.cxx index 2351540b6e..cfec12bfb7 100644 --- a/sw/source/core/unocore/unoevent.cxx +++ b/sw/source/core/unocore/unoevent.cxx @@ -73,93 +73,6 @@ const sal_Char sAPI_SwHyperlinkEventDescriptor[] = const sal_Char sAPI_SwAutoTextEventDescriptor[] = "SwAutoTextEventDescriptor"; - -// // -// // tables of all known events handled by this class -// // - -// // careful: keep aKnownEventIDs and aKnownEventNames in sync! - -// const USHORT aKnownEventIDs[] = -// { -// SW_EVENT_OBJECT_SELECT, -// SW_EVENT_START_INS_GLOSSARY, -// SW_EVENT_END_INS_GLOSSARY, -// SW_EVENT_MAIL_MERGE, -// SW_EVENT_FRM_KEYINPUT_ALPHA, -// SW_EVENT_FRM_KEYINPUT_NOALPHA, -// SW_EVENT_FRM_RESIZE, -// SW_EVENT_FRM_MOVE, -// SW_EVENT_PAGE_COUNT, -// SFX_EVENT_MOUSEOVER_OBJECT, -// SFX_EVENT_MOUSECLICK_OBJECT, -// SFX_EVENT_MOUSEOUT_OBJECT, -// SFX_EVENT_OPENDOC, -// SFX_EVENT_CLOSEDOC, -// SFX_EVENT_STARTAPP, -// SFX_EVENT_CLOSEAPP, -// SFX_EVENT_CREATEDOC, -// SFX_EVENT_SAVEDOC, -// SFX_EVENT_SAVEASDOC, -// SFX_EVENT_ACTIVATEDOC, -// SFX_EVENT_DEACTIVATEDOC, -// SFX_EVENT_PRINTDOC, -// SFX_EVENT_ONERROR, -// SFX_EVENT_LOADFINISHED, -// SFX_EVENT_SAVEFINISHED, -// SFX_EVENT_MODIFYCHANGED, -// SFX_EVENT_PREPARECLOSEDOC, -// SFX_EVENT_NEWMESSAGE, -// SFX_EVENT_TOGGLEFULLSCREENMODE, -// SFX_EVENT_SAVEDOCDONE, -// SFX_EVENT_SAVEASDOCDONE, -// SVX_EVENT_IMAGE_LOAD, -// SVX_EVENT_IMAGE_ABORT, -// SVX_EVENT_IMAGE_ERROR, -// 0 -// }; - -// const sal_Char* aKnownEventNames[] = -// { -// "OnSelect", // SW_EVENT_OBJECT_SELECT -// "OnInsertStart", // SW_EVENT_START_INS_GLOSSARY -// "OnInsertDone", // SW_EVENT_END_INS_GLOSSARY -// "OnMailMerge", // SW_EVENT_MAIL_MERGE -// "OnAlphaCharInput", // SW_EVENT_FRM_KEYINPUT_ALPHA -// "OnNonAlphaCharInput", // SW_EVENT_FRM_KEYINPUT_NOALPHA -// "OnResize", // SW_EVENT_FRM_RESIZE -// "OnMove", // SW_EVENT_FRM_MOVE -// "PageCountChange", // SW_EVENT_PAGE_COUNT -// "OnMouseOver", // SFX_EVENT_MOUSEOVER_OBJECT -// "OnClick", // SFX_EVENT_MOUSECLICK_OBJECT -// "OnMouseOut", // SFX_EVENT_MOUSEOUT_OBJECT -// "OnLoad", // SFX_EVENT_OPENDOC, -// "OnUnload", // SFX_EVENT_CLOSEDOC, -// "OnStartApp", // SFX_EVENT_STARTAPP, -// "OnCloseApp", // SFX_EVENT_CLOSEAPP, -// "OnNew", // SFX_EVENT_CREATEDOC, -// "OnSave", // SFX_EVENT_SAVEDOC, -// "OnSaveAs", // SFX_EVENT_SAVEASDOC, -// "OnFocus", // SFX_EVENT_ACTIVATEDOC, -// "OnUnfocus", // SFX_EVENT_DEACTIVATEDOC, -// "OnPrint", // SFX_EVENT_PRINTDOC, -// "OnError", // SFX_EVENT_ONERROR, -// "OnLoadFinished", // SFX_EVENT_LOADFINISHED, -// "OnSaveFinished", // SFX_EVENT_SAVEFINISHED, -// "OnModifyChanged", // SFX_EVENT_MODIFYCHANGED, -// "OnPrepareUnload", // SFX_EVENT_PREPARECLOSEDOC, -// "OnNewMail", // SFX_EVENT_NEWMESSAGE, -// "OnToggleFullscreen", // SFX_EVENT_TOGGLEFULLSCREENMODE, -// "OnSaveDone", // SFX_EVENT_SAVEDOCDONE, -// "OnSaveAsDone", // SFX_EVENT_SAVEASDOCDONE, -// "OnLoadError", // SVX_EVENT_IMAGE_LOAD, -// "OnLoadCancel", // SVX_EVENT_IMAGE_ABORT, -// "OnLoadDone", // SVX_EVENT_IMAGE_ERROR, - -// NULL -// }; - - // // tables of allowed events for specific objects // @@ -229,40 +142,6 @@ const struct SvEventDescription aFrameStyleEvents[] = { 0, NULL } }; -const struct SvEventDescription aDocumentEvents[] = -{ - { SFX_EVENT_STARTAPP, "OnStartApp" }, - { SFX_EVENT_CLOSEAPP, "OnCloseApp" }, - { SFX_EVENT_CREATEDOC, "OnNew" }, - { SFX_EVENT_OPENDOC, "OnLoad" }, - { SFX_EVENT_SAVEDOC, "OnSave" }, - { SFX_EVENT_SAVEASDOC, "OnSaveAs" }, -// ??? cf. SAVEDOCDONE, SAVEASDOCDONE - { SFX_EVENT_SAVEFINISHED, "OnSaveFinished" }, - { SFX_EVENT_CLOSEDOC, "OnUnload" }, - { SFX_EVENT_ACTIVATEDOC, "OnFocus" }, - { SFX_EVENT_DEACTIVATEDOC, "OnUnfocus" }, - { SFX_EVENT_ONERROR, "OnError" }, - { SFX_EVENT_NEWMESSAGE, "OnNewMail" }, - { SFX_EVENT_PRINTDOC, "OnPrint" }, - { SW_EVENT_MAIL_MERGE, "OnMailMerge" }, - { SW_EVENT_PAGE_COUNT, "PageCountChange" }, - { SW_EVENT_FIELD_MERGE, "OnFieldMerge" }, - { SW_EVENT_FIELD_MERGE_FINISHED, "OnFieldMergeFinished" }, -// SFX_EVENT_LOADFINISHED, -// SFX_EVENT_MODIFYCHANGED, -// SFX_EVENT_PREPARECLOSEDOC, -// SFX_EVENT_TOGGLEFULLSCREENMODE, -// SFX_EVENT_SAVEDOCDONE, -// SFX_EVENT_SAVEASDOCDONE, - - { 0, NULL } -}; - - - - - // // SwHyperlinkEventDescriptor // diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx index 29ce23c129..f8dc8e5cce 100644 --- a/sw/source/core/unocore/unofield.cxx +++ b/sw/source/core/unocore/unofield.cxx @@ -94,6 +94,7 @@ #include <textapi.hxx> #include <svx/outliner.hxx> #include <docsh.hxx> +#include <fmtmeta.hxx> // MetaFieldManager using ::rtl::OUString; using namespace ::com::sun::star; @@ -371,7 +372,7 @@ USHORT lcl_GetPropertyMapOfService( USHORT nServiceId ) case SW_SERVICE_FIELDTYPE_DUMMY_5: case SW_SERVICE_FIELDTYPE_DUMMY_6: case SW_SERVICE_FIELDTYPE_DUMMY_7: - case SW_SERVICE_FIELDTYPE_DUMMY_8: nRet = PROPERTY_MAP_FLDTYP_DUMMY_0; break; + nRet = PROPERTY_MAP_FLDTYP_DUMMY_0; break; case SW_SERVICE_FIELDMASTER_USER: nRet = PROPERTY_MAP_FLDMSTR_USER; break; case SW_SERVICE_FIELDMASTER_DDE: nRet = PROPERTY_MAP_FLDMSTR_DDE; break; case SW_SERVICE_FIELDMASTER_SET_EXP: nRet = PROPERTY_MAP_FLDMSTR_SET_EXP; break; @@ -784,24 +785,12 @@ uno::Any SwXFieldMaster::getPropertyValue(const OUString& rPropertyName) } uno::Sequence<uno::Reference <text::XDependentTextField> > aRetSeq(aFldArr.Count()); uno::Reference<text::XDependentTextField>* pRetSeq = aRetSeq.getArray(); - SwXTextField* pInsert = 0; for(USHORT i = 0; i < aFldArr.Count(); i++) { pFld = aFldArr.GetObject(i); - SwXTextField* pTemp = (SwXTextField*)aIter.First(TYPE(SwXTextField)); - while(pTemp) - { - if(pTemp->GetFldFmt() == pFld) - { - pInsert = pTemp; - break; - } - pTemp = (SwXTextField*)aIter.Next(); - } - if(!pInsert) - pInsert = new SwXTextField( *pFld, GetDoc()); + SwXTextField * pInsert = CreateSwXTextField(*GetDoc(), *pFld); + pRetSeq[i] = uno::Reference<text::XDependentTextField>(pInsert); - pInsert = 0; } aRet <<= aRetSeq; } @@ -1079,6 +1068,26 @@ OUString SwXFieldMaster::LocalizeFormula( } return rFormula; } + + +SwXTextField * CreateSwXTextField(SwDoc & rDoc, SwFmtFld const& rFmt) +{ + SwClientIter aIter(*rFmt.GetFld()->GetTyp()); + SwXTextField * pField = 0; + SwXTextField * pTemp = + static_cast<SwXTextField*>(aIter.First( TYPE(SwXTextField) )); + while (pTemp) + { + if (pTemp->GetFldFmt() == &rFmt) + { + pField = pTemp; + break; + } + pTemp = static_cast<SwXTextField*>(aIter.Next()); + } + return pField ? pField : new SwXTextField( rFmt, &rDoc ); +} + /****************************************************************** * ******************************************************************/ @@ -1809,8 +1818,18 @@ void SwXTextField::attachToRange( SwTxtAttr* pTxtAttr = 0; if(aPam.HasMark()) pDoc->DeleteAndJoin(aPam); - pDoc->Insert(aPam, aFmt, 10000); - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints( (pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + + pDoc->InsertPoolItem(aPam, aFmt, nInsertFlags); + + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FIELD); // was passiert mit dem Update der Felder ? (siehe fldmgr.cxx) @@ -1971,12 +1990,12 @@ void SwXTextField::setPropertyValue(const OUString& rPropertyName, const uno::An if (NULL != pDoc) { - SwPosition * pPos = GetPosition(); - - ASSERT(pPos, "no position"); - pDoc->PutValueToField( *pPos, rValue, pEntry->nWID); - - delete pPos; + const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld(); + if(!pTxtFld) + throw uno::RuntimeException(); + SwPosition aPosition( pTxtFld->GetTxtNode() ); + aPosition.nContent = *pTxtFld->GetStart(); + pDoc->PutValueToField( aPosition, rValue, pEntry->nWID); } // <- #111840# } @@ -2172,12 +2191,11 @@ uno::Any SwXTextField::getPropertyValue(const OUString& rPropertyName) xub_StrLen nHiddenStart; xub_StrLen nHiddenEnd; - SwPosition *pPos = pTxtFld->GetPosition(); - if (!pPos) - throw uno::RuntimeException(); + SwPosition aPosition( pTxtFld->GetTxtNode() ); + aPosition.nContent = *pTxtFld->GetStart(); - bHidden = SwScriptInfo::GetBoundsOfHiddenRange( rTxtNode, - pPos->nContent.GetIndex(), + bHidden = SwScriptInfo::GetBoundsOfHiddenRange( pTxtFld->GetTxtNode(), + *pTxtFld->GetStart(), nHiddenStart, nHiddenEnd ); } @@ -2477,23 +2495,6 @@ const SwField* SwXTextField::GetField() const return 0; } -// #111840# -SwPosition * SwXTextField::GetPosition() -{ - SwPosition * pResult = NULL; - const SwFmtFld * pFmtFld2 = GetFldFmt(); - - if (pFmtFld2) - { - const SwTxtFld * pTxtFld = pFmtFld2->GetTxtFld(); - - if (pTxtFld) - pResult = pTxtFld->GetPosition(); - } - - return pResult; -} - /****************************************************************** * ******************************************************************/ @@ -2933,6 +2934,22 @@ SwXFieldEnumeration::SwXFieldEnumeration(SwDoc* pDc) : } } } + // now handle meta-fields, which are not SwFields + const ::std::vector< uno::Reference<text::XTextField> > MetaFields( + pDc->GetMetaFieldManager().getMetaFields() ); + for (size_t i = 0; i < MetaFields.size(); ++i) + { + pItems[ nFillPos ] = MetaFields[i]; + nFillPos++; + + //FIXME UGLY + // enlarge sequence if necessary + if (aItems.getLength() == nFillPos) + { + aItems.realloc( 2 * aItems.getLength() ); + pItems = aItems.getArray(); + } + } // resize sequence to actual used size aItems.realloc( nFillPos ); } diff --git a/sw/source/core/unocore/unoflatpara.cxx b/sw/source/core/unocore/unoflatpara.cxx index bce475610d..68015384da 100644 --- a/sw/source/core/unocore/unoflatpara.cxx +++ b/sw/source/core/unocore/unoflatpara.cxx @@ -228,7 +228,7 @@ void SAL_CALL SwXFlatParagraph::changeText(::sal_Int32 nPos, ::sal_Int32 nLen, c mpTxtNode = pOldTxtNode; // setPropertyValue() modifies this. We restore the old state. IDocumentContentOperations* pIDCO = mpTxtNode->getIDocumentContentOperations(); - pIDCO->Replace( aPaM, aNewText, false ); + pIDCO->ReplaceRange( aPaM, aNewText, false ); mpTxtNode = 0; } diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 91b0993895..37f53ade45 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1082,18 +1082,48 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: } } } - else if( FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID && eType != FLYCNTTYPE_FRM ) + // --> OD 2009-07-13 #i73249# + // Attribute AlternativeText was never published. + // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances +// else if( FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID && eType != FLYCNTTYPE_FRM ) +// { +// const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); +// if(pIdx) +// { +// SwNodeIndex aIdx(*pIdx, 1); +// SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); +// OUString uTemp; +// aValue >>= uTemp; +// pNoTxt->SetAlternateText(uTemp); +// } +// } + // New attribute Title + else if( FN_UNO_TITLE == pEntry->nWID ) { - const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); - if(pIdx) - { - SwNodeIndex aIdx(*pIdx, 1); - SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); - OUString uTemp; - aValue >>= uTemp; - pNoTxt->SetAlternateText(uTemp); - } + SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); + ASSERT( pFmt, + "unexpected type of <pFmt> --> crash" ); + OUString uTemp; + aValue >>= uTemp; + const String sTitle(uTemp); + // assure that <SdrObject> instance exists. + GetOrCreateSdrObject( pFlyFmt ); + pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), sTitle ); } + // New attribute Description + else if( FN_UNO_DESCRIPTION == pEntry->nWID ) + { + SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); + ASSERT( pFmt, + "unexpected type of <pFmt> --> crash" ); + OUString uTemp; + aValue >>= uTemp; + const String sDescription(uTemp); + // assure that <SdrObject> instance exists. + GetOrCreateSdrObject( pFlyFmt ); + pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), sDescription ); + } + // <-- else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID) { SwFrmFmt *pFrmFmt = lcl_GetFrmFmt( aValue, pFmt->GetDoc() ); @@ -1232,7 +1262,7 @@ void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno:: bApply = true; } } - else + else { uno::Reference< graphic::XGraphic > xGraphic; aValue >>= xGraphic; @@ -1562,17 +1592,40 @@ uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) { aAny <<= OUString(SwStyleNameMapper::GetProgName(pFmt->DerivedFrom()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_FRMFMT ) ); } - else if(eType != FLYCNTTYPE_FRM && - FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID) + // --> OD 2009-07-13 #i73249# + // Attribute AlternativeText was never published. + // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances +// else if(eType != FLYCNTTYPE_FRM && +// FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID) +// { +// const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); +// if(pIdx) +// { +// SwNodeIndex aIdx(*pIdx, 1); +// SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); +// aAny <<= OUString(pNoTxt->GetAlternateText()); +// } +// } + else if( FN_UNO_TITLE == pEntry->nWID ) { - const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); - if(pIdx) - { - SwNodeIndex aIdx(*pIdx, 1); - SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); - aAny <<= OUString(pNoTxt->GetAlternateText()); - } + SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); + ASSERT( pFmt, + "unexpected type of <pFmt> --> crash" ); + // assure that <SdrObject> instance exists. + GetOrCreateSdrObject( pFlyFmt ); + aAny <<= OUString(pFlyFmt->GetObjTitle()); + } + // New attribute Description + else if( FN_UNO_DESCRIPTION == pEntry->nWID ) + { + SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); + ASSERT( pFmt, + "unexpected type of <pFmt> --> crash" ); + // assure that <SdrObject> instance exists. + GetOrCreateSdrObject( pFlyFmt ); + aAny <<= OUString(pFlyFmt->GetObjDescription()); } + // <-- else if(eType == FLYCNTTYPE_GRF && (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ACTUAL_SIZE)))) { @@ -1828,16 +1881,40 @@ void SwXFrame::setPropertyToDefault( const OUString& rPropertyName ) } } } - else if( eType != FLYCNTTYPE_FRM && FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID ) + // --> OD 2009-07-13 #i73249# + // Attribute AlternativeText was never published. + // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances +// else if( eType != FLYCNTTYPE_FRM && FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID ) +// { +// const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); +// if(pIdx) +// { +// SwNodeIndex aIdx(*pIdx, 1); +// SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); +// pNoTxt->SetAlternateText(aEmptyStr); +// } +// } + // New attribute Title + else if( FN_UNO_TITLE == pEntry->nWID ) { - const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); - if(pIdx) - { - SwNodeIndex aIdx(*pIdx, 1); - SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); - pNoTxt->SetAlternateText(aEmptyStr); - } + SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); + ASSERT( pFmt, + "unexpected type of <pFmt> --> crash" ); + // assure that <SdrObject> instance exists. + GetOrCreateSdrObject( pFlyFmt ); + pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), aEmptyStr ); } + // New attribute Description + else if( FN_UNO_DESCRIPTION == pEntry->nWID ) + { + SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); + ASSERT( pFmt, + "unexpected type of <pFmt> --> crash" ); + // assure that <SdrObject> instance exists. + GetOrCreateSdrObject( pFlyFmt ); + pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), aEmptyStr ); + } + // <-- else { SwDoc* pDoc = pFmt->GetDoc(); @@ -1951,7 +2028,7 @@ void SwXFrame::dispose(void) throw( uno::RuntimeException ) const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); const xub_StrLen nIdx = rPos.nContent.GetIndex(); - pTxtNode->Delete( RES_TXTATR_FLYCNT, nIdx, nIdx ); + pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); } else pFmt->GetDoc()->DelLayoutFmt(pFmt); @@ -2194,9 +2271,9 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan const ::uno::Any* pAutoContour; if(pProps->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR, 0, pAutoContour)) setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_AUTOMATIC_CONTOUR)), *pAutoContour); - const ::uno::Any* pAltText; - if(pProps->GetProperty(FN_UNO_ALTERNATIVE_TEXT, 0, pAltText)) - setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ALTERNATIVE_TEXT)), *pAltText); +// const ::uno::Any* pAltText; +// if(pProps->GetProperty(FN_UNO_ALTERNATIVE_TEXT, 0, pAltText)) +// setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ALTERNATIVE_TEXT)), *pAltText); } else { @@ -2305,6 +2382,20 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan const ::uno::Any* pReplacement; if( pProps->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC, 0, pReplacement) ) setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_GRAPHIC)), *pReplacement); + // --> OD 2009-07-13 #i73249# + // new attribute Title + const ::uno::Any* pTitle; + if ( pProps->GetProperty(FN_UNO_TITLE, 0, pTitle) ) + { + setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_TITLE)), *pTitle); + } + // new attribute Description + const ::uno::Any* pDescription; + if ( pProps->GetProperty(FN_UNO_DESCRIPTION, 0, pDescription) ) + { + setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_DESCRIPTION)), *pDescription); + } + // <-- } else throw lang::IllegalArgumentException(); diff --git a/sw/source/core/unocore/unoftn.cxx b/sw/source/core/unocore/unoftn.cxx index 11b004dd36..d7a974bfb1 100644 --- a/sw/source/core/unocore/unoftn.cxx +++ b/sw/source/core/unocore/unoftn.cxx @@ -254,11 +254,18 @@ void SwXFootnote::attachToRange(const uno::Reference< text::XTextRange > & xText SwFmtFtn aFootNote(m_bIsEndnote); if(m_sLabel.Len()) aFootNote.SetNumStr(m_sLabel); - SfxItemSet aSet(pNewDoc->GetAttrPool(), RES_TXTATR_FTN, RES_TXTATR_FTN, 0L); - aSet.Put(aFootNote); - SwXTextCursor::SetCrsrAttr(aPam, aSet, 0); - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints( (pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? nsSetAttrMode::SETATTR_FORCEHINTEXPAND + : nsSetAttrMode::SETATTR_DEFAULT; + + pNewDoc->InsertPoolItem(aPam, aFootNote, nInsertFlags); + + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_FTN ); if(pTxtAttr) diff --git a/sw/source/core/unocore/unoidx.cxx b/sw/source/core/unocore/unoidx.cxx index e2d0612eaa..41643101c1 100644 --- a/sw/source/core/unocore/unoidx.cxx +++ b/sw/source/core/unocore/unoidx.cxx @@ -1369,7 +1369,7 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: aPam.GetPoint()->nContent++; //die alte Marke loeschen - m_pDoc->Delete(m_pTOXMark); + m_pDoc->DeleteTOXMark(m_pTOXMark); m_pTOXMark = 0; SwTxtAttr* pTxtAttr = 0; @@ -1379,13 +1379,14 @@ void SwXDocumentIndexMark::setMarkEntry(const OUString& rIndexEntry) throw( uno: if( bInsAtPos ) { SwPaM aTmp( *pStt ); - m_pDoc->Insert( aTmp, aMark, 0 ); - pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( + m_pDoc->InsertPoolItem( aTmp, aMark, 0 ); + pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt( pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK); } else if( *pEnd != *pStt ) { - m_pDoc->Insert( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND ); + m_pDoc->InsertPoolItem( aPam, aMark, + nsSetAttrMode::SETATTR_DONTEXPAND ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK); } @@ -1501,7 +1502,17 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange // deshalb hier ein Leerzeichen - ob das die ideale Loesung ist? if(!bMark && !aMark.GetAlternativeText().Len()) aMark.SetAlternativeText( String(' ') ); - pDoc->Insert(aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND); + + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints( (!bMark && pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND; + + pDoc->InsertPoolItem(aPam, aMark, nInsertFlags); if( bMark && *aPam.GetPoint() > *aPam.GetMark()) aPam.Exchange(); @@ -1510,8 +1521,10 @@ void SwXDocumentIndexMark::attachToRange(const uno::Reference< text::XTextRange pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( aPam.GetPoint()->nContent, RES_TXTATR_TOXMARK ); else - pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttr( + { + pTxtAttr = aPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( aPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); + } if(pTxtAttr) { @@ -1571,7 +1584,7 @@ void SwXDocumentIndexMark::dispose(void) throw( uno::RuntimeException ) SwTOXType* pType = ((SwXDocumentIndexMark*)this)->GetTOXType(); if(pType && m_pTOXMark) { - m_pDoc->Delete(m_pTOXMark); + m_pDoc->DeleteTOXMark(m_pTOXMark); } else throw uno::RuntimeException(); @@ -1681,7 +1694,7 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, aPam.GetPoint()->nContent++; //delete the old mark - pLocalDoc->Delete(m_pTOXMark); + pLocalDoc->DeleteTOXMark(m_pTOXMark); m_pTOXMark = 0; sal_Bool bInsAtPos = aMark.IsAlternativeText(); @@ -1692,13 +1705,14 @@ void SwXDocumentIndexMark::setPropertyValue(const OUString& rPropertyName, if( bInsAtPos ) { SwPaM aTmp( *pStt ); - pLocalDoc->Insert( aTmp, aMark, 0 ); - pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( + pLocalDoc->InsertPoolItem( aTmp, aMark, 0 ); + pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttrForCharAt( pStt->nContent.GetIndex()-1, RES_TXTATR_TOXMARK ); } else if( *pEnd != *pStt ) { - pLocalDoc->Insert( aPam, aMark, nsSetAttrMode::SETATTR_DONTEXPAND ); + pLocalDoc->InsertPoolItem( aPam, aMark, + nsSetAttrMode::SETATTR_DONTEXPAND ); pTxtAttr = pStt->nNode.GetNode().GetTxtNode()->GetTxtAttr( pStt->nContent, RES_TXTATR_TOXMARK ); } diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx index 7088f7e5b2..4d535f1262 100644 --- a/sw/source/core/unocore/unomap.cxx +++ b/sw/source/core/unocore/unomap.cxx @@ -164,7 +164,7 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider() { SW_PROP_NMID(UNO_NAME_PARA_IS_NUMBERING_RESTART), FN_NUMBER_NEWSTART, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID, 0 }, \ { SW_PROP_NMID(UNO_NAME_PARA_CONTINUEING_PREVIOUS_SUB_TREE), FN_UNO_PARA_CONT_PREV_SUBTREE, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::READONLY, 0 }, \ { SW_PROP_NMID(UNO_NAME_PARA_LIST_LABEL_STRING), FN_UNO_PARA_NUM_STRING, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::READONLY, 0 }, \ - { SW_PROP_NMID(UNO_NAME_OUTLINE_LEVEL), RES_PARATR_OUTLINELEVEL, CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, 0}, //#outline level, zhaojianwei + { SW_PROP_NMID(UNO_NAME_OUTLINE_LEVEL), RES_PARATR_OUTLINELEVEL, CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, 0}, //#outline level, zhaojianwei #define COMMON_HYPERLINK_PROPERTIES \ { SW_PROP_NMID(UNO_NAME_HYPER_LINK_U_R_L), RES_TXTATR_INETFMT, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::MAYBEVOID ,MID_URL_URL}, \ @@ -309,6 +309,7 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider() // OD 18.09.2003 #i18732# - add property // OD 2004-05-05 #i28701# - add property 'WrapInfluenceOnObjPos' +// OD 2009-07-13 #i73249# - add properties 'Title' and 'Description' #define COMMON_FRAME_PROPERTIES \ { SW_PROP_NMID(UNO_NAME_ANCHOR_PAGE_NO), RES_ANCHOR, CPPU_E2T(CPPUTYPE_INT16), PROPERTY_NONE, MID_ANCHOR_PAGENUM }, \ { SW_PROP_NMID(UNO_NAME_ANCHOR_TYPE), RES_ANCHOR, CPPU_E2T(CPPUTYPE_TXTCNTANCHOR), PROPERTY_NONE, MID_ANCHOR_ANCHORTYPE}, \ @@ -369,6 +370,8 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider() { SW_PROP_NMID(UNO_NAME_Z_ORDER), FN_UNO_Z_ORDER, CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, 0}, \ { SW_PROP_NMID(UNO_NAME_IS_FOLLOWING_TEXT_FLOW), RES_FOLLOW_TEXT_FLOW, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0}, \ { SW_PROP_NMID(UNO_NAME_WRAP_INFLUENCE_ON_POSITION), RES_WRAP_INFLUENCE_ON_OBJPOS, CPPU_E2T(CPPUTYPE_INT8), PROPERTY_NONE, MID_WRAP_INFLUENCE}, \ + { SW_PROP_NMID(UNO_NAME_TITLE), FN_UNO_TITLE, CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE, 0}, \ + { SW_PROP_NMID(UNO_NAME_DESCRIPTION), FN_UNO_DESCRIPTION, CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE, 0}, \ { SW_PROP_NMID(UNO_NAME_LAYOUT_SIZE), WID_LAYOUT_SIZE, CPPU_E2T(CPPUTYPE_AWTSIZE), PropertyAttribute::MAYBEVOID | PropertyAttribute::READONLY, 0 }, @@ -487,7 +490,7 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider() { SW_PROP_NMID(UNO_NAME_WRITING_MODE), RES_FRAMEDIR, CPPU_E2T(CPPUTYPE_INT16), PROPERTY_NONE, 0 },\ { SW_PROP_NMID(UNO_NAME_PARA_IS_CONNECT_BORDER), RES_PARATR_CONNECT_BORDER, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID, 0},\ { SW_PROP_NMID(UNO_NAME_SNAP_TO_GRID), RES_PARATR_SNAPTOGRID, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID, 0 }, \ - { SW_PROP_NMID(UNO_NAME_OUTLINE_LEVEL), RES_PARATR_OUTLINELEVEL,CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, 0}, + { SW_PROP_NMID(UNO_NAME_OUTLINE_LEVEL), RES_PARATR_OUTLINELEVEL,CPPU_E2T(CPPUTYPE_INT16), PropertyAttribute::MAYBEVOID, 0}, #define COMMON_FLDTYP_PROPERTIES \ @@ -1123,7 +1126,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s { SW_PROP_NMID(UNO_NAME_GRAPHIC_FILTER), FN_UNO_GRAPHIC_FILTER, CPPU_E2T(CPPUTYPE_OUSTRING), 0, 0 }, { SW_PROP_NMID(UNO_NAME_GRAPHIC), FN_UNO_GRAPHIC, CPPU_E2T(CPPUTYPE_REFXGRAPHIC), 0, 0 }, { SW_PROP_NMID(UNO_NAME_ACTUAL_SIZE), FN_UNO_ACTUAL_SIZE, CPPU_E2T(CPPUTYPE_AWTSIZE), PropertyAttribute::READONLY, CONVERT_TWIPS}, - { SW_PROP_NMID(UNO_NAME_ALTERNATIVE_TEXT), FN_UNO_ALTERNATIVE_TEXT,CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE , 0 }, +// { SW_PROP_NMID(UNO_NAME_ALTERNATIVE_TEXT), FN_UNO_ALTERNATIVE_TEXT,CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE , 0 }, { SW_PROP_NMID(UNO_NAME_CONTOUR_POLY_POLYGON), FN_PARAM_COUNTOUR_PP, CPPU_E2T(CPPUTYPE_PNTSEQSEQ), PropertyAttribute::MAYBEVOID, 0 }, { SW_PROP_NMID(UNO_NAME_IS_PIXEL_CONTOUR), FN_UNO_IS_PIXEL_CONTOUR, CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0 }, { SW_PROP_NMID(UNO_NAME_IS_AUTOMATIC_CONTOUR), FN_UNO_IS_AUTOMATIC_CONTOUR , CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0 }, @@ -1158,7 +1161,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s { SW_PROP_NMID(UNO_NAME_GRAPHIC_URL), FN_UNO_REPLACEMENT_GRAPHIC_URL, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::MAYBEVOID, 0 }, { SW_PROP_NMID(UNO_NAME_GRAPHIC), FN_UNO_REPLACEMENT_GRAPHIC, CPPU_E2T(CPPUTYPE_REFXGRAPHIC), PropertyAttribute::MAYBEVOID, 0 }, { SW_PROP_NMID(UNO_NAME_COMPONENT),FN_UNO_COMPONENT, CPPU_E2T(CPPUTYPE_REFCOMPONENT), PropertyAttribute::READONLY, 0}, - { SW_PROP_NMID(UNO_NAME_ALTERNATIVE_TEXT), FN_UNO_ALTERNATIVE_TEXT,CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE , 0 }, +// { SW_PROP_NMID(UNO_NAME_ALTERNATIVE_TEXT), FN_UNO_ALTERNATIVE_TEXT,CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE , 0 }, {0,0,0,0,0,0} }; aMapEntriesArr[nPropertyId] = aEmbeddedPropertyMap_Impl; @@ -1646,6 +1649,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s {SW_PROP_NMID(UNO_NAME_IS_START), FN_UNO_IS_START, CPPU_E2T(CPPUTYPE_BOOLEAN), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0 }, //_REDLINE_PROPERTIES {SW_PROP_NMID(UNO_NAME_TEXT_PORTION_TYPE), FN_UNO_TEXT_PORTION_TYPE, CPPU_E2T(CPPUTYPE_OUSTRING), PropertyAttribute::READONLY, 0}, + {SW_PROP_NMID(UNO_NAME_META), FN_UNO_META, CPPU_E2T(CPPUTYPE_REFTEXTCNTNT), PropertyAttribute::MAYBEVOID|PropertyAttribute::READONLY, 0 }, {0,0,0,0,0,0} }; aMapEntriesArr[nPropertyId] = aTextPortionExtensionMap_Impl; @@ -2481,6 +2485,19 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s aMapEntriesArr[nPropertyId] = aChart2DataSequenceMap; } break; + case PROPERTY_MAP_METAFIELD: + { + static SfxItemPropertyMapEntry aMetaFieldMap[] = + { + { SW_PROP_NMID(UNO_NAME_NUMBER_FORMAT), 0, + CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, 0 }, + { SW_PROP_NMID(UNO_NAME_IS_FIXED_LANGUAGE), 0, + CPPU_E2T(CPPUTYPE_BOOLEAN), PROPERTY_NONE, 0 }, + {0,0,0,0,0,0} + }; + aMapEntriesArr[nPropertyId] = aMetaFieldMap; + } + break; default: DBG_ERROR( "unexpected property map ID" ); @@ -2513,583 +2530,589 @@ const SfxItemPropertySet* SwUnoPropertyMapProvider::GetPropertySet( sal_uInt16 switch( nPropertyId ) { case PROPERTY_MAP_TEXT_CURSOR: - { + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_CURSOR(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_CURSOR; } break; - case PROPERTY_MAP_CHAR_STYLE: - { + case PROPERTY_MAP_CHAR_STYLE: + { static SfxItemPropertySet aPROPERTY_MAP_CHAR_STYLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_CHAR_STYLE; } break; - case PROPERTY_MAP_PARA_STYLE: - { + case PROPERTY_MAP_PARA_STYLE: + { static SfxItemPropertySet aPROPERTY_MAP_PARA_STYLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_PARA_STYLE; } break; - case PROPERTY_MAP_FRAME_STYLE: - { + case PROPERTY_MAP_FRAME_STYLE: + { static SfxItemPropertySet aPROPERTY_MAP_FRAME_STYLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FRAME_STYLE; } break; case PROPERTY_MAP_PAGE_STYLE: - { + { static SfxItemPropertySet aPROPERTY_MAP_PAGE_STYLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_PAGE_STYLE; } break; case PROPERTY_MAP_NUM_STYLE: - { + { static SfxItemPropertySet aPROPERTY_MAP_NUM_STYLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_NUM_STYLE; } break; case PROPERTY_MAP_SECTION: - { + { static SfxItemPropertySet aPROPERTY_MAP_SECTION(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_SECTION; } break; - case PROPERTY_MAP_TEXT_TABLE: - { + case PROPERTY_MAP_TEXT_TABLE: + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_TABLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_TABLE; } break; - case PROPERTY_MAP_TABLE_CELL: - { + case PROPERTY_MAP_TABLE_CELL: + { static SfxItemPropertySet aPROPERTY_MAP_TABLE_CELL(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TABLE_CELL; } break; - case PROPERTY_MAP_TABLE_RANGE: - { + case PROPERTY_MAP_TABLE_RANGE: + { static SfxItemPropertySet aPROPERTY_MAP_TABLE_RANGE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TABLE_RANGE; } break; - case PROPERTY_MAP_TEXT_SEARCH: - { + case PROPERTY_MAP_TEXT_SEARCH: + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_SEARCH(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_SEARCH; } break; - case PROPERTY_MAP_TEXT_FRAME: - { + case PROPERTY_MAP_TEXT_FRAME: + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_FRAME(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_FRAME; } break; - case PROPERTY_MAP_TEXT_GRAPHIC: - { + case PROPERTY_MAP_TEXT_GRAPHIC: + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_GRAPHIC(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_GRAPHIC; } break; - case PROPERTY_MAP_TEXT_SHAPE: - { + case PROPERTY_MAP_TEXT_SHAPE: + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_SHAPE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_SHAPE; } break; - case PROPERTY_MAP_INDEX_USER: - { + case PROPERTY_MAP_INDEX_USER: + { static SfxItemPropertySet aPROPERTY_MAP_INDEX_USER(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_INDEX_USER; } break; - case PROPERTY_MAP_INDEX_CNTNT: - { + case PROPERTY_MAP_INDEX_CNTNT: + { static SfxItemPropertySet aPROPERTY_MAP_INDEX_CNTNT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_INDEX_CNTNT; } break; case PROPERTY_MAP_INDEX_IDX: - { + { static SfxItemPropertySet aPROPERTY_MAP_INDEX_IDX(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_INDEX_IDX; } break; case PROPERTY_MAP_USER_MARK: - { + { static SfxItemPropertySet aPROPERTY_MAP_USER_MARK(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_USER_MARK; } break; - case PROPERTY_MAP_CNTIDX_MARK: - { + case PROPERTY_MAP_CNTIDX_MARK: + { static SfxItemPropertySet aPROPERTY_MAP_CNTIDX_MARK(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_CNTIDX_MARK; } break; - case PROPERTY_MAP_INDEX_MARK: - { + case PROPERTY_MAP_INDEX_MARK: + { static SfxItemPropertySet aPROPERTY_MAP_INDEX_MARK(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_INDEX_MARK; } break; case PROPERTY_MAP_TEXT_TABLE_ROW: - { + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_TABLE_ROW(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_TABLE_ROW; } break; - case PROPERTY_MAP_TEXT_SHAPE_DESCRIPTOR: - { + case PROPERTY_MAP_TEXT_SHAPE_DESCRIPTOR: + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_SHAPE_DESCRIPTOR(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_SHAPE_DESCRIPTOR; } break; - case PROPERTY_MAP_TEXT_TABLE_CURSOR: - { + case PROPERTY_MAP_TEXT_TABLE_CURSOR: + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_TABLE_CURSOR(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_TABLE_CURSOR; } break; - case PROPERTY_MAP_BOOKMARK: - { + case PROPERTY_MAP_BOOKMARK: + { static SfxItemPropertySet aPROPERTY_MAP_BOOKMARK(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_BOOKMARK; } break; - case PROPERTY_MAP_PARAGRAPH_EXTENSIONS: - { + case PROPERTY_MAP_PARAGRAPH_EXTENSIONS: + { static SfxItemPropertySet aPROPERTY_MAP_PARAGRAPH_EXTENSIONS(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_PARAGRAPH_EXTENSIONS; } break; - case PROPERTY_MAP_INDEX_ILLUSTRATIONS: - { + case PROPERTY_MAP_INDEX_ILLUSTRATIONS: + { static SfxItemPropertySet aPROPERTY_MAP_INDEX_ILLUSTRATIONS(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_INDEX_ILLUSTRATIONS; } break; - case PROPERTY_MAP_INDEX_OBJECTS: - { + case PROPERTY_MAP_INDEX_OBJECTS: + { static SfxItemPropertySet aPROPERTY_MAP_INDEX_OBJECTS(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_INDEX_OBJECTS; } break; case PROPERTY_MAP_INDEX_TABLES: - { + { static SfxItemPropertySet aPROPERTY_MAP_INDEX_TABLES(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_INDEX_TABLES; } break; case PROPERTY_MAP_BIBLIOGRAPHY : - { + { static SfxItemPropertySet aPROPERTY_MAP_BIBLIOGRAPHY(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_BIBLIOGRAPHY; } break; case PROPERTY_MAP_TEXT_DOCUMENT: - { + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_DOCUMENT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_DOCUMENT; } break; case PROPERTY_MAP_LINK_TARGET : - { + { static SfxItemPropertySet aPROPERTY_MAP_LINK_TARGET(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_LINK_TARGET; } break; case PROPERTY_MAP_AUTO_TEXT_GROUP : - { + { static SfxItemPropertySet aPROPERTY_MAP_AUTO_TEXT_GROUP(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_AUTO_TEXT_GROUP; } break; case PROPERTY_MAP_TEXTPORTION_EXTENSIONS : - { + { static SfxItemPropertySet aPROPERTY_MAP_TEXTPORTION_EXTENSIONS(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXTPORTION_EXTENSIONS; } break; case PROPERTY_MAP_FOOTNOTE : - { + { static SfxItemPropertySet aPROPERTY_MAP_FOOTNOTE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FOOTNOTE; } break; case PROPERTY_MAP_TEXT_COLUMS : - { + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_COLUMS(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_COLUMS; } break; case PROPERTY_MAP_PARAGRAPH : - { + { static SfxItemPropertySet aPROPERTY_MAP_PARAGRAPH(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_PARAGRAPH; } break; case PROPERTY_MAP_EMBEDDED_OBJECT : - { + { static SfxItemPropertySet aPROPERTY_MAP_EMBEDDED_OBJECT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_EMBEDDED_OBJECT; } break; case PROPERTY_MAP_REDLINE : - { + { static SfxItemPropertySet aPROPERTY_MAP_REDLINE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_REDLINE; } break; case PROPERTY_MAP_TEXT_DEFAULT : - { + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_DEFAULT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_DEFAULT; } break; - case PROPERTY_MAP_FLDTYP_DATETIME: - { + case PROPERTY_MAP_FLDTYP_DATETIME: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DATETIME(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DATETIME; } break; - case PROPERTY_MAP_FLDTYP_USER: - { + case PROPERTY_MAP_FLDTYP_USER: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_USER(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_USER; } break; - case PROPERTY_MAP_FLDTYP_SET_EXP: - { + case PROPERTY_MAP_FLDTYP_SET_EXP: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_SET_EXP(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_SET_EXP; } break; - case PROPERTY_MAP_FLDTYP_GET_EXP: - { + case PROPERTY_MAP_FLDTYP_GET_EXP: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_GET_EXP(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_GET_EXP; } break; - case PROPERTY_MAP_FLDTYP_FILE_NAME: - { + case PROPERTY_MAP_FLDTYP_FILE_NAME: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_FILE_NAME(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_FILE_NAME; } break; - case PROPERTY_MAP_FLDTYP_PAGE_NUM: - { + case PROPERTY_MAP_FLDTYP_PAGE_NUM: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_PAGE_NUM(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_PAGE_NUM; } break; - case PROPERTY_MAP_FLDTYP_AUTHOR: - { + case PROPERTY_MAP_FLDTYP_AUTHOR: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_AUTHOR(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_AUTHOR; } break; - case PROPERTY_MAP_FLDTYP_CHAPTER: - { + case PROPERTY_MAP_FLDTYP_CHAPTER: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_CHAPTER(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_CHAPTER; } break; - case PROPERTY_MAP_FLDTYP_GET_REFERENCE: - { + case PROPERTY_MAP_FLDTYP_GET_REFERENCE: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_GET_REFERENCE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_GET_REFERENCE; } break; case PROPERTY_MAP_FLDTYP_CONDITIONED_TEXT: - { + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_CONDITIONED_TEXT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_CONDITIONED_TEXT; } break; - case PROPERTY_MAP_FLDTYP_HIDDEN_TEXT: - { + case PROPERTY_MAP_FLDTYP_HIDDEN_TEXT: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_HIDDEN_TEXT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_HIDDEN_TEXT; } break; - case PROPERTY_MAP_FLDTYP_ANNOTATION : - { + case PROPERTY_MAP_FLDTYP_ANNOTATION : + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_ANNOTATION(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_ANNOTATION; } break; - case PROPERTY_MAP_FLDTYP_INPUT: - { + case PROPERTY_MAP_FLDTYP_INPUT: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_INPUT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_INPUT; } break; - case PROPERTY_MAP_FLDTYP_MACRO: - { + case PROPERTY_MAP_FLDTYP_MACRO: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_MACRO(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_MACRO; } break; - case PROPERTY_MAP_FLDTYP_DDE: - { + case PROPERTY_MAP_FLDTYP_DDE: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DDE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DDE; } break; - case PROPERTY_MAP_FLDTYP_HIDDEN_PARA: - { + case PROPERTY_MAP_FLDTYP_HIDDEN_PARA: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_HIDDEN_PARA(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_HIDDEN_PARA; } break; - case PROPERTY_MAP_FLDTYP_DOC_INFO : - { + case PROPERTY_MAP_FLDTYP_DOC_INFO : + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOC_INFO(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOC_INFO; } break; - case PROPERTY_MAP_FLDTYP_TEMPLATE_NAME: - { + case PROPERTY_MAP_FLDTYP_TEMPLATE_NAME: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_TEMPLATE_NAME(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_TEMPLATE_NAME; } break; - case PROPERTY_MAP_FLDTYP_USER_EXT : - { + case PROPERTY_MAP_FLDTYP_USER_EXT : + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_USER_EXT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_USER_EXT; } break; - case PROPERTY_MAP_FLDTYP_REF_PAGE_SET: - { + case PROPERTY_MAP_FLDTYP_REF_PAGE_SET: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_REF_PAGE_SET(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_REF_PAGE_SET; } break; - case PROPERTY_MAP_FLDTYP_REF_PAGE_GET: - { + case PROPERTY_MAP_FLDTYP_REF_PAGE_GET: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_REF_PAGE_GET(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_REF_PAGE_GET; } break; - case PROPERTY_MAP_FLDTYP_JUMP_EDIT: - { + case PROPERTY_MAP_FLDTYP_JUMP_EDIT: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_JUMP_EDIT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_JUMP_EDIT; } break; - case PROPERTY_MAP_FLDTYP_SCRIPT: - { + case PROPERTY_MAP_FLDTYP_SCRIPT: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_SCRIPT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_SCRIPT; } break; case PROPERTY_MAP_FLDTYP_DATABASE_NEXT_SET: - { + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DATABASE_NEXT_SET(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DATABASE_NEXT_SET; } break; case PROPERTY_MAP_FLDTYP_DATABASE_NUM_SET: - { + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DATABASE_NUM_SET(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DATABASE_NUM_SET; } break; case PROPERTY_MAP_FLDTYP_DATABASE_SET_NUM: - { + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DATABASE_SET_NUM(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DATABASE_SET_NUM; } break; case PROPERTY_MAP_FLDTYP_DATABASE: - { + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DATABASE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DATABASE; } break; case PROPERTY_MAP_FLDTYP_DATABASE_NAME: - { + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DATABASE_NAME(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DATABASE_NAME; } break; case PROPERTY_MAP_FLDTYP_DOCSTAT: - { + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOCSTAT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCSTAT; } break; case PROPERTY_MAP_FLDTYP_DOCINFO_AUTHOR: - { + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOCINFO_AUTHOR(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_AUTHOR; } break; - case PROPERTY_MAP_FLDTYP_DOCINFO_DATE_TIME: - { + case PROPERTY_MAP_FLDTYP_DOCINFO_DATE_TIME: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOCINFO_DATE_TIME(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_DATE_TIME; } break; - case PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_DATE_TIME: - { + case PROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_DATE_TIME: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_DATE_TIME(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_CHANGE_DATE_TIME; } break; - case PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_DATE_TIME: - { + case PROPERTY_MAP_FLDTYP_DOCINFO_CREATE_DATE_TIME: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOCINFO_CREATE_DATE_TIME(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_CREATE_DATE_TIME; } break; - case PROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME: - { + case PROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_EDIT_TIME; } break; - case PROPERTY_MAP_FLDTYP_DOCINFO_MISC : - { + case PROPERTY_MAP_FLDTYP_DOCINFO_MISC : + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOCINFO_MISC(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_MISC; } break; - case PROPERTY_MAP_FLDTYP_DOCINFO_REVISION: - { + case PROPERTY_MAP_FLDTYP_DOCINFO_REVISION: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOCINFO_REVISION(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_REVISION; } break; - case PROPERTY_MAP_FLDTYP_COMBINED_CHARACTERS: - { + case PROPERTY_MAP_FLDTYP_COMBINED_CHARACTERS: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_COMBINED_CHARACTERS(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_COMBINED_CHARACTERS; } break; - case PROPERTY_MAP_FLDTYP_DUMMY_0: - { + case PROPERTY_MAP_FLDTYP_DUMMY_0: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DUMMY_0(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DUMMY_0; } break; - case PROPERTY_MAP_FLDTYP_TABLE_FORMULA: - { + case PROPERTY_MAP_FLDTYP_TABLE_FORMULA: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_TABLE_FORMULA(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_TABLE_FORMULA; } break; - case PROPERTY_MAP_FLDMSTR_USER: - { + case PROPERTY_MAP_FLDMSTR_USER: + { static SfxItemPropertySet aPROPERTY_MAP_FLDMSTR_USER(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDMSTR_USER; } break; - case PROPERTY_MAP_FLDMSTR_DDE: - { + case PROPERTY_MAP_FLDMSTR_DDE: + { static SfxItemPropertySet aPROPERTY_MAP_FLDMSTR_DDE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDMSTR_DDE; } break; - case PROPERTY_MAP_FLDMSTR_SET_EXP: - { + case PROPERTY_MAP_FLDMSTR_SET_EXP: + { static SfxItemPropertySet aPROPERTY_MAP_FLDMSTR_SET_EXP(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDMSTR_SET_EXP; } break; - case PROPERTY_MAP_FLDMSTR_DATABASE: - { + case PROPERTY_MAP_FLDMSTR_DATABASE: + { static SfxItemPropertySet aPROPERTY_MAP_FLDMSTR_DATABASE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDMSTR_DATABASE; } break; - case PROPERTY_MAP_FLDMSTR_DUMMY0: - { + case PROPERTY_MAP_FLDMSTR_DUMMY0: + { static SfxItemPropertySet aPROPERTY_MAP_FLDMSTR_DUMMY0(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDMSTR_DUMMY0; } break; - case PROPERTY_MAP_FLDTYP_BIBLIOGRAPHY: - { + case PROPERTY_MAP_FLDTYP_BIBLIOGRAPHY: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_BIBLIOGRAPHY(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_BIBLIOGRAPHY; } break; - case PROPERTY_MAP_FLDMSTR_BIBLIOGRAPHY: - { + case PROPERTY_MAP_FLDMSTR_BIBLIOGRAPHY: + { static SfxItemPropertySet aPROPERTY_MAP_FLDMSTR_BIBLIOGRAPHY(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDMSTR_BIBLIOGRAPHY; } break; - case PROPERTY_MAP_TEXT: - { + case PROPERTY_MAP_TEXT: + { static SfxItemPropertySet aPROPERTY_MAP_TEXT(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT; } break; - case PROPERTY_MAP_REDLINE_PORTION: - { + case PROPERTY_MAP_REDLINE_PORTION: + { static SfxItemPropertySet aPROPERTY_MAP_REDLINE_PORTION(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_REDLINE_PORTION; } break; - case PROPERTY_MAP_MAILMERGE: - { + case PROPERTY_MAP_MAILMERGE: + { static SfxItemPropertySet aPROPERTY_MAP_MAILMERGE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_MAILMERGE; } break; - case PROPERTY_MAP_FLDTYP_DROPDOWN: - { + case PROPERTY_MAP_FLDTYP_DROPDOWN: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DROPDOWN(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DROPDOWN; } break; - case PROPERTY_MAP_CHART2_DATA_SEQUENCE: - { + case PROPERTY_MAP_CHART2_DATA_SEQUENCE: + { static SfxItemPropertySet aPROPERTY_MAP_CHART2_DATA_SEQUENCE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_CHART2_DATA_SEQUENCE; } break; - case PROPERTY_MAP_TEXT_VIEW: - { + case PROPERTY_MAP_TEXT_VIEW: + { static SfxItemPropertySet aPROPERTY_MAP_TEXT_VIEW(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_TEXT_VIEW; } break; - case PROPERTY_MAP_CONDITIONAL_PARA_STYLE: - { + case PROPERTY_MAP_CONDITIONAL_PARA_STYLE: + { static SfxItemPropertySet aPROPERTY_MAP_CONDITIONAL_PARA_STYLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_CONDITIONAL_PARA_STYLE; } break; - case PROPERTY_MAP_CHAR_AUTO_STYLE: - { + case PROPERTY_MAP_CHAR_AUTO_STYLE: + { static SfxItemPropertySet aPROPERTY_MAP_CHAR_AUTO_STYLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_CHAR_AUTO_STYLE; } break; - case PROPERTY_MAP_RUBY_AUTO_STYLE: - { + case PROPERTY_MAP_RUBY_AUTO_STYLE: + { static SfxItemPropertySet aPROPERTY_MAP_RUBY_AUTO_STYLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_RUBY_AUTO_STYLE; } break; - case PROPERTY_MAP_PARA_AUTO_STYLE: - { + case PROPERTY_MAP_PARA_AUTO_STYLE: + { static SfxItemPropertySet aPROPERTY_MAP_PARA_AUTO_STYLE(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_PARA_AUTO_STYLE; } break; - case PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM: - { + case PROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM: + { static SfxItemPropertySet aPROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM(pEntries); aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_FLDTYP_DOCINFO_CUSTOM; } break; - } - } + case PROPERTY_MAP_METAFIELD: + { + static SfxItemPropertySet aPROPERTY_MAP_METAFIELD(pEntries); + aPropertySetArr[nPropertyId] = &aPROPERTY_MAP_METAFIELD; + } + break; + } + } return aPropertySetArr[nPropertyId]; } diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index d03c6b67c8..cb327b1962 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -59,7 +59,6 @@ #include <swerror.h> #include <swtblfmt.hxx> #include <fmtruby.hxx> -#include <fmthbsh.hxx> #include <docsh.hxx> #include <docstyle.hxx> #include <charfmt.hxx> @@ -92,6 +91,7 @@ #include <unocoll.hxx> #include <unostyle.hxx> #include <unofield.hxx> +#include <unometa.hxx> #include <fmtanchr.hxx> #include <svx/flstitem.hxx> #include <svtools/ctrltool.hxx> @@ -118,11 +118,10 @@ #include <dcontact.hxx> #include <SwStyleNameMapper.hxx> #include <crsskip.hxx> -#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPPP_ #include <com/sun/star/beans/PropertyAttribute.hpp> -#endif #include <memory> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -378,9 +377,11 @@ void lcl_SetTxtFmtColl(const uno::Any& rAny, SwPaM& rPaM) SwTxtFmtColl *pLocal = pStyle->GetCollection(); UnoActionContext aAction(pDoc); pDoc->StartUndo( UNDO_START, NULL ); - FOREACHUNOPAM_START(&rPaM) - pDoc->SetTxtFmtColl(*PUNOPAM, pLocal); - FOREACHUNOPAM_END() + SwPaM *pTmpCrsr = &rPaM; + do { + pDoc->SetTxtFmtColl(*pTmpCrsr, pLocal); + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != &rPaM ); pDoc->EndUndo( UNDO_END, NULL ); } else @@ -653,7 +654,7 @@ return bRet; /* -----------------30.06.98 08:39------------------- * * --------------------------------------------------*/ -SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) +SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPaM, BOOL bConditional) { static const sal_uInt16 nMaxLookup = 1000; SwFmtColl *pFmt = 0; @@ -661,12 +662,13 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) // if ( GetCrsrCnt() > nMaxLookup ) // return 0; sal_Bool bError = sal_False; - FOREACHUNOPAM_START(&rPam) + SwPaM *pTmpCrsr = &rPaM; + do { - ULONG nSttNd = PUNOPAM->GetMark()->nNode.GetIndex(), - nEndNd = PUNOPAM->GetPoint()->nNode.GetIndex(); - xub_StrLen nSttCnt = PUNOPAM->GetMark()->nContent.GetIndex(), - nEndCnt = PUNOPAM->GetPoint()->nContent.GetIndex(); + ULONG nSttNd = pTmpCrsr->GetMark()->nNode.GetIndex(); + ULONG nEndNd = pTmpCrsr->GetPoint()->nNode.GetIndex(); + xub_StrLen nSttCnt = pTmpCrsr->GetMark()->nContent.GetIndex(); + xub_StrLen nEndCnt = pTmpCrsr->GetPoint()->nContent.GetIndex(); if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt )) { @@ -680,7 +682,7 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) break; } - const SwNodes& rNds = rPam.GetDoc()->GetNodes(); + const SwNodes& rNds = rPaM.GetDoc()->GetNodes(); for( ULONG n = nSttNd; n <= nEndNd; ++n ) { const SwTxtNode* pNd = rNds[ n ]->GetTxtNode(); @@ -699,7 +701,9 @@ SwFmtColl* SwXTextCursor::GetCurTxtFmtColl(SwPaM& rPam, BOOL bConditional) } if(bError) break; - FOREACHUNOPAM_END() + + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != &rPaM ); return bError ? 0 : pFmt; } @@ -851,7 +855,8 @@ SwXTextCursor::~SwXTextCursor() /*-- 09.12.98 14:19:18--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::DeleteAndInsert(const String& rText) +void SwXTextCursor::DeleteAndInsert(const String& rText, + const bool bForceExpandHints) { SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) @@ -870,10 +875,12 @@ void SwXTextCursor::DeleteAndInsert(const String& rText) } if(nTxtLen) { - if( !SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *_pStartCrsr, rText ) ) - { - DBG_ASSERT( sal_False, "Doc->Insert(Str) failed." ); - } + const bool bSuccess( + SwUnoCursorHelper::DocInsertStringSplitCR( + *pDoc, *_pStartCrsr, rText, bForceExpandHints ) ); + DBG_ASSERT( bSuccess, "Doc->Insert(Str) failed." ); + (void) bSuccess; + SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); _pStartCrsr->Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); } @@ -881,6 +888,82 @@ void SwXTextCursor::DeleteAndInsert(const String& rText) pDoc->EndUndo(UNDO_INSERT, NULL); } } + + +enum ForceIntoMetaMode { META_CHECK_BOTH, META_INIT_START, META_INIT_END }; + +sal_Bool lcl_ForceIntoMeta(SwPaM & rCursor, + uno::Reference<text::XText> const & xParentText, + const enum ForceIntoMetaMode eMode) +{ + sal_Bool bRet( sal_True ); // means not forced in META_CHECK_BOTH + SwXMeta const * const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) ); + ASSERT(pXMeta, "no parent?"); + if (!pXMeta) + throw uno::RuntimeException(); + SwTxtNode * pTxtNode; + xub_StrLen nStart; + xub_StrLen nEnd; + const bool bSuccess( pXMeta->SetContentRange(pTxtNode, nStart, nEnd) ); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + throw uno::RuntimeException(); + // force the cursor back into the meta if it has moved outside + SwPosition start(*pTxtNode, nStart); + SwPosition end(*pTxtNode, nEnd); + switch (eMode) + { + case META_INIT_START: + *rCursor.GetPoint() = start; + break; + case META_INIT_END: + *rCursor.GetPoint() = end; + break; + case META_CHECK_BOTH: + if (*rCursor.Start() < start) + { + *rCursor.Start() = start; + bRet = sal_False; + } + if (*rCursor.End() > end) + { + *rCursor.End() = end; + bRet = sal_False; + } + break; + } + return bRet; +} + +bool SwXTextCursor::IsAtEndOfMeta() const +{ + if (CURSOR_META == eType) + { + SwUnoCrsr const * const pCursor( GetCrsr() ); + SwXMeta const*const pXMeta( dynamic_cast<SwXMeta*>(xParentText.get()) ); + ASSERT(pXMeta, "no meta?"); + if (pCursor && pXMeta) + { + SwTxtNode * pTxtNode; + xub_StrLen nStart; + xub_StrLen nEnd; + const bool bSuccess( + pXMeta->SetContentRange(pTxtNode, nStart, nEnd) ); + ASSERT(bSuccess, "no pam?"); + if (bSuccess) + { + const SwPosition end(*pTxtNode, nEnd); + if ( (*pCursor->GetPoint() == end) + || (*pCursor->GetMark() == end)) + { + return true; + } + } + } + } + return false; +} + /* -----------------------------10.03.00 18:02-------------------------------- ---------------------------------------------------------------------------*/ @@ -972,6 +1055,11 @@ sal_Bool SwXTextCursor::goLeft(sal_Int16 nCount, sal_Bool Expand) throw( uno::Ru { SwXTextCursor::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->Left( nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else { @@ -991,6 +1079,11 @@ sal_Bool SwXTextCursor::goRight(sal_Int16 nCount, sal_Bool Expand) throw( uno::R { SwXTextCursor::SelectPam(*pUnoCrsr, Expand); bRet = pUnoCrsr->Right(nCount, CRSR_SKIP_CHARS, FALSE, FALSE); + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else { @@ -1044,6 +1137,10 @@ void SwXTextCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException ) { pUnoCrsr->MoveSection( fnSectionCurr, fnSectionStart); } + else if (CURSOR_META == eType) + { + lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_START); + } } else { @@ -1061,7 +1158,9 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) { SwXTextCursor::SelectPam(*pUnoCrsr, Expand); if(eType == CURSOR_BODY) + { pUnoCrsr->Move( fnMoveForward, fnGoDoc ); + } else if(eType == CURSOR_FRAME || eType == CURSOR_TBLTEXT || eType == CURSOR_HEADER || @@ -1071,6 +1170,10 @@ void SwXTextCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException ) { pUnoCrsr->MoveSection( fnSectionCurr, fnSectionEnd); } + else if (CURSOR_META == eType) + { + lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_INIT_END); + } } else { @@ -1099,6 +1202,11 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); } + if (!pRange && !pCursor) + { + throw uno::RuntimeException(); + } + SwStartNodeType eSearchNodeType = SwNormalStartNode; switch(eType) { @@ -1141,6 +1249,27 @@ void SwXTextCursor::gotoRange(const uno::Reference< XTextRange > & xRange, sal_B throw uno::RuntimeException(); } + if (CURSOR_META == eType) + { + const SwPosition & rPoint( (pRange) + ? pRange->GetBookmark()->GetMarkPos() + : *pCursor->GetPaM()->GetPoint() ); + const SwPosition & rMark ( (pRange) + ? ((pRange->GetBookmark()->IsExpanded()) + ? pRange->GetBookmark()->GetOtherMarkPos() : rPoint) + : *pCursor->GetPaM()->GetMark() ); + SwPaM aPam(rPoint, rMark); + const bool bNotForced( + lcl_ForceIntoMeta(aPam, xParentText, META_CHECK_BOTH) ); + if (!bNotForced) + { + throw uno::RuntimeException( + C2U("gotoRange: parameter range not contained in nesting" + " text content for which this cursor was created"), + static_cast<text::XWordCursor*>(this)); + } + } + //jetzt muss die Selektion erweitert werden if(bExpand) { @@ -1277,7 +1406,9 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti //Absatzende? if(pUnoCrsr->GetCntntNode() && pPoint->nContent == pUnoCrsr->GetCntntNode()->Len()) + { pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } else { sal_Bool bTmp = pUnoCrsr->GoNextWordWT( i18n::WordType::DICTIONARY_WORD ); @@ -1289,6 +1420,10 @@ sal_Bool SwXTextCursor::gotoNextWord(sal_Bool Expand) throw( uno::RuntimeExcepti // return true if cursor has moved bRet = &pPoint->nNode.GetNode() != pOldNode || pPoint->nContent.GetIndex() != nOldIndex; + if (bRet && (CURSOR_META == eType)) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1316,7 +1451,9 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc SwXTextCursor::SelectPam(*pUnoCrsr, Expand); //Absatzanfang ? if(pPoint->nContent == 0) + { pUnoCrsr->Left(1, CRSR_SKIP_CHARS, FALSE, FALSE); + } else { pUnoCrsr->GoPrevWordWT( i18n::WordType::DICTIONARY_WORD ); @@ -1327,6 +1464,10 @@ sal_Bool SwXTextCursor::gotoPreviousWord(sal_Bool Expand) throw( uno::RuntimeExc // return true if cursor has moved bRet = &pPoint->nNode.GetNode() != pOldNode || pPoint->nContent.GetIndex() != nOldIndex; + if (bRet && (CURSOR_META == eType)) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1363,6 +1504,10 @@ sal_Bool SwXTextCursor::gotoEndOfWord(sal_Bool Expand) throw( uno::RuntimeExcept pPoint->nNode = rOldNode; pPoint->nContent = nOldIndex; } + else if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1399,6 +1544,10 @@ sal_Bool SwXTextCursor::gotoStartOfWord(sal_Bool Expand) throw( uno::RuntimeExce pPoint->nNode = rOldNode; pPoint->nContent = nOldIndex; } + else if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH); + } } else { @@ -1489,6 +1638,11 @@ sal_Bool SwXTextCursor::gotoNextSentence(sal_Bool Expand) throw( uno::RuntimeExc if (bWasEOS && !bNextWord) bRet = sal_False; } + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1516,6 +1670,11 @@ sal_Bool SwXTextCursor::gotoPreviousSentence(sal_Bool Expand) throw( uno::Runtim pUnoCrsr->GoSentence(SwCursor::PREV_SENT); } } + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1538,6 +1697,11 @@ sal_Bool SwXTextCursor::gotoStartOfSentence(sal_Bool Expand) throw( uno::Runtime bRet = SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr) || pUnoCrsr->GoSentence(SwCursor::START_SENT) || SwUnoCursorHelper::IsStartOfPara(*pUnoCrsr); + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1561,7 +1725,11 @@ sal_Bool SwXTextCursor::gotoEndOfSentence(sal_Bool Expand) throw( uno::RuntimeEx bRet = !bAlreadyParaEnd && (pUnoCrsr->GoSentence(SwCursor::END_SENT) || pUnoCrsr->MovePara(fnParaCurr, fnParaEnd)); - + if (CURSOR_META == eType) + { + bRet = lcl_ForceIntoMeta(*pUnoCrsr, xParentText, META_CHECK_BOTH) + && bRet; + } } else throw uno::RuntimeException(); @@ -1603,6 +1771,8 @@ sal_Bool SwXTextCursor::gotoStartOfParagraph(sal_Bool Expand) throw( uno::Runtim { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr ) { @@ -1627,6 +1797,8 @@ sal_Bool SwXTextCursor::gotoEndOfParagraph(sal_Bool Expand) throw( uno::RuntimeE { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { @@ -1651,6 +1823,8 @@ sal_Bool SwXTextCursor::gotoNextParagraph(sal_Bool Expand) throw( uno::RuntimeEx { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { @@ -1668,6 +1842,8 @@ sal_Bool SwXTextCursor::gotoPreviousParagraph(sal_Bool Expand) throw( uno::Runti { vos::OGuard aGuard(Application::GetSolarMutex()); sal_Bool bRet = sal_False; + if (CURSOR_META == eType) + return bRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); if(pUnoCrsr) { @@ -1697,7 +1873,19 @@ uno::Reference< XTextRange > SwXTextCursor::getStart(void) throw( uno::RuntimeE { SwPaM aPam(*pUnoCrsr->Start()); uno::Reference< XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); + if (CURSOR_META == eType) + { + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pCursor( + new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), + CURSOR_META, pUnoCrsr->GetDoc()) ); + pCursor->gotoStart(sal_False); + xRet = static_cast<text::XWordCursor*>(pCursor); + } + else + { + xRet = new SwXTextRange(aPam, xParent); + } } else throw uno::RuntimeException(); @@ -1715,7 +1903,19 @@ uno::Reference< XTextRange > SwXTextCursor::getEnd(void) throw( uno::RuntimeExc { SwPaM aPam(*pUnoCrsr->End()); uno::Reference< XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); + if (CURSOR_META == eType) + { + // return cursor to prevent modifying SwXTextRange for META + SwXTextCursor * const pCursor( + new SwXTextCursor(xParent, *pUnoCrsr->GetPoint(), + CURSOR_META, pUnoCrsr->GetDoc()) ); + pCursor->gotoEnd(sal_False); + xRet = static_cast<text::XWordCursor*>(pCursor); + } + else + { + xRet = new SwXTextRange(aPam, xParent); + } } else throw uno::RuntimeException(); @@ -1762,7 +1962,11 @@ void SwXTextCursor::setString(const OUString& aString) throw( uno::RuntimeExcept if(!pUnoCrsr) throw uno::RuntimeException(); - DeleteAndInsert(aString); + const bool bForceExpandHints( (CURSOR_META != eType) + ? false + : dynamic_cast<SwXMeta*>(xParentText.get())->CheckForOwnMemberMeta( + 0, GetPaM(), true) ); + DeleteAndInsert(aString, bForceExpandHints); } /* -----------------------------03.05.00 12:56-------------------------------- diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index e894d08e6b..36dd9cc160 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -57,7 +57,6 @@ #include <shellio.hxx> #include <swerror.h> #include <swtblfmt.hxx> -#include <fmthbsh.hxx> #include <docsh.hxx> #include <docstyle.hxx> #include <charfmt.hxx> @@ -124,6 +123,11 @@ // OD 2004-05-24 #i28701# #include <sortedobjs.hxx> +#include <algorithm> +#include <iterator> +#include <boost/bind.hpp> + + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -135,9 +139,20 @@ using namespace ::com::sun::star::drawing; using ::rtl::OUString; + +struct FrameDependSortListLess +{ + bool operator() (FrameDependSortListEntry const& r1, + FrameDependSortListEntry const& r2) + { + return (r1.nIndex < r2.nIndex) + || ((r1.nIndex == r2.nIndex) && (r1.nOrder < r2.nOrder)); + } +}; + // OD 2004-05-07 #i28701# - adjust 4th parameter void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, - SwDependArr& rFrameArr, + FrameDependSortList_t & rFrames, const bool _bAtCharAnchoredObjs ) { // _bAtCharAnchoredObjs: @@ -163,21 +178,21 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt(); if ( rFmt.GetAnchor().GetAnchorId() == nChkType ) { - //jetzt einen SwDepend anlegen und in das Array einfuegen + // create SwDepend and insert into array SwDepend* pNewDepend = new SwDepend( &rClnt, &rFmt ); + xub_StrLen idx = + rFmt.GetAnchor().GetCntntAnchor()->nContent.GetIndex(); + sal_uInt32 nOrder = rFmt.GetAnchor().GetOrder(); // OD 2004-05-07 #i28701# - sorting no longer needed, // because list <SwSortedObjs> is already sorted. - rFrameArr.C40_INSERT( SwDepend, pNewDepend, rFrameArr.Count() ); + FrameDependSortListEntry entry(idx, nOrder, pNewDepend); + rFrames.push_back(entry); } } } else { - // OD 2004-05-07 #i28701# - helper list to get <rFrameArr> sorted - std::vector< std::pair< xub_StrLen, sal_uInt32 > > aSortLst; - typedef std::vector< std::pair< xub_StrLen, sal_uInt32 > >::iterator tSortLstIter; - const SwSpzFrmFmts& rFmts = *pDoc->GetSpzFrmFmts(); USHORT nSize = rFmts.Count(); for ( USHORT i = 0; i < nSize; i++) @@ -194,32 +209,14 @@ void CollectFrameAtNode( SwClient& rClnt, const SwNodeIndex& rIdx, // OD 2004-05-07 #i28701# - determine insert position for // sorted <rFrameArr> - USHORT nInsPos = rFrameArr.Count(); - { - xub_StrLen nCntIndex = pAnchorPos->nContent.GetIndex(); - sal_uInt32 nAnchorOrder = rAnchor.GetOrder(); + xub_StrLen nIndex = pAnchorPos->nContent.GetIndex(); + sal_uInt32 nOrder = rAnchor.GetOrder(); - tSortLstIter aInsIter = aSortLst.end(); - for ( tSortLstIter aIter = aSortLst.begin(); - aIter != aSortLst.end(); - ++aIter ) - { - if ( (*aIter).first > nCntIndex || - ( (*aIter).first == nCntIndex && - (*aIter).second > nAnchorOrder ) ) - { - nInsPos = sal::static_int_cast< USHORT >(aIter - aSortLst.begin()); - aInsIter = aIter; - break; - } - } - std::pair< xub_StrLen, sal_uInt32 > aEntry( nCntIndex, - nAnchorOrder ); - aSortLst.insert( aInsIter, aEntry ); - } - rFrameArr.C40_INSERT( SwDepend, pNewDepend, nInsPos ); + FrameDependSortListEntry entry(nIndex, nOrder, pNewDepend); + rFrames.push_back(entry); } } + ::std::sort(rFrames.begin(), rFrames.end(), FrameDependSortListLess()); } } @@ -769,7 +766,9 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { if( _pStartCrsr->HasMark() && ( (CRSR_ATTR_MODE_TABLE & nAttrMode) || *_pStartCrsr->GetPoint() != *_pStartCrsr->GetMark() )) - pDoc->Insert(*_pStartCrsr, rSet, nFlags ); + { + pDoc->InsertItemSet(*_pStartCrsr, rSet, nFlags); + } } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != &rPam ); pDoc->EndUndo(UNDO_INSATTR, NULL); @@ -778,7 +777,7 @@ void SwXTextCursor::SetCrsrAttr(SwPaM& rPam, const SfxItemSet& rSet, USHORT nAtt { // if( !HasSelection() ) // UpdateAttr(); - pDoc->Insert( *pCrsr, rSet, nFlags ); + pDoc->InsertItemSet( *pCrsr, rSet, nFlags ); } //#outline level,add by zhaojianwei if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SFX_ITEM_AVAILABLE ) @@ -1214,9 +1213,16 @@ void SwXTextRange::_CreateNewBookmark(SwPaM& rPam) pMark->Add(this); } -void SwXTextRange::DeleteAndInsert(const String& rText) +void SwXTextRange::DeleteAndInsert( + const String& rText, const bool bForceExpandHints) throw(uno::RuntimeException) { + if (RANGE_IS_TABLE == eRangePosition) + { + // setString on table not allowed + throw uno::RuntimeException(); + } + ::sw::mark::IMark const * const pBkmk = GetBookmark(); if(pBkmk) { @@ -1231,11 +1237,14 @@ void SwXTextRange::DeleteAndInsert(const String& rText) UnoActionContext aAction(pDoc); pDoc->StartUndo(UNDO_INSERT, NULL); if(aNewCrsr.HasMark()) + { pDoc->DeleteAndJoin(aNewCrsr); + } if(rText.Len()) { - SwUnoCursorHelper::DocInsertStringSplitCR(*pDoc, aNewCrsr, rText); + SwUnoCursorHelper::DocInsertStringSplitCR( + *pDoc, aNewCrsr, rText, bForceExpandHints); SwXTextCursor::SelectPam(aNewCrsr, sal_True); aNewCrsr.Left(rText.Len(), CRSR_SKIP_CHARS, FALSE, FALSE); @@ -1335,13 +1344,7 @@ void SwXTextRange::setString(const OUString& aString) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(RANGE_IS_TABLE == eRangePosition) - { - //setString in Tabellen kann nicht erlaubt werden - throw uno::RuntimeException(); - } - else - DeleteAndInsert(aString); + DeleteAndInsert(aString, false); } void SwXTextRange::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) @@ -1438,12 +1441,10 @@ sal_Bool SwXTextRange::XTextRangeToSwPaM( SwUnoInternalPaM& rToFill, } else { - const SwPaM* pUnoCrsr = 0; - SwDoc* pDoc = pCursor ? pCursor->GetDoc() : NULL; - - if ( !pDoc ) - pDoc = pPortion ? pPortion->GetCrsr()->GetDoc() : NULL; - pUnoCrsr = pCursor ? pCursor->GetPaM() : pPortion ? pPortion->GetCrsr() : 0; + SwDoc* const pDoc = (pCursor) ? pCursor->GetDoc() + : ((pPortion) ? pPortion->GetCursor()->GetDoc() : 0); + const SwPaM* const pUnoCrsr = (pCursor) ? pCursor->GetPaM() + : ((pPortion) ? pPortion->GetCursor() : 0); if (pUnoCrsr && pDoc == rToFill.GetDoc()) { DBG_ASSERT((SwPaM*)pUnoCrsr->GetNext() == pUnoCrsr, "was machen wir mit Ringen?" ); @@ -1907,9 +1908,11 @@ sal_Int32 SwXTextRanges::getCount(void) throw( uno::RuntimeException ) SwUnoCrsr* pCrsr = GetCrsr(); if(pCrsr) { - FOREACHUNOPAM_START(pCrsr) + SwPaM *pTmpCrsr = pCrsr; + do { nRet++; - FOREACHUNOPAM_END() + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != pCrsr ); } else if(pRangeArr) nRet = pRangeArr->Count(); @@ -1958,15 +1961,20 @@ XTextRangeArr* SwXTextRanges::GetRangesArray() if(!pRangeArr && pCrsr) { pRangeArr = new XTextRangeArr(); - FOREACHUNOPAM_START(pCrsr) + SwPaM *pTmpCrsr = pCrsr; + do { uno::Reference< XTextRange >* pPtr = - new uno::Reference<XTextRange>( SwXTextRange::CreateTextRangeFromPosition(PUNOPAM->GetDoc(), - *PUNOPAM->GetPoint(), PUNOPAM->GetMark())); -// new uno::Reference<XTextRange>( SwXTextRange::createTextRangeFromPaM(*PUNOPAM, xParentText)); + new uno::Reference<XTextRange>( + SwXTextRange::CreateTextRangeFromPosition( + pTmpCrsr->GetDoc(), + *pTmpCrsr->GetPoint(), pTmpCrsr->GetMark())); +// new uno::Reference<XTextRange>( SwXTextRange::createTextRangeFromPaM(*pTmpCrsr, xParentText)); if(pPtr->is()) pRangeArr->Insert(pPtr, pRangeArr->Count()); - FOREACHUNOPAM_END() + + pTmpCrsr = static_cast<SwPaM*>(pTmpCrsr->GetNext()); + } while ( pTmpCrsr != pCrsr ); pCrsr->Remove( this ); } return pRangeArr; @@ -1994,37 +2002,107 @@ void SwXTextCursor::SetString(SwCursor& rCrsr, const OUString& rString) pDoc->DeleteAndJoin(rCrsr); if(nTxtLen) { - if( !SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, rCrsr, aText ) ) - { - DBG_ASSERT( sal_False, "DocInsertStringSplitCR" ); - } + const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR( + *pDoc, rCrsr, aText, false ) ); + DBG_ASSERT( bSuccess, "DocInsertStringSplitCR" ); + (void) bSuccess; SwXTextCursor::SelectPam(rCrsr, sal_True); rCrsr.Left(nTxtLen, CRSR_SKIP_CHARS, FALSE, FALSE); } pDoc->EndUndo(UNDO_INSERT, NULL); } + /****************************************************************** * SwXParaFrameEnumeration ******************************************************************/ -SV_IMPL_PTRARR(SwDependArr, SwDepend*); + +/* -----------------23.03.99 13:38------------------- + * + * --------------------------------------------------*/ +static sal_Bool +lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr, + uno::Reference<text::XTextContent> & o_rNextObject, + FrameDependList_t & i_rFrames) +{ + if (!i_rFrames.size()) + return sal_False; + + SwFrmFmt* pFormat = static_cast<SwFrmFmt*>(const_cast<SwModify*>( + i_rFrames.front()->GetRegisteredIn())); + i_rFrames.pop_front(); + // the format should be valid here, otherwise the client + // would have been removed in ::Modify + // check for a shape first + SwClientIter aIter(*pFormat); + SwDrawContact * const pContact = + static_cast<SwDrawContact*>( aIter.First(TYPE(SwDrawContact)) ); + if (pContact) + { + SdrObject * const pSdr = pContact->GetMaster(); + if (pSdr) + { + o_rNextObject.set(pSdr->getUnoShape(), uno::UNO_QUERY); + } + } + else + { + const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx(); + DBG_ASSERT(pIdx, "where is the index?"); + const SwNode* pNd = + i_rUnoCrsr.GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ]; + + const FlyCntType eType = (!pNd->IsNoTxtNode()) ? FLYCNTTYPE_FRM + : ( (pNd->IsGrfNode()) ? FLYCNTTYPE_GRF : FLYCNTTYPE_OLE ); + + const uno::Reference< container::XNamed > xFrame = + SwXFrames::GetObject(*pFormat, eType); + o_rNextObject.set(xFrame, uno::UNO_QUERY); + } + + return o_rNextObject.is(); +} + +/* -----------------------------03.04.00 10:15-------------------------------- + Description: Search for a FLYCNT text attribute at the cursor point + and fill the frame into the array + ---------------------------------------------------------------------------*/ +static void +lcl_FillFrame(SwXParaFrameEnumeration & rEnum, SwUnoCrsr& rUnoCrsr, + FrameDependList_t & rFrames) +{ + // search for objects at the cursor - anchored at/as char + const SwTxtAttr * pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( + rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT); + if (pTxtAttr) + { + const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt(); + SwFrmFmt * const pFrmFmt = rFlyCnt.GetFrmFmt(); + SwDepend * const pNewDepend = new SwDepend(&rEnum, pFrmFmt); + rFrames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); + } +} + /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXParaFrameEnumeration::getImplementationName(void) throw( RuntimeException ) +OUString SwXParaFrameEnumeration::getImplementationName() +throw( RuntimeException ) { return C2U("SwXParaFrameEnumeration"); } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException ) +sal_Bool SwXParaFrameEnumeration::supportsService(const OUString& rServiceName) +throw( RuntimeException ) { return C2U("com.sun.star.util.ContentEnumeration") == rServiceName; } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames(void) throw( RuntimeException ) +Sequence< OUString > SwXParaFrameEnumeration::getSupportedServiceNames() +throw( RuntimeException ) { Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); @@ -2049,14 +2127,17 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, if (PARAFRAME_PORTION_PARAGRAPH == nParaFrameMode) { - ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, - aFrameArr, FALSE ); + FrameDependSortList_t frames; + ::CollectFrameAtNode( *this, rPaM.GetPoint()->nNode, frames, false ); + ::std::transform(frames.begin(), frames.end(), + ::std::back_inserter(m_Frames), + ::boost::bind(&FrameDependSortListEntry::pFrameDepend, _1)); } else if (pFmt) { //jetzt einen SwDepend anlegen und in das Array einfuegen SwDepend* pNewDepend = new SwDepend(this, pFmt); - aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count()); + m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); } else if((PARAFRAME_PORTION_CHAR == nParaFrameMode) || (PARAFRAME_PORTION_TEXTRANGE == nParaFrameMode)) @@ -2072,7 +2153,7 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, SwFrmFmt* pFrmFmt = (SwFrmFmt*)&pPosFly->GetFmt(); //jetzt einen SwDepend anlegen und in das Array einfuegen SwDepend* pNewDepend = new SwDepend(this, pFrmFmt); - aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count()); + m_Frames.push_back( ::boost::shared_ptr<SwDepend>(pNewDepend) ); } //created from any text range if(pUnoCrsr->HasMark()) @@ -2081,13 +2162,13 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, pUnoCrsr->Exchange(); do { - FillFrame(*pUnoCrsr); + lcl_FillFrame(*this, *pUnoCrsr, m_Frames); pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); } while(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()); } } - FillFrame(*pUnoCrsr); + lcl_FillFrame(*this, *pUnoCrsr, m_Frames); } } /*-- 23.03.99 13:22:30--------------------------------------------------- @@ -2096,102 +2177,53 @@ SwXParaFrameEnumeration::SwXParaFrameEnumeration(const SwPaM& rPaM, SwXParaFrameEnumeration::~SwXParaFrameEnumeration() { vos::OGuard aGuard(Application::GetSolarMutex()); - aFrameArr.DeleteAndDestroy(0, aFrameArr.Count()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + + SwUnoCrsr* pUnoCrsr = GetCursor(); delete pUnoCrsr; } -/* -----------------------------03.04.00 10:15-------------------------------- - Description: Search for a FLYCNT text attribute at the cursor point - and fill the frame into the array - ---------------------------------------------------------------------------*/ -void SwXParaFrameEnumeration::FillFrame(SwUnoCrsr& rUnoCrsr) -{ - // search for objects at the cursor - anchored at/as char - SwTxtAttr* pTxtAttr = rUnoCrsr.GetNode()->GetTxtNode()->GetTxtAttr( - rUnoCrsr.GetPoint()->nContent, RES_TXTATR_FLYCNT); - if(pTxtAttr) - { - const SwFmtFlyCnt& rFlyCnt = pTxtAttr->GetFlyCnt(); - SwFrmFmt* pFrmFmt = rFlyCnt.GetFrmFmt(); - //jetzt einen SwDepend anlegen und in das Array einfuegen - SwDepend* pNewDepend = new SwDepend(this, pFrmFmt); - aFrameArr.C40_INSERT(SwDepend, pNewDepend, aFrameArr.Count()); - } -} + /*-- 23.03.99 13:22:32--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::hasMoreElements(void) throw( uno::RuntimeException ) +sal_Bool SwXParaFrameEnumeration::hasMoreElements() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetCrsr()) + + if (!GetCursor()) throw uno::RuntimeException(); - return xNextObject.is() ? sal_True : CreateNextObject(); + + return m_xNextObject.is() ? sal_True : + lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); } /*-- 23.03.99 13:22:33--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXParaFrameEnumeration::nextElement(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SwXParaFrameEnumeration::nextElement() + throw( container::NoSuchElementException, + lang::WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetCrsr()) + + if (!GetCursor()) throw uno::RuntimeException(); - if(!xNextObject.is() && aFrameArr.Count()) + + if (!m_xNextObject.is() && m_Frames.size()) { - CreateNextObject(); + lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames); } - if(!xNextObject.is()) + if(!m_xNextObject.is()) throw container::NoSuchElementException(); - uno::Any aRet(&xNextObject, ::getCppuType((uno::Reference<XTextContent>*)0)); - xNextObject = 0; + uno::Any aRet(&m_xNextObject, + ::getCppuType((uno::Reference<XTextContent>*)0)); + m_xNextObject = 0; return aRet; } -/* -----------------23.03.99 13:38------------------- - * - * --------------------------------------------------*/ -sal_Bool SwXParaFrameEnumeration::CreateNextObject() -{ - if(!aFrameArr.Count()) - return sal_False; - SwDepend* pDepend = aFrameArr.GetObject(0); - aFrameArr.Remove(0); - SwFrmFmt* pFormat = (SwFrmFmt*)pDepend->GetRegisteredIn(); - delete pDepend; - // the format should be valid her otherwise the client - // would have been removed in ::Modify - // check for a shape first - SwClientIter aIter(*pFormat); - SwDrawContact* pContact = (SwDrawContact*) - aIter.First(TYPE(SwDrawContact)); - if(pContact) - { - SdrObject* pSdr = pContact->GetMaster(); - if(pSdr) - { - xNextObject = uno::Reference< XTextContent >(pSdr->getUnoShape(), uno::UNO_QUERY); - } - } - else - { - const SwNodeIndex* pIdx = pFormat->GetCntnt().GetCntntIdx(); - DBG_ASSERT(pIdx, "where is the index?"); - const SwNode* pNd = GetCrsr()->GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ]; - FlyCntType eType; - if(!pNd->IsNoTxtNode()) - eType = FLYCNTTYPE_FRM; - else if(pNd->IsGrfNode()) - eType = FLYCNTTYPE_GRF; - else - eType = FLYCNTTYPE_OLE; - - uno::Reference< container::XNamed > xFrame = SwXFrames::GetObject(*pFormat, eType); - xNextObject = uno::Reference< XTextContent >(xFrame, uno::UNO_QUERY); - } - - return xNextObject.is(); -} +struct InvalidFrameDepend { + bool operator() (::boost::shared_ptr<SwDepend> const & rEntry) + { return !rEntry->GetRegisteredIn(); } +}; /*-- 23.03.99 13:22:37--------------------------------------------------- @@ -2215,21 +2247,16 @@ void SwXParaFrameEnumeration::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) } if(!GetRegisteredIn()) { - aFrameArr.DeleteAndDestroy(0, aFrameArr.Count()); - xNextObject = 0; + m_Frames.clear(); + m_xNextObject = 0; } else { - //dann war es vielleicht ein Frame am Absatz? - for(sal_uInt16 i = aFrameArr.Count(); i; i--) - { - SwDepend* pDepend = aFrameArr.GetObject(i-1); - if(!pDepend->GetRegisteredIn()) - { - delete pDepend; - aFrameArr.Remove(i-1); - } - } + // check if any frame went away... + FrameDependList_t::iterator iter = + ::std::remove_if(m_Frames.begin(), m_Frames.end(), + InvalidFrameDepend()); + m_Frames.erase(iter, m_Frames.end()); } } // ----------------------------------------------------------------------------- diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index 9408fda5cc..89032a3b20 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -35,6 +35,7 @@ #include <cmdid.h> #include <unomid.h> #include <unoobj.hxx> +#include <unoport.hxx> #include <unomap.hxx> #include <unocrsr.hxx> #include <unoprnms.hxx> diff --git a/sw/source/core/unocore/unoport.cxx b/sw/source/core/unocore/unoport.cxx index 0c8cbca39b..8671230214 100644 --- a/sw/source/core/unocore/unoport.cxx +++ b/sw/source/core/unocore/unoport.cxx @@ -41,20 +41,20 @@ #include <unoobj.hxx> #include <unomap.hxx> #include <unoprnms.hxx> -#ifndef _UNOMID_H #include <unomid.h> -#endif #include <txtatr.hxx> #include <txtfld.hxx> #include <ndtxt.hxx> #include <doc.hxx> #include <fmtflcnt.hxx> #include <fmtfld.hxx> + #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/SetPropertyTolerantFailed.hpp> #include <com/sun/star/beans/GetPropertyTolerantResult.hpp> #include <com/sun/star/beans/TolerantPropertySetResultType.hpp> + using namespace ::com::sun::star; using ::rtl::OUString; @@ -63,88 +63,95 @@ using ::rtl::OUString; * SwXTextPortion ******************************************************************/ -/*-- 11.12.98 09:56:52--------------------------------------------------- - - -----------------------------------------------------------------------*/ -SwFmtFld* SwXTextPortion::GetFldFmt(sal_Bool bInit) +static void init(SwXTextPortion & rPortion, const SwUnoCrsr* pPortionCursor) { - SwFmtFld* pRet = 0; - // initial wird es immer gesucht, danach nur noch, wenn es bereits existierte - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr && (bInit || pFmtFld)) + SwUnoCrsr* pUnoCursor = + pPortionCursor->GetDoc()->CreateUnoCrsr(*pPortionCursor->GetPoint()); + if (pPortionCursor->HasMark()) { - SwTxtNode *pNode = pUnoCrsr->GetPoint()->nNode.GetNode().GetTxtNode(); - SwTxtFld *pTxtFld = 0; - if( pNode ) - pTxtFld = pNode->GetTxtFld( pUnoCrsr->Start()->nContent ); - if(pTxtFld) - pFmtFld = pRet = (SwFmtFld*)&pTxtFld->GetFld(); + pUnoCursor->SetMark(); + *pUnoCursor->GetMark() = *pPortionCursor->GetMark(); } - return pRet; + pUnoCursor->Add(& rPortion); } + /*-- 11.12.98 09:56:55--------------------------------------------------- -----------------------------------------------------------------------*/ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > const& rParent, - SwTextPortionType eType) : - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet( - (PORTION_REDLINE_START == eType || - PORTION_REDLINE_END == eType) ? - PROPERTY_MAP_REDLINE_PORTION : PROPERTY_MAP_TEXTPORTION_EXTENSIONS)), - xParentText(rParent), - pRubyText(0), - pRubyStyle(0), - pRubyAdjust(0), - pRubyIsAbove(0), - pFmtFld(0), - aFrameDepend(this, 0), - pFrameFmt(0), - ePortionType(eType), - nControlChar(0), - bIsCollapsed(FALSE) + SwTextPortionType eType) + : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + , m_pPropSet(aSwMapProvider.GetPropertySet( + (PORTION_REDLINE_START == eType || + PORTION_REDLINE_END == eType) + ? PROPERTY_MAP_REDLINE_PORTION + : PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) + , m_xParentText(rParent) + , m_pRubyText(0) + , m_pRubyStyle(0) + , m_pRubyAdjust(0) + , m_pRubyIsAbove(0) + , m_FrameDepend(this, 0) + , m_pFrameFmt(0) + , m_ePortionType(eType) + , m_bIsCollapsed(false) { - SwUnoCrsr* pUnoCrsr = pPortionCrsr->GetDoc()->CreateUnoCrsr(*pPortionCrsr->GetPoint()); - if(pPortionCrsr->HasMark()) - { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pPortionCrsr->GetMark(); - } - pUnoCrsr->Add(this); - // erst nach ->Add() - if(ePortionType == PORTION_FIELD) - GetFldFmt(sal_True); -// else if(ePortionType == PORTION_FRAME) -// ...; + init(*this, pPortionCrsr); } + /* -----------------24.03.99 16:30------------------- * * --------------------------------------------------*/ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, uno::Reference< text::XText > const& rParent, - SwFrmFmt& rFmt ) : - aLstnrCntnr( (text::XTextRange*)this), - m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXTPORTION_EXTENSIONS)), - xParentText(rParent), - pRubyText(0), - pRubyStyle(0), - pRubyAdjust(0), - pRubyIsAbove(0), - pFmtFld(0), - aFrameDepend(this, &rFmt), - pFrameFmt(&rFmt), - ePortionType(PORTION_FRAME), - nControlChar(0), - bIsCollapsed(FALSE) + SwFrmFmt& rFmt ) + : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + , m_pPropSet(aSwMapProvider.GetPropertySet( + PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) + , m_xParentText(rParent) + , m_pRubyText(0) + , m_pRubyStyle(0) + , m_pRubyAdjust(0) + , m_pRubyIsAbove(0) + , m_FrameDepend(this, &rFmt) + , m_pFrameFmt(&rFmt) + , m_ePortionType(PORTION_FRAME) + , m_bIsCollapsed(false) { - SwUnoCrsr* pUnoCrsr = pPortionCrsr->GetDoc()->CreateUnoCrsr(*pPortionCrsr->GetPoint()); - if(pPortionCrsr->HasMark()) + init(*this, pPortionCrsr); +} + +/* -----------------------------19.02.01 10:52-------------------------------- + + ---------------------------------------------------------------------------*/ +SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, + SwTxtRuby const& rAttr, + uno::Reference< text::XText > const& xParent, + sal_Bool bIsEnd ) + : m_ListenerContainer( static_cast<text::XTextRange*>(this) ) + , m_pPropSet(aSwMapProvider.GetPropertySet( + PROPERTY_MAP_TEXTPORTION_EXTENSIONS)) + , m_xParentText(xParent) + , m_pRubyText ( bIsEnd ? 0 : new uno::Any ) + , m_pRubyStyle ( bIsEnd ? 0 : new uno::Any ) + , m_pRubyAdjust ( bIsEnd ? 0 : new uno::Any ) + , m_pRubyIsAbove( bIsEnd ? 0 : new uno::Any ) + , m_FrameDepend(this, 0) + , m_pFrameFmt(0) + , m_ePortionType( bIsEnd ? PORTION_RUBY_END : PORTION_RUBY_START ) + , m_bIsCollapsed(false) +{ + init(*this, pPortionCrsr); + + if (!bIsEnd) { - pUnoCrsr->SetMark(); - *pUnoCrsr->GetMark() = *pPortionCrsr->GetMark(); + const SfxPoolItem& rItem = rAttr.GetAttr(); + rItem.QueryValue(*m_pRubyText, MID_RUBY_TEXT); + rItem.QueryValue(*m_pRubyStyle, MID_RUBY_CHARSTYLE); + rItem.QueryValue(*m_pRubyAdjust, MID_RUBY_ADJUST); + rItem.QueryValue(*m_pRubyIsAbove, MID_RUBY_ABOVE); } - pUnoCrsr->Add(this); } /*-- 11.12.98 09:56:55--------------------------------------------------- @@ -153,77 +160,71 @@ SwXTextPortion::SwXTextPortion(const SwUnoCrsr* pPortionCrsr, SwXTextPortion::~SwXTextPortion() { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); delete pUnoCrsr; - delete pRubyText; - delete pRubyStyle; - delete pRubyAdjust; - delete pRubyIsAbove; } /*-- 11.12.98 09:56:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XText > SwXTextPortion::getText(void) throw( uno::RuntimeException ) +uno::Reference< text::XText > SwXTextPortion::getText() +throw( uno::RuntimeException ) { - return xParentText; + return m_xParentText; } /*-- 11.12.98 09:56:56--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextPortion::getStart(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SwXTextPortion::getStart() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - SwPaM aPam(*pUnoCrsr->Start()); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwPaM aPam(*pUnoCrsr->Start()); + uno::Reference< text::XText > xParent = getText(); + xRet = new SwXTextRange(aPam, xParent); return xRet; } /*-- 11.12.98 09:56:57--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextPortion::getEnd(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SwXTextPortion::getEnd() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > xRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - SwPaM aPam(*pUnoCrsr->End()); - uno::Reference< text::XText > xParent = getText(); - xRet = new SwXTextRange(aPam, xParent); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwPaM aPam(*pUnoCrsr->End()); + uno::Reference< text::XText > xParent = getText(); + xRet = new SwXTextRange(aPam, xParent); return xRet; } /*-- 11.12.98 09:56:57--------------------------------------------------- -----------------------------------------------------------------------*/ -OUString SwXTextPortion::getString(void) throw( uno::RuntimeException ) +OUString SwXTextPortion::getString() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - String aTxt; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + OUString aTxt; + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + + // TextPortions are always within a paragraph + SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode(); + if ( pTxtNd ) { - //TextPortions liegen immer innerhalb eines Absatzes - SwTxtNode* pTxtNd = pUnoCrsr->GetNode()->GetTxtNode(); - if( pTxtNd ) - { - xub_StrLen nStt = pUnoCrsr->Start()->nContent.GetIndex(); - aTxt = pTxtNd->GetExpandTxt( nStt, - pUnoCrsr->End()->nContent.GetIndex() - nStt ); - } + xub_StrLen nStt = pUnoCrsr->Start()->nContent.GetIndex(); + aTxt = pTxtNd->GetExpandTxt( nStt, + pUnoCrsr->End()->nContent.GetIndex() - nStt ); } - else - throw uno::RuntimeException(); return aTxt; } /*-- 11.12.98 09:56:57--------------------------------------------------- @@ -232,17 +233,19 @@ OUString SwXTextPortion::getString(void) throw( uno::RuntimeException ) void SwXTextPortion::setString(const OUString& aString) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - SwXTextCursor::SetString(*pUnoCrsr, aString); - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwXTextCursor::SetString(*pUnoCrsr, aString); } /*-- 11.12.98 09:56:57--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo(void) throw( uno::RuntimeException ) +uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo() +throw( uno::RuntimeException ) { + vos::OGuard aGuard(Application::GetSolarMutex()); //! PropertySetInfo for text portion extensions static uno::Reference< beans::XPropertySetInfo > xTxtPorExtRef = aSwMapProvider.GetPropertySet( @@ -252,8 +255,8 @@ uno::Reference< beans::XPropertySetInfo > SwXTextPortion::getPropertySetInfo(vo xRedlPorRef = aSwMapProvider.GetPropertySet( PROPERTY_MAP_REDLINE_PORTION)->getPropertySetInfo(); - return (PORTION_REDLINE_START == ePortionType || - PORTION_REDLINE_END == ePortionType) ? xRedlPorRef : xTxtPorExtRef; + return (PORTION_REDLINE_START == m_ePortionType || + PORTION_REDLINE_END == m_ePortionType) ? xRedlPorRef : xTxtPorExtRef; } /*-- 11.12.98 09:56:57--------------------------------------------------- @@ -264,13 +267,12 @@ void SwXTextPortion::setPropertyValue(const OUString& rPropertyName, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, rPropertyName, aValue); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwXTextCursor::SetPropertyValue(*pUnoCrsr, *m_pPropSet, + rPropertyName, aValue); } /*-- 04.11.03 09:56:58--------------------------------------------------- @@ -291,13 +293,12 @@ void SwXTextPortion::GetPropertyValue( case FN_UNO_TEXT_PORTION_TYPE: { const char* pRet; - switch (ePortionType) + switch (m_ePortionType) { case PORTION_TEXT: pRet = "Text";break; case PORTION_FIELD: pRet = "TextField";break; case PORTION_FRAME: pRet = "Frame";break; case PORTION_FOOTNOTE: pRet = "Footnote";break; - case PORTION_CONTROL_CHAR: pRet = "ControlCharacter";break; case PORTION_REFMARK_START: case PORTION_REFMARK_END: pRet = SW_PROP_NAME_STR(UNO_NAME_REFERENCE_MARK);break; case PORTION_TOXMARK_START: @@ -309,6 +310,7 @@ void SwXTextPortion::GetPropertyValue( case PORTION_RUBY_START: case PORTION_RUBY_END: pRet = "Ruby";break; case PORTION_SOFT_PAGEBREAK:pRet = "SoftPageBreak";break; + case PORTION_META: pRet = SW_PROP_NAME_STR(UNO_NAME_META); break; case PORTION_FIELD_START:pRet = "TextFieldStart";break; case PORTION_FIELD_END:pRet = "TextFieldEnd";break; case PORTION_FIELD_START_END:pRet = "TextFieldStartEnd";break; @@ -322,28 +324,29 @@ void SwXTextPortion::GetPropertyValue( rVal <<= sRet; } break; - case FN_UNO_CONTROL_CHARACTER: - { - if(PORTION_CONTROL_CHAR == ePortionType) - rVal <<= (sal_Int16) nControlChar; - } + case FN_UNO_CONTROL_CHARACTER: // obsolete! break; case FN_UNO_DOCUMENT_INDEX_MARK: - rVal <<= xTOXMark; + rVal <<= m_xTOXMark; break; case FN_UNO_REFERENCE_MARK: - rVal <<= xRefMark; + rVal <<= m_xRefMark; break; case FN_UNO_BOOKMARK: - rVal <<= xBookmark; + rVal <<= m_xBookmark; break; case FN_UNO_FOOTNOTE: - rVal <<= xFootnote; + rVal <<= m_xFootnote; + break; + case FN_UNO_TEXT_FIELD: + rVal <<= m_xTextField; + break; + case FN_UNO_META: + rVal <<= m_xMeta; break; case FN_UNO_IS_COLLAPSED: { - BOOL bPut = TRUE; - switch (ePortionType) + switch (m_ePortionType) { case PORTION_REFMARK_START: case PORTION_BOOKMARK_START : @@ -357,17 +360,17 @@ void SwXTextPortion::GetPropertyValue( case PORTION_RUBY_END: case PORTION_FIELD_START: case PORTION_FIELD_END: - rVal.setValue(&bIsCollapsed, ::getBooleanCppuType()); + rVal.setValue(&m_bIsCollapsed, ::getBooleanCppuType()); break; default: - bPut = FALSE; + break; } } break; case FN_UNO_IS_START: { BOOL bStart = TRUE, bPut = TRUE; - switch (ePortionType) + switch (m_ePortionType) { case PORTION_REFMARK_START: case PORTION_BOOKMARK_START: @@ -394,13 +397,13 @@ void SwXTextPortion::GetPropertyValue( break; case RES_TXTATR_CJK_RUBY: { - uno::Any* pToSet = 0; + const uno::Any* pToSet = 0; switch(rEntry.nMemberId) { - case MID_RUBY_TEXT : pToSet = pRubyText; break; - case MID_RUBY_ADJUST : pToSet = pRubyAdjust; break; - case MID_RUBY_CHARSTYLE:pToSet = pRubyStyle; break; - case MID_RUBY_ABOVE : pToSet = pRubyIsAbove; break; + case MID_RUBY_TEXT : pToSet = m_pRubyText.get(); break; + case MID_RUBY_ADJUST : pToSet = m_pRubyAdjust.get(); break; + case MID_RUBY_CHARSTYLE:pToSet = m_pRubyStyle.get(); break; + case MID_RUBY_ABOVE : pToSet = m_pRubyIsAbove.get();break; } if(pToSet) rVal = *pToSet; @@ -436,8 +439,10 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl( const OUString *pPropertyNames = rPropertyNames.getConstArray(); uno::Sequence< uno::Any > aValues(rPropertyNames.getLength()); uno::Any *pValues = aValues.getArray(); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + { SfxItemSet *pSet = 0; // get startting pount fo the look-up, either the provided one or else @@ -455,8 +460,6 @@ uno::Sequence< uno::Any > SAL_CALL SwXTextPortion::GetPropertyValues_Impl( } delete pSet; } - else - throw uno::RuntimeException(); return aValues; } /*-- 11.12.98 09:56:58--------------------------------------------------- @@ -480,8 +483,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + { const OUString* pPropertyNames = rPropertyNames.getConstArray(); const uno::Any* pValues = rValues.getConstArray(); @@ -494,11 +499,10 @@ void SAL_CALL SwXTextPortion::SetPropertyValues_Impl( if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) throw beans::PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + pPropertyNames[nProp], static_cast < cppu::OWeakObject * > ( this ) ); - SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet, pPropertyNames[nProp], pValues[nProp]); + SwXTextCursor::SetPropertyValue( *pUnoCrsr, *m_pPropSet, + pPropertyNames[nProp], pValues[nProp]); } } - else - throw uno::RuntimeException(); } void SwXTextPortion::setPropertyValues( @@ -564,7 +568,7 @@ uno::Sequence< beans::SetPropertyTolerantFailed > SAL_CALL SwXTextPortion::setPr if (rPropertyNames.getLength() != rValues.getLength()) throw lang::IllegalArgumentException(); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); + SwUnoCrsr* pUnoCrsr = this->GetCursor(); if (!pUnoCrsr) throw uno::RuntimeException(); @@ -664,7 +668,7 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion: { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); + SwUnoCrsr* pUnoCrsr = this->GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); @@ -701,6 +705,12 @@ uno::Sequence< beans::GetDirectPropertyTolerantResult > SAL_CALL SwXTextPortion: aResult.State = pPropertyStates[i]; aResult.Result = beans::TolerantPropertySetResultType::UNKNOWN_FAILURE; + //#i104499# ruby portion attributes need special handling: + if( pEntry->nWID == RES_TXTATR_CJK_RUBY && + m_ePortionType == PORTION_RUBY_START ) + { + aResult.State = beans::PropertyState_DIRECT_VALUE; + } if (!bDirectValuesOnly || beans::PropertyState_DIRECT_VALUE == aResult.State) { // get property value @@ -811,17 +821,20 @@ beans::PropertyState SwXTextPortion::getPropertyState(const OUString& rPropertyN { vos::OGuard aGuard(Application::GetSolarMutex()); beans::PropertyState eRet = beans::PropertyState_DEFAULT_VALUE; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) + throw uno::RuntimeException(); + + if (GetTextPortionType() == PORTION_RUBY_START && + !rPropertyName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") )) { - if(GetTextPortionType() == PORTION_RUBY_START && - !rPropertyName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("Ruby") )) - eRet = beans::PropertyState_DIRECT_VALUE; - else - eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, rPropertyName); + eRet = beans::PropertyState_DIRECT_VALUE; } else - throw uno::RuntimeException(); + { + eRet = SwXTextCursor::GetPropertyState(*pUnoCrsr, *m_pPropSet, + rPropertyName); + } return eRet; } /*-- 08.03.99 09:41:47--------------------------------------------------- @@ -832,10 +845,13 @@ uno::Sequence< beans::PropertyState > SwXTextPortion::getPropertyStates( throw( beans::UnknownPropertyException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); - uno::Sequence< beans::PropertyState > aRet = SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION); + + uno::Sequence< beans::PropertyState > aRet = + SwXTextCursor::GetPropertyStates(*pUnoCrsr, *m_pPropSet, + rPropertyNames, SW_PROPERTY_STATE_CALLER_SWX_TEXT_PORTION); if(GetTextPortionType() == PORTION_RUBY_START) { @@ -856,13 +872,11 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + SwXTextCursor::SetPropertyToDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); } /*-- 08.03.99 09:41:48--------------------------------------------------- @@ -870,33 +884,17 @@ void SwXTextPortion::setPropertyToDefault(const OUString& rPropertyName) uno::Any SwXTextPortion::getPropertyDefault(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) { + vos::OGuard aGuard(Application::GetSolarMutex()); uno::Any aRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, rPropertyName); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + aRet = SwXTextCursor::GetPropertyDefault(*pUnoCrsr, *m_pPropSet, + rPropertyName); return aRet; } -/*-- 11.12.98 09:56:59--------------------------------------------------- - -----------------------------------------------------------------------*/ -OUString SwXTextPortion::getPresentation(sal_Bool /*bShowCommand*/) throw( uno::RuntimeException ) -{ - vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - String sRet; - SwFmtFld* pFmt = 0; - if(pUnoCrsr && 0 != (pFmt = GetFldFmt())) - { - const SwField* pField = pFmt->GetFld(); - DBG_ERROR("bShowCommand auswerten!"); - sRet = pField->Expand(); - } - return sRet; -} /*-- 11.12.98 09:56:59--------------------------------------------------- -----------------------------------------------------------------------*/ @@ -911,31 +909,31 @@ void SwXTextPortion::attach(const uno::Reference< text::XTextRange > & /*xTextRa /*-- 11.12.98 09:57:00--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Reference< text::XTextRange > SwXTextPortion::getAnchor(void) throw( uno::RuntimeException ) +uno::Reference< text::XTextRange > SwXTextPortion::getAnchor() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Reference< text::XTextRange > aRet; - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - aRet = new SwXTextRange(*pUnoCrsr, xParentText); - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + aRet = new SwXTextRange(*pUnoCrsr, m_xParentText); return aRet; } /*-- 11.12.98 09:57:00--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextPortion::dispose(void) throw( uno::RuntimeException ) +void SwXTextPortion::dispose() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = ((SwXTextPortion*)this)->GetCrsr(); - if(pUnoCrsr) - { - setString(aEmptyStr); - pUnoCrsr->Remove(this); - } - else + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); + + setString(aEmptyStr); + pUnoCrsr->Remove(this); } /*-- 11.12.98 09:57:00--------------------------------------------------- @@ -945,7 +943,8 @@ void SwXTextPortion::addEventListener(const uno::Reference< lang::XEventListener vos::OGuard aGuard(Application::GetSolarMutex()); if(!GetRegisteredIn()) throw uno::RuntimeException(); - aLstnrCntnr.AddListener(aListener); + + m_ListenerContainer.AddListener(aListener); } /*-- 11.12.98 09:57:01--------------------------------------------------- @@ -953,7 +952,7 @@ void SwXTextPortion::addEventListener(const uno::Reference< lang::XEventListener void SwXTextPortion::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) + if (!GetRegisteredIn() || !m_ListenerContainer.RemoveListener(aListener)) throw uno::RuntimeException(); } /* -----------------24.03.99 13:30------------------- @@ -963,10 +962,13 @@ uno::Reference< container::XEnumeration > SwXTextPortion::createContentEnumerat throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); - uno::Reference< container::XEnumeration > xRet = new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_CHAR, pFrameFmt); + + uno::Reference< container::XEnumeration > xRet = + new SwXParaFrameEnumeration(*pUnoCrsr, PARAFRAME_PORTION_CHAR, + m_pFrameFmt); return xRet; } @@ -995,7 +997,8 @@ sal_Int64 SwXTextPortion::getSomething( const uno::Sequence< sal_Int8 >& rId ) /* -----------------24.03.99 13:30------------------- * * --------------------------------------------------*/ -uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames(void) throw( uno::RuntimeException ) +uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence< OUString > aRet(1); @@ -1006,7 +1009,8 @@ uno::Sequence< OUString > SwXTextPortion::getAvailableServiceNames(void) throw( /* -----------------25.03.99 10:30------------------- * * --------------------------------------------------*/ -OUString SwXTextPortion::getImplementationName(void) throw( uno::RuntimeException ) +OUString SwXTextPortion::getImplementationName() +throw( uno::RuntimeException ) { return C2U("SwXTextPortion"); } @@ -1016,7 +1020,7 @@ OUString SwXTextPortion::getImplementationName(void) throw( uno::RuntimeExceptio sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); @@ -1028,25 +1032,24 @@ sal_Bool SwXTextPortion::supportsService(const OUString& rServiceName) throw( un !rServiceName.compareToAscii("com.sun.star.style.ParagraphProperties") || !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") || !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex")) + { bRet = sal_True; - else if(COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextField")) - bRet = 0 != GetFldFmt(); + } return bRet; } /* --------------------------------------------------------------------------- ---------------------------------------------------------------------------*/ -uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void) - throw( uno::RuntimeException ) +uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(!pUnoCrsr) + SwUnoCrsr* pUnoCrsr = GetCursor(); + if (!pUnoCrsr) throw uno::RuntimeException(); - sal_Bool bField = 0 != GetFldFmt(); - sal_uInt16 nCount = bField ? 8 : 7; - uno::Sequence< OUString > aRet(nCount); + + uno::Sequence< OUString > aRet(7); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.TextPortion"); pArray[1] = C2U("com.sun.star.style.CharacterProperties"); @@ -1055,8 +1058,6 @@ uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void) pArray[4] = C2U("com.sun.star.style.ParagraphProperties"); pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian"); pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex"); - if(bField) - pArray[7] = C2U("com.sun.star.text.TextField"); return aRet; } /*-- 11.12.98 09:57:01--------------------------------------------------- @@ -1065,35 +1066,9 @@ uno::Sequence< OUString > SwXTextPortion::getSupportedServiceNames(void) void SwXTextPortion::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew) { ClientModify(this, pOld, pNew); - if(!aFrameDepend.GetRegisteredIn()) - pFrameFmt = 0; -} -/* -----------------------------19.02.01 10:52-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXRubyPortion::SwXRubyPortion(const SwUnoCrsr* pPortionCrsr, - SwTxtRuby& rAttr, - uno::Reference< text::XText > const& rParent, - sal_Bool bEnd ) : - SwXTextPortion(pPortionCrsr, rParent, bEnd ? PORTION_RUBY_END : PORTION_RUBY_START ) -{ - if(!bEnd) + if (!m_FrameDepend.GetRegisteredIn()) { - const SfxPoolItem& rItem = rAttr.GetAttr(); - pRubyText = new uno::Any; - pRubyStyle = new uno::Any; - pRubyAdjust = new uno::Any; - pRubyIsAbove = new uno::Any; - rItem.QueryValue(*pRubyText, MID_RUBY_TEXT); - rItem.QueryValue(*pRubyStyle, MID_RUBY_CHARSTYLE); - rItem.QueryValue(*pRubyAdjust, MID_RUBY_ADJUST); - rItem.QueryValue(*pRubyIsAbove, MID_RUBY_ABOVE); + m_pFrameFmt = 0; } } -/* -----------------------------19.02.01 10:52-------------------------------- - - ---------------------------------------------------------------------------*/ -SwXRubyPortion::~SwXRubyPortion() -{ -} diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 5aa9d224c4..327bfd7c68 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -32,30 +32,37 @@ #include "precompiled_sw.hxx" +#include <unoport.hxx> #include <IMark.hxx> // --> OD 2007-10-23 #i81002# #include <crossrefbookmark.hxx> // <-- #include <doc.hxx> #include <txatbase.hxx> +#include <txtatr.hxx> #include <ndhints.hxx> #include <ndtxt.hxx> #include <unocrsr.hxx> #include <docary.hxx> -#include <fmthbsh.hxx> #include <tox.hxx> #include <unoclbck.hxx> #include <unoobj.hxx> #include <unoredline.hxx> +#include <unofield.hxx> +#include <unometa.hxx> #include <fmtanchr.hxx> +#include <fmtrfmrk.hxx> #include <unoidx.hxx> #include <redline.hxx> #include <crsskip.hxx> #include <vos/mutex.hxx> #include <vcl/svapp.hxx> #include <set> + #include <boost/shared_ptr.hpp> #include <boost/bind.hpp> +#include <algorithm> +#include <stack> using namespace ::com::sun::star; @@ -64,6 +71,16 @@ using namespace ::com::sun::star::text; using ::rtl::OUString; using namespace ::std; +typedef ::std::pair< TextRangeList_t * const, SwTxtAttr const * const > PortionList_t; +typedef ::std::stack< PortionList_t > PortionStack_t; + +static void lcl_CreatePortions( + TextRangeList_t & i_rPortions, + uno::Reference< text::XText > const& i_xParentText, + SwUnoCrsr* pUnoCrsr, + FrameDependSortList_t & i_rFrames, + const sal_Int32 i_nStartPos, const sal_Int32 i_nEndPos ); + namespace { @@ -182,8 +199,9 @@ const uno::Sequence< sal_Int8 > & SwXTextPortionEnumeration::getUnoTunnelId() /* -----------------------------10.03.00 18:04-------------------------------- ---------------------------------------------------------------------------*/ -sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException) +sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( + const uno::Sequence< sal_Int8 >& rId ) +throw(uno::RuntimeException) { if( rId.getLength() == 16 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), @@ -196,167 +214,286 @@ sal_Int64 SAL_CALL SwXTextPortionEnumeration::getSomething( const uno::Sequence< /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -OUString SwXTextPortionEnumeration::getImplementationName(void) throw( RuntimeException ) +OUString SwXTextPortionEnumeration::getImplementationName() +throw( RuntimeException ) { return C2U("SwXTextPortionEnumeration"); } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -BOOL SwXTextPortionEnumeration::supportsService(const OUString& rServiceName) throw( RuntimeException ) +sal_Bool +SwXTextPortionEnumeration::supportsService(const OUString& rServiceName) +throw( RuntimeException ) { return C2U("com.sun.star.text.TextPortionEnumeration") == rServiceName; } /* -----------------------------06.04.00 16:39-------------------------------- ---------------------------------------------------------------------------*/ -Sequence< OUString > SwXTextPortionEnumeration::getSupportedServiceNames(void) throw( RuntimeException ) +Sequence< OUString > SwXTextPortionEnumeration::getSupportedServiceNames() +throw( RuntimeException ) { Sequence< OUString > aRet(1); OUString* pArray = aRet.getArray(); pArray[0] = C2U("com.sun.star.text.TextPortionEnumeration"); return aRet; } + /*-- 27.01.99 10:44:43--------------------------------------------------- -----------------------------------------------------------------------*/ SwXTextPortionEnumeration::SwXTextPortionEnumeration( - SwPaM& rParaCrsr, - uno::Reference< XText > xParentText, - sal_Int32 nStart, - sal_Int32 nEnd - ) : - xParent(xParentText), - bAtEnd(sal_False), - bFirstPortion(sal_True), - nStartPos(nStart), - nEndPos(nEnd) + SwPaM& rParaCrsr, + uno::Reference< XText > const & xParentText, + const sal_Int32 nStart, + const sal_Int32 nEnd ) + : m_Portions() { - SwUnoCrsr* pUnoCrsr = rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False); + SwUnoCrsr* pUnoCrsr = + rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False); pUnoCrsr->Add(this); DBG_ASSERT(nEnd == -1 || (nStart <= nEnd && nEnd <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().Len()), "start or end value invalid!"); - //alle Rahmen, Grafiken und OLEs suchen, die an diesem Absatz - // AM ZEICHEN gebunden sind - ::CollectFrameAtNode( *this, pUnoCrsr->GetPoint()->nNode, - aFrameArr, TRUE ); - CreatePortions(); + + // find all frames, graphics and OLEs that are bound AT character in para + FrameDependSortList_t frames; + ::CollectFrameAtNode(*this, pUnoCrsr->GetPoint()->nNode, frames, true); + lcl_CreatePortions(m_Portions, xParentText, pUnoCrsr, frames, nStart, nEnd); +} + +SwXTextPortionEnumeration::SwXTextPortionEnumeration( + SwPaM& rParaCrsr, + TextRangeList_t const & rPortions ) + : m_Portions( rPortions ) +{ + SwUnoCrsr* const pUnoCrsr = + rParaCrsr.GetDoc()->CreateUnoCrsr(*rParaCrsr.GetPoint(), sal_False); + pUnoCrsr->Add(this); } + /*-- 27.01.99 10:44:44--------------------------------------------------- -----------------------------------------------------------------------*/ SwXTextPortionEnumeration::~SwXTextPortionEnumeration() { vos::OGuard aGuard(Application::GetSolarMutex()); - for(sal_uInt16 nFrame = aFrameArr.Count(); nFrame; ) - delete aFrameArr.GetObject( --nFrame ); - aFrameArr.Remove(0, aFrameArr.Count()); - - if( aPortionArr.Count() ) - aPortionArr.DeleteAndDestroy(0, aPortionArr.Count() ); - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); delete pUnoCrsr; } /*-- 27.01.99 10:44:44--------------------------------------------------- -----------------------------------------------------------------------*/ -sal_Bool SwXTextPortionEnumeration::hasMoreElements(void) throw( uno::RuntimeException ) +sal_Bool SwXTextPortionEnumeration::hasMoreElements() +throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - return aPortionArr.Count() > 0; + + return (m_Portions.size() > 0) ? sal_True : sal_False; } /*-- 27.01.99 10:44:45--------------------------------------------------- -----------------------------------------------------------------------*/ -uno::Any SwXTextPortionEnumeration::nextElement(void) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException ) +uno::Any SwXTextPortionEnumeration::nextElement() +throw( container::NoSuchElementException, lang::WrappedTargetException, + uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(!aPortionArr.Count()) + + if (!m_Portions.size()) throw container::NoSuchElementException(); - XTextRangeRefPtr pPortion = aPortionArr.GetObject(0); - Any aRet(pPortion, ::getCppuType((uno::Reference<XTextRange>*)0)); - aPortionArr.Remove(0); - delete pPortion; - return aRet; + + Any any; + any <<= m_Portions.front(); + m_Portions.pop_front(); + return any; +} + +//====================================================================== + +typedef ::std::deque< xub_StrLen > FieldMarks_t; + +static void +lcl_FillFieldMarkArray(FieldMarks_t & rFieldMarks, SwUnoCrsr const & rUnoCrsr, + const sal_Int32 i_nStartPos) +{ + const SwTxtNode * const pTxtNode = + rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode(); + if (!pTxtNode) return; + + const sal_Unicode fld[] = { + CH_TXT_ATR_FIELDSTART, CH_TXT_ATR_FIELDEND, CH_TXT_ATR_FORMELEMENT, 0 }; + xub_StrLen pos = ::std::max(static_cast<const sal_Int32>(0), i_nStartPos); + while ((pos = pTxtNode->GetTxt().SearchChar(fld, pos)) != STRING_NOTFOUND) + { + rFieldMarks.push_back(pos); + ++pos; + } } + +static uno::Reference<text::XTextRange> +lcl_ExportFieldMark( + uno::Reference< text::XText > const & i_xParentText, + SwUnoCrsr * const pUnoCrsr, + const SwTxtNode * const pTxtNode ) +{ + uno::Reference<text::XTextRange> xRef; + SwDoc* pDoc = pUnoCrsr->GetDoc(); + //flr: maybe its a good idea to add a special hint to the hints array and rely on the hint segmentation.... + const xub_StrLen start = pUnoCrsr->Start()->nContent.GetIndex(); + ASSERT(pUnoCrsr->End()->nContent.GetIndex() == start, + "hmm --- why is this different"); + + pUnoCrsr->Right(1, CRSR_SKIP_CHARS, FALSE, FALSE); + if ( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) + { + ASSERT(false, "cannot move cursor?"); + return 0; + } + + const sal_Unicode Char = pTxtNode->GetTxt().GetChar(start); + if (CH_TXT_ATR_FIELDSTART == Char) + { + ::sw::mark::IFieldmark* pFieldmark = NULL; + if (pDoc) + { + pFieldmark = pDoc->getIDocumentMarkAccess()-> + getFieldmarkFor(*pUnoCrsr->GetMark()); + } + SwXTextPortion* pPortion = new SwXTextPortion( + pUnoCrsr, i_xParentText, PORTION_FIELD_START); + xRef = pPortion; + if (pPortion && pFieldmark && pDoc) + pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); + } + else if (CH_TXT_ATR_FIELDEND == Char) + { + ::sw::mark::IFieldmark* pFieldmark = NULL; + if (pDoc) + { + pFieldmark = pDoc->getIDocumentMarkAccess()-> + getFieldmarkFor(*pUnoCrsr->GetMark()); + } + SwXTextPortion* pPortion = new SwXTextPortion( + pUnoCrsr, i_xParentText, PORTION_FIELD_END); + xRef = pPortion; + if (pPortion && pFieldmark && pDoc) + pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); + } + else if (CH_TXT_ATR_FORMELEMENT == Char) + { + ::sw::mark::IFieldmark* pFieldmark = NULL; + if (pDoc) + { + pFieldmark = pDoc->getIDocumentMarkAccess()-> + getFieldmarkFor(*pUnoCrsr->GetMark()); + } + SwXTextPortion* pPortion = new SwXTextPortion( + pUnoCrsr, i_xParentText, PORTION_FIELD_START_END); + xRef = pPortion; + if (pPortion && pFieldmark && pDoc) + pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc)); + } + else + { + ASSERT(false, "no fieldmark found?"); + } + return xRef; +} + /* -----------------------------31.08.00 14:28-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_InsertRefMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, - Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) +static Reference<XTextRange> +lcl_CreateRefMarkPortion( + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + const SwTxtAttr & rAttr, const bool bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); - SwFmtRefMark& rRefMark = ((SwFmtRefMark&)pAttr->GetAttr()); - Reference<XTextContent> xContent = ((SwUnoCallBack*)pDoc->GetUnoCallBack())->GetRefMark(rRefMark); - if(!xContent.is()) + const SwFmtRefMark& rRefMark = + static_cast<const SwFmtRefMark&>(rAttr.GetAttr()); + Reference<XTextContent> xContent = + static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack()) + ->GetRefMark(rRefMark); + if (!xContent.is()) + { xContent = new SwXReferenceMark(pDoc, &rRefMark); + } SwXTextPortion* pPortion = 0; - if(!bEnd) + if (!bEnd) { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_REFMARK_START)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_REFMARK_START); pPortion->SetRefMark(xContent); - pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); + pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); } else { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_REFMARK_END)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_REFMARK_END); pPortion->SetRefMark(xContent); } + return pPortion; } + //----------------------------------------------------------------------------- -void lcl_InsertRubyPortion( XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, - Reference<XText> const& rParent, SwTxtAttr* pAttr, BOOL bEnd) +static void +lcl_InsertRubyPortion( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + const SwTxtAttr & rAttr, const sal_Bool bEnd) { - SwXRubyPortion* pPortion = - new SwXRubyPortion(pUnoCrsr, *(SwTxtRuby*)pAttr, rParent, bEnd); - rArr.Insert( new Reference< XTextRange >(pPortion), rArr.Count() ); - pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); + SwXTextPortion* pPortion = new SwXTextPortion(pUnoCrsr, + static_cast<const SwTxtRuby&>(rAttr), xParent, bEnd); + rPortions.push_back(pPortion); + pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); } + //----------------------------------------------------------------------------- -void lcl_InsertTOXMarkPortion( - XTextRangeArr& rArr, SwUnoCrsr* pUnoCrsr, Reference<XText> const& rParent, - SwTxtAttr* pAttr, BOOL bEnd) +static Reference<XTextRange> +lcl_CreateTOXMarkPortion( + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + const SwTxtAttr & rAttr, const bool bEnd) { SwDoc* pDoc = pUnoCrsr->GetDoc(); - SwTOXMark& rTOXMark = ((SwTOXMark&)pAttr->GetAttr()); + const SwTOXMark& rTOXMark = static_cast<const SwTOXMark&>(rAttr.GetAttr()); Reference<XTextContent> xContent = - ((SwUnoCallBack*)pDoc->GetUnoCallBack())->GetTOXMark(rTOXMark); - if(!xContent.is()) - xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), &rTOXMark, pDoc); + static_cast<SwUnoCallBack*>(pDoc->GetUnoCallBack()) + ->GetTOXMark(rTOXMark); + if (!xContent.is()) + { + xContent = new SwXDocumentIndexMark(rTOXMark.GetTOXType(), + &rTOXMark, pDoc); + } SwXTextPortion* pPortion = 0; - if(!bEnd) + if (!bEnd) { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_TOXMARK_START)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_TOXMARK_START); pPortion->SetTOXMark(xContent); - pPortion->SetCollapsed(pAttr->GetEnd() ? FALSE : TRUE); + pPortion->SetCollapsed(rAttr.GetEnd() ? false : true); } - if(bEnd) + else { - rArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_TOXMARK_END)), - rArr.Count()); + pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_TOXMARK_END); pPortion->SetTOXMark(xContent); } + return pPortion; } //----------------------------------------------------------------------------- -void lcl_ExportBookmark( - SwXBookmarkPortion_ImplList& rBkmArr, ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) +static void +lcl_ExportBookmark( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwXBookmarkPortion_ImplList& rBkmArr, const ULONG nIndex) { for ( SwXBookmarkPortion_ImplList::iterator aIter = rBkmArr.begin(), aEnd = rBkmArr.end(); aIter != aEnd; ) @@ -371,31 +508,37 @@ void lcl_ExportBookmark( break; SwXTextPortion* pPortion = 0; - if(BKM_TYPE_START == pPtr->nBkmType || BKM_TYPE_START_END == pPtr->nBkmType) + if ((BKM_TYPE_START == pPtr->nBkmType) || + (BKM_TYPE_START_END == pPtr->nBkmType)) { - rPortionArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_BOOKMARK_START)), - rPortionArr.Count()); + pPortion = + new SwXTextPortion(pUnoCrsr, xParent, PORTION_BOOKMARK_START); + rPortions.push_back(pPortion); pPortion->SetBookmark(pPtr->xBookmark); - pPortion->SetCollapsed(BKM_TYPE_START_END == pPtr->nBkmType ? TRUE : FALSE); + pPortion->SetCollapsed( (BKM_TYPE_START_END == pPtr->nBkmType) + ? true : false); } - if(BKM_TYPE_END == pPtr->nBkmType) + if (BKM_TYPE_END == pPtr->nBkmType) { - rPortionArr.Insert( - new Reference< XTextRange >(pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_BOOKMARK_END)), - rPortionArr.Count()); + pPortion = + new SwXTextPortion(pUnoCrsr, xParent, PORTION_BOOKMARK_END); + rPortions.push_back(pPortion); pPortion->SetBookmark(pPtr->xBookmark); } rBkmArr.erase( aIter++ ); } } -void lcl_ExportSoftPageBreak( - SwSoftPageBreakList& rBreakArr, ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) +static void +lcl_ExportSoftPageBreak( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwSoftPageBreakList& rBreakArr, const ULONG nIndex) { - for ( SwSoftPageBreakList::iterator aIter = rBreakArr.begin(), aEnd = rBreakArr.end(); + for ( SwSoftPageBreakList::iterator aIter = rBreakArr.begin(), + aEnd = rBreakArr.end(); aIter != aEnd; ) { if ( nIndex > *aIter ) @@ -406,9 +549,8 @@ void lcl_ExportSoftPageBreak( if ( nIndex < *aIter ) break; - rPortionArr.Insert( - new Reference< XTextRange >(new SwXTextPortion(pUnoCrsr, rParent, PORTION_SOFT_PAGEBREAK)), - rPortionArr.Count()); + rPortions.push_back( + new SwXTextPortion(pUnoCrsr, xParent, PORTION_SOFT_PAGEBREAK) ); rBreakArr.erase( aIter++ ); } } @@ -426,49 +568,60 @@ void lcl_ExportSoftPageBreak( struct SwXRedlinePortion_Impl { - const SwRedline* pRedline; - sal_Bool bStart; + const SwRedline* m_pRedline; + const bool m_bStart; - SwXRedlinePortion_Impl ( const SwRedline* pRed, sal_Bool bIsStart ) - : pRedline(pRed) - , bStart(bIsStart) + SwXRedlinePortion_Impl ( const SwRedline* pRed, const bool bIsStart ) + : m_pRedline(pRed) + , m_bStart(bIsStart) { } + ULONG getRealIndex () { - return bStart ? pRedline->Start()->nContent.GetIndex() : - pRedline->End() ->nContent.GetIndex(); + return m_bStart ? m_pRedline->Start()->nContent.GetIndex() + : m_pRedline->End() ->nContent.GetIndex(); } }; -typedef boost::shared_ptr < SwXRedlinePortion_Impl > SwXRedlinePortion_ImplSharedPtr; +typedef boost::shared_ptr < SwXRedlinePortion_Impl > + SwXRedlinePortion_ImplSharedPtr; + struct RedlineCompareStruct { const SwPosition& getPosition ( const SwXRedlinePortion_ImplSharedPtr &r ) { - return *(r->bStart ? r->pRedline->Start() : r->pRedline->End()); + return *(r->m_bStart ? r->m_pRedline->Start() : r->m_pRedline->End()); } + bool operator () ( const SwXRedlinePortion_ImplSharedPtr &r1, const SwXRedlinePortion_ImplSharedPtr &r2 ) { return getPosition ( r1 ) < getPosition ( r2 ); } }; -typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > SwXRedlinePortion_ImplList; + +typedef std::multiset < SwXRedlinePortion_ImplSharedPtr, RedlineCompareStruct > +SwXRedlinePortion_ImplList; //----------------------------------------------------------------------------- -Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, - XTextRangeArr& rPortionArr, - SwUnoCrsr* pUnoCrsr, - const Reference<XText> & rParent, +static Reference<XTextRange> +lcl_ExportHints( + PortionStack_t & rPortionStack, + const Reference<XText> & xParent, + SwUnoCrsr * const pUnoCrsr, + SwpHints * const pHints, + const sal_Int32 i_nStartPos, + const sal_Int32 i_nEndPos, const xub_StrLen nCurrentIndex, - SwTextPortionType & rePortionType, - bool & io_rbRightMoveForbidden, + const bool bRightMoveForbidden, + bool & o_rbCursorMoved, sal_Int32 & o_rNextAttrPosition ) { + // if the attribute has a dummy character, then xRef is set (except META) + // otherwise, the portion for the attribute is inserted into rPortions! Reference<XTextRange> xRef; SwDoc* pDoc = pUnoCrsr->GetDoc(); - bool bAlreadyMoved = false; //search for special text attributes - first some ends sal_uInt16 nEndIndex = 0; sal_uInt16 nNextEnd = 0; @@ -478,35 +631,88 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, { if(pHints->GetEnd(nEndIndex)->GetEnd()) { - SwTxtAttr* pAttr = pHints->GetEnd(nEndIndex); - USHORT nAttrWhich = pAttr->Which(); - if(nNextEnd == nCurrentIndex && - ( RES_TXTATR_TOXMARK == nAttrWhich || - RES_TXTATR_REFMARK == nAttrWhich || - RES_TXTATR_CJK_RUBY == nAttrWhich)) + SwTxtAttr * const pAttr = pHints->GetEnd(nEndIndex); + if (nNextEnd == nCurrentIndex) { - switch( nAttrWhich ) + const USHORT nWhich( pAttr->Which() ); + switch (nWhich) { case RES_TXTATR_TOXMARK: - lcl_InsertTOXMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - rePortionType = PORTION_TEXT; + { + Reference<XTextRange> xTmp = lcl_CreateTOXMarkPortion( + xParent, pUnoCrsr, *pAttr, true); + rPortionStack.top().first->push_back(xTmp); + } break; case RES_TXTATR_REFMARK: - lcl_InsertRefMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - rePortionType = PORTION_TEXT; + { + Reference<XTextRange> xTmp = lcl_CreateRefMarkPortion( + xParent, pUnoCrsr, *pAttr, true); + rPortionStack.top().first->push_back(xTmp); + } break; case RES_TXTATR_CJK_RUBY: //#i91534# GetEnd() == 0 mixes the order of ruby start/end if( *pAttr->GetEnd() == *pAttr->GetStart()) { - lcl_InsertRubyPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, sal_False); + lcl_InsertRubyPortion( *rPortionStack.top().first, + xParent, pUnoCrsr, *pAttr, sal_False); } - lcl_InsertRubyPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, TRUE); - rePortionType = PORTION_TEXT; + lcl_InsertRubyPortion( *rPortionStack.top().first, + xParent, pUnoCrsr, *pAttr, sal_True); + break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + { + ASSERT(*pAttr->GetStart() != *pAttr->GetEnd(), + "empty meta?"); + if ((i_nStartPos > 0) && + (*pAttr->GetStart() < i_nStartPos)) + { + // force skip pAttr and rest of attribute ends + // at nCurrentIndex + // because they are not contained in the meta pAttr + // and the meta pAttr itself is outside selection! + // (necessary for SwXMeta::createEnumeration) + if (*pAttr->GetStart() + 1 == i_nStartPos) + { + nEndIndex = pHints->GetEndCount() - 1; + } + break; + } + PortionList_t Top = rPortionStack.top(); + if (Top.second != pAttr) + { + ASSERT(false, "ExportHints: stack error" ); + } + else + { + TextRangeList_t *const pCurrentPortions(Top.first); + rPortionStack.pop(); + SwXTextPortion * pPortion; + if (RES_TXTATR_META == nWhich) + { + SwXMeta * const pMeta = + new SwXMeta(pDoc, xParent, + pCurrentPortions, + static_cast<SwTxtMeta * const>(pAttr)); + pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_META); + pPortion->SetMeta(pMeta); + } + else + { + SwXMetaField * const pMeta = + new SwXMetaField(pDoc, xParent, + pCurrentPortions, + static_cast<SwTxtMeta * const>(pAttr)); + pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FIELD); + pPortion->SetTextField(pMeta); + } + rPortionStack.top().first->push_back(pPortion); + } + } break; } } @@ -520,128 +726,126 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, while(nStartIndex < pHints->GetStartCount() && nCurrentIndex >= (nNextStart = (*pHints->GetStart(nStartIndex)->GetStart()))) { - SwTxtAttr* pAttr = pHints->GetStart(nStartIndex); + const SwTxtAttr * const pAttr = pHints->GetStart(nStartIndex); USHORT nAttrWhich = pAttr->Which(); - if(nNextStart == nCurrentIndex && - (!pAttr->GetEnd() || - RES_TXTATR_TOXMARK == nAttrWhich || - RES_TXTATR_REFMARK == nAttrWhich|| - RES_TXTATR_CJK_RUBY == nAttrWhich)) + if (nNextStart == nCurrentIndex) { switch( nAttrWhich ) { case RES_TXTATR_FIELD: - if(!io_rbRightMoveForbidden) + if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; - bAlreadyMoved = true; - rePortionType = PORTION_FIELD; + SwXTextPortion* pPortion; + xRef = pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FIELD); + Reference<XTextField> xField = + CreateSwXTextField(*pDoc, pAttr->GetFld()); + pPortion->SetTextField(xField); } break; case RES_TXTATR_FLYCNT : - if(!io_rbRightMoveForbidden) + if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; // Robust #i81708 content in covered cells pUnoCrsr->Exchange(); - bAlreadyMoved = true; - rePortionType = PORTION_FRAME; + xRef = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FRAME); } break; case RES_TXTATR_FTN : { - if(!io_rbRightMoveForbidden) + if(!bRightMoveForbidden) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); if( *pUnoCrsr->GetMark() == *pUnoCrsr->GetPoint() ) break; SwXTextPortion* pPortion; - xRef = pPortion = new SwXTextPortion(pUnoCrsr, rParent, PORTION_FOOTNOTE); - Reference<XTextContent> xContent = - Reference<XTextContent>( - SwXFootnotes::GetObject(*pDoc, pAttr->SwTxtAttr::GetFtn()), - UNO_QUERY); + xRef = pPortion = new SwXTextPortion( + pUnoCrsr, xParent, PORTION_FOOTNOTE); + Reference<XFootnote> xContent = + SwXFootnotes::GetObject(*pDoc, pAttr->GetFtn()); pPortion->SetFootnote(xContent); - bAlreadyMoved = true; - rePortionType = PORTION_TEXT; } } break; - case RES_TXTATR_SOFTHYPH : - { - SwXTextPortion* pPortion = 0; - rPortionArr.Insert( - new Reference< XTextRange >( - pPortion = new SwXTextPortion( - pUnoCrsr, rParent, PORTION_CONTROL_CHAR)), - rPortionArr.Count()); - pPortion->SetControlChar(3); - rePortionType = PORTION_TEXT; - } - break; - case RES_TXTATR_HARDBLANK: - { - rePortionType = PORTION_CONTROL_CHAR; - SwXTextPortion* pPortion = 0; - rPortionArr.Insert( - new Reference< XTextRange >( - pPortion = new SwXTextPortion( - pUnoCrsr, rParent, PORTION_CONTROL_CHAR)), - rPortionArr.Count()); - const SwFmtHardBlank& rFmt = pAttr->GetHardBlank(); - if(rFmt.GetChar() == '-') - pPortion->SetControlChar(2);//HARD_HYPHEN - else - pPortion->SetControlChar(4);//HARD_SPACE - rePortionType = PORTION_TEXT; - } - break; case RES_TXTATR_TOXMARK: - lcl_InsertTOXMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - rePortionType = PORTION_TEXT; - break; case RES_TXTATR_REFMARK: - - if(!io_rbRightMoveForbidden || pAttr->GetEnd()) + { + bool bIsPoint = !(pAttr->GetEnd()); + if (!bRightMoveForbidden || !bIsPoint) { - if(!pAttr->GetEnd()) + if (bIsPoint) { pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); - bAlreadyMoved = true; } - lcl_InsertRefMarkPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - rePortionType = PORTION_TEXT; - if(!pAttr->GetEnd()) + Reference<XTextRange> xTmp = + (RES_TXTATR_REFMARK == nAttrWhich) + ? lcl_CreateRefMarkPortion( + xParent, pUnoCrsr, *pAttr, false) + : lcl_CreateTOXMarkPortion( + xParent, pUnoCrsr, *pAttr, false); + if (bIsPoint) // consume CH_TXTATR! { - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); + pUnoCrsr->Normalize(FALSE); pUnoCrsr->DeleteMark(); + xRef = xTmp; + } + else // just insert it + { + rPortionStack.top().first->push_back(xTmp); } } + } break; case RES_TXTATR_CJK_RUBY: //#i91534# GetEnd() == 0 mixes the order of ruby start/end if(pAttr->GetEnd() && (*pAttr->GetEnd() != *pAttr->GetStart())) { - lcl_InsertRubyPortion( - rPortionArr, pUnoCrsr, rParent, pAttr, FALSE); - rePortionType = PORTION_TEXT; + lcl_InsertRubyPortion( *rPortionStack.top().first, + xParent, pUnoCrsr, *pAttr, sal_False); } break; + case RES_TXTATR_META: + case RES_TXTATR_METAFIELD: + if (*pAttr->GetStart() != *pAttr->GetEnd()) + { + if (!bRightMoveForbidden) + { + pUnoCrsr->Right(1,CRSR_SKIP_CHARS,FALSE,FALSE); + o_rbCursorMoved = true; + // only if the end is included in selection! + if ((i_nEndPos < 0) || + (*pAttr->GetEnd() <= i_nEndPos)) + { + rPortionStack.push( ::std::make_pair( + new TextRangeList_t, pAttr )); + } + } + } + break; + case RES_TXTATR_AUTOFMT: + case RES_TXTATR_INETFMT: + case RES_TXTATR_CHARFMT: + case RES_TXTATR_UNKNOWN_CONTAINER: + break; // these are handled as properties of a "Text" portion default: - DBG_ERROR("was fuer ein Attribut?"); + DBG_ERROR("unknown attribute"); + break; } - } nStartIndex++; } - if (!bAlreadyMoved) + if (xRef.is()) // implies that we have moved the cursor + { + o_rbCursorMoved = true; + } + if (!o_rbCursorMoved) { // search for attribute changes behind the current cursor position // break up at frames, bookmarks, redlines @@ -666,17 +870,15 @@ Reference<XTextRange> lcl_ExportHints(SwpHints* pHints, o_rNextAttrPosition = nNextPos; } } - else - { - io_rbRightMoveForbidden = true; - } return xRef; } -void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr, +//----------------------------------------------------------------------------- +void lcl_MoveCursor( SwUnoCrsr * const pUnoCrsr, const xub_StrLen nCurrentIndex, const sal_Int32 nNextFrameIndex, const sal_Int32 nNextPortionIndex, - const sal_Int32 nNextAttrIndex, const sal_Int32 nEndPos ) + const sal_Int32 nNextAttrIndex, const sal_Int32 nNextFieldMarkIndex, + const sal_Int32 nEndPos ) { sal_Int32 nMovePos = pUnoCrsr->GetCntntNode()->Len(); @@ -700,26 +902,22 @@ void lcl_MoveCursor( SwUnoCrsr* pUnoCrsr, nMovePos = nNextAttrIndex; } + if ((nNextFieldMarkIndex >= 0) && (nNextFieldMarkIndex < nMovePos)) + { + nMovePos = nNextFieldMarkIndex; + } + if (nMovePos > nCurrentIndex) { // pUnoCrsr->Right(nMovePos - nCurrentIndex); pUnoCrsr->GetPoint()->nContent = static_cast<USHORT>(nMovePos); } - else if(nEndPos < 0 || nCurrentIndex < nEndPos) - { - // ensure proper exit: move to paragraph end - // (this should not be necessary any more; we assert it only - // happens when the above would move to the end of the - // paragraph anyway) - DBG_ASSERT(nMovePos == pUnoCrsr->GetCntntNode()->Len()|| - (nEndPos > 0 && nMovePos == nEndPos), - "may only happen at paragraph end"); - pUnoCrsr->MovePara(fnParaCurr, fnParaEnd); - } } //----------------------------------------------------------------------------- -void lcl_FillRedlineArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXRedlinePortion_ImplList& rRedArr ) +static void +lcl_FillRedlineArray(SwDoc const & rDoc, SwUnoCrsr const & rUnoCrsr, + SwXRedlinePortion_ImplList& rRedArr ) { const SwRedlineTbl& rRedTbl = rDoc.GetRedlineTbl(); USHORT nRedTblCount = rRedTbl.Count(); @@ -736,18 +934,21 @@ void lcl_FillRedlineArray(SwDoc& rDoc,SwUnoCrsr& rUnoCrsr, SwXRedlinePortion_Imp const SwNodeIndex nRedNode = pRedStart->nNode; if ( nOwnNode == nRedNode ) rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( - new SwXRedlinePortion_Impl ( pRedline, TRUE) ) ); + new SwXRedlinePortion_Impl ( pRedline, true ) ) ); if( pRedline->HasMark() && pRedline->End()->nNode == nOwnNode ) rRedArr.insert( SwXRedlinePortion_ImplSharedPtr ( - new SwXRedlinePortion_Impl ( pRedline, FALSE) ) ); + new SwXRedlinePortion_Impl ( pRedline, false) ) ); } } } //----------------------------------------------------------------------------- -void lcl_FillSoftPageBreakArray( SwUnoCrsr& rUnoCrsr, SwSoftPageBreakList& rBreakArr ) +static void +lcl_FillSoftPageBreakArray( + SwUnoCrsr const & rUnoCrsr, SwSoftPageBreakList& rBreakArr ) { - const SwTxtNode *pTxtNode = rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode(); + const SwTxtNode *pTxtNode = + rUnoCrsr.GetPoint()->nNode.GetNode().GetTxtNode(); if( pTxtNode ) pTxtNode->fillSoftPageBreakList( rBreakArr ); } @@ -755,9 +956,12 @@ void lcl_FillSoftPageBreakArray( SwUnoCrsr& rUnoCrsr, SwSoftPageBreakList& rBrea /* -----------------------------19.12.00 12:25-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_ExportRedline( - SwXRedlinePortion_ImplList& rRedlineArr, ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) +static void +lcl_ExportRedline( + TextRangeList_t & rPortions, + Reference<XText> const& xParent, + const SwUnoCrsr * const pUnoCrsr, + SwXRedlinePortion_ImplList& rRedlineArr, const ULONG nIndex) { // MTG: 23/11/05: We want this loop to iterate over all red lines in this @@ -773,10 +977,8 @@ void lcl_ExportRedline( // MTG: 23/11/05: If the elements match, and them to the list else if ( nIndex == nRealIndex ) { - rPortionArr.Insert( - new Reference< XTextRange >( new SwXRedlinePortion( - pPtr->pRedline, pUnoCrsr, rParent, pPtr->bStart)), - rPortionArr.Count()); + rPortions.push_back( new SwXRedlinePortion( + pPtr->m_pRedline, pUnoCrsr, xParent, pPtr->m_bStart) ); rRedlineArr.erase ( aIter++ ); } // MTG: 23/11/05: If we've iterated past nIndex, exit the loop @@ -784,29 +986,63 @@ void lcl_ExportRedline( break; } } + /* -----------------------------19.12.00 13:09-------------------------------- ---------------------------------------------------------------------------*/ -void lcl_ExportBkmAndRedline( +static void +lcl_ExportBkmAndRedline( + TextRangeList_t & rPortions, + Reference<XText> const & xParent, + const SwUnoCrsr * const pUnoCrsr, SwXBookmarkPortion_ImplList& rBkmArr, SwXRedlinePortion_ImplList& rRedlineArr, SwSoftPageBreakList& rBreakArr, - ULONG nIndex, - SwUnoCrsr* pUnoCrsr, Reference<XText> & rParent, XTextRangeArr& rPortionArr) + const ULONG nIndex) { if (rBkmArr.size()) - lcl_ExportBookmark(rBkmArr, nIndex, pUnoCrsr, rParent, rPortionArr); + lcl_ExportBookmark(rPortions, xParent, pUnoCrsr, rBkmArr, nIndex); if (rRedlineArr.size()) - lcl_ExportRedline(rRedlineArr, nIndex, pUnoCrsr, rParent, rPortionArr); + lcl_ExportRedline(rPortions, xParent, pUnoCrsr, rRedlineArr, nIndex); if (rBreakArr.size()) - lcl_ExportSoftPageBreak(rBreakArr, nIndex, pUnoCrsr, rParent, rPortionArr); + lcl_ExportSoftPageBreak(rPortions, xParent, pUnoCrsr, rBreakArr, nIndex); } + //----------------------------------------------------------------------------- -sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList& rBkmArr, - SwXRedlinePortion_ImplList& rRedlineArr, - SwSoftPageBreakList& rBreakArr ) +static sal_Int32 +lcl_ExportFrames( + TextRangeList_t & rPortions, + Reference<XText> const & i_xParent, + SwUnoCrsr * const i_pUnoCrsr, + FrameDependSortList_t & i_rFrames, + xub_StrLen const i_nCurrentIndex) +{ + // find first Frame in (sorted) i_rFrames at current position + while (i_rFrames.size() && (i_rFrames.front().nIndex == i_nCurrentIndex)) + // do not check for i_nEnd here; this is done implicity by lcl_MoveCursor + { + const SwModify * const pFrame = + i_rFrames.front().pFrameDepend->GetRegisteredIn(); + if (pFrame) // Frame could be disposed + { + SwXTextPortion* pPortion = new SwXTextPortion(i_pUnoCrsr, i_xParent, + *static_cast<SwFrmFmt*>( const_cast<SwModify*>( pFrame ) ) ); + rPortions.push_back(pPortion); + } + i_rFrames.pop_front(); + } + + return i_rFrames.size() ? i_rFrames.front().nIndex : -1; +} + +//----------------------------------------------------------------------------- +static sal_Int32 +lcl_GetNextIndex( + SwXBookmarkPortion_ImplList const & rBkmArr, + SwXRedlinePortion_ImplList const & rRedlineArr, + SwSoftPageBreakList const & rBreakArr ) { sal_Int32 nRet = -1; if(rBkmArr.size()) @@ -828,284 +1064,146 @@ sal_Int32 lcl_GetNextIndex(SwXBookmarkPortion_ImplList& rBkmArr, } return nRet; }; + //----------------------------------------------------------------------------- -void SwXTextPortionEnumeration::CreatePortions() +static void +lcl_CreatePortions( + TextRangeList_t & i_rPortions, + uno::Reference< text::XText > const & i_xParentText, + SwUnoCrsr * const pUnoCrsr, + FrameDependSortList_t & i_rFrames, + const sal_Int32 i_nStartPos, + const sal_Int32 i_nEndPos ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + if (!pUnoCrsr) + return; + // set the start if a selection should be exported - if(nStartPos > 0 && pUnoCrsr->Start()->nContent.GetIndex() != nStartPos) + if ((i_nStartPos > 0) && + (pUnoCrsr->Start()->nContent.GetIndex() != i_nStartPos)) { - if(pUnoCrsr->HasMark()) - pUnoCrsr->DeleteMark(); + pUnoCrsr->DeleteMark(); DBG_ASSERT(pUnoCrsr->Start()->nNode.GetNode().GetTxtNode() && - nStartPos <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()->GetTxt().Len(), - "Incorrect start position" ); - // ??? should this be nStartPos - current position ? - pUnoCrsr->Right((xub_StrLen)nStartPos,CRSR_SKIP_CHARS,FALSE,FALSE); + (i_nStartPos <= pUnoCrsr->Start()->nNode.GetNode().GetTxtNode()-> + GetTxt().Len()), "Incorrect start position" ); + // ??? should this be i_nStartPos - current position ? + pUnoCrsr->Right(static_cast<xub_StrLen>(i_nStartPos), + CRSR_SKIP_CHARS, FALSE, FALSE); } - if(pUnoCrsr /*&& !bAtEnd*/) + + FieldMarks_t FieldMarks; + SwXBookmarkPortion_ImplList Bookmarks; + SwXRedlinePortion_ImplList Redlines; + SwSoftPageBreakList SoftPageBreaks; + + SwDoc * const pDoc = pUnoCrsr->GetDoc(); + lcl_FillFieldMarkArray(FieldMarks, *pUnoCrsr, i_nStartPos); + lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, Bookmarks); + lcl_FillRedlineArray(*pDoc, *pUnoCrsr, Redlines); + lcl_FillSoftPageBreakArray(*pUnoCrsr, SoftPageBreaks); + + PortionStack_t PortionStack; + PortionStack.push( PortionList_t(&i_rPortions, 0) ); + + bool bAtEnd( false ); + while (!bAtEnd) // every iteration consumes at least current character! { - SwXBookmarkPortion_ImplList aBkmArr; - SwXRedlinePortion_ImplList aRedArr; - SwSoftPageBreakList aBreakArr; - - SwDoc* pDoc = pUnoCrsr->GetDoc(); - lcl_FillRedlineArray(*pDoc, *pUnoCrsr, aRedArr); - lcl_FillBookmarkArray(*pDoc, *pUnoCrsr, aBkmArr ); - lcl_FillSoftPageBreakArray( *pUnoCrsr, aBreakArr ); -#if OSL_DEBUG_LEVEL > 1 - for (SwXBookmarkPortion_ImplList::const_iterator aIter = aBkmArr.begin(), aEnd = aBkmArr.end(); - aIter != aEnd; - ++aIter ) + if (pUnoCrsr->HasMark()) { - SwXBookmarkPortion_ImplSharedPtr pPtr = (*aIter); + pUnoCrsr->Normalize(FALSE); + pUnoCrsr->DeleteMark(); } -#endif - while(!bAtEnd) + SwTxtNode * const pTxtNode = pUnoCrsr->GetNode()->GetTxtNode(); + if (!pTxtNode) { - if(pUnoCrsr->HasMark()) + DBG_ERROR("lcl_CreatePortions: no TextNode - what now ?"); + return; + } + + SwpHints * const pHints = pTxtNode->GetpSwpHints(); + const xub_StrLen nCurrentIndex = + pUnoCrsr->GetPoint()->nContent.GetIndex(); + // this contains the portion which consumes the character in the + // text at nCurrentIndex; i.e. it must be set _once_ per iteration + uno::Reference< XTextRange > xRef; + + SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); // set mark + + const sal_Int32 nFirstFrameIndex = + lcl_ExportFrames( *PortionStack.top().first, + i_xParentText, pUnoCrsr, i_rFrames, nCurrentIndex); + + lcl_ExportBkmAndRedline( *PortionStack.top().first, i_xParentText, + pUnoCrsr, Bookmarks, Redlines, SoftPageBreaks, nCurrentIndex ); + + bool bCursorMoved( false ); + sal_Int32 nNextAttrIndex = -1; + // #111716# the cursor must not move right at the + // end position of a selection! + bAtEnd = ((i_nEndPos >= 0) && (nCurrentIndex >= i_nEndPos)) + || (nCurrentIndex >= pTxtNode->Len()); + if (pHints) + { + // N.B.: side-effects nNextAttrIndex, bCursorMoved; may move cursor + xRef = lcl_ExportHints(PortionStack, i_xParentText, pUnoCrsr, + pHints, i_nStartPos, i_nEndPos, nCurrentIndex, bAtEnd, + bCursorMoved, nNextAttrIndex); + if (PortionStack.empty()) { - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - pUnoCrsr->DeleteMark(); + ASSERT(false, "CreatePortions: stack underflow"); + return; } - SwNode* pNode = pUnoCrsr->GetNode(); - SwCntntNode *pCNd = pNode->GetCntntNode(); - if(!bFirstPortion && pCNd && - pUnoCrsr->GetPoint()->nContent == pCNd->Len()) + } + + if (!xRef.is() && !bCursorMoved) + { + if (!bAtEnd && + FieldMarks.size() && (FieldMarks.front() == nCurrentIndex)) { - //hier sollte man nie ankommen! - bAtEnd = sal_True; + // moves cursor + xRef = lcl_ExportFieldMark(i_xParentText, pUnoCrsr, pTxtNode); + FieldMarks.pop_front(); } - else - { - if(ND_TEXTNODE == pNode->GetNodeType()) - { - SwTxtNode* pTxtNode = (SwTxtNode*)pNode; - SwpHints* pHints = pTxtNode->GetpSwpHints(); - SwTextPortionType ePortionType = PORTION_TEXT; - xub_StrLen nCurrentIndex = pUnoCrsr->GetPoint()->nContent.GetIndex(); - xub_StrLen nFirstFrameIndex = STRING_MAXLEN; - uno::Reference< XTextRange > xRef; - if(!pCNd->Len()) - { - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, 0, pUnoCrsr, xParent, aPortionArr); - // the paragraph is empty - xRef = new SwXTextPortion(pUnoCrsr, xParent, ePortionType); - // are there any frames? - while(aFrameArr.Count()) - { - SwDepend* pCurDepend = aFrameArr.GetObject(0); - if(pCurDepend->GetRegisteredIn()) - { - //the previously created portion has to be inserted here - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - xRef = new SwXTextPortion(pUnoCrsr, xParent, - *(SwFrmFmt*)pCurDepend->GetRegisteredIn()); - } - delete pCurDepend; - aFrameArr.Remove(0); - } - } - else - { - //falls schon Rahmen entsorgt wurden, dann raus hier - for(sal_uInt16 nFrame = aFrameArr.Count(); nFrame; nFrame--) - { - SwDepend* pCurDepend = aFrameArr.GetObject(nFrame - 1); - if(!pCurDepend->GetRegisteredIn()) - { - delete pCurDepend; - aFrameArr.Remove(nFrame - 1); - } - } + } + else + { + ASSERT(!FieldMarks.size() || + (FieldMarks.front() != nCurrentIndex), + "fieldmark and hint with CH_TXTATR at same pos?"); + } - //zunaechst den ersten Frame im aFrameArr finden (bezogen auf die Position im Absatz) - SwDepend* pFirstFrameDepend = 0; - //Eintraege im aFrameArr sind sortiert! - if(aFrameArr.Count()) - { - SwDepend* pCurDepend = aFrameArr.GetObject(0); - SwFrmFmt* pFormat = (SwFrmFmt*)pCurDepend->GetRegisteredIn(); - const SwFmtAnchor& rAnchor = pFormat->GetAnchor(); - const SwPosition* pAnchorPos = rAnchor.GetCntntAnchor(); - pFirstFrameDepend = pCurDepend; - nFirstFrameIndex = pAnchorPos->nContent.GetIndex(); - if(nEndPos >= 0 && nFirstFrameIndex >= nEndPos) - nFirstFrameIndex = USHRT_MAX; - } + if (!bAtEnd && !xRef.is() && !bCursorMoved) + { + const sal_Int32 nNextPortionIndex = + lcl_GetNextIndex(Bookmarks, Redlines, SoftPageBreaks); + const sal_Int32 nNextFieldMarkIndex( + FieldMarks.size() ? FieldMarks.front() : -1); - SwXTextCursor::SelectPam(*pUnoCrsr, sal_True); + lcl_MoveCursor(pUnoCrsr, nCurrentIndex, + nFirstFrameIndex, nNextPortionIndex, nNextAttrIndex, + nNextFieldMarkIndex, + i_nEndPos); - //ist hier schon ein Rahmen faellig? - if(nCurrentIndex == nFirstFrameIndex) - { - xRef = new SwXTextPortion(pUnoCrsr, xParent, - *(SwFrmFmt*)pFirstFrameDepend->GetRegisteredIn()); - SwDepend* pCurDepend = aFrameArr.GetObject(0); - delete pCurDepend; - aFrameArr.Remove(0); - } - } - if(!xRef.is()) - { - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, - nCurrentIndex, pUnoCrsr, xParent, aPortionArr); - sal_Int32 nNextAttrIndex = -1; - sal_Int32 nNextPortionIndex = - lcl_GetNextIndex(aBkmArr, aRedArr, aBreakArr); - // #111716# the cursor must not move right at the - // end position of a selection! - bool bRightMoveForbidden = - ((nEndPos > 0) && (nCurrentIndex >= nEndPos)); - if (pHints) - { - // N.B.: side-effects bRightMoveForbidden - // and nNextAttrIndex - xRef = lcl_ExportHints(pHints, aPortionArr, - pUnoCrsr, xParent, nCurrentIndex, ePortionType, - bRightMoveForbidden, nNextAttrIndex); - } - if (!bRightMoveForbidden) - { - lcl_MoveCursor(pUnoCrsr, nCurrentIndex, - nFirstFrameIndex, nNextPortionIndex, - nNextAttrIndex, nEndPos); - } - } - if(!xRef.is() && pUnoCrsr->HasMark() ) { - //flr: maybe its a good idea to add a special hint to the hints array and rely on the hint segmentation.... - xub_StrLen start=pUnoCrsr->Start()->nContent.GetIndex(); - xub_StrLen end=pUnoCrsr->End()->nContent.GetIndex(); - ASSERT(start<=end, "hmm --- why is this different"); - xub_StrLen startMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDSTART, start); - xub_StrLen endMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FIELDEND, start); - xub_StrLen formMarkerPos=pTxtNode->GetTxt().Search(CH_TXT_ATR_FORMELEMENT, start); - xub_StrLen markerPos=STRING_LEN; - if (startMarkerPos>=start && startMarkerPos<end) - { - markerPos=startMarkerPos; - } - if (endMarkerPos>=start && endMarkerPos<end) - { - if (endMarkerPos<markerPos) - markerPos=endMarkerPos; - } - if (formMarkerPos>=start && formMarkerPos<end) - { - if (formMarkerPos<markerPos) - markerPos=formMarkerPos; - } - if (markerPos<end) - { - if (start==markerPos) - end = markerPos+1; - else - end = markerPos; - bAtEnd = sal_False; - pUnoCrsr->GetPoint()->nContent = end; - } - if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FIELDSTART) - { - ::sw::mark::IFieldmark* pFieldmark = NULL; - if (pDoc && pUnoCrsr->GetPoint()) - pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(*pUnoCrsr->GetPoint()); - SwXTextPortion* pPortion = NULL; - xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_START)); - if (pPortion && pFieldmark && pDoc) - pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); - } - else if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FIELDEND) - { - ::sw::mark::IFieldmark* pFieldmark = NULL; - if (pDoc && pUnoCrsr->GetPoint()) - { - SwPosition aPos(*pUnoCrsr->GetPoint()); - aPos.nContent = markerPos; - pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(aPos); - } - SwXTextPortion* pPortion = NULL; - xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_END)); - if (pPortion && pFieldmark && pDoc) - pPortion->SetBookmark(new SwXFieldmark(false, pFieldmark, pDoc)); - } - else if (start+1==end && pTxtNode->GetTxt().GetChar(start)==CH_TXT_ATR_FORMELEMENT) - { - ::sw::mark::IFieldmark* pFieldmark = NULL; - if (pDoc && pUnoCrsr->GetPoint()) - { - SwPosition aPos(*pUnoCrsr->GetPoint()); - aPos.nContent=markerPos; - pFieldmark = pDoc->getIDocumentMarkAccess()->getFieldmarkFor(aPos); - } - SwXTextPortion* pPortion=NULL; - xRef = (pPortion = new SwXTextPortion(pUnoCrsr, xParent, PORTION_FIELD_START_END)); - if(pPortion && pFieldmark && pDoc) - pPortion->SetBookmark(new SwXFieldmark(true, pFieldmark, pDoc)); - } - else - { - xRef = new SwXTextPortion(pUnoCrsr, xParent, ePortionType); - } - } - if(xRef.is()) - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - } - else - { - DBG_ERROR("kein TextNode - was nun?"); - } - } - if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark()) - pUnoCrsr->Exchange(); - - // Absatzende ? - pNode = pUnoCrsr->GetNode(); - pCNd = pNode->GetCntntNode(); - sal_Int32 nLocalEnd = nEndPos >= 0 ? nEndPos : pCNd->Len(); - if( pCNd && pUnoCrsr->GetPoint()->nContent >= (xub_StrLen)nLocalEnd) - { - bAtEnd = sal_True; - lcl_ExportBkmAndRedline(aBkmArr, aRedArr, aBreakArr, nLocalEnd, - pUnoCrsr, xParent, aPortionArr); - if(ND_TEXTNODE == pNode->GetNodeType()) - { - SwTxtNode* pTxtNode = (SwTxtNode*)pNode; - SwpHints* pHints = pTxtNode->GetpSwpHints(); - if(pHints) - { - SwTextPortionType ePortionType = PORTION_TEXT; - bool bDummy = false; - sal_Int32 nDummy = -1; - Reference<XTextRange> xRef = lcl_ExportHints(pHints, - aPortionArr, - pUnoCrsr, - xParent, - static_cast< xub_StrLen >(nLocalEnd), - ePortionType, - bDummy, nDummy); - if(xRef.is()) - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - } - } - while(aFrameArr.Count()) - { - SwDepend* pCurDepend = aFrameArr.GetObject(0); - if(pCurDepend->GetRegisteredIn()) - { - Reference<XTextRange> xRef = new SwXTextPortion(pUnoCrsr, xParent, - *(SwFrmFmt*)pCurDepend->GetRegisteredIn()); - aPortionArr.Insert(new Reference<XTextRange>(xRef), aPortionArr.Count()); - } - delete pCurDepend; - aFrameArr.Remove(0); - } + xRef = new SwXTextPortion(pUnoCrsr, i_xParentText, PORTION_TEXT); + } + else if (bAtEnd && !xRef.is() && !pTxtNode->Len()) + { + // special case: for an empty paragraph, we better put out a + // text portion because there may be a hyperlink attribute + xRef = new SwXTextPortion(pUnoCrsr, i_xParentText, PORTION_TEXT); + } - } + if (xRef.is()) + { + PortionStack.top().first->push_back(xRef); } } + + ASSERT((PortionStack.size() == 1) && !PortionStack.top().second, + "CreatePortions: stack error" ); } + /*-- 27.01.99 10:44:45--------------------------------------------------- -----------------------------------------------------------------------*/ diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx index fa5712a8d4..fc0cddd250 100644 --- a/sw/source/core/unocore/unoprnms.cxx +++ b/sw/source/core/unocore/unoprnms.cxx @@ -778,7 +778,9 @@ const SwPropNameTab aPropNameTab = { /* 0733 CHAR_OVERLINE */ {MAP_CHAR_LEN("CharOverline")}, /* 0734 CHAR_OVERLINE_COLOR */ {MAP_CHAR_LEN("CharOverlineColor")}, /* 0735 CHAR_OVERLINE_HAS_COLOR */ {MAP_CHAR_LEN("CharOverlineHasColor")}, -/* 0736 UNO_NAME_OUTLINE_LEVEL */ {MAP_CHAR_LEN("OutlineLevel")}//#outline level,add<-zhaojianwei Outlinelevel +/* 0736 UNO_NAME_OUTLINE_LEVEL */ {MAP_CHAR_LEN("OutlineLevel")},//#outline level,add<-zhaojianwei Outlinelevel +/* 0737 UNO_NAME_DESCRIPTION */ {MAP_CHAR_LEN("Description")}, +/* 0738 UNO_NAME_META */ {MAP_CHAR_LEN("InContentMetadata")}, }; const SwPropNameLen& SwGetPropName( USHORT nId ) diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 22a12bb157..d3b85ff340 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -295,7 +295,7 @@ uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName ) { if ( 1 < ( pNodeIdx->GetNode().EndOfSectionIndex() - pNodeIdx->GetNode().GetIndex() ) ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); uno::Reference<text::XText> xRet = new SwXRedlineText(pUnoCrsr->GetDoc(), *pNodeIdx); aRet <<= xRet; } @@ -318,7 +318,7 @@ uno::Any SwXRedlinePortion::getPropertyValue( const OUString& rPropertyName ) ---------------------------------------------------------------------------*/ void SwXRedlinePortion::Validate() throw( uno::RuntimeException ) { - SwUnoCrsr* pUnoCrsr = GetCrsr(); + SwUnoCrsr* pUnoCrsr = GetCursor(); if(!pUnoCrsr) throw uno::RuntimeException(); //search for the redline diff --git a/sw/source/core/unocore/unorefmk.cxx b/sw/source/core/unocore/unorefmk.cxx index 336ba97e68..752022c763 100644 --- a/sw/source/core/unocore/unorefmk.cxx +++ b/sw/source/core/unocore/unorefmk.cxx @@ -124,7 +124,7 @@ SwXReferenceMark::~SwXReferenceMark() /* -----------------03.11.99 14:14------------------- --------------------------------------------------*/ -void SwXReferenceMark::InsertRefMark( SwPaM& rPam ) +void SwXReferenceMark::InsertRefMark(SwPaM& rPam, SwXTextCursor * pCursor) { //! in some cases when this function is called the pDoc pointer member may have become //! invalid/deleted thus we obtain the document pointer from rPaM where it should always @@ -134,10 +134,19 @@ void SwXReferenceMark::InsertRefMark( SwPaM& rPam ) UnoActionContext aCont(pDoc2); SwTxtAttr* pTxtAttr = 0; SwFmtRefMark aRefMark(sMarkName); - SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L); - aSet.Put(aRefMark); +// SfxItemSet aSet(pDoc2->GetAttrPool(), RES_TXTATR_REFMARK, RES_TXTATR_REFMARK, 0L); +// aSet.Put(aRefMark); sal_Bool bMark = *rPam.GetPoint() != *rPam.GetMark(); - SwXTextCursor::SetCrsrAttr(rPam, aSet, 0); +// SwXTextCursor::SetCrsrAttr(rPam, aSet, 0); + + const bool bForceExpandHints( (!bMark && pCursor) + ? pCursor->IsAtEndOfMeta() : false ); + const SetAttrMode nInsertFlags = (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND; + + pDoc2->InsertPoolItem( rPam, aRefMark, nInsertFlags ); if( bMark && *rPam.GetPoint() > *rPam.GetMark()) rPam.Exchange(); @@ -146,8 +155,10 @@ void SwXReferenceMark::InsertRefMark( SwPaM& rPam ) pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr( rPam.GetPoint()->nContent, RES_TXTATR_REFMARK ); else - pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttr( + { + pTxtAttr = rPam.GetNode()->GetTxtNode()->GetTxtAttrForCharAt( rPam.GetPoint()->nContent.GetIndex()-1, RES_TXTATR_REFMARK ); + } if(pTxtAttr) pMark = &pTxtAttr->GetRefMark(); @@ -179,7 +190,7 @@ void SwXReferenceMark::attachToRange(const uno::Reference< text::XTextRange > & SwUnoInternalPaM aPam(*pDocument); //das muss jetzt sal_True liefern SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange); - InsertRefMark(aPam); + InsertRefMark(aPam, dynamic_cast<SwXTextCursor*>(pCursor)); m_bIsDescriptor = sal_False; pDoc = pDocument; pDoc->GetUnoCallBack()->Add(this); @@ -318,7 +329,7 @@ void SwXReferenceMark::setName(const OUString& Name_) throw( uno::RuntimeExcepti sMarkName = sNewName; //create a new one - InsertRefMark( aPam ); + InsertRefMark( aPam, 0 ); pDoc = aPam.GetDoc(); } } @@ -424,3 +435,1056 @@ void SwXReferenceMark::removeVetoableChangeListener( { } +#include <com/sun/star/lang/DisposedException.hpp> +#include <unometa.hxx> +#include <unoport.hxx> +#include <txtatr.hxx> +#include <fmtmeta.hxx> +#include <docsh.hxx> + +//============================================================================= + +/****************************************************************** + * SwXMetaText + ******************************************************************/ + +class SwXMetaText + : public SwXText +{ +private: + SwXMeta & m_rMeta; + + virtual void PrepareForAttach(uno::Reference< text::XTextRange > & xRange, + const SwXTextRange* const pRange, const SwPaM * const pPam); + + virtual bool CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException); + +protected: + virtual const SwStartNode *GetStartNode() const; + virtual uno::Reference< text::XTextCursor > + createCursor() throw (uno::RuntimeException); + +public: + SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta); + + // XInterface + virtual void SAL_CALL acquire() throw() + { OSL_ENSURE(false, "ERROR: SwXMetaText::acquire"); } + virtual void SAL_CALL release() throw() + { OSL_ENSURE(false, "ERROR: SwXMetaText::release"); } + + // XTypeProvider + virtual uno::Sequence< sal_Int8 > SAL_CALL + getImplementationId() throw (uno::RuntimeException); + + // XText + virtual uno::Reference< text::XTextCursor > SAL_CALL + createTextCursor() throw (uno::RuntimeException); + virtual uno::Reference< text::XTextCursor > SAL_CALL + createTextCursorByRange( + const uno::Reference< text::XTextRange > & xTextPosition) + throw (uno::RuntimeException); + +}; + +SwXMetaText::SwXMetaText(SwDoc & rDoc, SwXMeta & rMeta) + : SwXText(&rDoc, CURSOR_META) + , m_rMeta(rMeta) +{ +} + +const SwStartNode *SwXMetaText::GetStartNode() const +{ + SwXText const * const pParent( + dynamic_cast<SwXText*>(m_rMeta.GetParentText().get())); + return (pParent) ? pParent->GetStartNode() : 0; +} + +void SwXMetaText::PrepareForAttach( uno::Reference<text::XTextRange> & xRange, + const SwXTextRange* const pRange, const SwPaM * const pPam) +{ + SwPosition const* pPoint(0); + SwPosition const* pMark (0); + if (pRange) + { + ::sw::mark::IMark const& rIMark(*pRange->GetBookmark()); + pMark = &rIMark.GetMarkPos(); + if (rIMark.IsExpanded()) + { + pMark = &rIMark.GetOtherMarkPos(); + } + } + else if (pPam) + { + pPoint = pPam->GetPoint(); + if (pPam->HasMark()) + { + pMark = pPam->GetMark(); + } + } + // create a new cursor to prevent modifying SwXTextRange + if (pPoint) + { + xRange = static_cast<text::XWordCursor*>( + new SwXTextCursor(&m_rMeta, *pPoint, CURSOR_META, GetDoc(), pMark)); + } +} + +bool SwXMetaText::CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) +{ + return m_rMeta.CheckForOwnMemberMeta(pRange, pPam, bAbsorb); +} + +uno::Reference< text::XTextCursor > SwXMetaText::createCursor() +throw (uno::RuntimeException) +{ + uno::Reference< text::XTextCursor > xRet; + if (IsValid()) + { + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess( + m_rMeta.SetContentRange(pTxtNode, nMetaStart, nMetaEnd) ); + if (bSuccess) + { + SwPosition aPos(*pTxtNode, nMetaStart); + xRet = static_cast<text::XWordCursor*>( + new SwXTextCursor(&m_rMeta, aPos, CURSOR_META, GetDoc())); + } + } + return xRet; +} + +uno::Sequence<sal_Int8> SAL_CALL +SwXMetaText::getImplementationId() throw (uno::RuntimeException) +{ + return m_rMeta.getImplementationId(); +} + +// XText +uno::Reference< text::XTextCursor > SAL_CALL +SwXMetaText::createTextCursor() throw (uno::RuntimeException) +{ + return createCursor(); +} + +uno::Reference< text::XTextCursor > SAL_CALL +SwXMetaText::createTextCursorByRange( + const uno::Reference<text::XTextRange> & xTextPosition) + throw (uno::RuntimeException) +{ + const uno::Reference<text::XTextCursor> xCursor( createCursor() ); + xCursor->gotoRange(xTextPosition, sal_False); + return xCursor; +} + +/****************************************************************** + * SwXMeta + ******************************************************************/ + +// the Meta has a cached list of text portions for its contents +// this list is created by SwXTextPortionEnumeration +// the Meta listens at the SwTxtNode and throws away the cache when it changes + +struct SwXMeta::Impl +{ + SwEventListenerContainer m_ListenerContainer; + ::std::auto_ptr<const TextRangeList_t> m_pTextPortions; + // 3 possible states: not attached, attached, disposed + bool m_bIsDisposed; + bool m_bIsDescriptor; + uno::Reference<text::XText> m_xParentText; + SwXMetaText m_Text; + + Impl(SwXMeta & rThis, SwDoc & rDoc, + uno::Reference<text::XText> const& xParentText, + TextRangeList_t const * const pPortions, + SwTxtMeta const * const pHint) + : m_ListenerContainer( + static_cast< ::cppu::OWeakObject* >(&rThis)) + , m_pTextPortions( pPortions ) + , m_bIsDisposed( false ) + , m_bIsDescriptor( 0 == pHint ) + , m_xParentText(xParentText) + , m_Text(rDoc, rThis) + { + } +}; + +TYPEINIT1(SwXMeta, SwClient); + +inline const ::sw::Meta * SwXMeta::GetMeta() const +{ + return static_cast< const ::sw::Meta * >(GetRegisteredIn()); +} + +uno::Reference<text::XText> SwXMeta::GetParentText() const +{ + return m_pImpl->m_xParentText; +} + +bool SwXMeta::SetContentRange( + SwTxtNode *& rpNode, xub_StrLen & rStart, xub_StrLen & rEnd ) const +{ + ::sw::Meta const * const pMeta( GetMeta() ); + if (pMeta) + { + SwTxtMeta const * const pTxtAttr( pMeta->GetTxtAttr() ); + if (pTxtAttr) + { + rpNode = pTxtAttr->GetTxtNode(); + if (rpNode) + { + // rStart points at the first position _within_ the meta! + rStart = *pTxtAttr->GetStart() + 1; + rEnd = *pTxtAttr->GetEnd(); + return true; + } + } + } + return false; +} + +SwXMeta::SwXMeta(SwDoc *const pDoc, + uno::Reference<text::XText> const& xParentText, + TextRangeList_t * const pPortions, SwTxtMeta * const pHint) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, xParentText, pPortions, pHint) ) +{ + if (pHint) + { + ::sw::Meta * const pMeta( + static_cast<SwFmtMeta&>(pHint->GetAttr()).GetMeta() ); + ASSERT(pMeta, "SwXMeta: no meta?") + if (pMeta) + { + pMeta->Add(this); + } + } +} + +bool SwXMeta::CheckForOwnMemberMeta(const SwXTextRange* const pRange, + const SwPaM* const pPam, bool bAbsorb) + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + ASSERT((pPam && !pRange) || (!pPam && pRange), "ERROR: pam xor range"); + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess( SetContentRange(pTxtNode, nMetaStart, nMetaEnd) ); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + throw lang::DisposedException(); + SwPosition const * const pStartPos( (pPam) + ? pPam->Start() + : &pRange->GetBookmark()->GetMarkStart() ); + if (&pStartPos->nNode.GetNode() != pTxtNode) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but start " + "of text range not in same paragraph as text content"), + 0, 0); + } + bool bForceExpandHints(false); + const xub_StrLen nStartPos(pStartPos->nContent.GetIndex()); + // not <= but < because nMetaStart is behind dummy char! + // not >= but > because == means insert at end! + if ((nStartPos < nMetaStart) || (nStartPos > nMetaEnd)) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but start " + "of text range not inside text content"), + 0, 0); + } + else if (nStartPos == nMetaEnd) + { + bForceExpandHints = true; + } + const bool bHasEnd( (pPam) + ? pPam->HasMark() + : pRange->GetBookmark()->IsExpanded()); + if (bHasEnd && bAbsorb) + { + SwPosition const * const pEndPos( (pPam) + ? pPam->End() + : &pRange->GetBookmark()->GetMarkEnd() ); + if (&pEndPos->nNode.GetNode() != pTxtNode) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but end " + "of text range not in same paragraph as text content"), + 0, 0); + } + const xub_StrLen nEndPos(pEndPos->nContent.GetIndex()); + // not <= but < because nMetaStart is behind dummy char! + // not >= but > because == means insert at end! + if ((nEndPos < nMetaStart) || (nEndPos > nMetaEnd)) + { + throw lang::IllegalArgumentException( + C2U("trying to insert into a nesting text content, but end " + "of text range not inside text content"), + 0, 0); + } + else if (nEndPos == nMetaEnd) + { + bForceExpandHints = true; + } + } + return bForceExpandHints; +} + + +SwXMeta::SwXMeta(SwDoc *const pDoc) + : m_pImpl( new SwXMeta::Impl(*this, *pDoc, 0, 0, 0) ) +{ +} + +SwXMeta::~SwXMeta() +{ +} + +const uno::Sequence< sal_Int8 > & SwXMeta::getUnoTunnelId() +{ + static uno::Sequence< sal_Int8 > aSeq( ::CreateUnoTunnelId() ); + return aSeq; +} + +// XUnoTunnel +sal_Int64 SAL_CALL +SwXMeta::getSomething( const uno::Sequence< sal_Int8 > & i_rId ) +throw (uno::RuntimeException) +{ + if ( i_rId.getLength() == 16 && + 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), + i_rId.getConstArray(), 16 ) ) + { + return sal::static_int_cast< sal_Int64 >( + reinterpret_cast< sal_IntPtr >(this) ); + } + return 0; +} + +// XServiceInfo +::rtl::OUString SAL_CALL +SwXMeta::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXMeta"); +} + +sal_Bool SAL_CALL +SwXMeta::supportsService(const ::rtl::OUString& rServiceName) +throw (uno::RuntimeException) +{ + return rServiceName.equalsAscii("com.sun.star.text.TextContent") + || rServiceName.equalsAscii("com.sun.star.text.InContentMetadata"); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL +SwXMeta::getSupportedServiceNames() throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aRet(2); + aRet[0] = C2U("com.sun.star.text.TextContent"); + aRet[1] = C2U("com.sun.star.text.InContentMetadata"); + return aRet; +} + + +// XComponent +void SAL_CALL +SwXMeta::addEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + m_pImpl->m_ListenerContainer.AddListener(xListener); + if (m_pImpl->m_bIsDisposed) + { + m_pImpl->m_ListenerContainer.Disposing(); + } +} + +void SAL_CALL +SwXMeta::removeEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (!m_pImpl->m_bIsDisposed) + { + m_pImpl->m_ListenerContainer.RemoveListener(xListener); + } +} + +void SAL_CALL +SwXMeta::dispose() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDescriptor) + { + m_pImpl->m_pTextPortions.reset(); + m_pImpl->m_ListenerContainer.Disposing(); + m_pImpl->m_bIsDisposed = true; + m_pImpl->m_Text.Invalidate(); + } + else if (!m_pImpl->m_bIsDisposed) + { + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd)); + ASSERT(bSuccess, "no pam?"); + if (bSuccess) + { + // -1 because of CH_TXTATR + SwPaM aPam( *pTxtNode, nMetaStart - 1, *pTxtNode, nMetaEnd ); + SwDoc * const pDoc( pTxtNode->GetDoc() ); + pDoc->DeleteAndJoin( aPam ); + + // removal should call Modify and do the dispose + OSL_ENSURE(m_pImpl->m_bIsDisposed, "zombie meta"); + } + } +} + + +void SAL_CALL +SwXMeta::AttachImpl(const uno::Reference< text::XTextRange > & i_xTextRange, + const USHORT i_nWhich) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDisposed) + { + throw lang::DisposedException(); + } + if (!m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException( + C2S("SwXMeta::attach(): already attached"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + uno::Reference<lang::XUnoTunnel> xRangeTunnel(i_xTextRange, uno::UNO_QUERY); + if (!xRangeTunnel.is()) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): argument is no XUnoTunnel"), + static_cast< ::cppu::OWeakObject* >(this), 0); + } + SwXTextRange * const pRange( + reinterpret_cast< SwXTextRange * >( + sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( + SwXTextRange::getUnoTunnelId() ))) ); + OTextCursorHelper * const pCursor( pRange ? 0 : + reinterpret_cast< OTextCursorHelper * >( + sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( + OTextCursorHelper::getUnoTunnelId() ))) ); + if (!pRange && !pCursor) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): argument not supported type"), + static_cast< ::cppu::OWeakObject* >(this), 0); + } + + SwDoc * const pDoc( + pRange ? pRange->GetDoc() : pCursor ? pCursor->GetDoc() : 0 ); + if (!pDoc) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): argument has no SwDoc"), + static_cast< ::cppu::OWeakObject* >(this), 0); + } + + SwUnoInternalPaM aPam(*pDoc); + SwXTextRange::XTextRangeToSwPaM(aPam, i_xTextRange); + + UnoActionContext aContext(pDoc); + + SwXTextCursor const*const pTextCursor( + dynamic_cast<SwXTextCursor*>(pCursor)); + const bool bForceExpandHints((pTextCursor) + ? pTextCursor->IsAtEndOfMeta() : false); + const SetAttrMode nInsertFlags( (bForceExpandHints) + ? ( nsSetAttrMode::SETATTR_FORCEHINTEXPAND + | nsSetAttrMode::SETATTR_DONTEXPAND) + : nsSetAttrMode::SETATTR_DONTEXPAND ); + + const ::boost::shared_ptr< ::sw::Meta> pMeta( (RES_TXTATR_META == i_nWhich) + ? ::boost::shared_ptr< ::sw::Meta>( new ::sw::Meta() ) + : ::boost::shared_ptr< ::sw::Meta>( + pDoc->GetMetaFieldManager().makeMetaField()) ); + SwFmtMeta meta(pMeta, i_nWhich); // this is cloned by Insert! + const bool bSuccess( pDoc->InsertPoolItem( aPam, meta, nInsertFlags ) ); + SwTxtAttr * const pTxtAttr( pMeta->GetTxtAttr() ); + if (!bSuccess) + { + throw lang::IllegalArgumentException( + C2S("SwXMeta::attach(): cannot create meta: range invalid?"), + static_cast< ::cppu::OWeakObject* >(this), 1); + } + if (!pTxtAttr) + { + ASSERT(false, "meta inserted, but has no text attribute?"); + throw uno::RuntimeException( + C2S("SwXMeta::attach(): cannot create meta"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + pMeta->Add(this); + + m_pImpl->m_xParentText = + SwXTextRange::CreateParentXText(pDoc, *aPam.GetPoint()); + + m_pImpl->m_bIsDescriptor = false; +} + +// XTextContent +void SAL_CALL +SwXMeta::attach(const uno::Reference< text::XTextRange > & i_xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + return SwXMeta::AttachImpl(i_xTextRange, RES_TXTATR_META); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMeta::getAnchor() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDisposed) + { + throw lang::DisposedException(); + } + if (m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException( + C2S("SwXMeta::getAnchor(): not inserted"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd)); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + { + throw lang::DisposedException( + C2S("SwXMeta::getAnchor(): not attached"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + const SwPosition start(*pTxtNode, nMetaStart - 1); // -1 due to CH_TXTATR + const SwPosition end(*pTxtNode, nMetaEnd); + return SwXTextRange::CreateTextRangeFromPosition( + pTxtNode->GetDoc(), start, &end); +} + +// XTextRange +uno::Reference< text::XText > SAL_CALL +SwXMeta::getText() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + //TODO probably this should return outer meta in case there is nesting, + // but currently that is not done; would need to change at least + // SwXTextPortionEnumeration and SwXMeta::attach and other places where + // SwXMeta is constructed + return GetParentText(); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMeta::getStart() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.getStart(); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMeta::getEnd() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.getEnd(); +} + +rtl::OUString SAL_CALL +SwXMeta::getString() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.getString(); +} + +void SAL_CALL +SwXMeta::setString(const rtl::OUString& rString) throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.setString(rString); +} + +// XSimpleText +uno::Reference< text::XTextCursor > SAL_CALL +SwXMeta::createTextCursor() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.createTextCursor(); +} + +uno::Reference< text::XTextCursor > SAL_CALL +SwXMeta::createTextCursorByRange( + const uno::Reference<text::XTextRange> & xTextPosition) + throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.createTextCursorByRange(xTextPosition); +} + +void SAL_CALL +SwXMeta::insertString(const uno::Reference<text::XTextRange> & xRange, + const rtl::OUString& rString, sal_Bool bAbsorb) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.insertString(xRange, rString, bAbsorb); +} + +void SAL_CALL +SwXMeta::insertControlCharacter(const uno::Reference<text::XTextRange> & xRange, + sal_Int16 nControlCharacter, sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.insertControlCharacter(xRange, nControlCharacter, + bAbsorb); +} + +// XText +void SAL_CALL +SwXMeta::insertTextContent( const uno::Reference<text::XTextRange> & xRange, + const uno::Reference<text::XTextContent> & xContent, sal_Bool bAbsorb) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.insertTextContent(xRange, xContent, bAbsorb); +} + +void SAL_CALL +SwXMeta::removeTextContent( + const uno::Reference< text::XTextContent > & xContent) + throw (container::NoSuchElementException, uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + return m_pImpl->m_Text.removeTextContent(xContent); +} + +// XElementAccess +uno::Type SAL_CALL +SwXMeta::getElementType() throw (uno::RuntimeException) +{ + return text::XTextRange::static_type(); +} + +sal_Bool SAL_CALL +SwXMeta::hasElements() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + return GetRegisteredIn() ? sal_True : sal_False; +} + +// XEnumerationAccess +uno::Reference< container::XEnumeration > SAL_CALL +SwXMeta::createEnumeration() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (m_pImpl->m_bIsDisposed) + { + throw lang::DisposedException(); + } + if (m_pImpl->m_bIsDescriptor) + { + throw uno::RuntimeException( + C2S("getAnchor(): not inserted"), + static_cast< ::cppu::OWeakObject* >(this)); + } + + SwTxtNode * pTxtNode; + xub_StrLen nMetaStart; + xub_StrLen nMetaEnd; + const bool bSuccess(SetContentRange(pTxtNode, nMetaStart, nMetaEnd)); + ASSERT(bSuccess, "no pam?"); + if (!bSuccess) + throw lang::DisposedException(); + + SwPaM aPam(*pTxtNode, nMetaStart); + + if (!m_pImpl->m_pTextPortions.get()) + { + return new SwXTextPortionEnumeration( + aPam, GetParentText(), nMetaStart, nMetaEnd); + } + else // cached! + { + return new SwXTextPortionEnumeration(aPam, *m_pImpl->m_pTextPortions); + } +} + + +// MetadatableMixin +::sfx2::Metadatable* SwXMeta::GetCoreObject() +{ + return const_cast< ::sw::Meta * >(GetMeta()); +} + +uno::Reference<frame::XModel> SwXMeta::GetModel() +{ + ::sw::Meta const * const pMeta( GetMeta() ); + if (pMeta) + { + SwTxtNode const * const pTxtNode( pMeta->GetTxtNode() ); + if (pTxtNode) + { + SwDocShell const * const pShell(pTxtNode->GetDoc()->GetDocShell()); + return (pShell) ? pShell->GetModel() : 0; + } + } + return 0; +} + +// SwModify +void SwXMeta::Modify( SfxPoolItem *pOld, SfxPoolItem *pNew ) +{ + m_pImpl->m_pTextPortions.reset(); // throw away cache (SwTxtNode changed) + + ClientModify(this, pOld, pNew); + + if (!GetRegisteredIn()) // removed => dispose + { + m_pImpl->m_ListenerContainer.Disposing(); + m_pImpl->m_bIsDisposed = true; + m_pImpl->m_Text.Invalidate(); + } +} + + +/****************************************************************** + * SwXMetaField + ******************************************************************/ + +inline const ::sw::MetaField * SwXMetaField::GetMetaField() const +{ + return static_cast< const ::sw::MetaField * >(GetRegisteredIn()); +} + +SwXMetaField::SwXMetaField(SwDoc *const pDoc, + uno::Reference<text::XText> const& xParentText, + TextRangeList_t * const pPortions, SwTxtMeta * const pHint) + : SwXMetaFieldBaseClass(pDoc, xParentText, pPortions, pHint) +{ + ASSERT(!pHint || RES_TXTATR_METAFIELD == pHint->Which(), + "SwXMetaField created for wrong hint!"); +} + +SwXMetaField::SwXMetaField(SwDoc *const pDoc) + : SwXMetaFieldBaseClass(pDoc) +{ +} + +SwXMetaField::~SwXMetaField() +{ +} + +// XServiceInfo +::rtl::OUString SAL_CALL +SwXMetaField::getImplementationName() throw (uno::RuntimeException) +{ + return C2U("SwXMetaField"); +} + +sal_Bool SAL_CALL +SwXMetaField::supportsService(const ::rtl::OUString& rServiceName) +throw (uno::RuntimeException) +{ + return rServiceName.equalsAscii("com.sun.star.text.TextContent") + || rServiceName.equalsAscii("com.sun.star.text.TextField") + || rServiceName.equalsAscii("com.sun.star.text.textfield.MetadataField"); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL +SwXMetaField::getSupportedServiceNames() throw (uno::RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aRet(3); + aRet[0] = C2U("com.sun.star.text.TextContent"); + aRet[1] = C2U("com.sun.star.text.TextField"); + aRet[2] = C2U("com.sun.star.text.textfield.MetadataField"); + return aRet; +} + +// XComponent +void SAL_CALL +SwXMetaField::addEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + return SwXMeta::addEventListener(xListener); +} + +void SAL_CALL +SwXMetaField::removeEventListener( + uno::Reference< lang::XEventListener> const & xListener ) +throw (uno::RuntimeException) +{ + return SwXMeta::removeEventListener(xListener); +} + +void SAL_CALL +SwXMetaField::dispose() throw (uno::RuntimeException) +{ + return SwXMeta::dispose(); +} + +// XTextContent +void SAL_CALL +SwXMetaField::attach(const uno::Reference< text::XTextRange > & i_xTextRange) +throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + return SwXMeta::AttachImpl(i_xTextRange, RES_TXTATR_METAFIELD); +} + +uno::Reference< text::XTextRange > SAL_CALL +SwXMetaField::getAnchor() throw (uno::RuntimeException) +{ + return SwXMeta::getAnchor(); +} + +// XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL +SwXMetaField::getPropertySetInfo() throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + static uno::Reference< beans::XPropertySetInfo > xRef( + aSwMapProvider.GetPropertySet(PROPERTY_MAP_METAFIELD) + ->getPropertySetInfo() ); + return xRef; +} + +void SAL_CALL +SwXMetaField::setPropertyValue( + const ::rtl::OUString& rPropertyName, const uno::Any& rValue) +throw (beans::UnknownPropertyException, beans::PropertyVetoException, + lang::IllegalArgumentException, lang::WrappedTargetException, + uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + ::sw::MetaField * const pMeta( + const_cast< ::sw::MetaField * >(GetMetaField()) ); + if (!pMeta) + throw lang::DisposedException(); + + if (rPropertyName.equalsAscii("NumberFormat")) + { + sal_Int32 nNumberFormat(0); + if (rValue >>= nNumberFormat) + { + pMeta->SetNumberFormat(static_cast<sal_uInt32>(nNumberFormat)); + } + } + else if (rPropertyName.equalsAscii("IsFixedLanguage")) + { + bool b(false); + if (rValue >>= b) + { + pMeta->SetIsFixedLanguage(b); + } + } + else + { + throw beans::UnknownPropertyException(); + } +} + +uno::Any SAL_CALL +SwXMetaField::getPropertyValue(const ::rtl::OUString& rPropertyName) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + ::sw::MetaField const * const pMeta( GetMetaField() ); + if (!pMeta) + throw lang::DisposedException(); + + uno::Any any; + + if (rPropertyName.equalsAscii("NumberFormat")) + { + const ::rtl::OUString text( getPresentation(sal_False) ); + any <<= static_cast<sal_Int32>(pMeta->GetNumberFormat(text)); + } + else if (rPropertyName.equalsAscii("IsFixedLanguage")) + { + any <<= pMeta->IsFixedLanguage(); + } + else + { + throw beans::UnknownPropertyException(); + } + + return any; +} + +void SAL_CALL +SwXMetaField::addPropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::addPropertyChangeListener(): not implemented"); +} + +void SAL_CALL +SwXMetaField::removePropertyChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::removePropertyChangeListener(): not implemented"); +} + +void SAL_CALL +SwXMetaField::addVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::addVetoableChangeListener(): not implemented"); +} + +void SAL_CALL +SwXMetaField::removeVetoableChangeListener( + const ::rtl::OUString& /*rPropertyName*/, + const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/) +throw (beans::UnknownPropertyException, lang::WrappedTargetException, + uno::RuntimeException) +{ + OSL_ENSURE(false, + "SwXMetaField::removeVetoableChangeListener(): not implemented"); +} + +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> +#include <com/sun/star/rdf/Statement.hpp> +#include <com/sun/star/rdf/URI.hpp> +#include <com/sun/star/rdf/URIs.hpp> +#include <com/sun/star/rdf/XLiteral.hpp> +#include <com/sun/star/rdf/XRepositorySupplier.hpp> +#include <comphelper/processfactory.hxx> + +static uno::Reference<rdf::XURI> const& +lcl_getURI(const bool bPrefix) +{ + static uno::Reference< uno::XComponentContext > xContext( + ::comphelper::getProcessComponentContext()); + static uno::Reference< rdf::XURI > xOdfPrefix( + rdf::URI::createKnown(xContext, rdf::URIs::ODF_PREFIX), + uno::UNO_SET_THROW); + static uno::Reference< rdf::XURI > xOdfSuffix( + rdf::URI::createKnown(xContext, rdf::URIs::ODF_SUFFIX), + uno::UNO_SET_THROW); + return (bPrefix) ? xOdfPrefix : xOdfSuffix; +} + +static ::rtl::OUString +lcl_getPrefixOrSuffix( + uno::Reference<rdf::XRepository> const & xRepository, + uno::Reference<rdf::XResource> const & xMetaField, + uno::Reference<rdf::XURI> const & xPredicate) +{ + const uno::Reference<container::XEnumeration> xEnum( + xRepository->getStatements(xMetaField, xPredicate, 0), + uno::UNO_SET_THROW); + while (xEnum->hasMoreElements()) { + rdf::Statement stmt; + if (!(xEnum->nextElement() >>= stmt)) { + throw uno::RuntimeException(); + } + const uno::Reference<rdf::XLiteral> xObject(stmt.Object, + uno::UNO_QUERY); + if (!xObject.is()) continue; + if (xEnum->hasMoreElements()) { + OSL_TRACE("ignoring other odf:Prefix/odf:Suffix statements"); + } + return xObject->getValue(); + } + return ::rtl::OUString(); +} + +void +getPrefixAndSuffix( + const uno::Reference<frame::XModel>& xModel, + const uno::Reference<rdf::XMetadatable>& xMetaField, + ::rtl::OUString *const o_pPrefix, ::rtl::OUString *const o_pSuffix) +{ + try { + const uno::Reference<rdf::XRepositorySupplier> xRS( + xModel, uno::UNO_QUERY_THROW); + const uno::Reference<rdf::XRepository> xRepo( + xRS->getRDFRepository(), uno::UNO_SET_THROW); + const uno::Reference<rdf::XResource> xMeta( + xMetaField, uno::UNO_QUERY_THROW); + if (o_pPrefix) + { + *o_pPrefix = lcl_getPrefixOrSuffix(xRepo, xMeta, lcl_getURI(true)); + } + if (o_pSuffix) + { + *o_pSuffix = lcl_getPrefixOrSuffix(xRepo, xMeta, lcl_getURI(false)); + } + } catch (uno::RuntimeException &) { + throw; + } catch (uno::Exception & e) { + throw lang::WrappedTargetRuntimeException( + ::rtl::OUString::createFromAscii("getPrefixAndSuffix: exception"), + 0, uno::makeAny(e)); + } +} + +// XTextField +::rtl::OUString SAL_CALL +SwXMetaField::getPresentation(sal_Bool bShowCommand) +throw (uno::RuntimeException) +{ + vos::OGuard g(Application::GetSolarMutex()); + + if (bShowCommand) + { +//FIXME ? + return ::rtl::OUString(); + } + else + { + // getString should check if this is invalid + const ::rtl::OUString content( this->getString() ); + ::rtl::OUString prefix; + ::rtl::OUString suffix; + getPrefixAndSuffix(GetModel(), this, &prefix, &suffix); + return prefix + content + suffix; + } +} + diff --git a/sw/source/core/unocore/unosect.cxx b/sw/source/core/unocore/unosect.cxx index fc5c8984c3..55b6fc7d0f 100644 --- a/sw/source/core/unocore/unosect.cxx +++ b/sw/source/core/unocore/unosect.cxx @@ -461,7 +461,7 @@ void SwXTextSection::attachToRange(const uno::Reference< text::XTextRange > & xT if (pProps->aPassword.getLength() > 0) aSect.SetPasswd(pProps->aPassword); - pRet = pDoc->Insert( aPam, aSect, aSet.Count() ? &aSet : 0 ); + pRet = pDoc->InsertSwSection( aPam, aSect, aSet.Count() ? &aSet : 0 ); // now create the client m_refCount++; // keep block to remove Reference before the refcount is decremented diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx index 192e3a1aec..4caa5a735e 100644 --- a/sw/source/core/unocore/unosett.cxx +++ b/sw/source/core/unocore/unosett.cxx @@ -2041,8 +2041,7 @@ void SwXNumberingRules::SetNumberingRuleByIndex( case 15: //"BulletId", { sal_Int16 nSet = 0; - pData->aVal >>= nSet; - if(nSet < 0xff) + if( pData->aVal >>= nSet ) aFmt.SetBulletChar(nSet); else bWrongArg = sal_True; diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index ad6154f533..73d08d7cf5 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -45,6 +45,7 @@ #include <unoidx.hxx> #include <unoframe.hxx> #include <unofield.hxx> +#include <unometa.hxx> #include <unodraw.hxx> #include <unoredline.hxx> #include <unomap.hxx> @@ -58,7 +59,6 @@ #include <swundo.hxx> #include <section.hxx> #include <IMark.hxx> -#include <fmthbsh.hxx> #include <fmtanchr.hxx> #include <crsskip.hxx> #include <ndtxt.hxx> @@ -77,6 +77,21 @@ const sal_Char cInvalidObject[] = "this object is invalid"; -----------------------------------------------------------------------*/ +void SwXText::PrepareForAttach( ::com::sun::star::uno::Reference< + ::com::sun::star::text::XTextRange > &, + const SwXTextRange* const, const SwPaM * const) +{ +} + +bool SwXText::CheckForOwnMemberMeta(const SwXTextRange* const, + const SwPaM* const, bool) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::uno::RuntimeException) +{ + ASSERT(CURSOR_META != eCrsrType, "should not be called!"); + return false; +} + const SwStartNode *SwXText::GetStartNode() const { return GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode(); @@ -85,12 +100,12 @@ const SwStartNode *SwXText::GetStartNode() const uno::Reference< text::XTextCursor > SwXText::createCursor() throw (uno::RuntimeException) { uno::Reference< text::XTextCursor > xRet; - OUString sRet; if(IsValid()) { SwNode& rNode = GetDoc()->GetNodes().GetEndOfContent(); SwPosition aPos(rNode); - xRet = (text::XWordCursor*)new SwXTextCursor(this, aPos, GetTextType(), GetDoc()); + xRet = static_cast<text::XWordCursor*>( + new SwXTextCursor(this, aPos, GetTextType(), GetDoc())); xRet->gotoStart(sal_False); } return xRet; @@ -278,12 +293,41 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, if(!pOwnStartNode || pOwnStartNode != pTmp) throw uno::RuntimeException(); } + bool bForceExpandHints( false ); + if (CURSOR_META == eCrsrType) + { + try + { + bForceExpandHints = CheckForOwnMemberMeta( + pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb); + } + catch (lang::IllegalArgumentException & iae) + { + // stupid method not allowed to throw iae + throw uno::RuntimeException(iae.Message, 0); + } + } if(bAbsorb) { //!! scan for CR characters and inserting the paragraph breaks //!! has to be done in the called function. //!! Implemented in SwXTextRange::DeleteAndInsert - xTextRange->setString(aString); + if (pCursor) + { + SwXTextCursor * const pTextCursor( dynamic_cast<SwXTextCursor*>(pCursor) ); + if (pTextCursor) + { + pTextCursor->DeleteAndInsert(aString, bForceExpandHints); + } + else + { + xTextRange->setString(aString); + } + } + else + { + pRange->DeleteAndInsert(aString, bForceExpandHints); + } } else { @@ -294,10 +338,11 @@ void SwXText::insertString(const uno::Reference< text::XTextRange >& xTextRange, ? pCursor->GetPaM()->Start() : &pRange->GetBookmark()->GetMarkStart(); SwPaM aInsertPam(*pPos); - sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); + const sal_Bool bGroupUndo = GetDoc()->DoesGroupUndo(); GetDoc()->DoGroupUndo(sal_False); - SwUnoCursorHelper::DocInsertStringSplitCR(*GetDoc(), aInsertPam, aString); + SwUnoCursorHelper::DocInsertStringSplitCR( + *GetDoc(), aInsertPam, aString, bForceExpandHints ); GetDoc()->DoGroupUndo(bGroupUndo); } } @@ -316,15 +361,29 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & throw( lang::IllegalArgumentException, uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - if(GetDoc() && xTextRange.is()) + if (!xTextRange.is()) + throw lang::IllegalArgumentException(); + if (GetDoc()) { SwUnoInternalPaM aPam(*GetDoc()); if(SwXTextRange::XTextRangeToSwPaM(aPam, xTextRange)) { + const bool bForceExpandHints( + CheckForOwnMemberMeta( 0, &aPam, bAbsorb) ); + + const enum IDocumentContentOperations::InsertFlags nInsertFlags = + (bForceExpandHints) + ? static_cast<IDocumentContentOperations::InsertFlags>( + IDocumentContentOperations::INS_FORCEHINTEXPAND | + IDocumentContentOperations::INS_EMPTYEXPAND) + : IDocumentContentOperations::INS_EMPTYEXPAND; + //Steuerzeichen einfuegen SwPaM aTmp(*aPam.Start()); if(bAbsorb && aPam.HasMark()) + { pDoc->DeleteAndJoin(aPam); + } sal_Unicode cIns = 0; switch( nControlCharacter ) @@ -367,7 +426,9 @@ void SwXText::insertControlCharacter(const uno::Reference< text::XTextRange > & case text::ControlCharacter::HARD_SPACE: cIns = CHAR_HARDBLANK; break; } if( cIns ) - pDoc->Insert( aTmp, cIns ); + { + pDoc->InsertString( aTmp, cIns, nInsertFlags ); + } if(bAbsorb) { @@ -476,9 +537,9 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang ::sw::mark::IMark const * const pBkmk = pRange->GetBookmark(); pSrcNode = &pBkmk->GetMarkPos().nNode.GetNode(); } - else if (pPortion && pPortion->GetCrsr()) + else if (pPortion && pPortion->GetCursor()) { - pSrcNode = pPortion->GetCrsr()->GetNode(); + pSrcNode = pPortion->GetCursor()->GetNode(); } else if (pText) { @@ -511,9 +572,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang aRunException.Message = C2U("text interface and cursor not related"); throw aRunException; } + + const bool bForceExpandHints( CheckForOwnMemberMeta( + pRange, (pCursor) ? pCursor->GetPaM() : 0, bAbsorb) ); + // Sonderbehandlung fuer Contents, die den Range nicht ersetzen, sonder darueber gelegt werden // Bookmarks, IndexEntry - sal_Bool bAttribute = sal_False; uno::Reference<lang::XUnoTunnel> xContentTunnel( xContent, uno::UNO_QUERY); if(!xContentTunnel.is()) { @@ -529,8 +593,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXBookmark::getUnoTunnelId()) )); SwXReferenceMark* pReferenceMark = reinterpret_cast< SwXReferenceMark * >( sal::static_int_cast< sal_IntPtr >( xContentTunnel->getSomething( SwXReferenceMark::getUnoTunnelId()) )); + SwXMeta *const pMeta = reinterpret_cast< SwXMeta* >( + sal::static_int_cast< sal_IntPtr >( + xContentTunnel->getSomething( SwXMeta::getUnoTunnelId()))); - bAttribute = pBookmark || pDocumentIndexMark || pSection || pReferenceMark; + const bool bAttribute = pBookmark || pDocumentIndexMark + || pSection || pReferenceMark || pMeta; if(bAbsorb && !bAttribute) { @@ -542,6 +610,12 @@ void SwXText::insertTextContent(const uno::Reference< text::XTextRange > & xRang xTempRange = xRange; else xTempRange = xRange->getStart(); + if (bForceExpandHints) + { + // if necessary, replace xTempRange with a new SwXTextCursor + PrepareForAttach(xTempRange, pRange, + (pCursor) ? pCursor->GetPaM() : 0); + } xContent->attach(xTempRange); } else @@ -582,7 +656,7 @@ void SwXText::insertTextContentBefore( if(!pPara || !pPara->IsDescriptor() || !xSuccessor.is()) throw lang::IllegalArgumentException(); - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; @@ -636,7 +710,7 @@ void SwXText::insertTextContentAfter( SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; if(pTableFmt && pTableFmt->GetDoc() == GetDoc()) { SwTable* pTable = SwTable::FindTable( pTableFmt ); @@ -680,7 +754,7 @@ void SwXText::removeTextContentBefore( throw aRuntime; } - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xSuccessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation( xSuccessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; @@ -727,7 +801,7 @@ void SwXText::removeTextContentAfter(const uno::Reference< text::XTextContent>& throw aRuntime; } - sal_Bool bRet = FALSE; + sal_Bool bRet = sal_False; SwXTextSection* pXSection = SwXTextSection::GetImplementation( xPredecessor ); SwXTextTable* pXTable = SwXTextTable::GetImplementation(xPredecessor ); SwFrmFmt* pTableFmt = pXTable ? pXTable->GetFrmFmt() : 0; @@ -818,10 +892,8 @@ uno::Reference< text::XTextRange > SwXText::getEnd(void) throw( uno::RuntimeExc aRuntime.Message = C2U(cInvalidObject); throw aRuntime; } - else - xRef->gotoEnd(sal_False); - uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY);; - + xRef->gotoEnd(sal_False); + uno::Reference< text::XTextRange > xRet(xRef, uno::UNO_QUERY); return xRet; } /*-- 09.12.98 12:43:29--------------------------------------------------- @@ -856,6 +928,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) GetDoc()->StartUndo(UNDO_START, NULL); //insert an empty paragraph at the start and at the end to ensure that //all tables and sections can be removed by the selecting text::XTextCursor + if (CURSOR_META != eCrsrType) { SwPosition aStartPos(*pStartNode); const SwEndNode* pEnd = pStartNode->EndOfSectionNode(); @@ -903,6 +976,7 @@ void SwXText::setString(const OUString& aString) throw( uno::RuntimeException ) GetDoc()->EndUndo(UNDO_END, NULL); } +//FIXME why is CheckForOwnMember duplicated in some insert methods? // Description: Checks if pRange/pCursor are member of the same text interface. // Only one of the pointers has to be set! sal_Bool SwXText::CheckForOwnMember( @@ -1361,7 +1435,8 @@ uno::Reference< text::XTextRange > SwXText::appendTextPortion( if(rText.getLength()) { xub_StrLen nContentPos = pCursor->GetPoint()->nContent.GetIndex(); - SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText ); + SwUnoCursorHelper::DocInsertStringSplitCR( *pDoc, *pCursor, rText, + false ); SwXTextCursor::SelectPam(*pCursor, sal_True); pCursor->GetPoint()->nContent = nContentPos; } diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index e284204796..fa038871c0 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1347,7 +1347,15 @@ BOOL ViewShell::SmoothScroll( long lXDiff, long lYDiff, const Rectangle *pRect ) // #i75172# isolated static conditions const bool bOnlyYScroll(!lXDiff && Abs(lYDiff) != 0 && Abs(lYDiff) < lMax); const bool bAllowedWithChildWindows(GetWin()->GetWindowClipRegionPixel(WINDOW_GETCLIPREGION_NOCHILDREN|WINDOW_GETCLIPREGION_NULL).IsNull()); +// --> OD 2009-08-12 #i98766# - disable smooth scrolling for Mac port builds +#ifdef QUARTZ + const bool bSmoothScrollAllowed(false); + (void) bOnlyYScroll; + (void) bAllowedWithChildWindows; +#else const bool bSmoothScrollAllowed(bOnlyYScroll && bEnableSmooth && GetViewOptions()->IsSmoothScroll() && bAllowedWithChildWindows); +#endif +// <- const bool bIAmCursorShell(ISA(SwCrsrShell)); (void) bIAmCursorShell; @@ -1744,7 +1752,7 @@ void ViewShell::_PaintDesktop( const SwRegionRects &rRegion ) // (3) expand DLPostPaint2 with a flag to signal if FormControl paints shall // be done or not // - // Currently, (3) will be the best possible solution. It will keep overlay and + // Currently, (3) will be the best possible solution. It will keep overlay and // buffering intact and work without MapMode for single pages. In the medium // to long run, (1) will need to be used and the bool bPaintFormLayer needs // to be removed again @@ -1971,6 +1979,11 @@ void ViewShell::Paint(const Rectangle &rRect) //angemeldet hat, so muessen Repaints ausgeloest werden. if ( !CheckInvalidForPaint( aRect ) ) { + // --> OD 2009-08-12 #i101192# + // start Pre/PostPaint encapsulation to avoid screen blinking + const Region aRepaintRegion(aRect.SVRect()); + DLPrePaint2(aRepaintRegion); + // <-- PaintDesktop( aRect ); //Falls sinnvoll gleich das alte InvalidRect verarbeiten bzw. //vernichten. @@ -1979,6 +1992,10 @@ void ViewShell::Paint(const Rectangle &rRect) ViewShell::bLstAct = TRUE; GetLayout()->Paint( aRect ); ViewShell::bLstAct = FALSE; + // --> OD 2009-08-12 #i101192# + // end Pre/PostPaint encapsulation + DLPostPaint2(true); + // <-- } //delete pSaveHdl; @@ -2213,12 +2230,12 @@ void ViewShell::ApplyViewOptions( const SwViewOption &rOpt ) { SwViewOption aOpt( *pSh->GetViewOptions() ); aOpt.SetFldName( rOpt.IsFldName() ); - aOpt.SetShowHiddenField( rOpt.IsShowHiddenField() ); + aOpt.SetShowHiddenField( rOpt.IsShowHiddenField() ); aOpt.SetShowHiddenPara( rOpt.IsShowHiddenPara() ); - aOpt.SetShowHiddenChar( rOpt.IsShowHiddenChar() ); - aOpt.SetViewLayoutBookMode( rOpt.IsViewLayoutBookMode() ); - aOpt.SetViewLayoutColumns( rOpt.GetViewLayoutColumns() ); - + aOpt.SetShowHiddenChar( rOpt.IsShowHiddenChar() ); + aOpt.SetViewLayoutBookMode( rOpt.IsViewLayoutBookMode() ); + aOpt.SetViewLayoutColumns( rOpt.GetViewLayoutColumns() ); + aOpt.SetPostIts(rOpt.IsPostIts()); if ( !(aOpt == *pSh->GetViewOptions()) ) pSh->ImplApplyViewOptions( aOpt ); pSh = (ViewShell*)pSh->GetNext(); @@ -2721,4 +2738,3 @@ const IDocumentOutlineNodes* ViewShell::getIDocumentOutlineNodesAccess() const return pDoc; } // <-- - diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx index 3c066aed10..98e18159a4 100644 --- a/sw/source/core/view/vprint.cxx +++ b/sw/source/core/view/vprint.cxx @@ -1,4 +1,5 @@ -/************************************************************************* +/************************************************************************** + * * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -61,6 +62,7 @@ #include <unotxdoc.hxx> #include <docsh.hxx> +#include <svtools/syslocale.hxx> #include <txtfld.hxx> #include <fmtfld.hxx> #include <fmtfsize.hxx> @@ -1271,7 +1273,9 @@ BOOL ViewShell::IsAnyFieldInDoc() const { const SwFmtFld* pFmtFld = (SwFmtFld*)pItem; const SwTxtFld* pTxtFld = pFmtFld->GetTxtFld(); - if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() ) + //#i101026# mod: do not include postits in field check + const SwField* pFld = pFmtFld->GetFld(); + if( pTxtFld && pTxtFld->GetTxtNode().GetNodes().IsDocNodes() && (pFld->Which() != RES_POSTITFLD)) return TRUE; } return FALSE; diff --git a/sw/source/filter/ascii/ascatr.cxx b/sw/source/filter/ascii/ascatr.cxx index 5d313e5905..10e85b5c08 100644 --- a/sw/source/filter/ascii/ascatr.cxx +++ b/sw/source/filter/ascii/ascatr.cxx @@ -88,20 +88,16 @@ xub_StrLen SwASC_AttrIter::SearchNext( xub_StrLen nStartPos ) const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); if( pTxtAttrs ) { - USHORT i; - xub_StrLen nPos; - const xub_StrLen * pPos; - // kann noch optimiert werden, wenn ausgenutzt wird, dass die TxtAttrs // nach der Anfangsposition geordnet sind. Dann muessten // allerdings noch 2 Indices gemerkt werden - for( i = 0; i < pTxtAttrs->Count(); i++ ) + for ( USHORT i = 0; i < pTxtAttrs->Count(); i++ ) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; - nPos = *pHt->GetStart(); // gibt erstes Attr-Zeichen - pPos = pHt->GetEnd(); - if( !pPos ) + if (pHt->HasDummyChar()) { + xub_StrLen nPos = *pHt->GetStart(); + if( nPos >= nStartPos && nPos <= nMinPos ) nMinPos = nPos; @@ -124,8 +120,7 @@ BOOL SwASC_AttrIter::OutAttr( xub_StrLen nSwPos ) for( i = 0; i < pTxtAttrs->Count(); i++ ) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; - const xub_StrLen * pEnd = pHt->GetEnd(); - if( !pEnd && nSwPos == *pHt->GetStart() ) + if ( pHt->HasDummyChar() && nSwPos == *pHt->GetStart() ) { bRet = TRUE; String sOut; @@ -135,10 +130,6 @@ BOOL SwASC_AttrIter::OutAttr( xub_StrLen nSwPos ) sOut = ((SwTxtFld*)pHt)->GetFld().GetFld()->Expand(); break; - case RES_TXTATR_HARDBLANK: - sOut = ((SwTxtHardBlank*)pHt)->GetChar(); - break; - case RES_TXTATR_FTN: { const SwFmtFtn& rFtn = pHt->GetFtn(); diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx index 96d23eabee..b713190564 100644 --- a/sw/source/filter/ascii/parasc.cxx +++ b/sw/source/filter/ascii/parasc.cxx @@ -261,7 +261,7 @@ ULONG SwASCIIParser::CallParser() // !!!!! ASSERT( !this, "Have to change - hard attr. to para. style" ); - pDoc->Insert( *pInsPam, *pItemSet, 0 ); + pDoc->InsertItemSet( *pInsPam, *pItemSet, 0 ); } } delete pItemSet, pItemSet = 0; @@ -467,7 +467,7 @@ ULONG SwASCIIParser::ReadChars() InsertText( String( pLastStt )); } pDoc->SplitNode( *pPam->GetPoint(), false ); - pDoc->Insert( *pPam, SvxFmtBreakItem( + pDoc->InsertPoolItem( *pPam, SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ), 0); pLastStt = pStt; nLineLen = 0; @@ -528,7 +528,7 @@ ULONG SwASCIIParser::ReadChars() void SwASCIIParser::InsertText( const String& rStr ) { - pDoc->Insert( *pPam, rStr, true ); + pDoc->InsertString( *pPam, rStr ); if( pItemSet && pBreakIt && nScript != ( SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX ) ) diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 25f50924a6..4e55ee6ce6 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -670,13 +670,13 @@ void CalculateFlySize(SfxItemSet& rFlySet, const SwNodeIndex& rAnchor, // if the first node dont contained any content, then // insert one char in it calc again and delete once again SwIndex aNdIdx( pFirstTxtNd ); - pFirstTxtNd->Insert( String::CreateFromAscii( + pFirstTxtNd->InsertText( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "MM" )), aNdIdx ); ULONG nAbsMinCnts; pFirstTxtNd->GetMinMaxSize( pFirstTxtNd->GetIndex(), nMinFrm, nMaxFrm, nAbsMinCnts ); aNdIdx -= 2; - pFirstTxtNd->Erase( aNdIdx, 2 ); + pFirstTxtNd->EraseText( aNdIdx, 2 ); } // Umrandung und Abstand zum Inhalt beachten diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx index 819fba7325..ab62e9d2ee 100644 --- a/sw/source/filter/html/htmlatr.cxx +++ b/sw/source/filter/html/htmlatr.cxx @@ -81,7 +81,6 @@ #include <txatbase.hxx> #include <frmatr.hxx> #include <charfmt.hxx> -#include <fmthbsh.hxx> #include <fmtfld.hxx> #include <doc.hxx> #include <pam.hxx> @@ -1801,8 +1800,8 @@ HTMLEndPosLst::HTMLEndPosLst( SwDoc *pD, SwDoc* pTempl, xub_StrLen nPos = 0; while( nPos < nEndPos ) { - sal_uInt16 nScript = pBreakIt->xBreak->getScriptType( rText, nPos ); - nPos = (xub_StrLen)pBreakIt->xBreak->endOfScript( rText, nPos, nScript ); + sal_uInt16 nScript = pBreakIt->GetBreakIter()->getScriptType( rText, nPos ); + nPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( rText, nPos, nScript ); aScriptChgLst.Insert( nPos, aScriptChgLst.Count() ); aScriptLst.Insert( nScript, aScriptLst.Count() ); } @@ -2495,7 +2494,7 @@ Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode ) if( RES_TXTATR_FIELD == pHt->Which() ) // Felder nicht continue; // ausgeben - if( pHt->GetEnd() ) + if ( pHt->GetEnd() && !pHt->HasDummyChar() ) { xub_StrLen nHtEnd = *pHt->GetEnd(), nHtStt = *pHt->GetStart(); @@ -2555,7 +2554,7 @@ Writer& OutHTML_SwTxtNode( Writer& rWrt, const SwCntntNode& rNode ) && nStrPos != nEnde ) { do { - if( pHt->GetEnd() ) + if ( pHt->GetEnd() && !pHt->HasDummyChar() ) { if( RES_CHRATR_KERNING == pHt->Which() && rHTMLWrt.IsHTMLMode(HTMLMODE_FIRSTLINE) && @@ -3041,15 +3040,6 @@ static Writer& OutHTML_SwFlyCnt( Writer& rWrt, const SfxPoolItem& rHt ) return rWrt; } -static Writer& OutHTML_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt ) -{ - HTMLOutContext aContext ( ((SwHTMLWriter&)rWrt).eDestEnc ); - HTMLOutFuncs::Out_Char( rWrt.Strm(), ((SwFmtHardBlank&)rHt).GetChar(), - aContext, - &((SwHTMLWriter&)rWrt).aNonConvertableCharacters); - HTMLOutFuncs::FlushToAscii( rWrt.Strm(), aContext ); - return rWrt; -} // Das ist jetzt unser Blink-Item. Blinkend wird eingeschaltet, indem man // das Item auf TRUE setzt! @@ -3416,7 +3406,7 @@ SwAttrFnTab aHTMLAttrFnTab = { /* RES_TXTATR_FLYCNT */ OutHTML_SwFlyCnt, /* RES_TXTATR_FTN */ OutHTML_SwFmtFtn, /* RES_TXTATR_SOFTHYPH */ 0, -/* RES_TXTATR_HARDBLANK*/ OutHTML_SwHardBlank, +/* RES_TXTATR_HARDBLANK*/ 0, /* RES_TXTATR_DUMMY1 */ 0, // Dummy: /* RES_TXTATR_DUMMY2 */ 0, // Dummy: diff --git a/sw/source/filter/html/htmlbas.cxx b/sw/source/filter/html/htmlbas.cxx index 3f3a5aa74a..1eab2c7fbc 100644 --- a/sw/source/filter/html/htmlbas.cxx +++ b/sw/source/filter/html/htmlbas.cxx @@ -47,6 +47,8 @@ #include <svtools/htmltokn.h> #include <svtools/htmlkywd.hxx> +#include <com/sun/star/document/XEventsSupplier.hpp> +#include <com/sun/star/uno/Reference.hxx> #include <fmtornt.hxx> #include <fmtfld.hxx> @@ -251,7 +253,7 @@ void SwHTMLParser::AddScriptSource() } } -void SwHTMLParser::InsertBasicDocEvent( USHORT nEvent, const String& rName, +void SwHTMLParser::InsertBasicDocEvent( rtl::OUString aEvent, const String& rName, ScriptType eScrType, const String& rScrType ) { @@ -270,8 +272,10 @@ void SwHTMLParser::InsertBasicDocEvent( USHORT nEvent, const String& rName, if( EXTENDED_STYPE == eScrType ) sScriptType = rScrType; + rtl::OUString aEventName; + SfxEventConfiguration* pECfg = SFX_APP()->GetEventConfig(); - pECfg->ConfigureEvent( nEvent, SvxMacro( sEvent, sScriptType, eScrType ), + pECfg->ConfigureEvent( aEvent, SvxMacro( sEvent, sScriptType, eScrType ), pDocSh ); } @@ -338,6 +342,10 @@ void SwHTMLWriter::OutBasic() SFX_APP()->LeaveBasicCall(); } +static const char* aEventNames[] = +{ + "OnLoad", "OnPrepareUnload", "OnFocus", "OnUnfocus" +}; void SwHTMLWriter::OutBasicBodyEvents() { @@ -345,14 +353,19 @@ void SwHTMLWriter::OutBasicBodyEvents() if( !pDocSh ) return; - SfxEventConfiguration* pECfg = SFX_APP()->GetEventConfig(); - ASSERT( pECfg, "Wo ist die Event-Konfiguration?" ); - if( !pECfg ) - return; + SvxMacroTableDtor *pDocTable = new SvxMacroTableDtor; + + uno::Reference< document::XEventsSupplier > xSup( pDocSh->GetModel(), uno::UNO_QUERY ); + uno::Reference < container::XNameReplace > xEvents = xSup->getEvents(); + for ( sal_Int32 i=0; i<4; i++ ) + { + SvxMacro* pMacro = SfxEventConfiguration::ConvertToMacro( xEvents->getByName( ::rtl::OUString::createFromAscii(aEventNames[i]) ), pDocSh, TRUE ); + if ( pMacro ) + pDocTable->Insert( aBodyEventTable[i].nEvent, pMacro ); + } - SvxMacroTableDtor *pMacTable = pECfg->GetDocEventTable( pDocSh ); - if( pMacTable && pMacTable->Count() ) - HTMLOutFuncs::Out_Events( Strm(), *pMacTable, aBodyEventTable, + if( pDocTable && pDocTable->Count() ) + HTMLOutFuncs::Out_Events( Strm(), *pDocTable, aBodyEventTable, bCfgStarBasic, eDestEnc, &aNonConvertableCharacters ); } diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx index 2a28f63b67..0017b15db7 100644 --- a/sw/source/filter/html/htmlfld.cxx +++ b/sw/source/filter/html/htmlfld.cxx @@ -547,7 +547,7 @@ void SwHTMLParser::NewField() } else { - pDoc->Insert( *pPam, SwFmtFld(*pFld), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld(*pFld), 0 ); delete pFld; } bInField = TRUE; @@ -585,7 +585,7 @@ void SwHTMLParser::EndField() break; } - pDoc->Insert( *pPam, SwFmtFld(*pField), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld(*pField), 0 ); delete pField; pField = 0; } diff --git a/sw/source/filter/html/htmlfldw.cxx b/sw/source/filter/html/htmlfldw.cxx index 0d961cf5e3..4027ddc7be 100644 --- a/sw/source/filter/html/htmlfldw.cxx +++ b/sw/source/filter/html/htmlfldw.cxx @@ -312,8 +312,8 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pFld, sal_Bool bNeedsCJKProcessing = sal_False; if( sExpand.Len() ) { - sal_uInt16 nScriptType = pBreakIt->xBreak->getScriptType( sExpand, 0 ); - xub_StrLen nPos = (xub_StrLen)pBreakIt->xBreak->endOfScript( sExpand, 0, + sal_uInt16 nScriptType = pBreakIt->GetBreakIter()->getScriptType( sExpand, 0 ); + xub_StrLen nPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( sExpand, 0, nScriptType ); sal_uInt16 nScript = @@ -361,10 +361,10 @@ static Writer& OutHTML_SwField( Writer& rWrt, const SwField* pFld, xub_StrLen nPos = 0; do { - sal_uInt16 nScriptType = pBreakIt->xBreak->getScriptType( sExpand, nPos ); + sal_uInt16 nScriptType = pBreakIt->GetBreakIter()->getScriptType( sExpand, nPos ); sal_uInt16 nScript = SwHTMLWriter::GetCSS1ScriptForScriptType( nScriptType ); - xub_StrLen nEndPos = (xub_StrLen)pBreakIt->xBreak->endOfScript( + xub_StrLen nEndPos = (xub_StrLen)pBreakIt->GetBreakIter()->endOfScript( sExpand, nPos, nScriptType ); if( nScript != CSS1_OUTMODE_ANY_SCRIPT && /* #108791# */ nScript != rHTMLWrt.nCSS1Script ) diff --git a/sw/source/filter/html/htmlfly.cxx b/sw/source/filter/html/htmlfly.cxx index f830276c77..880009e3a9 100644 --- a/sw/source/filter/html/htmlfly.cxx +++ b/sw/source/filter/html/htmlfly.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -1640,7 +1640,7 @@ static Writer& OutHTML_FrmFmtGrfNode( Writer& rWrt, const SwFrmFmt& rFrmFmt, ULONG nFrmFlags = bInCntnr ? HTML_FRMOPTS_IMG_CNTNR : HTML_FRMOPTS_IMG; if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bInCntnr ) nFrmFlags |= HTML_FRMOPTS_IMG_CSS1; - OutHTML_Image( rWrt, rFrmFmt, aGrfNm, pGrfNd->GetAlternateText(), + OutHTML_Image( rWrt, rFrmFmt, aGrfNm, pGrfNd->GetTitle(), pGrfNd->GetTwipSize(), nFrmFlags, pMarkToGraphic ); return rWrt; diff --git a/sw/source/filter/html/htmlftn.cxx b/sw/source/filter/html/htmlftn.cxx index f823fca63f..eb306d979c 100644 --- a/sw/source/filter/html/htmlftn.cxx +++ b/sw/source/filter/html/htmlftn.cxx @@ -228,11 +228,10 @@ void SwHTMLParser::FinishFootEndNote() if( pFootEndNoteImpl->bFixed ) aFtn.SetNumStr( pFootEndNoteImpl->sContent ); - pDoc->Insert( *pPam, aFtn, 0 ); - SwTxtFtn *pTxtFtn = - (SwTxtFtn *)pPam->GetNode()->GetTxtNode()->GetTxtAttr( - pPam->GetPoint()->nContent.GetIndex() - 1, - RES_TXTATR_FTN ); + pDoc->InsertPoolItem( *pPam, aFtn, 0 ); + SwTxtFtn * const pTxtFtn = static_cast<SwTxtFtn *>( + pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt( + pPam->GetPoint()->nContent.GetIndex() - 1, RES_TXTATR_FTN ) ); // In Kopf- und Fusszeilen duerfen keine Fussnoten eingefuegt werden. if( pTxtFtn ) { diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx index 5049afacd4..688ed149a5 100644 --- a/sw/source/filter/html/htmlgrin.cxx +++ b/sw/source/filter/html/htmlgrin.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -53,7 +53,7 @@ #include <svtools/imap.hxx> #include <svtools/htmltokn.h> #include <svtools/htmlkywd.hxx> - +#include <svtools/eventcfg.hxx> #include <fmtornt.hxx> #include <fmturl.hxx> @@ -743,7 +743,7 @@ IMAGE_SETEVENT: } if( sAltNm.Len() ) - pGrfNd->SetAlternateText( sAltNm ); + pGrfNd->SetTitle( sAltNm ); if( bSetTwipSize ) pGrfNd->SetTwipSize( aGrfSz ); @@ -841,7 +841,7 @@ void SwHTMLParser::InsertBodyOptions() { const HTMLOption *pOption = (*pHTMLOptions)[--i]; ScriptType eScriptType2 = eDfltScriptType; - USHORT nEvent = 0; + rtl::OUString aEvent; BOOL bSetEvent = FALSE; switch( pOption->GetToken() ) @@ -872,28 +872,28 @@ void SwHTMLParser::InsertBodyOptions() case HTML_O_SDONLOAD: eScriptType2 = STARBASIC; case HTML_O_ONLOAD: - nEvent = SFX_EVENT_OPENDOC; + aEvent = GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ); bSetEvent = TRUE; break; case HTML_O_SDONUNLOAD: eScriptType2 = STARBASIC; case HTML_O_ONUNLOAD: - nEvent = SFX_EVENT_PREPARECLOSEDOC; + aEvent = GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ); bSetEvent = TRUE; break; case HTML_O_SDONFOCUS: eScriptType2 = STARBASIC; case HTML_O_ONFOCUS: - nEvent = SFX_EVENT_ACTIVATEDOC; + aEvent = GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ); bSetEvent = TRUE; break; case HTML_O_SDONBLUR: eScriptType2 = STARBASIC; case HTML_O_ONBLUR: - nEvent = SFX_EVENT_DEACTIVATEDOC; + aEvent = GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ); bSetEvent = TRUE; break; @@ -919,7 +919,7 @@ void SwHTMLParser::InsertBodyOptions() { const String& rEvent = pOption->GetString(); if( rEvent.Len() ) - InsertBasicDocEvent( nEvent, rEvent, eScriptType2, + InsertBasicDocEvent( aEvent, rEvent, eScriptType2, sDfltScriptType ); } } @@ -1374,7 +1374,7 @@ void SwHTMLParser::StripTrailingPara() if( pPrvNd ) { SwIndex aSrc( pCNd, 0 ); - pCNd->GetTxtNode()->Cut( pPrvNd, aSrc, pCNd->Len() ); + pCNd->GetTxtNode()->CutText( pPrvNd, aSrc, pCNd->Len() ); } } @@ -1436,9 +1436,10 @@ void SwHTMLParser::StripTrailingPara() xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex(); while( bSetSmallFont && nPos>0 ) { - bSetSmallFont = CH_TXTATR_BREAKWORD == - pTxtNd->GetTxt().GetChar( --nPos ) && - 0 != pTxtNd->GetTxtAttr( nPos, RES_TXTATR_FLYCNT ); + --nPos; + bSetSmallFont = + (CH_TXTATR_BREAKWORD == pTxtNd->GetTxt().GetChar( nPos )) && + (0 != pTxtNd->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT )); } } diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx index 235c50e3aa..27852b37ab 100644 --- a/sw/source/filter/html/htmlplug.cxx +++ b/sw/source/filter/html/htmlplug.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -491,7 +491,7 @@ void SwHTMLParser::InsertEmbed() SwNoTxtNode *pNoTxtNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx() ->GetIndex()+1 ]->GetNoTxtNode(); - pNoTxtNd->SetAlternateText( aAlt ); + pNoTxtNd->SetTitle( aAlt ); // Ggf Frames anlegen und auto-geb. Rahmen registrieren if( !bHidden ) @@ -665,7 +665,7 @@ void SwHTMLParser::EndObject() SwNoTxtNode *pNoTxtNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx() ->GetIndex()+1 ]->GetNoTxtNode(); - pNoTxtNd->SetAlternateText( pAppletImpl->GetAltText() ); + pNoTxtNd->SetTitle( pAppletImpl->GetAltText() ); // Ggf Frames anlegen und auto-geb. Rahmen registrieren RegisterFlyFrm( pFlyFmt ); @@ -798,7 +798,7 @@ void SwHTMLParser::EndApplet() SwNoTxtNode *pNoTxtNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx() ->GetIndex()+1 ]->GetNoTxtNode(); - pNoTxtNd->SetAlternateText( pAppletImpl->GetAltText() ); + pNoTxtNd->SetTitle( pAppletImpl->GetAltText() ); // Ggf Frames anlegen und auto-geb. Rahmen registrieren RegisterFlyFrm( pFlyFmt ); @@ -975,7 +975,7 @@ void SwHTMLParser::InsertFloatingFrame() SwNoTxtNode *pNoTxtNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx() ->GetIndex()+1 ]->GetNoTxtNode(); - pNoTxtNd->SetAlternateText( aAlt ); + pNoTxtNd->SetTitle( aAlt ); // Ggf Frames anlegen und auto-geb. Rahmen registrieren RegisterFlyFrm( pFlyFmt ); @@ -1254,7 +1254,7 @@ Writer& OutHTML_FrmFmtOLENode( Writer& rWrt, const SwFrmFmt& rFrmFmt, // ALT, WIDTH, HEIGHT, HSPACE, VSPACE, ALIGN if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed ) nFrmOpts |= HTML_FRMOPTS_OLE_CSS1; - rHTMLWrt.OutFrmFmtOptions( rFrmFmt, pOLENd->GetAlternateText(), + rHTMLWrt.OutFrmFmtOptions( rFrmFmt, pOLENd->GetTitle(), aEndTags, nFrmOpts ); if( rHTMLWrt.IsHTMLMode( HTMLMODE_ABS_POS_FLY ) && !bHiddenEmbed ) rHTMLWrt.OutCSS1_FrmFmtOptions( rFrmFmt, nFrmOpts ); @@ -1398,7 +1398,7 @@ Writer& OutHTML_FrmFmtOLENodeGrf( Writer& rWrt, const SwFrmFmt& rFrmFmt, ULONG nFlags = bInCntnr ? HTML_FRMOPTS_GENIMG_CNTNR : HTML_FRMOPTS_GENIMG; OutHTML_Image( rWrt, rFrmFmt, aGrfNm, - pOLENd->GetAlternateText(), pOLENd->GetTwipSize(), + pOLENd->GetTitle(), pOLENd->GetTwipSize(), nFlags, pMarkToOLE ); } diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx index 0ab0427017..293a7f8a64 100644 --- a/sw/source/filter/html/htmlsect.cxx +++ b/sw/source/filter/html/htmlsect.cxx @@ -351,7 +351,7 @@ void SwHTMLParser::NewDivision( int nToken ) aItemSet.ClearItem( RES_FRAMEDIR ); } - pDoc->Insert( *pPam, aSection, &aFrmItemSet, sal_False ); + pDoc->InsertSwSection( *pPam, aSection, &aFrmItemSet, false ); // ggfs. einen Bereich anspringen if( JUMPTO_REGION == eJumpTo && aName == sJmpMark ) @@ -746,7 +746,7 @@ void SwHTMLParser::NewMultiCol() aFrmItemSet.Put( *pItem ); aItemSet.ClearItem( RES_FRAMEDIR ); } - pDoc->Insert( *pPam, aSection, &aFrmItemSet, sal_False ); + pDoc->InsertSwSection( *pPam, aSection, &aFrmItemSet, false ); // Jump to section, if this is requested. if( JUMPTO_REGION == eJumpTo && aName == sJmpMark ) diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index 2e9379b409..90489ff312 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -3030,7 +3030,7 @@ xub_StrLen SwHTMLParser::StripTrailingLF() nPos = nLen - nLFCount; SwIndex nIdx( pTxtNd, nPos ); - pTxtNd->Erase( nIdx, nLFCount ); + pTxtNd->EraseText( nIdx, nLFCount ); nStripped = nLFCount; } } @@ -5495,7 +5495,8 @@ HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust, pNd = pTblStNd->EndOfSectionNode(); SwNodeIndex aDstIdx( *pNd, bTop ? 0 : 1 ); - pDoc->Move( aSrcRg, aDstIdx, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aSrcRg, aDstIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // Wenn die Caption vor der Tabelle eingefuegt wurde muss // eine an der Tabelle gestzte Seitenvorlage noch in den diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 8d4edbde04..a883fa4207 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -79,7 +79,6 @@ #include <charatr.hxx> #include <fmtfld.hxx> #include <fmtpdsc.hxx> -#include <fmthbsh.hxx> #include <txtfld.hxx> #include <fmtanchr.hxx> #include <fmtsrnd.hxx> @@ -235,7 +234,7 @@ ULONG HTMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPam, const // sonst ist sie schon gesetzt. if( !rDoc.get(IDocumentSettingAccess::HTML_MODE) ) { - rDoc.Insert( rPam, SwFmtPageDesc( + rDoc.InsertPoolItem( rPam, SwFmtPageDesc( rDoc.GetPageDescFromPool( RES_POOLPAGE_HTML, false )), 0 ); } } @@ -1282,7 +1281,9 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) pPageDesc = pCSS1Parser->GetRightPageDesc(); if( pPageDesc ) - pDoc->Insert( *pPam, SwFmtPageDesc( pPageDesc ), 0 ); + { + pDoc->InsertPoolItem( *pPam, SwFmtPageDesc( pPageDesc ), 0 ); + } } break; @@ -1436,11 +1437,11 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) break; case HTML_NONBREAKSPACE: - pDoc->Insert( *pPam, CHAR_HARDBLANK ); + pDoc->InsertString( *pPam, CHAR_HARDBLANK ); break; case HTML_SOFTHYPH: - pDoc->Insert( *pPam, CHAR_SOFTHYPHEN ); + pDoc->InsertString( *pPam, CHAR_SOFTHYPHEN ); break; case HTML_LINEFEEDCHAR: @@ -1482,7 +1483,7 @@ void __EXPORT SwHTMLParser::NextToken( int nToken ) { if( !bDocInitalized ) DocumentDetected(); - pDoc->Insert( *pPam, aToken, true ); + pDoc->InsertString( *pPam, aToken ); // wenn es noch vorlaefige Absatz-Attribute gibt, der Absatz aber // nicht leer ist, dann sind die Absatz-Attribute entgueltig. @@ -2190,9 +2191,9 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) { const String& rText = pTxtNd->GetTxt(); sal_uInt16 nScriptTxt = - pBreakIt->xBreak->getScriptType( + pBreakIt->GetBreakIter()->getScriptType( rText, pAttr->GetSttCnt() ); - xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->xBreak + xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter() ->endOfScript( rText, nStt, nScriptTxt ); while( nScriptEnd < nEndCnt ) { @@ -2212,9 +2213,9 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) pNext->InsertPrev( pSetAttr ); } nStt = nScriptEnd; - nScriptTxt = pBreakIt->xBreak->getScriptType( + nScriptTxt = pBreakIt->GetBreakIter()->getScriptType( rText, nStt ); - nScriptEnd = (xub_StrLen)pBreakIt->xBreak + nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter() ->endOfScript( rText, nStt, nScriptTxt ); } bInsert = nScriptItem == nScriptTxt; @@ -2336,7 +2337,7 @@ BOOL SwHTMLParser::AppendTxtNode( SwHTMLAppendMode eMode, BOOL bUpdateNum ) // also delete the SwpHints!!! To avoid any trouble // we leave the loop immediately if this is the last // hint. - pTxtNd->Delete( pHt, sal_True ); + pTxtNd->DeleteAttribute( pHt ); if( 1 == nCntAttr ) break; i--; @@ -2821,7 +2822,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, eJumpTo = JUMPTO_NONE; } - pDoc->Insert( *pAttrPam, *pAttr->pItem, nsSetAttrMode::SETATTR_DONTREPLACE ); + pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, nsSetAttrMode::SETATTR_DONTREPLACE ); } pAttrPam->DeleteMark(); @@ -2903,7 +2904,7 @@ void SwHTMLParser::_SetAttr( BOOL bChkEnd, BOOL bBeforeTable, pAttrPam->Move( fnMoveBackward ); } - pDoc->Insert( *pAttrPam, *pAttr->pItem, 0 ); + pDoc->InsertPoolItem( *pAttrPam, *pAttr->pItem, 0 ); aFields.Remove( 0, 1 ); delete pAttr; @@ -3007,9 +3008,9 @@ void SwHTMLParser::EndAttr( _HTMLAttr* pAttr, _HTMLAttr **ppDepAttr, .GetTxtNode(); ASSERT( pTxtNd, "No text node" ); const String& rText = pTxtNd->GetTxt(); - sal_uInt16 nScriptTxt = pBreakIt->xBreak->getScriptType( + sal_uInt16 nScriptTxt = pBreakIt->GetBreakIter()->getScriptType( rText, pAttr->GetSttCnt() ); - xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->xBreak + xub_StrLen nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter() ->endOfScript( rText, pAttr->GetSttCnt(), nScriptTxt ); while( nScriptEnd < nEndCnt ) { @@ -3027,9 +3028,9 @@ void SwHTMLParser::EndAttr( _HTMLAttr* pAttr, _HTMLAttr **ppDepAttr, } } pAttr->nSttCntnt = nScriptEnd; - nScriptTxt = pBreakIt->xBreak->getScriptType( + nScriptTxt = pBreakIt->GetBreakIter()->getScriptType( rText, nScriptEnd ); - nScriptEnd = (xub_StrLen)pBreakIt->xBreak + nScriptEnd = (xub_StrLen)pBreakIt->GetBreakIter() ->endOfScript( rText, nScriptEnd, nScriptTxt ); } bInsert = nScriptItem == nScriptTxt; @@ -4941,7 +4942,7 @@ void SwHTMLParser::InsertSpacer() { NewAttr( &aAttrTab.pKerning, SvxKerningItem( (short)nSize, RES_CHRATR_KERNING ) ); String aTmp( ' ' ); - pDoc->Insert( *pPam, aTmp /*, CHARSET_ANSI*/, true ); + pDoc->InsertString( *pPam, aTmp ); EndAttr( aAttrTab.pKerning ); } } @@ -5149,7 +5150,7 @@ void SwHTMLParser::InsertLineBreak() // wenn kein CLEAR ausgefuehrt werden sollte oder konnte, wird // ein Zeilenumbruch eingef?gt String sTmp( (sal_Unicode)0x0a ); // make the Mac happy :-) - pDoc->Insert( *pPam, sTmp, true ); + pDoc->InsertString( *pPam, sTmp ); } else if( pPam->GetPoint()->nContent.GetIndex() ) { diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index 2559dfade4..9ba812b62e 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -782,7 +782,7 @@ private: void AddScriptSource(); // ein Event in die SFX-Konfiguation eintragen (htmlbas.cxx) - void InsertBasicDocEvent( sal_uInt16 nEvent, const String& rName, + void InsertBasicDocEvent( rtl::OUString aEventName, const String& rName, ScriptType eScrType, const String& rScrType ); // ein Event an ein VC-Control anhaengen (htmlform.cxx) diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx index f5655eb5b5..463a4305c4 100644 --- a/sw/source/filter/inc/fltshell.hxx +++ b/sw/source/filter/inc/fltshell.hxx @@ -88,7 +88,7 @@ public: void SetStartPos(const SwPosition & rStartPos); SW_DLLPUBLIC void SetEndPos( const SwPosition & rEndPos); - SW_DLLPUBLIC BOOL MakeRegion(SwDoc* pDoc, SwPaM& rRegion, BOOL bCheck ); + SW_DLLPUBLIC BOOL MakeRegion(SwDoc* pDoc, SwPaM& rRegion, BOOL bCheck ); }; class SW_DLLPUBLIC SwFltControlStack @@ -144,19 +144,37 @@ public: void DeleteAndDestroy(Entries::size_type nCnt); }; +class SwFltAnchorClient; + class SW_DLLPUBLIC SwFltAnchor : public SfxPoolItem { SwFrmFmt* pFrmFmt; + SwFltAnchorClient * pClient; + public: SwFltAnchor(SwFrmFmt* pFlyFmt); SwFltAnchor(const SwFltAnchor&); + virtual ~SwFltAnchor(); + // "pure virtual Methoden" vom SfxPoolItem virtual int operator==(const SfxPoolItem&) const; virtual SfxPoolItem* Clone(SfxItemPool* = 0) const; - const SwFrmFmt* GetFrmFmt() const { return pFrmFmt; } - SwFrmFmt* GetFrmFmt() { return pFrmFmt; } + void SetFrmFmt(SwFrmFmt * _pFrmFmt); + const SwFrmFmt* GetFrmFmt() const; + SwFrmFmt* GetFrmFmt(); +}; + +class SwFltAnchorClient : public SwClient +{ + SwFltAnchor * m_pFltAnchor; + +public: + SwFltAnchorClient(SwFltAnchor * pFltAnchor); + + virtual void Modify (SfxPoolItem *pOld, SfxPoolItem *pNew); }; + class SW_DLLPUBLIC SwFltRedline : public SfxPoolItem { public: diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx index d86d472662..f7688da6ec 100644 --- a/sw/source/filter/inc/msfilter.hxx +++ b/sw/source/filter/inc/msfilter.hxx @@ -146,9 +146,7 @@ namespace sw struct AuthorInfo; typedef AuthorInfo* AuthorInfo_Ptr; - //----------------------------------------- - // Redlining Authors - //----------------------------------------- + /// Redlining Authors struct AuthorInfo { USHORT nWWAuthorId; diff --git a/sw/source/filter/inc/wrtswtbl.hxx b/sw/source/filter/inc/wrtswtbl.hxx index 7660bbf0b6..7edf77ba37 100644 --- a/sw/source/filter/inc/wrtswtbl.hxx +++ b/sw/source/filter/inc/wrtswtbl.hxx @@ -34,6 +34,8 @@ #include <tools/color.hxx> #include <svtools/svarray.hxx> +#include <swdllapi.h> + class Color; class SwTableBox; class SwTableLine; @@ -299,6 +301,13 @@ protected: public: static long GetBoxWidth( const SwTableBox *pBox ); + + USHORT GetRawWidth( USHORT nCol, USHORT nColSpan ) const; + USHORT GetAbsWidth( USHORT nCol, USHORT nColSpan ) const; + USHORT GetRelWidth( USHORT nCol, USHORT nColSpan ) const; + USHORT GetPrcWidth( USHORT nCol, USHORT nColSpan ) const; + + long GetAbsHeight( long nRawWidth, USHORT nRow, USHORT nRowSpan ) const; protected: long GetLineHeight( const SwTableLine *pLine ); @@ -309,12 +318,6 @@ protected: USHORT GetLeftSpace( USHORT nCol ) const; USHORT GetRightSpace( USHORT nCol, USHORT nColSpan ) const; - USHORT GetRawWidth( USHORT nCol, USHORT nColSpan ) const; - USHORT GetAbsWidth( USHORT nCol, USHORT nColSpan ) const; - USHORT GetRelWidth( USHORT nCol, USHORT nColSpan ) const; - USHORT GetPrcWidth( USHORT nCol, USHORT nColSpan ) const; - - long GetAbsHeight( long nRawWidth, USHORT nRow, USHORT nRowSpan ) const; public: SwWriteTable( const SwTableLines& rLines, long nWidth, USHORT nBWidth, diff --git a/sw/source/filter/rtf/rtfatr.cxx b/sw/source/filter/rtf/rtfatr.cxx index 142efcd6d8..ba95d018ac 100644 --- a/sw/source/filter/rtf/rtfatr.cxx +++ b/sw/source/filter/rtf/rtfatr.cxx @@ -102,7 +102,6 @@ #include <fmtfld.hxx> #include <fmtflcnt.hxx> #include <fmtftn.hxx> -#include <fmthbsh.hxx> #include <fchrfmt.hxx> #include <fmtautofmt.hxx> #include <fmtcntnt.hxx> @@ -230,6 +229,8 @@ void OutRTF_SfxItemSet( SwRTFWriter& rWrt, const SfxItemSet& rSet, ( *pItem != rPool.GetDefaultItem( nWhich ) || ( rSet.GetParent() && *pItem != rSet.GetParent()->Get( nWhich ) ) + || ( rWrt.GetAttrSet() && + *pItem != rWrt.GetAttrSet()->Get( nWhich ) ) ) ) ; else @@ -1760,17 +1761,29 @@ static void OutSwTblBorder(SwRTFWriter& rWrt, const SvxBoxItem& rBox, { BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT }; +#ifdef __MINGW32__ + static const char* aBorderNames[] __attribute__((section(".data"))) = +#else static const char* aBorderNames[] = +#endif { OOO_STRING_SVTOOLS_RTF_CLBRDRT, OOO_STRING_SVTOOLS_RTF_CLBRDRL, OOO_STRING_SVTOOLS_RTF_CLBRDRB, OOO_STRING_SVTOOLS_RTF_CLBRDRR }; //Yes left and top are swapped with eachother for cell padding! Because //that's what the thunderingly annoying rtf export/import word xp does. +#ifdef __MINGW32__ + static const char* aCellPadNames[] __attribute__((section(".data"))) = +#else static const char* aCellPadNames[] = +#endif { OOO_STRING_SVTOOLS_RTF_CLPADL, OOO_STRING_SVTOOLS_RTF_CLPADT, OOO_STRING_SVTOOLS_RTF_CLPADB, OOO_STRING_SVTOOLS_RTF_CLPADR }; +#ifdef __MINGW32__ + static const char* aCellPadUnits[] __attribute__((section(".data"))) = +#else static const char* aCellPadUnits[] = +#endif { OOO_STRING_SVTOOLS_RTF_CLPADFL, OOO_STRING_SVTOOLS_RTF_CLPADFT, OOO_STRING_SVTOOLS_RTF_CLPADFB, OOO_STRING_SVTOOLS_RTF_CLPADFR }; @@ -1895,7 +1908,12 @@ Writer& OutRTF_SwTblNode(Writer& rWrt, const SwTableNode & rNode) const SwWriteTableCells& rCells = pRow->GetCells(); BOOL bFixRowHeight = false; - for( nColCnt = 0, nBox = 0; nBox < rCells.Count(); ++nColCnt ) + + USHORT nBoxes = rCells.Count(); + if (nColCnt < nBoxes) + nBoxes = nColCnt; + + for( nColCnt = 0, nBox = 0; nBox < rCells.Count() && nColCnt < nBoxes; ++nColCnt ) { SwWriteTableCell* pCell = rCells[ nBox ]; const bool bProcessCoveredCell = bNewTableModel && 0 == pCell->GetRowSpan(); @@ -1972,7 +1990,11 @@ Writer& OutRTF_SwTblNode(Writer& rWrt, const SwTableNode & rNode) { BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT }; +#ifdef __MINGW32__ + static const char* aRowPadNames[] __attribute__((section(".data"))) = +#else static const char* aRowPadNames[] = +#endif { OOO_STRING_SVTOOLS_RTF_TRPADDT, OOO_STRING_SVTOOLS_RTF_TRPADDL, OOO_STRING_SVTOOLS_RTF_TRPADDB, OOO_STRING_SVTOOLS_RTF_TRPADDR }; @@ -1994,7 +2016,7 @@ Writer& OutRTF_SwTblNode(Writer& rWrt, const SwTableNode & rNode) for( nBox = 0; nBox < nColCnt; ++nBox ) { SwWriteTableCell* pCell = pBoxArr[ nBox ]; - if( nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ] ) + if( (nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ]) || (pCell == NULL) ) continue; const SwFrmFmt& rFmt = *pCell->GetBox()->GetFrmFmt(); @@ -2045,15 +2067,17 @@ Writer& OutRTF_SwTblNode(Writer& rWrt, const SwTableNode & rNode) // Inhalt der Boxen ausgeben rWrt.Strm() << SwRTFWriter::sNewLine << OOO_STRING_SVTOOLS_RTF_PARD << OOO_STRING_SVTOOLS_RTF_INTBL; - for( nBox = 0; nBox < nColCnt; ++nBox ) + for( nBox = 0; nBox < nBoxes; ++nBox ) { - if( nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ] ) + SwWriteTableCell * pCell = pBoxArr[nBox]; + + if( (nBox && pBoxArr[ nBox-1 ] == pBoxArr[ nBox ]) || pCell == NULL) continue; - if( pBoxArr[ nBox ]->GetRowSpan() == pRowSpans[ nBox ] ) + if( pCell->GetRowSpan() == pRowSpans[ nBox ] ) { // new Box - const SwStartNode* pSttNd = pBoxArr[ nBox ]->GetBox()->GetSttNd(); + const SwStartNode* pSttNd = pCell->GetBox()->GetSttNd(); RTFSaveData aSaveData( rRTFWrt, pSttNd->GetIndex()+1, pSttNd->EndOfSectionIndex() ); rRTFWrt.bOutTable = TRUE; @@ -2765,8 +2789,8 @@ static Writer& OutRTF_SwField( Writer& rWrt, const SfxPoolItem& rHt ) */ const String& rFldPar1 = pFld->GetPar1(); USHORT nScript; - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( rFldPar1, 0); + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( rFldPar1, 0); else nScript = i18n::ScriptType::ASIAN; @@ -3023,14 +3047,6 @@ static Writer& OutRTF_SwFtn( Writer& rWrt, const SfxPoolItem& rHt ) return rWrt; } -static Writer& OutRTF_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt) -{ - RTFOutFuncs::Out_String(rWrt.Strm(), - String(((SwFmtHardBlank&)rHt).GetChar()), ((SwRTFWriter&)rWrt).eDefaultEncoding, - ((SwRTFWriter&)rWrt).bWriteHelpFmt); - return rWrt; -} - static Writer& OutRTF_SwTxtCharFmt( Writer& rWrt, const SfxPoolItem& rHt ) { const SwFmtCharFmt& rChrFmt = (const SwFmtCharFmt&)rHt; @@ -3085,8 +3101,8 @@ static Writer& OutRTF_SwTxtRuby( Writer& rWrt, const SfxPoolItem& rHt ) defaulting to asian. */ USHORT nScript; - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( rRuby.GetText(), 0); + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( rRuby.GetText(), 0); else nScript = i18n::ScriptType::ASIAN; @@ -3128,8 +3144,8 @@ static Writer& OutRTF_SwTxtRuby( Writer& rWrt, const SfxPoolItem& rHt ) rWrt.Strm() << "\\\\a" << cDirective; rWrt.Strm() << "(\\\\s\\\\up "; - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( pNd->GetTxt(), + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( pNd->GetTxt(), *pRubyTxt->GetStart() ); else nScript = i18n::ScriptType::ASIAN; @@ -4250,7 +4266,7 @@ SwAttrFnTab aRTFAttrFnTab = { /* RES_TXTATR_FLYCNT */ OutRTF_SwFlyCntnt, /* RES_TXTATR_FTN */ OutRTF_SwFtn, /* RES_TXTATR_SOFTHYPH */ 0, // old attr. - coded now by character -/* RES_TXTATR_HARDBLANK*/ OutRTF_SwHardBlank, +/* RES_TXTATR_HARDBLANK*/ 0, /* RES_TXTATR_DUMMY1 */ 0, // Dummy: /* RES_TXTATR_DUMMY2 */ 0, // Dummy: diff --git a/sw/source/filter/rtf/rtffld.cxx b/sw/source/filter/rtf/rtffld.cxx index c41818de81..d891d53fd2 100644 --- a/sw/source/filter/rtf/rtffld.cxx +++ b/sw/source/filter/rtf/rtffld.cxx @@ -450,7 +450,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) // steht jetzt geanu auf dem Format-Namen aFld.ChangeFormat( CheckNumberFmtStr( aSaveStr )); } - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); SkipGroup(); } break; @@ -469,7 +469,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) // steht jetzt geanu auf dem Format-Namen aPF.ChangeFormat( CheckNumberFmtStr( aSaveStr )); } - pDoc->Insert( *pPam, SwFmtFld( aPF ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aPF ), 0 ); SkipGroup(); // ueberlese den Rest } break; @@ -480,8 +480,8 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) { // es fehlt die Format - Angabe: defaulten auf Datum pFldType = pDoc->GetSysFldType( RES_DATETIMEFLD ); - pDoc->Insert( *pPam, SwFmtFld( SwDateTimeField( - (SwDateTimeFieldType*)pFldType, DATEFLD )), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( SwDateTimeField( + static_cast<SwDateTimeFieldType*>(pFldType), DATEFLD)), 0); } else { @@ -524,7 +524,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) if( pFld ) { - pDoc->Insert( *pPam, SwFmtFld( *pFld ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( *pFld ), 0); delete pFld; } } @@ -553,8 +553,8 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) if( bField ) { pFldType = pDoc->GetSysFldType( RES_DBNAMEFLD ); - pDoc->Insert( *pPam, SwFmtFld( SwDBNameField( - (SwDBNameFieldType*)pFldType, SwDBData() ) ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( SwDBNameField( + static_cast<SwDBNameFieldType*>(pFldType), SwDBData())), 0); } else pDoc->ChgDBData( aData ); // MS: Keine DBInfo verwenden @@ -569,7 +569,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwDBField aDBFld( (SwDBFieldType*)pDoc->InsertFldType( aTmp )); aDBFld.ChangeFormat( UF_STRING ); - pDoc->Insert( *pPam, SwFmtFld( aDBFld ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld( aDBFld ), 0); SkipGroup(); // ueberlese den Rest } break; @@ -598,7 +598,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) sal_Unicode nChar = (sal_Unicode)sParam.ToInt32(); if( nChar ) { - pDoc->Insert( *pPam, nChar ); + pDoc->InsertString( *pPam, nChar ); bCharIns = TRUE; } } @@ -708,8 +708,8 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) { //Make a guess at which of asian of western we should be setting USHORT nScript; - if (pBreakIt->xBreak.is()) - nScript = pBreakIt->xBreak->getScriptType( aData.sUp, 0); + if (pBreakIt->GetBreakIter().is()) + nScript = pBreakIt->GetBreakIter()->getScriptType( aData.sUp, 0); else nScript = i18n::ScriptType::ASIAN; @@ -763,10 +763,11 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) aRuby.SetAdjustment( (USHORT)aData.nJustificationCode ); // im FieldStr steht der anzuzeigenden Text, im - pDoc->Insert( *pPam, aData.sText, true ); + pDoc->InsertString( *pPam, aData.sText ); pPam->SetMark(); pPam->GetMark()->nContent -= aData.sText.Len(); - pDoc->Insert( *pPam, aRuby, nsSetAttrMode::SETATTR_DONTEXPAND ); + pDoc->InsertPoolItem( *pPam, aRuby, + nsSetAttrMode::SETATTR_DONTEXPAND ); pPam->DeleteMark(); } // or a combined character field? @@ -778,7 +779,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) sFld += aData.sDown; SwCombinedCharField aFld((SwCombinedCharFieldType*)pDoc-> GetSysFldType( RES_COMBINED_CHARS ), sFld ); - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0); } SkipGroup(); // ueberlese den Rest @@ -808,7 +809,9 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) sOrigBkmName,REF_BOOKMARK,0,REF_PAGE); if(!bNestedField) - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + { + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); + } else bNestedField = false; } @@ -850,14 +853,14 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwGetRefField aFld( (SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName,REF_BOOKMARK,0,REF_CHAPTER); - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); } else { SwGetRefField aFld( (SwGetRefFieldType*)pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName,REF_BOOKMARK,0,REF_CONTENT); - pDoc->Insert( *pPam, SwFmtFld( aFld ), 0 ); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aFld ), 0 ); } } @@ -866,7 +869,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwGetRefField aFld( (SwGetRefFieldType*) pDoc->GetSysFldType( RES_GETREFFLD ), sOrigBkmName, REF_BOOKMARK, 0, REF_UPDOWN ); - pDoc->Insert(*pPam, SwFmtFld(aFld), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld(aFld), 0); } } break; @@ -882,7 +885,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) SwUserFieldType aTmp( pDoc, aSaveStr ); SwUserField aUFld( (SwUserFieldType*)pDoc->InsertFldType( aTmp )); aUFld.ChangeFormat( UF_STRING ); - pDoc->Insert( *pPam, SwFmtFld( aUFld ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtFld( aUFld ), 0); nRet = RTFFLD_UNKNOWN; } break; @@ -1045,7 +1048,8 @@ void SwRTFParser::ReadField() // FieldResult wurde eingelesen if (SwTxtNode* pTxtNd = pPam->GetPoint()->nNode.GetNode().GetTxtNode()) { - SwTxtAttr* pFldAttr = pTxtNd->GetTxtAttr( + SwTxtAttr* const pFldAttr = + pTxtNd->GetTxtAttrForCharAt( pPam->GetPoint()->nContent.GetIndex()-1 ); if (pFldAttr) @@ -1078,7 +1082,7 @@ void SwRTFParser::ReadField() sNestedFieldStr.Erase(); // im FieldStr steht der anzuzeigenden Text, im - pDoc->Insert( *pPam, sFieldStr, true ); + pDoc->InsertString( *pPam, sFieldStr ); String sTarget( sFieldNm.GetToken( 1, '\1' )); if( sTarget.Len() ) @@ -1087,7 +1091,7 @@ void SwRTFParser::ReadField() // oder ueber den Stack setzen?? pPam->SetMark(); pPam->GetMark()->nContent -= sFieldStr.Len(); - pDoc->Insert( *pPam, + pDoc->InsertPoolItem( *pPam, SwFmtINetFmt( sFieldNm, sTarget ), nsSetAttrMode::SETATTR_DONTEXPAND ); pPam->DeleteMark(); diff --git a/sw/source/filter/rtf/rtffly.cxx b/sw/source/filter/rtf/rtffly.cxx index 881a8a0345..706dc39b81 100644 --- a/sw/source/filter/rtf/rtffly.cxx +++ b/sw/source/filter/rtf/rtffly.cxx @@ -263,20 +263,26 @@ void SwRTFParser::SetFlysInDoc() pSttNd->GetIndex() + 1 == pEndNd->GetIndex() && pSttNd->GetTxt().Len()>0 /* #i38227# leave drop caps with no content as fly frames */ ) { + ULONG nPos = pSttNd->GetIndex(); + SwDoc * pDoc1 = pSttNd->GetDoc(); + BOOL bJoined; { - SwPaM aTmp( *pEndNd, 0, *pSttNd, pSttNd->GetTxt().Len() ); - bJoined = pDoc->DeleteAndJoin( aTmp ); + SwPaM aTmp( *pSttNd, pSttNd->GetTxt().Len(), *pEndNd, 0 ); + bJoined = pDoc1->DeleteAndJoin( aTmp ); } - if( bJoined ) + + SwTxtNode * pNd = (pDoc1->GetNodes()[nPos])->GetTxtNode(); + + if( bJoined && pNd != NULL) { SwFmtDrop aDropCap; aDropCap.GetLines() = (BYTE)pFlySave->nDropLines; aDropCap.GetChars() = 1; SwIndex aIdx( pEndNd ); - pEndNd->RstAttr( aIdx, 1, RES_CHRATR_FONTSIZE ); - pEndNd->SetAttr( aDropCap ); + pNd->RstAttr( aIdx, 1, RES_CHRATR_FONTSIZE ); + pNd->SetAttr( aDropCap ); } delete pFlySave; continue; @@ -390,7 +396,8 @@ void SwRTFParser::SetFlysInDoc() } } aTmpIdx = *pSttNd->EndOfSectionNode(); - pDoc->Move( aRg, aTmpIdx, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aRg, aTmpIdx, + IDocumentContentOperations::DOC_MOVEDEFAULT ); } // patch from cmc for #i52542# @@ -1168,7 +1175,7 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) { SwTxtNode* pTxtNd = pFlySave->nSttNd.GetNode().GetTxtNode(); - SwTxtFlyCnt* pFlyCnt; + SwTxtFlyCnt* pFlyCnt = 0; if( 1 == pTxtNd->GetTxt().Len() && 0 != ( pFlyCnt = (SwTxtFlyCnt*)pTxtNd->GetTxtAttr( 0, RES_TXTATR_FLYCNT )) && @@ -1226,7 +1233,8 @@ void SwRTFParser::ReadFly( int nToken, SfxItemSet* pSet ) (SwTxtFmtColl*)pDoc->GetDfltTxtFmtColl() ); SwNodeIndex aTmp( pFlySave->nSttNd, +1 ); - pDoc->Move( aRg, aTmp, IDocumentContentOperations::DOC_MOVEDEFAULT ); + pDoc->MoveNodeRange( aRg, aTmp, + IDocumentContentOperations::DOC_MOVEDEFAULT ); // now delete the redundant txtnode pDoc->GetNodes().Delete( pFlySave->nSttNd, 1 ); diff --git a/sw/source/filter/rtf/rtftbl.cxx b/sw/source/filter/rtf/rtftbl.cxx index 0931f6e5c0..c3a56f64e3 100644 --- a/sw/source/filter/rtf/rtftbl.cxx +++ b/sw/source/filter/rtf/rtftbl.cxx @@ -851,7 +851,8 @@ void SwRTFParser::ReadTable( int nToken ) //table aRg.SetMark(); aRg.GetMark()->nContent.Assign(aRg.GetCntntNode(), 0); - pDoc->Move(aRg, *pPam->GetPoint(), IDocumentContentOperations::DOC_MOVEDEFAULT); + pDoc->MoveRange(aRg, *pPam->GetPoint(), + IDocumentContentOperations::DOC_MOVEDEFAULT); } //Update the attribute stack entries to reflect that the properties diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index ec166173b1..0cac44fb90 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -55,7 +55,6 @@ #include <svx/hyznitem.hxx> #include <fmtpdsc.hxx> #include <fmtfld.hxx> -#include <fmthbsh.hxx> #include <fmthdft.hxx> #include <fmtcntnt.hxx> #include <txtftn.hxx> @@ -449,7 +448,6 @@ if( pSttNdIdx->GetIndex()+1 == pPam->GetBound( FALSE ).nNode.GetIndex() ) for (rtfSections::myrDummyIter aI = maSegments.maDummyPageNos.rbegin(); aI != aDEnd; ++aI) pDoc->DelPageDesc(*aI); - if( aFlyArr.Count() ) SetFlysInDoc(); @@ -852,7 +850,8 @@ SwSectionFmt *rtfSections::InsertSection(SwPaM& rMyPaM, rtfSection &rSection) aSet.Put(SvxFrameDirectionItem( nRTLPgn ? FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR)); - rSection.mpSection = mrReader.pDoc->Insert( rMyPaM, aSection, &aSet ); + rSection.mpSection = + mrReader.pDoc->InsertSwSection( rMyPaM, aSection, &aSet ); ASSERT(rSection.mpSection, "section not inserted!"); if (!rSection.mpSection) return 0; @@ -1003,7 +1002,7 @@ void rtfSections::InsertSegments(bool bNewDoc) aIter->maStart.GetNode().GetCntntNode(), 0); SwPaM aPage(aPamStart); - mrReader.pDoc->Insert(aPage, aPgDesc, 0); + mrReader.pDoc->InsertPoolItem(aPage, aPgDesc, 0); } ++nDesc; } @@ -1824,7 +1823,8 @@ void SwRTFParser::NextToken( int nToken ) if (lcl_UsedPara(*pPam)) InsertPara(); CheckInsNewTblLine(); - pDoc->Insert(*pPam, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); + pDoc->InsertPoolItem(*pPam, + SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); } break; @@ -1948,7 +1948,9 @@ void SwRTFParser::NextToken( int nToken ) break; case RTF_REVDTTM: - pRedlineInsert->aStamp = sw::ms::DTTM2DateTime(nTokenValue); + if (pRedlineInsert != NULL) + pRedlineInsert->aStamp = sw::ms::DTTM2DateTime(nTokenValue); + break; case RTF_REVDTTMDEL: @@ -1974,12 +1976,13 @@ void SwRTFParser::NextToken( int nToken ) &const_cast<const SwDoc *>(pDoc) ->GetPageDesc( USHORT(nTokenValue) ); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtPageDesc( pPgDsc ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtPageDesc( pPgDsc ), 0); } break; case RTF_COLUM: - pDoc->Insert( *pPam, SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0); + pDoc->InsertPoolItem(*pPam, + SvxFmtBreakItem( SVX_BREAK_COLUMN_BEFORE, RES_BREAK ), 0); break; case RTF_DXFRTEXT: // werden nur im Zusammenhang mit Flys ausgewertet @@ -1999,7 +2002,7 @@ SETCHDATEFIELD: SwDateTimeField aDateFld( (SwDateTimeFieldType*) pDoc->GetSysFldType( RES_DATETIMEFLD ), DATEFLD, nFormat); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtFld( aDateFld ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld( aDateFld ), 0); } break; @@ -2011,7 +2014,7 @@ SETCHDATEFIELD: SwDateTimeField aTimeFld( (SwDateTimeFieldType*) pDoc->GetSysFldType( RES_DATETIMEFLD ), TIMEFLD, nFormat); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtFld( aTimeFld ), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld( aTimeFld ), 0); } break; @@ -2021,7 +2024,7 @@ SETCHDATEFIELD: pDoc->GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM, SVX_NUM_ARABIC ); CheckInsNewTblLine(); - pDoc->Insert( *pPam, SwFmtFld( aPageFld), 0); + pDoc->InsertPoolItem(*pPam, SwFmtFld(aPageFld), 0); } break; @@ -2051,7 +2054,7 @@ SETCHDATEFIELD: CheckInsNewTblLine(); if( nTokenValue ) aToken = (sal_Unicode )nTokenValue; - pDoc->Insert( *pPam, aToken, true ); + pDoc->InsertString( *pPam, aToken ); } break; @@ -2117,7 +2120,7 @@ void SwRTFParser::InsertText() if(pRedlineDelete) mpRedlineStack->open(*pPam->GetPoint(), *pRedlineDelete); - pDoc->Insert( *pPam, aToken, true ); + pDoc->InsertString( *pPam, aToken ); if(pRedlineDelete) { @@ -2281,14 +2284,15 @@ void SwRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) } } while( 0 != (pStyle = GetStyleTbl().Next()) ); - pDoc->Insert(aPam, *pCharFmt, 0); + pDoc->InsertPoolItem(aPam, *pCharFmt, 0); rSet.GetAttrSet().ClearItem(RES_TXTATR_CHARFMT); //test hack } if (rSet.GetAttrSet().Count()) { // dann setze ueber diesen Bereich die Attrbiute SetSwgValues(rSet.GetAttrSet()); - pDoc->Insert(aPam, rSet.GetAttrSet(), nsSetAttrMode::SETATTR_DONTCHGNUMRULE); + pDoc->InsertItemSet(aPam, rSet.GetAttrSet(), + nsSetAttrMode::SETATTR_DONTCHGNUMRULE); } } @@ -2450,7 +2454,7 @@ void SwRTFParser::SetPageInformationAsDefault(const DocPageInformation &rInfo) { SwFmtPageDesc aPgDsc( &rPg ); aPgDsc.SetNumOffset( nPgStart ); - pDoc->Insert( *pPam, aPgDsc, 0 ); + pDoc->InsertPoolItem( *pPam, aPgDsc, 0 ); } } } @@ -3709,7 +3713,7 @@ void SwRTFParser::ReadHeaderFooter( int nToken, SwPageDesc* pPageDesc ) aSet.Put( SwFmtAnchor( FLY_IN_CNTNT )); pHdFtFmt = pDoc->MakeFlySection( FLY_IN_CNTNT, pPam->GetPoint(), &aSet ); - pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttr( + pTxtAttr = pPam->GetNode()->GetTxtNode()->GetTxtAttrForCharAt( nPos, RES_TXTATR_FLYCNT ); ASSERT( pTxtAttr, "konnte den Fly nicht einfuegen/finden" ); @@ -4295,7 +4299,7 @@ void SwRTFParser::UnknownAttrToken( int nToken, SfxItemSet* pSet ) { const SwPageDesc* pPgDsc = &const_cast<const SwDoc *>(pDoc) ->GetPageDesc( (USHORT)nTokenValue ); - pDoc->Insert( *pPam, SwFmtPageDesc( pPgDsc ), 0); + pDoc->InsertPoolItem( *pPam, SwFmtPageDesc( pPgDsc ), 0); } break; case RTF_CS: diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx index 676916e59a..e0a2067cfc 100644 --- a/sw/source/filter/writer/writer.cxx +++ b/sw/source/filter/writer/writer.cxx @@ -223,7 +223,7 @@ sal_Int32 Writer::FindPos_Bkmk(const SwPosition& rPos) const SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, - BOOL bNodesArray ) const + BOOL bNodesArray ) { SwNodes* pNds = bNodesArray ? &rDoc.GetNodes() : (SwNodes*)rDoc.GetUndoNds(); @@ -231,7 +231,7 @@ SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, SwCntntNode* pCNode = aStt.GetNode().GetCntntNode(); if( !pCNode && 0 == ( pCNode = pNds->GoNext( &aStt )) ) { - ASSERT( !this, "An StartPos kein ContentNode mehr" ); + ASSERT( false, "An StartPos kein ContentNode mehr" ); } SwPaM* pNew = new SwPaM( aStt ); @@ -240,7 +240,7 @@ SwPaM* Writer::NewSwPaM( SwDoc & rDoc, ULONG nStartIdx, ULONG nEndIdx, if( 0 == (pCNode = aStt.GetNode().GetCntntNode()) && 0 == (pCNode = pNds->GoPrevious( &aStt )) ) { - ASSERT( !this, "An StartPos kein ContentNode mehr" ); + ASSERT( false, "An StartPos kein ContentNode mehr" ); } pCNode->MakeEndIndex( &pNew->GetPoint()->nContent ); pNew->GetPoint()->nNode = aStt; @@ -340,10 +340,6 @@ ULONG Writer::Write( SwPaM& rPam, SfxMedium& rMed, const String* pFileName ) // This method must be overloaded in SwXMLWriter a storage from medium will be used there. // The microsoft format can write to storage but the storage will be based on the stream. return Write( rPam, *rMed.GetOutStream(), pFileName ); - - // return IsStgWriter() - // ? Write( rPam, rMed.GetStorage(), pFileName ) - // : Write( rPam, *rMed.GetOutStream(), pFileName ); } ULONG Writer::Write( SwPaM& /*rPam*/, SvStorage&, const String* ) diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index 3d9c9cc6db..bf79021866 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -33,6 +33,7 @@ #include <ctype.h> #include <hintids.hxx> +#include <hints.hxx> #ifndef _GRAPH_HXX //autogen #include <vcl/graph.hxx> @@ -176,7 +177,6 @@ BOOL SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, BOOL bCheck ) return TRUE; } - SwFltControlStack::SwFltControlStack(SwDoc* pDo, ULONG nFieldFl) : nFieldFlags(nFieldFl), pDoc(pDo), bIsEndStack(false) { @@ -426,17 +426,21 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* switch(pEntry->pAttr->Which()) { case RES_FLTR_ANCHOR: - { - MakePoint(pEntry, pDoc, aRegion); + { SwFrmFmt* pFmt = ((SwFltAnchor*)pEntry->pAttr)->GetFrmFmt(); - SwFmtAnchor aAnchor(pFmt->GetAnchor()); - aAnchor.SetAnchor(aRegion.GetPoint()); - pFmt->SetFmtAttr(aAnchor); - // Damit die Frames bei Einfuegen in existierendes Doc - // erzeugt werden (erst nach Setzen des Ankers!): - if(pDoc->GetRootFrm() - && FLY_AT_CNTNT == pFmt->GetAnchor().GetAnchorId()){ - pFmt->MakeFrms(); + if (pFmt != NULL) + { + MakePoint(pEntry, pDoc, aRegion); + SwFmtAnchor aAnchor(pFmt->GetAnchor()); + aAnchor.SetAnchor(aRegion.GetPoint()); + pFmt->SetFmtAttr(aAnchor); + // Damit die Frames bei Einfuegen in existierendes Doc + // erzeugt werden (erst nach Setzen des Ankers!): + if(pDoc->GetRootFrm() + && FLY_AT_CNTNT == pFmt->GetAnchor().GetAnchorId()) + { + pFmt->MakeFrms(); + } } } break; @@ -488,7 +492,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* { // XRefs und Bookmarks sind bereits geUpcased MakeBookRegionOrPoint(pEntry, pDoc, aRegion, TRUE); - pDoc->Insert(aRegion, SwFmtRefMark(rName), 0); + pDoc->InsertPoolItem(aRegion, SwFmtRefMark(rName), 0); } else if( !pB->IsOnlyRef() ) { @@ -502,7 +506,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* pB->GetValSys()); aFld.SetSubType( nsSwExtendedSubType::SUB_INVISIBLE ); MakePoint(pEntry, pDoc, aRegion); - pDoc->Insert(aRegion, SwFmtFld(aFld), 0); + pDoc->InsertPoolItem(aRegion, SwFmtFld(aFld), 0); MoveAttrs( *(aRegion.GetPoint()) ); } } @@ -560,8 +564,9 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* break; case RES_FLTR_SECTION: MakePoint(pEntry, pDoc, aRegion); // bislang immer Point==Mark - pDoc->Insert(aRegion, *((SwFltSection*)pEntry->pAttr)->GetSection(), - 0, FALSE); + pDoc->InsertSwSection(aRegion, + *(static_cast<SwFltSection*>(pEntry->pAttr))->GetSection(), + 0, false); delete(((SwFltSection*)pEntry->pAttr)->GetSection()); break; case RES_FLTR_REDLINE: @@ -598,7 +603,9 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, SwFltStackEntry* break; default: if (pEntry->MakeRegion(pDoc, aRegion, FALSE)) - pDoc->Insert(aRegion, *pEntry->pAttr, 0); + { + pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0); + } break; } } @@ -728,11 +735,35 @@ void SwFltControlStack::Delete(const SwPaM &rPam) SwFltAnchor::SwFltAnchor(SwFrmFmt* pFmt) : SfxPoolItem(RES_FLTR_ANCHOR), pFrmFmt(pFmt) { + pClient = new SwFltAnchorClient(this); + pFrmFmt->Add(pClient); } SwFltAnchor::SwFltAnchor(const SwFltAnchor& rCpy) : SfxPoolItem(RES_FLTR_ANCHOR), pFrmFmt(rCpy.pFrmFmt) { + pClient = new SwFltAnchorClient(this); + pFrmFmt->Add(pClient); +} + +SwFltAnchor::~SwFltAnchor() +{ + delete pClient; +} + +void SwFltAnchor::SetFrmFmt(SwFrmFmt * _pFrmFmt) +{ + pFrmFmt = _pFrmFmt; +} + +const SwFrmFmt * SwFltAnchor::GetFrmFmt() const +{ + return pFrmFmt; +} + +SwFrmFmt * SwFltAnchor::GetFrmFmt() +{ + return pFrmFmt; } int SwFltAnchor::operator==(const SfxPoolItem& rItem) const @@ -745,6 +776,29 @@ SfxPoolItem* __EXPORT SwFltAnchor::Clone(SfxItemPool*) const return new SwFltAnchor(*this); } +// SwFltAnchorClient + +SwFltAnchorClient::SwFltAnchorClient(SwFltAnchor * pFltAnchor) +: m_pFltAnchor(pFltAnchor) +{ +} + +void SwFltAnchorClient::Modify(SfxPoolItem *, SfxPoolItem * pNew) +{ + if (pNew->Which() == RES_FMT_CHG) + { + SwFmtChg * pFmtChg = dynamic_cast<SwFmtChg *> (pNew); + + if (pFmtChg != NULL) + { + SwFrmFmt * pFrmFmt = dynamic_cast<SwFrmFmt *> (pFmtChg->pChangedFmt); + + if (pFrmFmt != NULL) + m_pFltAnchor->SetFrmFmt(pFrmFmt); + } + } +} + //------ hier stehen die Methoden von SwFltRedline ----------- int SwFltRedline::operator==(const SfxPoolItem& rItem) const { @@ -955,7 +1009,7 @@ SwFltShell::~SwFltShell() SwFltShell& SwFltShell::operator << ( const String& rStr ) { ASSERT(eSubMode != Style, "char insert while in style-mode"); - GetDoc().Insert( *pPaM, rStr, true ); + GetDoc().InsertString( *pPaM, rStr ); return *this; } @@ -992,7 +1046,7 @@ String SwFltShell::QuoteStr( const String& rIn ) SwFltShell& SwFltShell::operator << ( const sal_Unicode c ) { ASSERT( eSubMode != Style, "char insert while in style-mode"); - GetDoc().Insert( *pPaM, c ); + GetDoc().InsertString( *pPaM, c ); return *this; } @@ -1009,7 +1063,7 @@ SwFltShell& SwFltShell::AddError( const sal_Char* pErr ) SwSetExpField aFld( (SwSetExpFieldType*)pFT, String::CreateFromAscii( pErr )); //, VVF_INVISIBLE - GetDoc().Insert(*pPaM, SwFmtFld(aFld), 0); + GetDoc().InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return *this; } @@ -1028,7 +1082,8 @@ void SwFltShell::NextParagraph() void SwFltShell::NextPage() { NextParagraph(); - GetDoc().Insert(*pPaM, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); + GetDoc().InsertPoolItem(*pPaM, + SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); } SwFltShell& SwFltShell::AddGraphic( const String& rPicName ) @@ -1119,7 +1174,7 @@ SwFltShell& SwFltShell::EndItem( USHORT nAttrId ) SwFltShell& SwFltShell::operator << (const SwField& rField) { - GetDoc().Insert(*pPaM, SwFmtFld(rField), 0); + GetDoc().InsertPoolItem(*pPaM, SwFmtFld(rField), 0); return *this; } @@ -1880,7 +1935,7 @@ void SwFltShell::BeginFootnote() // Fussnoten im PMW uebernommen werden SwFmtFtn aFtn; - GetDoc().Insert(*pPaM, aFtn, 0); + GetDoc().InsertPoolItem(*pPaM, aFtn, 0); ASSERT(pSavedPos == NULL, "SwFltShell"); pSavedPos = new SwPosition(*pPaM->GetPoint()); pPaM->Move(fnMoveBackward, fnGoCntnt); @@ -1980,7 +2035,9 @@ SwPageDesc* SwFltShell::MakePageDesc(SwPageDesc* pFirstPageDesc) pNewPD->SetFollow(pNewPD); } else - GetDoc().Insert( *pPaM, SwFmtPageDesc( pNewPD ), 0 ); + { + GetDoc().InsertPoolItem( *pPaM, SwFmtPageDesc( pNewPD ), 0 ); + } pNewPD->WriteUseOn( // alle Seiten (UseOnPage)(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE)); return pNewPD; diff --git a/sw/source/filter/ww8/WW8TableInfo.cxx b/sw/source/filter/ww8/WW8TableInfo.cxx index a7961a9eef..022b3d045b 100644 --- a/sw/source/filter/ww8/WW8TableInfo.cxx +++ b/sw/source/filter/ww8/WW8TableInfo.cxx @@ -190,7 +190,9 @@ WW8TableNodeInfo::~WW8TableNodeInfo() } #ifdef DEBUG - sResult += dbg_out(*mpNode); +//!! does not compile with debug=t -> unresolved external (dbg_out), +//!! sommeone who knows what he wants to get should fix this +// sResult += dbg_out(*mpNode); #endif sResult +="</tableNodeInfo>"; @@ -359,7 +361,7 @@ void WW8TableInfo::processSwTable(const SwTable * pTable) pPrev = processTableLine(pTable, pLine, n, 1, pPrev); } - + #ifdef DEBUG ::std::clog << "</processSwTable>" << ::std::endl; #endif @@ -498,7 +500,7 @@ WW8TableInfo::processTableBox(const SwTable * pTable, { if (nDepthInsideCell > 0) pEndOfCellInfo.reset(); - + nDepthInsideCell++; } @@ -557,8 +559,7 @@ WW8TableNodeInfo::Pointer_t WW8TableInfo::insertTableNodeInfo if (pNodeInfo.get() == NULL) { - pNodeInfo = WW8TableNodeInfo::Pointer_t - (new WW8TableNodeInfo(pNode)); + pNodeInfo = WW8TableNodeInfo::Pointer_t(new WW8TableNodeInfo(pNode)); mMap.insert(Map_t::value_type(pNode, pNodeInfo)); } @@ -566,7 +567,7 @@ WW8TableNodeInfo::Pointer_t WW8TableInfo::insertTableNodeInfo pNodeInfo->setTable(pTable); pNodeInfo->setTableBox(pTableBox); - + pNodeInfo->setCell(nCell); pNodeInfo->setRow(nRow); diff --git a/sw/source/filter/ww8/WW8TableInfo.hxx b/sw/source/filter/ww8/WW8TableInfo.hxx index bb6e30c6dc..b5eee16dd6 100644 --- a/sw/source/filter/ww8/WW8TableInfo.hxx +++ b/sw/source/filter/ww8/WW8TableInfo.hxx @@ -62,7 +62,7 @@ class WW8TableNodeInfoInner public: typedef boost::shared_ptr<WW8TableNodeInfoInner> Pointer_t; - + WW8TableNodeInfoInner(WW8TableNodeInfo * pParent); ~WW8TableNodeInfoInner(); @@ -83,7 +83,7 @@ public: const SwTable * getTable() const; const SwNode * getNode() const; - + string toString() const; }; @@ -100,7 +100,7 @@ private: public: typedef boost::shared_ptr<WW8TableNodeInfo> Pointer_t; - + WW8TableNodeInfo(const SwNode * pTxtNode); virtual ~WW8TableNodeInfo(); @@ -127,7 +127,7 @@ public: sal_uInt32 getCell() const; sal_uInt32 getRow() const; - + ::std::string toString() const; }; diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx new file mode 100644 index 0000000000..cf6c68cafb --- /dev/null +++ b/sw/source/filter/ww8/attributeoutputbase.hxx @@ -0,0 +1,581 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _ATTRIBUTEOUTPUTBASE_HXX_ +#define _ATTRIBUTEOUTPUTBASE_HXX_ + +#include "fields.hxx" +#include "WW8TableInfo.hxx" + +#include <rtl/textenc.h> +#include <svx/svxenum.hxx> +#include <tools/solar.h> + +#include <swtypes.hxx> +#include <wrtswtbl.hxx> +#include <fldbas.hxx> + +#include <vector> + +class Point; +class SvxCaseMapItem; +class SvxColorItem; +class SvxContourItem; +class SvxCrossedOutItem; +class SvxEscapementItem; +class SvxFontItem; +class SvxFontHeightItem; +class SvxKerningItem; +class SvxLanguageItem; +class SvxPostureItem; +class SvxShadowedItem; +class SvxUnderlineItem; +class SvxWeightItem; +class SvxAutoKernItem; +class SvxBlinkItem; +class SvxBrushItem; +class SvxFontItem; +class SvxFontHeightItem; +class SvxLanguageItem; +class SvxPostureItem; +class SvxWeightItem; +class SvxFontItem; +class SvxFontHeightItem; +class SvxLanguageItem; +class SvxPostureItem; +class SvxWeightItem; +class SvxCharRotateItem; +class SvxEmphasisMarkItem; +class SvxTwoLinesItem; +class SvxCharScaleWidthItem; +class SvxCharReliefItem; +class SvxCharHiddenItem; +class SwFmtINetFmt; +class SwFmtCharFmt; +class SwFmtFld; +class SwFmtFlyCnt; +class SwFmtFtn; +class SwFmtHardBlank; +class SvxLineSpacingItem; +class SvxAdjustItem; +class SvxFmtSplitItem; +class SvxWidowsItem; +class SvxTabStopItem; +class SvxHyphenZoneItem; +class SwNumRuleItem; +class SfxBoolItem; +class SfxPoolItem; +class SfxItemSet; +class SvxParaVertAlignItem; +class SvxParaGridItem; +class SwFmtFrmSize; +class SvxPaperBinItem; +class SvxLRSpaceItem; +class SvxULSpaceItem; +class SwFmtPageDesc; +class SvxFmtBreakItem; +class SwFmtSurround; +class SwFmtVertOrient; +class SwFmtHoriOrient; +class SwFmtAnchor; +class SvxBrushItem; +class SvxBoxItem; +class SwFmtCol; +class SvxFmtKeepItem; +class SwTextGridItem; +class SwFmtLineNumber; +class SvxFrameDirectionItem; +class SwFmtRuby; +class SwTxtNode; +class SwTOXMark; +class SwRedlineData; +class SwSection; +class SwFmtDrop; +class SwFrmFmt; +class SwNumFmt; +class SwFmt; +class SwTableNode; +struct WW8_SepInfo; +struct WW8_PdAttrDesc; +class SwLineNumberInfo; +class SwNumRule; +class wwFont; + +class String; + +class MSWordExportBase; + +namespace sw { class Frame; } + +namespace msword { + const BYTE ColumnBreak = 0xE; + const BYTE PageBreak = 0xC; +} + +class AttributeOutputBase +{ +public: + /// Export the state of RTL/CJK. + virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ) = 0; + + /// Start of the paragraph. + virtual void StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo ) = 0; + + /// End of the paragraph. + virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) = 0; + + /// Called before we start outputting the attributes. + virtual void StartParagraphProperties( const SwTxtNode& rNode ) = 0; + + /// Called after we end outputting the attributes. + virtual void EndParagraphProperties() = 0; + + /// Empty paragraph. + virtual void EmptyParagraph() = 0; + + /// Start of the text run. + virtual void StartRun( const SwRedlineData* pRedlineData ) = 0; + + /// End of the text run. + virtual void EndRun() = 0; + + /// Called before we start outputting the attributes. + virtual void StartRunProperties() = 0; + + /// Called after we end outputting the attributes. + virtual void EndRunProperties( const SwRedlineData* pRedlineData ) = 0; + + /// Output text (inside a run). + virtual void RunText( const String& rText, rtl_TextEncoding eCharSet ) = 0; + + /// Output text (without markup). + virtual void RawText( const String& rText, bool bForceUnicode, rtl_TextEncoding eCharSet ) = 0; + + /// Output ruby start. + virtual void StartRuby( const SwTxtNode& rNode, const SwFmtRuby& rRuby ) = 0; + + /// Output ruby end. + virtual void EndRuby() = 0; + + /// Output URL start. + virtual bool StartURL( const String& rUrl, const String& rTarget ) = 0; + + /// Output URL end. + virtual bool EndURL() = 0; + + virtual void FieldVanish( const String& rTxt, ww::eField eType ) = 0; + + void StartTOX( const SwSection& rSect ); + + void EndTOX( const SwSection& rSect ); + + virtual void TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAttr ); + + /// Output redlining. + virtual void Redline( const SwRedlineData* pRedline ) = 0; + + virtual void FormatDrop( const SwTxtNode& rNode, const SwFmtDrop& rSwFmtDrop, USHORT nStyle, ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) = 0; + + /// Output FKP (Formatted disK Page) - necessary for binary formats only. + /// FIXME having it in AttributeOutputBase is probably a hack, it + /// should be in WW8AttributeOutput only... + virtual void OutputFKP() {} + + /// Output style. + virtual void ParagraphStyle( USHORT nStyle ) = 0; + + virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0; + + virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0; + + virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0; + + virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0; + + virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0; + + virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0; + + virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0; + + virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0; + + virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ) = 0; + + virtual void TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t pNodeInfo ) = 0; + + virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ) = 0; + + virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) = 0; + + virtual void TableRowEnd( sal_uInt32 nDepth ) = 0; + + /// Start of the styles table. + virtual void StartStyles() = 0; + + /// End of the styles table. + virtual void EndStyles( USHORT nNumberOfStyles ) = 0; + + /// Write default style. + virtual void DefaultStyle( USHORT nStyle ) = 0; + + /// Start of a style in the styles table. + virtual void StartStyle( const String& rName, bool bPapFmt, + USHORT nBase, USHORT nNext, USHORT nWwId, USHORT nId ) = 0; + + /// End of a style in the styles table. + virtual void EndStyle() = 0; + + /// Start of (paragraph or run) properties of a style. + virtual void StartStyleProperties( bool bParProp, USHORT nStyle ) = 0; + + /// End of (paragraph or run) properties of a style. + virtual void EndStyleProperties( bool bParProp ) = 0; + + /// Numbering rule and Id. + virtual void OutlineNumbering( BYTE nLvl, const SwNumFmt& rNFmt, const SwFmt& rFmt ) = 0; + + /// Page break + /// As a paragraph property - the paragraph should be on the next page. + virtual void PageBreakBefore( bool bBreak ) = 0; + + /// Write a section break + /// msword::ColumnBreak or msword::PageBreak + virtual void SectionBreak( BYTE nC, const WW8_SepInfo* pSectionInfo = NULL ) = 0; + + /// Start of the section properties. + virtual void StartSection() = 0; + + /// End of the section properties. + virtual void EndSection() = 0; + + /// Protection of forms. + virtual void SectionFormProtection( bool bProtected ) = 0; + + /// Numbering of the lines in the document. + virtual void SectionLineNumbering( ULONG nRestartNo, const SwLineNumberInfo& rLnNumInfo ) = 0; + + /// Has different headers/footers for the title page. + virtual void SectionTitlePage() = 0; + + /// Description of the page borders. + virtual void SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* pFirstPageFmt ) = 0; + + /// Columns populated from right/numbers on the right side? + virtual void SectionBiDi( bool bBiDi ) = 0; + + /// The style of the page numbers. + /// + /// nPageRestartNumberr being 0 means no restart. + virtual void SectionPageNumbering( USHORT nNumType, USHORT nPageRestartNumber ) = 0; + + /// The type of breaking. + virtual void SectionType( BYTE nBreakCode ) = 0; + + /// Special header/footer flags, needed for old versions only. + virtual void SectionWW6HeaderFooterFlags( BYTE /*nHeadFootFlags*/ ) {} + + /// Definition of a numbering instance. + virtual void NumberingDefinition( USHORT nId, const SwNumRule &rRule ) = 0; + + /// Start of the abstract numbering definition instance. + virtual void StartAbstractNumbering( USHORT /*nId*/ ) {} + + /// End of the abstract numbering definition instance. + virtual void EndAbstractNumbering() {} + + /// All the numbering level information. + virtual void NumberingLevel( BYTE nLevel, + USHORT nStart, + USHORT nNumberingType, + SvxAdjust eAdjust, + const BYTE *pNumLvlPos, + BYTE nFollow, + const wwFont *pFont, + const SfxItemSet *pOutSet, + sal_Int16 nIndentAt, + sal_Int16 nFirstLineIndex, + sal_Int16 nListTabPos, + const String &rNumberingString ) = 0; + +protected: + + void GetNumberPara( String& rStr, const SwField& rFld ); + + /// Output frames - the implementation. + virtual void OutputFlyFrame_Impl( const sw::Frame& rFmt, const Point& rNdTopLeft ) = 0; + + /// Sfx item Sfx item RES_CHRATR_CASEMAP + virtual void CharCaseMap( const SvxCaseMapItem& ) = 0; + + /// Sfx item Sfx item RES_CHRATR_COLOR + virtual void CharColor( const SvxColorItem& ) = 0; + + /// Sfx item Sfx item RES_CHRATR_CONTOUR + virtual void CharContour( const SvxContourItem& ) = 0; + + /// Sfx item RES_CHRATR_CROSSEDOUT + virtual void CharCrossedOut( const SvxCrossedOutItem& ) = 0; + + /// Sfx item RES_CHRATR_ESCAPEMENT + virtual void CharEscapement( const SvxEscapementItem& ) = 0; + + /// Sfx item RES_CHRATR_FONT + virtual void CharFont( const SvxFontItem& ) = 0; + + /// Sfx item RES_CHRATR_FONTSIZE + virtual void CharFontSize( const SvxFontHeightItem& ) = 0; + + /// Sfx item RES_CHRATR_KERNING + virtual void CharKerning( const SvxKerningItem& ) = 0; + + /// Sfx item RES_CHRATR_LANGUAGE + virtual void CharLanguage( const SvxLanguageItem& ) = 0; + + /// Sfx item RES_CHRATR_POSTURE + virtual void CharPosture( const SvxPostureItem& ) = 0; + + /// Sfx item RES_CHRATR_SHADOWED + virtual void CharShadow( const SvxShadowedItem& ) = 0; + + /// Sfx item RES_CHRATR_UNDERLINE + virtual void CharUnderline( const SvxUnderlineItem& ) = 0; + + /// Sfx item RES_CHRATR_WEIGHT + virtual void CharWeight( const SvxWeightItem& ) = 0; + + /// Sfx item RES_CHRATR_AUTOKERN + virtual void CharAutoKern( const SvxAutoKernItem& ) = 0; + + /// Sfx item RES_CHRATR_BLINK + virtual void CharAnimatedText( const SvxBlinkItem& ) = 0; + + /// Sfx item RES_CHRATR_BACKGROUND + virtual void CharBackground( const SvxBrushItem& ) = 0; + + /// Sfx item RES_CHRATR_CJK_FONT + virtual void CharFontCJK( const SvxFontItem& ) = 0; + + /// Sfx item RES_CHRATR_CJK_FONTSIZE + virtual void CharFontSizeCJK( const SvxFontHeightItem& ) = 0; + + /// Sfx item RES_CHRATR_CJK_LANGUAGE + virtual void CharLanguageCJK( const SvxLanguageItem& ) = 0; + + /// Sfx item RES_CHRATR_CJK_POSTURE + virtual void CharPostureCJK( const SvxPostureItem& ) = 0; + + /// Sfx item RES_CHRATR_CJK_WEIGHT + virtual void CharWeightCJK( const SvxWeightItem& ) = 0; + + /// Sfx item RES_CHRATR_CTL_FONT + virtual void CharFontCTL( const SvxFontItem& ) = 0; + + /// Sfx item RES_CHRATR_CTL_FONTSIZE + virtual void CharFontSizeCTL( const SvxFontHeightItem& ) = 0; + + /// Sfx item RES_CHRATR_CTL_LANGUAGE + virtual void CharLanguageCTL( const SvxLanguageItem& ) = 0; + + /// Sfx item RES_CHRATR_CTL_POSTURE + virtual void CharPostureCTL( const SvxPostureItem& ) = 0; + + /// Sfx item RES_CHRATR_CTL_WEIGHT + virtual void CharWeightCTL( const SvxWeightItem& ) = 0; + + /// Sfx item RES_CHRATR_ROTATE + virtual void CharRotate( const SvxCharRotateItem& ) = 0; + + /// Sfx item RES_CHRATR_EMPHASIS_MARK + virtual void CharEmphasisMark( const SvxEmphasisMarkItem& ) = 0; + + /// Sfx item RES_CHRATR_TWO_LINES + virtual void CharTwoLines( const SvxTwoLinesItem& ) = 0; + + /// Sfx item RES_CHRATR_SCALEW + virtual void CharScaleWidth( const SvxCharScaleWidthItem& ) = 0; + + /// Sfx item RES_CHRATR_RELIEF + virtual void CharRelief( const SvxCharReliefItem& ) = 0; + + /// Sfx item RES_CHRATR_HIDDEN + virtual void CharHidden( const SvxCharHiddenItem& ) = 0; + + /// Sfx item RES_TXTATR_INETFMT + virtual void TextINetFormat( const SwFmtINetFmt& ) = 0; + + /// Sfx item RES_TXTATR_CHARFMT + virtual void TextCharFormat( const SwFmtCharFmt& ) = 0; + + /// Sfx item RES_TXTATR_FIELD + void TextField( const SwFmtFld& ); + + /// Sfx item RES_TXTATR_FLYCNT + virtual void TextFlyContent( const SwFmtFlyCnt& ); + + /// Sfx item RES_TXTATR_FTN + /// + /// This one is common for both WW8AttributeOutput as well as + /// DocxAttributeOutput. + void TextFootnote( const SwFmtFtn& ); + + /// Sfx item RES_TXTATR_FTN + virtual void TextFootnote_Impl( const SwFmtFtn& ) = 0; + + /// Sfx item RES_PARATR_LINESPACING + void ParaLineSpacing( const SvxLineSpacingItem& ); + + /// Count the values in ParaLineSpacing, and pass theme here. + virtual void ParaLineSpacing_Impl( short nSpace, short nMulti ) = 0; + + /// Sfx item RES_PARATR_ADJUST + virtual void ParaAdjust( const SvxAdjustItem& ) = 0; + + /// Sfx item RES_PARATR_SPLIT + virtual void ParaSplit( const SvxFmtSplitItem& ) = 0; + + /// Sfx item RES_PARATR_WIDOWS + virtual void ParaWidows( const SvxWidowsItem& ) = 0; + + /// Sfx item RES_PARATR_TABSTOP + virtual void ParaTabStop( const SvxTabStopItem& ) = 0; + + /// Sfx item RES_PARATR_HYPHENZONE + virtual void ParaHyphenZone( const SvxHyphenZoneItem& ) = 0; + + /// Sfx item RES_PARATR_NUMRULE + void ParaNumRule( const SwNumRuleItem& ); + + /// Numbering - the implementation. + virtual void ParaNumRule_Impl( const SwTxtNode *pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId ) = 0; + + /// Sfx item RES_PARATR_SCRIPTSPACE + virtual void ParaScriptSpace( const SfxBoolItem& ) = 0; + + /// Sfx item RES_PARATR_HANGINGPUNCTUATION + void ParaHangingPunctuation( const SfxBoolItem& rHt ) { ParaScriptSpace( rHt ); }; + + /// Sfx item RES_PARATR_FORBIDDEN_RULES + void ParaForbiddenRules( const SfxBoolItem& rHt ) { ParaScriptSpace( rHt ); }; + + /// Sfx item RES_PARATR_VERTALIGN + virtual void ParaVerticalAlign( const SvxParaVertAlignItem& ) = 0; + + /// Sfx item RES_PARATR_SNAPTOGRID + virtual void ParaSnapToGrid( const SvxParaGridItem& ) = 0; + + /// Sfx item RES_FRM_SIZE + virtual void FormatFrameSize( const SwFmtFrmSize& ) = 0; + + /// Sfx item RES_PAPER_BIN + virtual void FormatPaperBin( const SvxPaperBinItem& ) = 0; + + /// Sfx item RES_LR_SPACE + virtual void FormatLRSpace( const SvxLRSpaceItem& ) = 0; + + /// Sfx item RES_UL_SPACE + virtual void FormatULSpace( const SvxULSpaceItem& ) = 0; + + /// Sfx item RES_PAGEDESC + void FormatPageDescription( const SwFmtPageDesc& ); + + /// Sfx item RES_BREAK + void FormatBreak( const SvxFmtBreakItem& ); + + /// Sfx item RES_SURROUND + virtual void FormatSurround( const SwFmtSurround& ) = 0; + + /// Sfx item RES_VERT_ORIENT + virtual void FormatVertOrientation( const SwFmtVertOrient& ) = 0; + + /// Sfx item RES_HORI_ORIENT + virtual void FormatHorizOrientation( const SwFmtHoriOrient& ) = 0; + + /// Sfx item RES_ANCHOR + virtual void FormatAnchor( const SwFmtAnchor& ) = 0; + + /// Sfx item RES_BACKGROUND + virtual void FormatBackground( const SvxBrushItem& ) = 0; + + /// Sfx item RES_BOX + virtual void FormatBox( const SvxBoxItem& ) = 0; + + /// Sfx item RES_COL + void FormatColumns( const SwFmtCol& ); + + virtual void FormatColumns_Impl( USHORT nCols, const SwFmtCol & rCol, bool bEven, SwTwips nPageSize ) = 0; + + /// Sfx item RES_KEEP + virtual void FormatKeep( const SvxFmtKeepItem& ) = 0; + + /// Sfx item RES_TEXTGRID + virtual void FormatTextGrid( const SwTextGridItem& ) = 0; + + /// Sfx item RES_LINENUMBER + virtual void FormatLineNumbering( const SwFmtLineNumber& ) = 0; + + /// Sfx item RES_FRAMEDIR + virtual void FormatFrameDirection( const SvxFrameDirectionItem& ) = 0; + + /// Write the expanded field + virtual void WriteExpand( const SwField* pFld ) = 0; + + virtual void RefField( const SwField& rFld, const String& rRef ) = 0; + virtual void HiddenField( const SwField& rFld ) = 0; + virtual void SetField( const SwField& rFld, ww::eField eType, const String& rCmd ) = 0; + virtual void PostitField( const SwField* pFld ) = 0; + virtual bool DropdownField( const SwField* pFld ) = 0; + + virtual bool AnalyzeURL( const String& rUrl, const String& rTarget, String* pLinkURL, String* pMark ); + + std::vector<SwTwips> GetGridCols( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + void GetTablePageSize( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner, sal_uInt32& rPageSize, bool& rRelBoxSize ); + +public: + AttributeOutputBase() {} + virtual ~AttributeOutputBase() {} + + /// Return the right export class. + virtual MSWordExportBase& GetExport() = 0; + + /// Call the right virtual function according to the type of the item. + void OutputItem( const SfxPoolItem& rHt ); + + /// Use OutputItem() on an item set - for styles. + void OutputStyleItemSet( const SfxItemSet& rSet, BOOL bDeep, BOOL bTestForDefault ); + + /// Output frames. + void OutputFlyFrame( const sw::Frame& rFmt ); +}; + +#endif // _ATTRIBUTEOUTPUTBASE_HXX_ + +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx new file mode 100644 index 0000000000..44a5c329a5 --- /dev/null +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -0,0 +1,3324 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "docxattributeoutput.hxx" +#include "docxexport.hxx" +#include "docxfootnotes.hxx" +#include "writerwordglue.hxx" +#include "wrtww8.hxx" +#include "ww8par.hxx" + +#include <oox/core/tokens.hxx> +#include <oox/export/drawingml.hxx> +#include <oox/export/utils.hxx> +#include <oox/export/vmlexport.hxx> + +#include <i18npool/mslangid.hxx> + +#include <hintids.hxx> + +#include <svtools/poolitem.hxx> + +#include <svx/fontitem.hxx> +#include <svx/tstpitem.hxx> +#include <svx/adjitem.hxx> +#include <svx/spltitem.hxx> +#include <svx/widwitem.hxx> +#include <svx/lspcitem.hxx> +#include <svx/keepitem.hxx> +#include <svx/shaditem.hxx> +#include <svx/brshitem.hxx> +#include <svx/postitem.hxx> +#include <svx/wghtitem.hxx> +#include <svx/kernitem.hxx> +#include <svx/crsditem.hxx> +#include <svx/cmapitem.hxx> +#include <svx/wrlmitem.hxx> +#include <svx/udlnitem.hxx> +#include <svx/langitem.hxx> +#include <svx/escpitem.hxx> +#include <svx/fhgtitem.hxx> +#include <svx/colritem.hxx> +#include <svx/hyznitem.hxx> +#include <svx/brkitem.hxx> +#include <svx/lrspitem.hxx> +#include <svx/ulspitem.hxx> +#include <svx/boxitem.hxx> +#include <svx/cntritem.hxx> +#include <svx/shdditem.hxx> +#include <svx/akrnitem.hxx> +#include <svx/pbinitem.hxx> +#include <svx/emphitem.hxx> +#include <svx/twolinesitem.hxx> +#include <svx/charscaleitem.hxx> +#include <svx/charrotateitem.hxx> +#include <svx/charreliefitem.hxx> +#include <svx/paravertalignitem.hxx> +#include <svx/pgrditem.hxx> +#include <svx/frmdiritem.hxx> +#include <svx/blnkitem.hxx> +#include <svx/charhiddenitem.hxx> +#include <svx/svdmodel.hxx> +#include <svx/svdobj.hxx> + +#include <docufld.hxx> +#include <flddropdown.hxx> +#include <format.hxx> +#include <fmtclds.hxx> +#include <fmtinfmt.hxx> +#include <fmtfld.hxx> +#include <fmtfsize.hxx> +#include <fmtftn.hxx> +#include <fmtrowsplt.hxx> +#include <fmtline.hxx> +#include <frmfmt.hxx> +#include <frmatr.hxx> +#include <ftninfo.hxx> +#include <htmltbl.hxx> +#include <ndgrf.hxx> +#include <ndtxt.hxx> +#include <node.hxx> +#include <pagedesc.hxx> +#include <paratr.hxx> +#include <swmodule.hxx> +#include <swtable.hxx> +#include <txtftn.hxx> +#include <txtinet.hxx> +#include <numrule.hxx> + +#include <rtl/strbuf.hxx> +#include <rtl/ustrbuf.hxx> +#include <rtl/ustring.hxx> + +#include <tools/color.hxx> + +#include <com/sun/star/i18n/ScriptType.hdl> + +#if OSL_DEBUG_LEVEL > 0 +#include <stdio.h> +#endif + +using rtl::OString; +using rtl::OStringBuffer; +using rtl::OUString; +using rtl::OUStringBuffer; +using rtl::OUStringToOString; + +using namespace docx; +using namespace sax_fastparser; +using namespace nsSwDocInfoSubType; +using namespace nsFieldFlags; +using namespace sw::util; + +void DocxAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 /*nScript*/ ) +{ + if (bIsRTL) + m_pSerializer->singleElementNS( XML_w, XML_rtl, FSNS( XML_w, XML_val ), "true", FSEND ); +} + +void DocxAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo ) +{ + if ( m_nColBreakStatus == COLBRK_POSTPONE ) + m_nColBreakStatus = COLBRK_WRITE; + + // Output table/table row/table cell starts if needed + if ( pTextNodeInfo.get() ) + { + sal_uInt32 nRow = pTextNodeInfo->getRow(); + sal_uInt32 nCell = pTextNodeInfo->getCell(); + + // New cell/row? + if ( m_nTableDepth > 0 && !m_bTableCellOpen ) + { + ww8::WW8TableNodeInfoInner::Pointer_t pDeepInner( pTextNodeInfo->getInnerForDepth( m_nTableDepth ) ); + if ( pDeepInner->getCell() == 0 ) + StartTableRow( pDeepInner ); + + StartTableCell( pDeepInner ); + } + + if ( nRow == 0 && nCell == 0 ) + { + // Do we have to start the table? + // [If we are at the rigth depth already, it means that we + // continue the table cell] + sal_uInt32 nCurrentDepth = pTextNodeInfo->getDepth(); + + if ( nCurrentDepth > m_nTableDepth ) + { + // Start all the tables that begin here + for ( sal_uInt32 nDepth = m_nTableDepth + 1; nDepth <= pTextNodeInfo->getDepth(); ++nDepth ) + { + ww8::WW8TableNodeInfoInner::Pointer_t pInner( pTextNodeInfo->getInnerForDepth( nDepth ) ); + + StartTable( pInner ); + StartTableRow( pInner ); + StartTableCell( pInner ); + } + + m_nTableDepth = nCurrentDepth; + } + } + } + + m_pSerializer->startElementNS( XML_w, XML_p, FSEND ); + + // postpone the output of the run (we get it before the paragraph + // properties, but must write it after them) + m_pSerializer->mark(); + + // no section break in this paragraph yet; can be set in SectionBreak() + m_pSectionInfo = NULL; + + m_bParagraphOpened = true; +} + +void DocxAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) +{ + // write the paragraph properties + the run, already in the correct order + m_pSerializer->mergeTopMarks(); + m_pSerializer->endElementNS( XML_w, XML_p ); + + // Check for end of cell, rows, tables here + FinishTableRowCell( pTextNodeInfoInner ); + + m_bParagraphOpened = false; +} + +void DocxAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool bForceEmptyParagraph ) +{ + if ( pInner.get() ) + { + // Where are we in the table + sal_uInt32 nRow = pInner->getRow( ); + + const SwTable *pTable = pInner->getTable( ); + const SwTableLines& rLines = pTable->GetTabLines( ); + USHORT nLinesCount = rLines.Count( ); + + if ( pInner->isEndOfCell() ) + { + if ( bForceEmptyParagraph ) + m_pSerializer->singleElementNS( XML_w, XML_p, FSEND ); + + EndTableCell(); + } + + // This is a line end + if ( pInner->isEndOfLine() ) + EndTableRow(); + + // This is the end of the table + if ( pInner->isEndOfLine( ) && ( nRow + 1 ) == nLinesCount ) + EndTable(); + } +} + +void DocxAttributeOutput::EmptyParagraph() +{ + m_pSerializer->singleElementNS( XML_w, XML_p, FSEND ); +} + +void DocxAttributeOutput::StartParagraphProperties( const SwTxtNode& rNode ) +{ + // output page/section breaks + // Writer can have them at the beginning of a paragraph, or at the end, but + // in docx, we have to output them in the paragraph properties of the last + // paragraph in a section. To get it right, we have to switch to the next + // paragraph, and detect the section breaks there. + SwNodeIndex aNextIndex( rNode, 1 ); + if ( aNextIndex.GetNode().IsTxtNode() ) + { + const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >( &aNextIndex.GetNode() ); + m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode ); + } + else if ( aNextIndex.GetNode().IsTableNode() ) + { + const SwTableNode* pTableNode = static_cast< SwTableNode* >( &aNextIndex.GetNode() ); + const SwFrmFmt *pFmt = pTableNode->GetTable().GetFrmFmt(); + m_rExport.OutputSectionBreaks( &(pFmt->GetAttrSet()), *pTableNode ); + } + + // postpone the output so that we can later [in EndParagraphProperties()] + // prepend the properties before the run + m_pSerializer->mark(); + + m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND ); + + // and output the section break now (if it appeared) + if ( m_pSectionInfo ) + { + m_rExport.SectionProperties( *m_pSectionInfo ); + m_pSectionInfo = NULL; + } + + InitCollectedParagraphProperties(); +} + +void DocxAttributeOutput::InitCollectedParagraphProperties() +{ + m_pSpacingAttrList = NULL; +} + +void DocxAttributeOutput::WriteCollectedParagraphProperties() +{ + if ( m_pSpacingAttrList ) + { + XFastAttributeListRef xAttrList( m_pSpacingAttrList ); + m_pSpacingAttrList = NULL; + + m_pSerializer->singleElementNS( XML_w, XML_spacing, xAttrList ); + } +} + +void DocxAttributeOutput::EndParagraphProperties() +{ + WriteCollectedParagraphProperties(); + + m_pSerializer->endElementNS( XML_w, XML_pPr ); + + if ( m_nColBreakStatus == COLBRK_WRITE ) + { + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_br, + FSNS( XML_w, XML_type ), "column", FSEND ); + m_pSerializer->endElementNS( XML_w, XML_r ); + + m_nColBreakStatus = COLBRK_NONE; + } + + // merge the properties _before_ the run (strictly speaking, just + // after the start of the paragraph) + m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND ); +} + +void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData ) +{ + // if there is some redlining in the document, output it + StartRedline( pRedlineData ); + + // postpone the output of the start of a run (there are elements that need + // to be written before the start of the run, but we learn which they are + // _inside_ of the run) + m_pSerializer->mark(); // let's call it "postponed run start" + + // postpone the output of the text (we get it before the run properties, + // but must write it after them) + m_pSerializer->mark(); // let's call it "postponed text" +} + +void DocxAttributeOutput::EndRun() +{ + // Write field starts + for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin(); pIt != m_Fields.end(); ++pIt ) + { + // Add the fields starts for all but hyperlinks and TOCs + if ( pIt->bOpen && pIt->pField ) + { + StartField_Impl( *pIt ); + + // Remove the field from the stack if only the start has to be written + // Unknown fields sould be removed too + if ( !pIt->bClose || ( pIt->eType == ww::eUNKNOWN ) ) + { + m_Fields.erase( pIt ); + --pIt; + } + } + } + + + // write the run properties + the text, already in the correct order + m_pSerializer->mergeTopMarks(); // merges with "postponed text", see above + + // level down, to be able to prepend the actual run start attribute (just + // before "postponed run start") + m_pSerializer->mark(); // let's call it "actual run start" + + // prepend the actual run start + if ( m_pHyperlinkAttrList ) + { + XFastAttributeListRef xAttrList ( m_pHyperlinkAttrList ); + + m_pSerializer->startElementNS( XML_w, XML_hyperlink, xAttrList ); + } + + // Write the hyperlink and toc fields starts + for ( std::vector<FieldInfos>::iterator pIt = m_Fields.begin(); pIt != m_Fields.end(); ++pIt ) + { + // Add the fields starts for hyperlinks, TOCs and index marks + if ( pIt->bOpen ) + { + StartField_Impl( *pIt, sal_True ); + + // Remove the field if no end needs to be written + if ( !pIt->bClose ) { + m_Fields.erase( pIt ); + --pIt; + } + } + } + + DoWriteBookmarks( ); + + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND ); // merges with "postponed run start", see above + + // write the run start + the run content + m_pSerializer->mergeTopMarks(); // merges the "actual run start" + + // append the actual run end + m_pSerializer->endElementNS( XML_w, XML_r ); + + if ( m_pHyperlinkAttrList ) + { + m_pSerializer->endElementNS( XML_w, XML_hyperlink ); + m_pHyperlinkAttrList = NULL; + } + + while ( m_Fields.begin() != m_Fields.end() ) + { + EndField_Impl( m_Fields.front( ) ); + m_Fields.erase( m_Fields.begin( ) ); + } + + // if there is some redlining in the document, output it + EndRedline(); +} + +void DocxAttributeOutput::DoWriteBookmarks() +{ + // Write the start bookmarks + for ( std::vector< OString >::const_iterator it = m_rMarksStart.begin(), end = m_rMarksStart.end(); + it < end; ++it ) + { + const OString& rName = *it; + + // Output the bookmark + USHORT nId = m_nNextMarkId++; + m_rOpenedMarksIds[rName] = nId; + m_pSerializer->singleElementNS( XML_w, XML_bookmarkStart, + FSNS( XML_w, XML_id ), OString::valueOf( sal_Int32( nId ) ).getStr( ), + FSNS( XML_w, XML_name ), rName.getStr(), + FSEND ); + } + m_rMarksStart.clear(); + + // export the end bookmarks + for ( std::vector< OString >::const_iterator it = m_rMarksEnd.begin(), end = m_rMarksEnd.end(); + it < end; ++it ) + { + const OString& rName = *it; + + // Get the id of the bookmark + std::map< OString, USHORT >::iterator pPos = m_rOpenedMarksIds.find( rName ); + if ( pPos != m_rOpenedMarksIds.end( ) ) + { + USHORT nId = ( *pPos ).second; + m_pSerializer->singleElementNS( XML_w, XML_bookmarkEnd, + FSNS( XML_w, XML_id ), OString::valueOf( sal_Int32( nId ) ).getStr( ), + FSEND ); + m_rOpenedMarksIds.erase( rName ); + } + } + m_rMarksEnd.clear(); +} + +void DocxAttributeOutput::StartField_Impl( FieldInfos& rInfos, sal_Bool bWriteRun ) +{ + if ( rInfos.pField && rInfos.eType == ww::eUNKNOWN ) + { + // Expand unsupported fields + RunText( rInfos.pField->Expand( ) ); + } + else if ( rInfos.eType != ww::eNONE ) // HYPERLINK fields are just commands + { + if ( bWriteRun ) + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + + if ( rInfos.eType == ww::eFORMDROPDOWN ) + { + m_pSerializer->startElementNS( XML_w, XML_fldChar, + FSNS( XML_w, XML_fldCharType ), "begin", + FSEND ); + + const SwDropDownField& rFld2 = *(SwDropDownField*)rInfos.pField; + uno::Sequence<rtl::OUString> aItems = + rFld2.GetItemSequence(); + GetExport().DoComboBox(rFld2.GetName(), + rFld2.GetHelp(), + rFld2.GetToolTip(), + rFld2.GetSelectedItem(), aItems); + + m_pSerializer->endElementNS( XML_w, XML_fldChar ); + + if ( bWriteRun ) + m_pSerializer->endElementNS( XML_w, XML_r ); + + } + else + { + // Write the field start + m_pSerializer->singleElementNS( XML_w, XML_fldChar, + FSNS( XML_w, XML_fldCharType ), "begin", + FSEND ); + + if ( bWriteRun ) + m_pSerializer->endElementNS( XML_w, XML_r ); + + // The hyperlinks fields can't be expanded: the value is + // normally in the text run + if ( !rInfos.pField ) + CmdField_Impl( rInfos ); + } + } +} + +void DocxAttributeOutput::DoWriteCmd( String& rCmd ) +{ + // Write the Field command + m_pSerializer->startElementNS( XML_w, XML_instrText, FSEND ); + m_pSerializer->writeEscaped( OUString( rCmd ) ); + m_pSerializer->endElementNS( XML_w, XML_instrText ); + +} + +void DocxAttributeOutput::CmdField_Impl( FieldInfos& rInfos ) +{ + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + xub_StrLen nNbToken = rInfos.sCmd.GetTokenCount( '\t' ); + + for ( xub_StrLen i = 0; i < nNbToken; i++ ) + { + String sToken = rInfos.sCmd.GetToken( i, '\t' ); + // Write the Field command + DoWriteCmd( sToken ); + + // Replace tabs by </instrText><tab/><instrText> + if ( i < ( nNbToken - 1 ) ) + RunText( String::CreateFromAscii( "\t" ) ); + } + + m_pSerializer->endElementNS( XML_w, XML_r ); + + + // Write the Field separator + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_fldChar, + FSNS( XML_w, XML_fldCharType ), "separate", + FSEND ); + m_pSerializer->endElementNS( XML_w, XML_r ); +} + +void DocxAttributeOutput::EndField_Impl( FieldInfos& rInfos ) +{ + // The command has to be written before for the hyperlinks + if ( rInfos.pField ) + { + CmdField_Impl( rInfos ); + } + + // Write the bookmark start if any + OUString aBkmName( m_sFieldBkm ); + if ( aBkmName.getLength( ) > 0 ) + { + m_pSerializer->singleElementNS( XML_w, XML_bookmarkStart, + FSNS( XML_w, XML_id ), OString::valueOf( sal_Int32( m_nNextMarkId ) ).getStr( ), + FSNS( XML_w, XML_name ), OUStringToOString( aBkmName, RTL_TEXTENCODING_UTF8 ).getStr( ), + FSEND ); + } + + if (rInfos.pField ) // For hyperlinks and TOX + { + // Write the Field latest value + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + + // Find another way for hyperlinks + RunText( rInfos.pField->Expand( ) ); + m_pSerializer->endElementNS( XML_w, XML_r ); + } + + // Write the bookmark end if any + if ( aBkmName.getLength( ) > 0 ) + { + m_pSerializer->singleElementNS( XML_w, XML_bookmarkEnd, + FSNS( XML_w, XML_id ), OString::valueOf( sal_Int32( m_nNextMarkId ) ).getStr( ), + FSEND ); + + m_nNextMarkId++; + } + + // Write the Field end + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_fldChar, + FSNS( XML_w, XML_fldCharType ), "end", + FSEND ); + m_pSerializer->endElementNS( XML_w, XML_r ); + + + // Write the ref field if a bookmark had to be set and the field + // should be visible + if ( rInfos.pField ) + { + USHORT nSubType = rInfos.pField->GetSubType( ); + bool bIsSetField = rInfos.pField->GetTyp( )->Which( ) == RES_SETEXPFLD; + bool bShowRef = ( !bIsSetField || ( nSubType & nsSwExtendedSubType::SUB_INVISIBLE ) ) ? false : true; + + if ( ( m_sFieldBkm.Len( ) > 0 ) && bShowRef ) + { + // Write the field beginning + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_fldChar, + FSNS( XML_w, XML_fldCharType ), "begin", + FSEND ); + m_pSerializer->endElementNS( XML_w, XML_r ); + + rInfos.sCmd = FieldString( ww::eREF ); + rInfos.sCmd.APPEND_CONST_ASC( "\"" ); + rInfos.sCmd += m_sFieldBkm; + rInfos.sCmd.APPEND_CONST_ASC( "\" " ); + + // Clean the field bookmark data to avoid infinite loop + m_sFieldBkm = String( ); + + // Write the end of the field + EndField_Impl( rInfos ); + } + } +} + +void DocxAttributeOutput::StartRunProperties() +{ + // postpone the output so that we can later [in EndRunProperties()] + // prepend the properties before the text + m_pSerializer->mark(); + + m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND ); + + InitCollectedRunProperties(); +} + +void DocxAttributeOutput::InitCollectedRunProperties() +{ + m_pFontsAttrList = NULL; + m_pEastAsianLayoutAttrList = NULL; + m_pCharLangAttrList = NULL; +} + +void DocxAttributeOutput::WriteCollectedRunProperties() +{ + // Write all differed properties + if ( m_pFontsAttrList ) + { + XFastAttributeListRef xAttrList( m_pFontsAttrList ); + m_pFontsAttrList = NULL; + + m_pSerializer->singleElementNS( XML_w, XML_rFonts, xAttrList ); + } + + if ( m_pEastAsianLayoutAttrList ) + { + XFastAttributeListRef xAttrList( m_pEastAsianLayoutAttrList ); + m_pEastAsianLayoutAttrList = NULL; + + m_pSerializer->singleElementNS( XML_w, XML_eastAsianLayout, xAttrList ); + } + + if ( m_pCharLangAttrList ) + { + XFastAttributeListRef xAttrList( m_pCharLangAttrList ); + m_pCharLangAttrList = NULL; + + m_pSerializer->singleElementNS( XML_w, XML_lang, xAttrList ); + } +} + +void DocxAttributeOutput::EndRunProperties( const SwRedlineData* /*pRedlineData*/ ) +{ + WriteCollectedRunProperties(); + + m_pSerializer->endElementNS( XML_w, XML_rPr ); + + // write footnotes/endnotes if we have any + FootnoteEndnoteReference(); + + // merge the properties _before_ the run text (strictly speaking, just + // after the start of the run) + m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND ); +} + +/** Output sal_Unicode* as a run text (<t>the text</t>). + + When bMove is true, update rBegin to point _after_ the end of the text + + 1, meaning that it skips one character after the text. This is to make + the switch in DocxAttributeOutput::RunText() nicer ;-) + */ +static void impl_WriteRunText( FSHelperPtr pSerializer, sal_Int32 nTextToken, + const sal_Unicode* &rBegin, const sal_Unicode* pEnd, bool bMove = true ) +{ + const sal_Unicode *pBegin = rBegin; + + // skip one character after the end + if ( bMove ) + rBegin = pEnd + 1; + + if ( pBegin >= pEnd ) + return; // we want to write at least one character + + // we have to add 'preserve' when starting/ending with space + if ( *pBegin == sal_Unicode( ' ' ) || *( pEnd - 1 ) == sal_Unicode( ' ' ) ) + { + pSerializer->startElementNS( XML_w, nTextToken, FSNS( XML_xml, XML_space ), "preserve", FSEND ); + } + else + pSerializer->startElementNS( XML_w, nTextToken, FSEND ); + + pSerializer->writeEscaped( OUString( pBegin, pEnd - pBegin ) ); + + pSerializer->endElementNS( XML_w, nTextToken ); +} + +void DocxAttributeOutput::RunText( const String& rText, rtl_TextEncoding /*eCharSet*/ ) +{ + OUString aText( rText ); + + // one text can be split into more <w:t>blah</w:t>'s by line breaks etc. + const sal_Unicode *pBegin = aText.getStr(); + const sal_Unicode *pEnd = pBegin + aText.getLength(); + + // the text run is usually XML_t, with the exception of the deleted text + sal_Int32 nTextToken = XML_t; + if ( m_pRedlineData && m_pRedlineData->GetType() == nsRedlineType_t::REDLINE_DELETE ) + nTextToken = XML_delText; + + for ( const sal_Unicode *pIt = pBegin; pIt < pEnd; ++pIt ) + { + switch ( *pIt ) + { + case 0x09: // tab + impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ); + m_pSerializer->singleElementNS( XML_w, XML_tab, FSEND ); + break; + case 0x0b: // line break + impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ); + m_pSerializer->singleElementNS( XML_w, XML_br, FSEND ); + break; + default: + if ( *pIt < 0x0020 ) // filter out the control codes + { + impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pIt ); +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "Ignored control code %x in a text run.", *pIt ); +#endif + } + break; + } + } + + impl_WriteRunText( m_pSerializer, nTextToken, pBegin, pEnd, false ); +} + +void DocxAttributeOutput::RawText( const String& /*rText*/, bool /*bForceUnicode*/, rtl_TextEncoding /*eCharSet*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::RawText( const String& rText, bool bForceUnicode, rtl_TextEncoding eCharSet )\n" ); +#endif +} + +void DocxAttributeOutput::StartRuby( const SwTxtNode& /*rNode*/, const SwFmtRuby& /*rRuby*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::StartRuby( const SwTxtNode& rNode, const SwFmtRuby& rRuby )\n" ); +#endif +} + +void DocxAttributeOutput::EndRuby() +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::EndRuby()\n" ); +#endif +} + +bool DocxAttributeOutput::AnalyzeURL( const String& rUrl, const String& rTarget, String* pLinkURL, String* pMark ) +{ + bool bBookMarkOnly = AttributeOutputBase::AnalyzeURL( rUrl, rTarget, pLinkURL, pMark ); + + String sURL = *pLinkURL; + String sMark = *pMark; + + bool bOutputField = sMark.Len(); + + if ( bOutputField ) + { + if ( bBookMarkOnly ) + sURL = FieldString( ww::eHYPERLINK ); + else + { + String sFld( FieldString( ww::eHYPERLINK ) ); + sFld.APPEND_CONST_ASC( "\"" ); + sURL.Insert( sFld, 0 ); + sURL += '\"'; + } + + if ( sMark.Len() ) + ( ( sURL.APPEND_CONST_ASC( " \\l \"" ) ) += sMark ) += '\"'; + + if ( rTarget.Len() ) + ( sURL.APPEND_CONST_ASC( " \\n " ) ) += rTarget; + } + + *pLinkURL = sURL; + *pMark = sMark; + + return bBookMarkOnly; +} + +bool DocxAttributeOutput::StartURL( const String& rUrl, const String& rTarget ) +{ + String sMark; + String sUrl; + + bool bBookmarkOnly = AnalyzeURL( rUrl, rTarget, &sUrl, &sMark ); + + if ( sMark.Len() && !bBookmarkOnly ) + { + m_rExport.OutputField( NULL, ww::eHYPERLINK, sUrl ); + } + else + { + // Output a hyperlink XML element + + m_pHyperlinkAttrList = m_pSerializer->createAttrList(); + if ( !bBookmarkOnly ) + { + OUString osUrl( sUrl ); + + ::rtl::OString sId = m_rExport.AddRelation( + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" ), + osUrl, S("External") ); + m_pHyperlinkAttrList->add( FSNS( XML_r, XML_id), sId.getStr()); + } + else + m_pHyperlinkAttrList->add( FSNS( XML_w, XML_anchor ), + OUStringToOString( OUString( sMark ), RTL_TEXTENCODING_UTF8 ).getStr( ) ); + + OUString sTarget( rTarget ); + if ( sTarget.getLength( ) > 0 ) + { + OString soTarget = OUStringToOString( sTarget, RTL_TEXTENCODING_UTF8 ); + m_pHyperlinkAttrList->add(FSNS( XML_w, XML_tgtFrame ), soTarget.getStr()); + } + } + + return true; +} + +bool DocxAttributeOutput::EndURL() +{ + return true; +} + +void DocxAttributeOutput::FieldVanish( const String& rTxt, ww::eField eType ) +{ + WriteField_Impl( NULL, eType, rTxt, WRITEFIELD_ALL ); +} + +void DocxAttributeOutput::Redline( const SwRedlineData* /*pRedline*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::Redline( const SwRedlineData* pRedline )\n" ); +#endif +} + +/// Append the number as 2-digit when less than 10. +static void impl_AppendTwoDigits( OStringBuffer &rBuffer, sal_Int32 nNum ) +{ + if ( nNum < 0 || nNum > 99 ) + { + rBuffer.append( "00" ); + return; + } + + if ( nNum < 10 ) + rBuffer.append( '0' ); + + rBuffer.append( nNum ); +} + +/** Convert DateTime to xsd::dateTime string. + +I guess there must be an implementation of this somewhere in OOo, but I failed +to find it, unfortunately :-( +*/ +static OString impl_DateTimeToOString( const DateTime& rDateTime ) +{ + DateTime aInUTC( rDateTime ); + aInUTC.ConvertToUTC(); + + OStringBuffer aBuffer( 25 ); + aBuffer.append( sal_Int32( aInUTC.GetYear() ) ); + aBuffer.append( '-' ); + + impl_AppendTwoDigits( aBuffer, aInUTC.GetMonth() ); + aBuffer.append( '-' ); + + impl_AppendTwoDigits( aBuffer, aInUTC.GetDay() ); + aBuffer.append( 'T' ); + + impl_AppendTwoDigits( aBuffer, aInUTC.GetHour() ); + aBuffer.append( ':' ); + + impl_AppendTwoDigits( aBuffer, aInUTC.GetMin() ); + aBuffer.append( ':' ); + + impl_AppendTwoDigits( aBuffer, aInUTC.GetSec() ); + aBuffer.append( 'Z' ); // we are in UTC + + return aBuffer.makeStringAndClear(); +} + +void DocxAttributeOutput::StartRedline( const SwRedlineData* pRedlineData ) +{ + m_pRedlineData = pRedlineData; + + if ( !m_pRedlineData ) + return; + + // FIXME check if it's necessary to travel over the Next()'s in pRedlineData + + OString aId( OString::valueOf( m_nRedlineId++ ) ); + + const String &rAuthor( SW_MOD()->GetRedlineAuthor( pRedlineData->GetAuthor() ) ); + OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) ); + + OString aDate( impl_DateTimeToOString( pRedlineData->GetTimeStamp() ) ); + + switch ( pRedlineData->GetType() ) + { + case nsRedlineType_t::REDLINE_INSERT: + m_pSerializer->startElementNS( XML_w, XML_ins, + FSNS( XML_w, XML_id ), aId.getStr(), + FSNS( XML_w, XML_author ), aAuthor.getStr(), + FSNS( XML_w, XML_date ), aDate.getStr(), + FSEND ); + break; + + case nsRedlineType_t::REDLINE_DELETE: + m_pSerializer->startElementNS( XML_w, XML_del, + FSNS( XML_w, XML_id ), aId.getStr(), + FSNS( XML_w, XML_author ), aAuthor.getStr(), + FSNS( XML_w, XML_date ), aDate.getStr(), + FSEND ); + break; + + case nsRedlineType_t::REDLINE_FORMAT: +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::StartRedline()\n" ); +#endif + default: + break; + } +} + +void DocxAttributeOutput::EndRedline() +{ + if ( !m_pRedlineData ) + return; + + switch ( m_pRedlineData->GetType() ) + { + case nsRedlineType_t::REDLINE_INSERT: + m_pSerializer->endElementNS( XML_w, XML_ins ); + break; + + case nsRedlineType_t::REDLINE_DELETE: + m_pSerializer->endElementNS( XML_w, XML_del ); + break; + + case nsRedlineType_t::REDLINE_FORMAT: +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::EndRedline()\n" ); +#endif + break; + default: + break; + } + + m_pRedlineData = NULL; +} + +void DocxAttributeOutput::FormatDrop( const SwTxtNode& /*rNode*/, const SwFmtDrop& /*rSwFmtDrop*/, USHORT /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FormatDrop( const SwTxtNode& rNode, const SwFmtDrop& rSwFmtDrop, USHORT nStyle )\n" ); +#endif +} + +void DocxAttributeOutput::ParagraphStyle( USHORT nStyle ) +{ + OString aStyleId( "style" ); + aStyleId += OString::valueOf( sal_Int32( nStyle ) ); + + m_pSerializer->singleElementNS( XML_w, XML_pStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND ); +} + +#if 0 +void DocxAttributeOutput::InTable() +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::InTable()\n" ); +#endif +} + + +void DocxAttributeOutput::TableRowProperties( bool /*bHeader*/, long /*nCellHeight*/, bool /*bCannotSplit*/, bool /*bRightToLeft*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::TableRowProperties()\n" ); +#endif +} +#endif + +static OString impl_ConvertColor( const Color &rColor ) +{ + OString color( "auto" ); + if ( rColor.GetColor() != COL_AUTO ) + { + const char pHexDigits[] = "0123456789ABCDEF"; + char pBuffer[] = "000000"; + + pBuffer[0] = pHexDigits[ ( rColor.GetRed() >> 4 ) & 0x0F ]; + pBuffer[1] = pHexDigits[ rColor.GetRed() & 0x0F ]; + pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ]; + pBuffer[3] = pHexDigits[ rColor.GetGreen() & 0x0F ]; + pBuffer[4] = pHexDigits[ ( rColor.GetBlue() >> 4 ) & 0x0F ]; + pBuffer[5] = pHexDigits[ rColor.GetBlue() & 0x0F ]; + + color = OString( pBuffer ); + } + return color; +} + +static void impl_borderLine( FSHelperPtr pSerializer, sal_Int32 elementToken, const SvxBorderLine* pBorderLine, USHORT nDist ) +{ + FastAttributeList* pAttr = pSerializer->createAttrList(); + + USHORT inW = pBorderLine->GetInWidth(); + USHORT outW = pBorderLine->GetOutWidth(); + USHORT nWidth = inW + outW; + + // Compute val attribute value + // Can be one of: + // single, double, + // basicWideOutline, basicWideInline + // OOXml also supports those types of borders, but we'll try to play with the first ones. + // thickThinMediumGap, thickThinLargeGap, thickThinSmallGap + // thinThickLargeGap, thinThickMediumGap, thinThickSmallGap + const char* pVal = "single"; + if ( pBorderLine->isDouble() ) + { + if ( inW == outW ) + pVal = ( sal_Char* )"double"; + else if ( inW > outW ) + { + pVal = ( sal_Char* )"thinThickMediumGap"; + } + else if ( inW < outW ) + { + pVal = ( sal_Char* )"thickThinMediumGap"; + } + } + + pAttr->add( FSNS( XML_w, XML_val ), OString( pVal ) ); + + // Compute the sz attribute + + // The unit is the 8th of point + nWidth = sal_Int32( nWidth / 2.5 ); + USHORT nMinWidth = 2; + USHORT nMaxWidth = 96; + + if ( nWidth > nMaxWidth ) + nWidth = nMaxWidth; + else if ( nWidth < nMinWidth ) + nWidth = nMinWidth; + + pAttr->add( FSNS( XML_w, XML_sz ), OString::valueOf( sal_Int32( nWidth ) ) ); + + // Get the distance (in pt) + pAttr->add( FSNS( XML_w, XML_space ), OString::valueOf( sal_Int32( nDist / 20 ) ) ); + + // Get the color code as an RRGGBB hex value + OString sColor( impl_ConvertColor( pBorderLine->GetColor( ) ) ); + pAttr->add( FSNS( XML_w, XML_color ), sColor ); + + XFastAttributeListRef xAttrs( pAttr ); + pSerializer->singleElementNS( XML_w, elementToken, xAttrs ); +} + +static void impl_pageBorders( FSHelperPtr pSerializer, const SvxBoxItem& rBox ) +{ + static const USHORT aBorders[] = + { + BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT + }; + + static const USHORT aXmlElements[] = + { + XML_top, XML_left, XML_bottom, XML_right + }; + const USHORT* pBrd = aBorders; + for( int i = 0; i < 4; ++i, ++pBrd ) + { + const SvxBorderLine* pLn = rBox.GetLine( *pBrd ); + if ( pLn ) + impl_borderLine( pSerializer, aXmlElements[i], pLn, 0 ); + } +} + +void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + m_pSerializer->startElementNS( XML_w, XML_tcPr, FSEND ); + + const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( ); + + // The cell borders + m_pSerializer->startElementNS( XML_w, XML_tcBorders, FSEND ); + SwFrmFmt *pFmt = pTblBox->GetFrmFmt( ); + impl_pageBorders( m_pSerializer, pFmt->GetBox( ) ); + m_pSerializer->endElementNS( XML_w, XML_tcBorders ); + + // Vertical merges + long vSpan = pTblBox->getRowSpan( ); + if ( vSpan > 1 ) + { + m_pSerializer->singleElementNS( XML_w, XML_vMerge, + FSNS( XML_w, XML_val ), "restart", + FSEND ); + } + else if ( vSpan < 0 ) + { + m_pSerializer->singleElementNS( XML_w, XML_vMerge, + FSNS( XML_w, XML_val ), "continue", + FSEND ); + } + + // Horizontal spans + const SwWriteTableRows& aRows = m_pTableWrt->GetRows( ); + SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ]; + SwWriteTableCell *pCell = pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ]; + + USHORT nColSpan = pCell->GetColSpan(); + if ( nColSpan > 1 ) + m_pSerializer->singleElementNS( XML_w, XML_gridSpan, + FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nColSpan ) ).getStr(), + FSEND ); + + TableBackgrounds( pTableTextNodeInfoInner ); + + // Cell prefered width + SwTwips nWidth = GetGridCols( pTableTextNodeInfoInner )[ pTableTextNodeInfoInner->getCell() ]; + m_pSerializer->singleElementNS( XML_w, XML_tcW, + FSNS( XML_w, XML_w ), OString::valueOf( sal_Int32( nWidth ) ).getStr( ), + FSNS( XML_w, XML_type ), "dxa", + FSEND ); + + // Cell margins + m_pSerializer->startElementNS( XML_w, XML_tcMar, FSEND ); + const SvxBoxItem& rBox = pFmt->GetBox( ); + static const USHORT aBorders[] = + { + BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT + }; + + static const USHORT aXmlElements[] = + { + XML_top, XML_left, XML_bottom, XML_right + }; + const USHORT* pBrd = aBorders; + for( int i = 0; i < 4; ++i, ++pBrd ) + { + sal_Int32 nDist = sal_Int32( rBox.GetDistance( *pBrd ) ); + m_pSerializer->singleElementNS( XML_w, aXmlElements[i], + FSNS( XML_w, XML_w ), OString::valueOf( nDist ).getStr( ), + FSNS( XML_w, XML_type ), "dxa", + FSEND ); + } + + m_pSerializer->endElementNS( XML_w, XML_tcMar ); + + TableVerticalCell( pTableTextNodeInfoInner ); + + m_pSerializer->endElementNS( XML_w, XML_tcPr ); +} + +void DocxAttributeOutput::InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + sal_uInt32 nPageSize = 0; + bool bRelBoxSize = false; + + // Create the SwWriteTable instance to use col spans (and maybe other infos) + GetTablePageSize( pTableTextNodeInfoInner, nPageSize, bRelBoxSize ); + + const SwTable* pTable = pTableTextNodeInfoInner->getTable( ); + const SwFrmFmt *pFmt = pTable->GetFrmFmt( ); + SwTwips nTblSz = pFmt->GetFrmSize( ).GetWidth( ); + + const SwHTMLTableLayout *pLayout = pTable->GetHTMLTableLayout(); + if( pLayout && pLayout->IsExportable() ) + m_pTableWrt = new SwWriteTable( pLayout ); + else + m_pTableWrt = new SwWriteTable( pTable->GetTabLines(), (USHORT)nPageSize, + (USHORT)nTblSz, false); +} + +void DocxAttributeOutput::StartTable( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + m_pSerializer->startElementNS( XML_w, XML_tbl, FSEND ); + + InitTableHelper( pTableTextNodeInfoInner ); + TableDefinition( pTableTextNodeInfoInner ); +} + +void DocxAttributeOutput::EndTable() +{ + m_pSerializer->endElementNS( XML_w, XML_tbl ); + + if ( m_nTableDepth > 0 ) + --m_nTableDepth; + + // We closed the table; if it is a nested table, the cell that contains it + // still continues + m_bTableCellOpen = true; + + // Cleans the table helper + delete m_pTableWrt, m_pTableWrt = NULL; +} + +void DocxAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + m_pSerializer->startElementNS( XML_w, XML_tr, FSEND ); + + // Output the row properties + m_pSerializer->startElementNS( XML_w, XML_trPr, FSEND ); + + // Header row: tblHeader + const SwTable *pTable = pTableTextNodeInfoInner->getTable( ); + if ( pTable->GetRowsToRepeat( ) > pTableTextNodeInfoInner->getRow( ) ) + m_pSerializer->singleElementNS( XML_w, XML_tblHeader, + FSNS( XML_w, XML_val ), "true", + FSEND ); + + TableHeight( pTableTextNodeInfoInner ); + TableCanSplit( pTableTextNodeInfoInner ); + + m_pSerializer->endElementNS( XML_w, XML_trPr ); +} + +void DocxAttributeOutput::EndTableRow( ) +{ + m_pSerializer->endElementNS( XML_w, XML_tr ); +} + + +void DocxAttributeOutput::StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + if ( !m_pTableWrt ) + InitTableHelper( pTableTextNodeInfoInner ); + + m_pSerializer->startElementNS( XML_w, XML_tc, FSEND ); + + // Write the cell properties here + TableCellProperties( pTableTextNodeInfoInner ); + + m_bTableCellOpen = true; +} + +void DocxAttributeOutput::EndTableCell( ) +{ + m_pSerializer->endElementNS( XML_w, XML_tc ); + + m_bTableCellOpen = false; +} + +void DocxAttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ ) +{ +} + +void DocxAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfo*/ ) +{ +} + +void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + // Write the table properties + m_pSerializer->startElementNS( XML_w, XML_tblPr, FSEND ); + + sal_uInt32 nPageSize = 0; + bool bRelBoxSize = false; + + // Create the SwWriteTable instance to use col spans (and maybe other infos) + GetTablePageSize( pTableTextNodeInfoInner, nPageSize, bRelBoxSize ); + + // Output the table prefered width + if ( nPageSize != 0 ) + m_pSerializer->singleElementNS( XML_w, XML_tblW, + FSNS( XML_w, XML_w ), OString::valueOf( sal_Int32( nPageSize ) ).getStr( ), + FSNS( XML_w, XML_type ), "dxa", + FSEND ); + + // Output the table borders + TableDefaultBorders( pTableTextNodeInfoInner ); + TableBidi( pTableTextNodeInfoInner ); + + // Output the table alignement + const SwTable *pTable = pTableTextNodeInfoInner->getTable(); + SwFrmFmt *pTblFmt = pTable->GetFrmFmt( ); + const char* pJcVal; + sal_Int32 nIndent = 0; + switch ( pTblFmt->GetHoriOrient( ).GetHoriOrient( ) ) + { + case text::HoriOrientation::CENTER: + pJcVal = "center"; + break; + case text::HoriOrientation::RIGHT: + pJcVal = "right"; + break; + default: + case text::HoriOrientation::NONE: + case text::HoriOrientation::LEFT_AND_WIDTH: + { + pJcVal = "left"; + nIndent = sal_Int32( pTblFmt->GetLRSpace( ).GetLeft( ) ); + break; + } + } + m_pSerializer->singleElementNS( XML_w, XML_jc, + FSNS( XML_w, XML_val ), pJcVal, + FSEND ); + + // Table indent + if ( nIndent != 0 ) + m_pSerializer->singleElementNS( XML_w, XML_tblInd, + FSNS( XML_w, XML_w ), OString::valueOf( nIndent ).getStr( ), + FSNS( XML_w, XML_type ), "dxa", + FSEND ); + + m_pSerializer->endElementNS( XML_w, XML_tblPr ); + + + // Write the table grid infos + m_pSerializer->startElementNS( XML_w, XML_tblGrid, FSEND ); + + std::vector<SwTwips> gridCols = GetGridCols( pTableTextNodeInfoInner ); + for ( std::vector<SwTwips>::const_iterator it = gridCols.begin(); it != gridCols.end(); ++it ) + m_pSerializer->singleElementNS( XML_w, XML_gridCol, + FSNS( XML_w, XML_w ), OString::valueOf( sal_Int32( *it ) ).getStr( ), + FSEND ); + + m_pSerializer->endElementNS( XML_w, XML_tblGrid ); +} + +void DocxAttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); + const SwFrmFmt * pFrmFmt = pTabBox->GetFrmFmt(); + + // the defaults of the table are taken from the top-left cell + m_pSerializer->startElementNS( XML_w, XML_tblBorders, FSEND ); + impl_pageBorders( m_pSerializer, pFrmFmt->GetBox( ) ); + m_pSerializer->endElementNS( XML_w, XML_tblBorders ); +} + +void DocxAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( ); + const SwFrmFmt *pFmt = pTblBox->GetFrmFmt( ); + const SfxPoolItem *pI = NULL; + + Color aColor; + if ( SFX_ITEM_ON == pFmt->GetAttrSet().GetItemState( RES_BACKGROUND, false, &pI ) ) + aColor = dynamic_cast<const SvxBrushItem *>(pI)->GetColor(); + else + aColor = COL_AUTO; + + OString sColor = impl_ConvertColor( aColor ); + m_pSerializer->singleElementNS( XML_w, XML_shd, + FSNS( XML_w, XML_fill ), sColor.getStr( ), + FSEND ); +} + +void DocxAttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); + const SwTableLine * pTabLine = pTabBox->GetUpper(); + const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt(); + + const SwFmtFrmSize& rLSz = pLineFmt->GetFrmSize(); + if ( ATT_VAR_SIZE != rLSz.GetHeightSizeType() && rLSz.GetHeight() ) + { + sal_Int32 nHeight = rLSz.GetHeight(); + const char *pRule = NULL; + + switch ( rLSz.GetHeightSizeType() ) + { + case ATT_FIX_SIZE: pRule = "exact"; break; + case ATT_MIN_SIZE: pRule = "atLeast"; break; + default: break; + } + + if ( pRule ) + m_pSerializer->singleElementNS( XML_w, XML_trHeight, + FSNS( XML_w, XML_val ), OString::valueOf( nHeight ).getStr( ), + FSNS( XML_w, XML_hRule ), pRule, + FSEND ); + } +} + +void DocxAttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); + const SwTableLine * pTabLine = pTabBox->GetUpper(); + const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt(); + + const SwFmtRowSplit& rSplittable = pLineFmt->GetRowSplit( ); + const char* pCantSplit = ( !rSplittable.GetValue( ) ) ? "on" : "off"; + + m_pSerializer->singleElementNS( XML_w, XML_cantSplit, + FSNS( XML_w, XML_val ), pCantSplit, + FSEND ); +} + +void DocxAttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + const SwTable * pTable = pTableTextNodeInfoInner->getTable(); + const SwFrmFmt * pFrmFmt = pTable->GetFrmFmt(); + + if ( m_rExport.TrueFrameDirection( *pFrmFmt ) == FRMDIR_HORI_RIGHT_TOP ) + { + m_pSerializer->singleElementNS( XML_w, XML_bidiVisual, + FSNS( XML_w, XML_val ), "on", + FSEND ); + } +} + +void DocxAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); + const SwFrmFmt *pFrmFmt = pTabBox->GetFrmFmt( ); + + if ( FRMDIR_VERT_TOP_RIGHT == m_rExport.TrueFrameDirection( *pFrmFmt ) ) + m_pSerializer->singleElementNS( XML_w, XML_textDirection, + FSNS( XML_w, XML_val ), "tbRl", + FSEND ); +} + +void DocxAttributeOutput::TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t /*pNodeInfo*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO: DocxAttributeOutput::TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t pNodeInfo )\n" ); +#endif +} + +void DocxAttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ) +{ + // This is called when the nested table ends in a cell, and there's no + // paragraph benhind that; so we must check for the ends of cell, rows, + // tables + // ['true' to write an empty paragraph, MS Word insists on that] + FinishTableRowCell( pNodeInfoInner, true ); +} + +void DocxAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO: DocxAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )\n" ); +#endif +} + +void DocxAttributeOutput::TableRowEnd( sal_uInt32 /*nDepth*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO: DocxAttributeOutput::TableRowEnd( sal_uInt32 nDepth = 1 )\n" ); +#endif +} + +void DocxAttributeOutput::StartStyles() +{ + m_pSerializer->startElementNS( XML_w, XML_styles, + FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + FSEND ); +} + +void DocxAttributeOutput::EndStyles( USHORT /*nNumberOfStyles*/ ) +{ + m_pSerializer->endElementNS( XML_w, XML_styles ); +} + +void DocxAttributeOutput::DefaultStyle( USHORT nStyle ) +{ + // are these the values of enum ww::sti (see ../inc/wwstyles.hxx)? +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::DefaultStyle( USHORT nStyle )- %d\n", nStyle ); +#else + (void) nStyle; // to quiet the warning +#endif +} + +void DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize ) - some stuff still missing\n" ); +#endif + // create the relation ID + OString aRelId; + sal_Int32 nImageType; + if ( rGrfNode.IsLinkedFile() ) + { + // linked image, just create the relation + String aFileName; + rGrfNode.GetFileFilterNms( &aFileName, 0 ); + + // TODO Convert the file name to relative for better interoperability + + aRelId = m_rExport.AddRelation( + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" ), + OUString( aFileName ), + S( "External" ) ); + + nImageType = XML_link; + } + else + { + // inline, we also have to write the image itself + Graphic& rGraphic = const_cast< Graphic& >( rGrfNode.GetGrf() ); + + m_rDrawingML.SetFS( m_pSerializer ); // to be sure that we write to the right stream + OUString aImageId = m_rDrawingML.WriteImage( rGraphic ); + + aRelId = OUStringToOString( aImageId, RTL_TEXTENCODING_UTF8 ); + + nImageType = XML_embed; + } + + if ( aRelId.getLength() == 0 ) + return; + + m_pSerializer->startElementNS( XML_w, XML_drawing, + FSEND ); + m_pSerializer->startElementNS( XML_wp, XML_inline, + XML_distT, "0", XML_distB, "0", XML_distL, "0", XML_distR, "0", + FSEND ); + + // extent of the image + OString aWidth( OString::valueOf( TwipsToEMU( rSize.Width() ) ) ); + OString aHeight( OString::valueOf( TwipsToEMU( rSize.Height() ) ) ); + m_pSerializer->singleElementNS( XML_wp, XML_extent, + XML_cx, aWidth.getStr(), + XML_cy, aHeight.getStr(), + FSEND ); + // TODO - the right effectExtent, extent including the effect + m_pSerializer->singleElementNS( XML_wp, XML_effectExtent, + XML_l, "0", XML_t, "0", XML_r, "0", XML_b, "0", + FSEND ); + + // picture description + // TODO the right image description + m_pSerializer->startElementNS( XML_wp, XML_docPr, + XML_id, "1", + XML_name, "Picture", + XML_descr, "A description...", + FSEND ); + // TODO hyperlink + // m_pSerializer->singleElementNS( XML_a, XML_hlinkClick, + // FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main", + // FSNS( XML_r, XML_id ), "rId4", + // FSEND ); + m_pSerializer->endElementNS( XML_wp, XML_docPr ); + + m_pSerializer->startElementNS( XML_wp, XML_cNvGraphicFramePr, + FSEND ); + // TODO change aspect? + m_pSerializer->singleElementNS( XML_a, XML_graphicFrameLocks, + FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main", + XML_noChangeAspect, "1", + FSEND ); + m_pSerializer->endElementNS( XML_wp, XML_cNvGraphicFramePr ); + + m_pSerializer->startElementNS( XML_a, XML_graphic, + FSNS( XML_xmlns, XML_a ), "http://schemas.openxmlformats.org/drawingml/2006/main", + FSEND ); + m_pSerializer->startElementNS( XML_a, XML_graphicData, + XML_uri, "http://schemas.openxmlformats.org/drawingml/2006/picture", + FSEND ); + + m_pSerializer->startElementNS( XML_pic, XML_pic, + FSNS( XML_xmlns, XML_pic ), "http://schemas.openxmlformats.org/drawingml/2006/picture", + FSEND ); + + m_pSerializer->startElementNS( XML_pic, XML_nvPicPr, + FSEND ); + // TODO the right image description + m_pSerializer->startElementNS( XML_pic, XML_cNvPr, + XML_id, "0", + XML_name, "Picture", + XML_descr, "A description...", + FSEND ); + // TODO hyperlink + // m_pSerializer->singleElementNS( XML_a, XML_hlinkClick, + // FSNS( XML_r, XML_id ), "rId4", + // FSEND ); + m_pSerializer->endElementNS( XML_pic, XML_cNvPr ); + + m_pSerializer->startElementNS( XML_pic, XML_cNvPicPr, + FSEND ); + // TODO change aspect? + m_pSerializer->singleElementNS( XML_a, XML_picLocks, + XML_noChangeAspect, "1", XML_noChangeArrowheads, "1", + FSEND ); + m_pSerializer->endElementNS( XML_pic, XML_cNvPicPr ); + m_pSerializer->endElementNS( XML_pic, XML_nvPicPr ); + + // the actual picture + m_pSerializer->startElementNS( XML_pic, XML_blipFill, + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_blip, + FSNS( XML_r, nImageType ), aRelId.getStr(), + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_srcRect, + FSEND ); + m_pSerializer->startElementNS( XML_a, XML_stretch, + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_fillRect, + FSEND ); + m_pSerializer->endElementNS( XML_a, XML_stretch ); + m_pSerializer->endElementNS( XML_pic, XML_blipFill ); + + // TODO setup the right values below + m_pSerializer->startElementNS( XML_pic, XML_spPr, + XML_bwMode, "auto", + FSEND ); + m_pSerializer->startElementNS( XML_a, XML_xfrm, + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_off, + XML_x, "0", XML_y, "0", + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_ext, + XML_cx, aWidth.getStr(), + XML_cy, aHeight.getStr(), + FSEND ); + m_pSerializer->endElementNS( XML_a, XML_xfrm ); + m_pSerializer->startElementNS( XML_a, XML_prstGeom, + XML_prst, "rect", + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_avLst, + FSEND ); + m_pSerializer->endElementNS( XML_a, XML_prstGeom ); + m_pSerializer->singleElementNS( XML_a, XML_noFill, + FSEND ); + m_pSerializer->startElementNS( XML_a, XML_ln, + XML_w, "9525", + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_noFill, + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_miter, + XML_lim, "800000", + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_headEnd, + FSEND ); + m_pSerializer->singleElementNS( XML_a, XML_tailEnd, + FSEND ); + m_pSerializer->endElementNS( XML_a, XML_ln ); + m_pSerializer->endElementNS( XML_pic, XML_spPr ); + + m_pSerializer->endElementNS( XML_pic, XML_pic ); + + m_pSerializer->endElementNS( XML_a, XML_graphicData ); + m_pSerializer->endElementNS( XML_a, XML_graphic ); + m_pSerializer->endElementNS( XML_wp, XML_inline ); + + m_pSerializer->endElementNS( XML_w, XML_drawing ); +} + +void DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame &rFrame, const Point& /*rNdTopLeft*/ ) +{ + m_pSerializer->mark(); + + switch ( rFrame.GetWriterType() ) + { + case sw::Frame::eGraphic: + { + const SwNode *pNode = rFrame.GetContent(); + const SwGrfNode *pGrfNode = pNode ? pNode->GetGrfNode() : 0; + if ( pGrfNode ) + FlyFrameGraphic( *pGrfNode, rFrame.GetLayoutSize() ); + } + break; + case sw::Frame::eDrawing: + { + const SdrObject* pSdrObj = rFrame.GetFrmFmt().FindRealSdrObject(); + if ( pSdrObj ) + { + bool bSwapInPage = false; + if ( !pSdrObj->GetPage() ) + { + if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() ) + { + if ( SdrPage *pPage = pModel->GetPage( 0 ) ) + { + bSwapInPage = true; + const_cast< SdrObject* >( pSdrObj )->SetPage( pPage ); + } + } + } + + m_pSerializer->startElementNS( XML_w, XML_pict, + FSEND ); + + m_rExport.VMLExporter().AddSdrObject( *pSdrObj ); + + m_pSerializer->endElementNS( XML_w, XML_pict ); + + if ( bSwapInPage ) + const_cast< SdrObject* >( pSdrObj )->SetPage( 0 ); + } + } + break; + default: +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& rNdTopLeft ) - frame type '%s'\n", + rFrame.GetWriterType() == sw::Frame::eTxtBox? "eTxtBox": + ( rFrame.GetWriterType() == sw::Frame::eOle? "eOle": + ( rFrame.GetWriterType() == sw::Frame::eFormControl? "eFormControl": "???" ) ) ); +#endif + break; + } + + m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_POSTPONE ); +} + +void DocxAttributeOutput::StartStyle( const String& rName, bool bPapFmt, + USHORT nBase, USHORT nNext, USHORT /*nWwId*/, USHORT nId ) +{ + OString aStyle( "style" ); + + m_pSerializer->startElementNS( XML_w, XML_style, + FSNS( XML_w, XML_type ), bPapFmt? "paragraph": "character", // FIXME is this correct? + FSNS( XML_w, XML_styleId ), ( aStyle + OString::valueOf( sal_Int32( nId ) ) ).getStr(), + FSEND ); + + m_pSerializer->singleElementNS( XML_w, XML_name, + FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); + + if ( nBase != 0x0FFF ) + { + m_pSerializer->singleElementNS( XML_w, XML_basedOn, + FSNS( XML_w, XML_val ), ( aStyle + OString::valueOf( sal_Int32( nBase ) ) ).getStr(), + FSEND ); + } + + m_pSerializer->singleElementNS( XML_w, XML_next, + FSNS( XML_w, XML_val ), ( aStyle + OString::valueOf( sal_Int32( nNext ) ) ).getStr(), + FSEND ); +} + +void DocxAttributeOutput::EndStyle() +{ + m_pSerializer->endElementNS( XML_w, XML_style ); +} + +void DocxAttributeOutput::StartStyleProperties( bool bParProp, USHORT /*nStyle*/ ) +{ + if ( bParProp ) + { + m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND ); + InitCollectedParagraphProperties(); + } + else + { + m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND ); + InitCollectedRunProperties(); + } +} + +void DocxAttributeOutput::EndStyleProperties( bool bParProp ) +{ + if ( bParProp ) + { + WriteCollectedParagraphProperties(); + m_pSerializer->endElementNS( XML_w, XML_pPr ); + } + else + { + WriteCollectedRunProperties(); + m_pSerializer->endElementNS( XML_w, XML_rPr ); + } +} + +void DocxAttributeOutput::OutlineNumbering( BYTE nLvl, const SwNumFmt& /*rNFmt*/, const SwFmt& /*rFmt*/ ) +{ + if ( nLvl >= WW8ListManager::nMaxLevel ) + nLvl = WW8ListManager::nMaxLevel - 1; + + m_pSerializer->singleElementNS( XML_w, XML_outlineLvl, + FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nLvl ) ).getStr( ), + FSEND ); +} + +void DocxAttributeOutput::PageBreakBefore( bool bBreak ) +{ + if ( bBreak ) + m_pSerializer->singleElementNS( XML_w, XML_pageBreakBefore, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_pageBreakBefore, + FSNS( XML_w, XML_val ), "off", + FSEND ); +} + +void DocxAttributeOutput::SectionBreak( BYTE nC, const WW8_SepInfo* pSectionInfo ) +{ + switch ( nC ) + { + case msword::ColumnBreak: + // The column break should be output in the next paragraph... + m_nColBreakStatus = COLBRK_POSTPONE; + break; + case msword::PageBreak: + if ( pSectionInfo ) + { + if ( !m_bParagraphOpened ) + { + // Create a dummy paragraph if needed + m_pSerializer->startElementNS( XML_w, XML_p, FSEND ); + m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND ); + + m_rExport.SectionProperties( *pSectionInfo ); + + m_pSerializer->endElementNS( XML_w, XML_pPr ); + m_pSerializer->endElementNS( XML_w, XML_p ); + } + else + { + // postpone the output of this; it has to be done inside the + // paragraph properties, so remember it until then + m_pSectionInfo = pSectionInfo; + } + } + else + { + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_br, + FSNS( XML_w, XML_type ), "page", FSEND ); + m_pSerializer->endElementNS( XML_w, XML_r ); + } + break; + default: +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "Unknown section break to write: %d\n", nC ); +#endif + break; + } +} + +void DocxAttributeOutput::StartSection() +{ + m_pSerializer->startElementNS( XML_w, XML_sectPr, FSEND ); + m_bOpenedSectPr = true; +} + +void DocxAttributeOutput::EndSection() +{ + // Write the section properties + if ( m_pSpacingAttrList ) + { + XFastAttributeListRef xAttrList( m_pSpacingAttrList ); + m_pSpacingAttrList = NULL; + + m_pSerializer->singleElementNS( XML_w, XML_pgMar, xAttrList ); + } + + m_pSerializer->endElementNS( XML_w, XML_sectPr ); + m_bOpenedSectPr = false; +} + +void DocxAttributeOutput::SectionFormProtection( bool bProtected ) +{ + if ( bProtected ) + m_pSerializer->singleElementNS( XML_w, XML_formProt, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_formProt, + FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::SectionLineNumbering( ULONG /*nRestartNo*/, const SwLineNumberInfo& /*rLnNumInfo*/ ) +{ + // see 2.6.8 lnNumType (Line Numbering Settings) +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::SectionLineNumbering()\n" ); +#endif +} + +void DocxAttributeOutput::SectionTitlePage() +{ + m_pSerializer->singleElementNS( XML_w, XML_titlePg, FSEND ); +} + +void DocxAttributeOutput::SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* /*pFirstPageFmt*/ ) +{ + // Output the margins + + + const SvxBoxItem& rBox = pFmt->GetBox( ); + + const SvxBorderLine* pBottom = rBox.GetBottom( ); + const SvxBorderLine* pTop = rBox.GetTop( ); + const SvxBorderLine* pLeft = rBox.GetLeft( ); + const SvxBorderLine* pRight = rBox.GetRight( ); + + if ( pBottom || pTop || pLeft || pRight ) + { + // All distances are relative to the text margins + m_pSerializer->startElementNS( XML_w, XML_pgBorders, + FSNS( XML_w, XML_display ), "allPages", + FSNS( XML_w, XML_offsetFrom ), "text", + FSEND ); + + m_pSerializer->mark(); + + m_pSerializer->endElementNS( XML_w, XML_pgBorders ); + m_pSerializer->mark(); + } +} + +void DocxAttributeOutput::SectionBiDi( bool bBiDi ) +{ + if ( bBiDi ) + m_pSerializer->singleElementNS( XML_w, XML_bidi, FSEND ); +} + +static OString impl_NumberingType( USHORT nNumberingType ) +{ + OString aType; + + switch ( nNumberingType ) + { + case SVX_NUM_CHARS_UPPER_LETTER: + case SVX_NUM_CHARS_UPPER_LETTER_N: aType = "upperLetter"; break; + case SVX_NUM_CHARS_LOWER_LETTER: + case SVX_NUM_CHARS_LOWER_LETTER_N: aType = "lowerLetter"; break; + case SVX_NUM_ROMAN_UPPER: aType = "upperRoman"; break; + case SVX_NUM_ROMAN_LOWER: aType = "lowerRoman"; break; + + case SVX_NUM_ARABIC: aType = "decimal"; break; + + case SVX_NUM_BITMAP: + case SVX_NUM_CHAR_SPECIAL: aType = "bullet"; break; + + default: aType = "none"; break; + } + + return aType; +} + +void DocxAttributeOutput::SectionPageNumbering( USHORT nNumType, USHORT nPageRestartNumber ) +{ + // FIXME Not called properly with page styles like "First Page" + + FastAttributeList* pAttr = m_pSerializer->createAttrList(); + + // 0 means no restart: then don't output that attribute if 0 + if ( nPageRestartNumber > 0 ) + pAttr->add( FSNS( XML_w, XML_start ), OString::valueOf( sal_Int32( nPageRestartNumber ) ) ); + + // nNumType corresponds to w:fmt. See WW8Export::GetNumId() for more precisions + OString aFmt( impl_NumberingType( nNumType ) ); + if ( aFmt.getLength() ) + pAttr->add( FSNS( XML_w, XML_fmt ), aFmt.getStr() ); + + XFastAttributeListRef xAttrs( pAttr ); + m_pSerializer->singleElementNS( XML_w, XML_pgNumType, xAttrs ); + + // see 2.6.12 pgNumType (Page Numbering Settings) +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::SectionPageNumbering()\n" ); +#endif +} + +void DocxAttributeOutput::SectionType( BYTE nBreakCode ) +{ + /* break code: 0 No break, 1 New column + 2 New page, 3 Even page, 4 Odd page + */ + const char* pType = NULL; + switch ( nBreakCode ) + { + case 1: pType = "nextColumn"; break; + case 2: pType = "nextPage"; break; + case 3: pType = "evenPage"; break; + case 4: pType = "oddPage"; break; + default: pType = "continuous"; break; + } + + if ( pType ) + m_pSerializer->singleElementNS( XML_w, XML_type, + FSNS( XML_w, XML_val ), pType, + FSEND ); +} + +void DocxAttributeOutput::StartFont( const String& rFamilyName ) const +{ + m_pSerializer->startElementNS( XML_w, XML_font, + FSNS( XML_w, XML_name ), OUStringToOString( OUString( rFamilyName ), RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); +} + +void DocxAttributeOutput::EndFont() const +{ + m_pSerializer->endElementNS( XML_w, XML_font ); +} + +void DocxAttributeOutput::FontAlternateName( const String& rName ) const +{ + m_pSerializer->singleElementNS( XML_w, XML_altName, + FSNS( XML_w, XML_val ), OUStringToOString( OUString( rName ), RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); +} + +void DocxAttributeOutput::FontCharset( sal_uInt8 nCharSet ) const +{ + OString aCharSet( OString::valueOf( sal_Int32( nCharSet ), 16 ) ); + if ( aCharSet.getLength() == 1 ) + aCharSet = OString( "0" ) + aCharSet; + + m_pSerializer->singleElementNS( XML_w, XML_charset, + FSNS( XML_w, XML_val ), aCharSet.getStr(), + FSEND ); +} + +void DocxAttributeOutput::FontFamilyType( FontFamily eFamily ) const +{ + const char *pFamily = NULL; + switch ( eFamily ) + { + case FAMILY_ROMAN: pFamily = "roman"; break; + case FAMILY_SWISS: pFamily = "swiss"; break; + case FAMILY_MODERN: pFamily = "modern"; break; + case FAMILY_SCRIPT: pFamily = "script"; break; + case FAMILY_DECORATIVE: pFamily = "decorative"; break; + default: pFamily = "auto"; break; // no font family + } + + if ( pFamily ) + m_pSerializer->singleElementNS( XML_w, XML_family, + FSNS( XML_w, XML_val ), pFamily, + FSEND ); +} + +void DocxAttributeOutput::FontPitchType( FontPitch ePitch ) const +{ + const char *pPitch = NULL; + switch ( ePitch ) + { + case PITCH_VARIABLE: pPitch = "variable"; break; + case PITCH_FIXED: pPitch = "fixed"; break; + default: pPitch = "default"; break; // no info about the pitch + } + + if ( pPitch ) + m_pSerializer->singleElementNS( XML_w, XML_pitch, + FSNS( XML_w, XML_val ), pPitch, + FSEND ); +} + +void DocxAttributeOutput::NumberingDefinition( USHORT nId, const SwNumRule &rRule ) +{ + // nId is the same both for abstract numbering definition as well as the + // numbering definition itself + // TODO check that this is actually true & fix if not ;-) + OString aId( OString::valueOf( sal_Int32( nId ) ) ); + + m_pSerializer->startElementNS( XML_w, XML_num, + FSNS( XML_w, XML_numId ), aId.getStr(), + FSEND ); + + m_pSerializer->singleElementNS( XML_w, XML_abstractNumId, + FSNS( XML_w, XML_val ), aId.getStr(), + FSEND ); + +#if OSL_DEBUG_LEVEL > 0 + // TODO ww8 version writes this, anything to do about it here? + if ( rRule.IsContinusNum() ) + fprintf( stderr, "TODO DocxAttributeOutput::NumberingDefinition()\n" ); +#else + (void) rRule; // to quiet the warning... +#endif + + m_pSerializer->endElementNS( XML_w, XML_num ); +} + +void DocxAttributeOutput::StartAbstractNumbering( USHORT nId ) +{ + m_pSerializer->startElementNS( XML_w, XML_abstractNum, + FSNS( XML_w, XML_abstractNumId ), OString::valueOf( sal_Int32( nId ) ).getStr(), + FSEND ); +} + +void DocxAttributeOutput::EndAbstractNumbering() +{ + m_pSerializer->endElementNS( XML_w, XML_abstractNum ); +} + +void DocxAttributeOutput::NumberingLevel( BYTE nLevel, + USHORT nStart, + USHORT nNumberingType, + SvxAdjust eAdjust, + const BYTE * /*pNumLvlPos*/, + BYTE nFollow, + const wwFont *pFont, + const SfxItemSet *pOutSet, + sal_Int16 nIndentAt, + sal_Int16 nFirstLineIndex, + sal_Int16 /*nListTabPos*/, + const String &rNumberingString ) +{ + m_pSerializer->startElementNS( XML_w, XML_lvl, + FSNS( XML_w, XML_ilvl ), OString::valueOf( sal_Int32( nLevel ) ).getStr(), + FSEND ); + + // start with the nStart value + m_pSerializer->singleElementNS( XML_w, XML_start, + FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nStart ) ).getStr(), + FSEND ); + + // format + OString aFmt( impl_NumberingType( nNumberingType ) ); + + if ( aFmt.getLength() ) + m_pSerializer->singleElementNS( XML_w, XML_numFmt, + FSNS( XML_w, XML_val ), aFmt.getStr(), + FSEND ); + + // justification + const char *pJc; + switch ( eAdjust ) + { + case SVX_ADJUST_CENTER: pJc = "center"; break; + case SVX_ADJUST_RIGHT: pJc = "right"; break; + default: pJc = "left"; break; + } + m_pSerializer->singleElementNS( XML_w, XML_lvlJc, + FSNS( XML_w, XML_val ), pJc, + FSEND ); + + // suffix + const char *pSuffix = NULL; + switch ( nFollow ) + { + case 1: pSuffix = "space"; break; + case 2: pSuffix = "nothing"; break; + default: /*pSuffix = "tab";*/ break; + } + if ( pSuffix ) + m_pSerializer->singleElementNS( XML_w, XML_suff, + FSNS( XML_w, XML_val ), pSuffix, + FSEND ); + + // text + OUString aText( rNumberingString ); + OUStringBuffer aBuffer( aText.getLength() + WW8ListManager::nMaxLevel ); + + const sal_Unicode *pPrev = aText.getStr(); + const sal_Unicode *pIt = aText.getStr(); + while ( pIt < aText.getStr() + aText.getLength() ) + { + // convert the level values to %NUMBER form + // (we don't use pNumLvlPos at all) + // FIXME so far we support the ww8 limit of levels only + if ( *pIt < sal_Unicode( WW8ListManager::nMaxLevel ) ) + { + aBuffer.append( pPrev, pIt - pPrev ); + aBuffer.appendAscii( "%" ); + aBuffer.append( OUString::valueOf( sal_Int32( *pIt ) + 1 ) ); + + pPrev = pIt + 1; + } + ++pIt; + } + if ( pPrev < pIt ) + aBuffer.append( pPrev, pIt - pPrev ); + + m_pSerializer->singleElementNS( XML_w, XML_lvlText, + FSNS( XML_w, XML_val ), OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); + + // indentation + m_pSerializer->startElementNS( XML_w, XML_pPr, FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_ind, + FSNS( XML_w, XML_left ), OString::valueOf( sal_Int32( nIndentAt ) ).getStr(), + FSNS( XML_w, XML_hanging ), OString::valueOf( sal_Int32( -nFirstLineIndex ) ).getStr(), + FSEND ); + m_pSerializer->endElementNS( XML_w, XML_pPr ); + + // font + if ( pOutSet ) + { + m_pSerializer->startElementNS( XML_w, XML_rPr, FSEND ); + + if ( pFont ) + { + OString aFamilyName( OUStringToOString( OUString( pFont->GetFamilyName() ), RTL_TEXTENCODING_UTF8 ) ); + m_pSerializer->singleElementNS( XML_w, XML_rFonts, + FSNS( XML_w, XML_ascii ), aFamilyName.getStr(), + FSNS( XML_w, XML_hAnsi ), aFamilyName.getStr(), + FSNS( XML_w, XML_cs ), aFamilyName.getStr(), + FSNS( XML_w, XML_hint ), "default", + FSEND ); + } + m_rExport.OutputItemSet( *pOutSet, false, true, i18n::ScriptType::LATIN ); + + m_pSerializer->endElementNS( XML_w, XML_rPr ); + } + + // TODO anything to do about nListTabPos? + + m_pSerializer->endElementNS( XML_w, XML_lvl ); +} + +void DocxAttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap ) +{ + switch ( rCaseMap.GetValue() ) + { + case SVX_CASEMAP_KAPITAELCHEN: + m_pSerializer->singleElementNS( XML_w, XML_smallCaps, FSEND ); + break; + case SVX_CASEMAP_VERSALIEN: + m_pSerializer->singleElementNS( XML_w, XML_caps, FSEND ); + break; + default: // Something that ooxml does not support + m_pSerializer->singleElementNS( XML_w, XML_smallCaps, FSNS( XML_w, XML_val ), "off", FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_caps, FSNS( XML_w, XML_val ), "off", FSEND ); + break; + } +} + +void DocxAttributeOutput::CharColor( const SvxColorItem& rColor ) +{ + const Color aColor( rColor.GetValue() ); + OString aColorString; + + aColorString = impl_ConvertColor( aColor ); + + m_pSerializer->singleElementNS( XML_w, XML_color, + FSNS( XML_w, XML_val ), aColorString.getStr(), FSEND ); +} + +void DocxAttributeOutput::CharContour( const SvxContourItem& rContour ) +{ + if ( rContour.GetValue() ) + m_pSerializer->singleElementNS( XML_w, XML_outline, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_outline, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossedOut ) +{ + switch ( rCrossedOut.GetStrikeout() ) + { + case STRIKEOUT_DOUBLE: + m_pSerializer->singleElementNS( XML_w, XML_dstrike, FSEND ); + break; + case STRIKEOUT_NONE: + m_pSerializer->singleElementNS( XML_w, XML_dstrike, FSNS( XML_w, XML_val ), "off", FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_strike, FSNS( XML_w, XML_val ), "off", FSEND ); + break; + default: + m_pSerializer->singleElementNS( XML_w, XML_strike, FSEND ); + break; + } +} + +void DocxAttributeOutput::CharEscapement( const SvxEscapementItem& /*rEscapement*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::CharEscapement()\n" ); +#endif +} + +void DocxAttributeOutput::CharFont( const SvxFontItem& rFont) +{ + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); + OUString sFontName(rFont.GetFamilyName()); + OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8); + m_pFontsAttrList->add(FSNS(XML_w, XML_ascii), sFontNameUtf8); + m_pFontsAttrList->add(FSNS(XML_w, XML_hAnsi), sFontNameUtf8); +} + +void DocxAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize) +{ + OString fontSize = OString::valueOf( sal_Int32( ( rFontSize.GetHeight() + 5 ) / 10 ) ); + + switch ( rFontSize.Which() ) + { + case RES_CHRATR_FONTSIZE: + case RES_CHRATR_CJK_FONTSIZE: + m_pSerializer->singleElementNS( XML_w, XML_sz, FSNS( XML_w, XML_val ), fontSize.getStr(), FSEND ); + break; + case RES_CHRATR_CTL_FONTSIZE: + m_pSerializer->singleElementNS( XML_w, XML_szCs, FSNS( XML_w, XML_val ), fontSize.getStr(), FSEND ); + break; + } +} + +void DocxAttributeOutput::CharKerning( const SvxKerningItem& rKerning ) +{ + OString aKerning = OString::valueOf( ( sal_Int32 ) rKerning.GetValue() ); + m_pSerializer->singleElementNS( XML_w, XML_kern, FSNS(XML_w, XML_val), aKerning.getStr(), FSEND ); +} + +void DocxAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage ) +{ + if (!m_pCharLangAttrList) + m_pCharLangAttrList = m_pSerializer->createAttrList(); + + ::com::sun::star::lang::Locale xLocale= MsLangId::convertLanguageToLocale( rLanguage.GetLanguage( ) ); + OString sLanguage = OUStringToOString(xLocale.Language, RTL_TEXTENCODING_UTF8); + OString sCountry = OUStringToOString(xLocale.Country, RTL_TEXTENCODING_UTF8); + + OString aLanguageCode = sLanguage + "-" + sCountry; + + switch ( rLanguage.Which() ) + { + case RES_CHRATR_LANGUAGE: + m_pCharLangAttrList->add(FSNS(XML_w, XML_val), aLanguageCode); + break; + case RES_CHRATR_CJK_LANGUAGE: + m_pCharLangAttrList->add(FSNS(XML_w, XML_eastAsia), aLanguageCode); + break; + case RES_CHRATR_CTL_LANGUAGE: + m_pCharLangAttrList->add(FSNS(XML_w, XML_bidi), aLanguageCode); + break; + } +} + +void DocxAttributeOutput::CharPosture( const SvxPostureItem& rPosture ) +{ + if ( rPosture.GetPosture() != ITALIC_NONE ) + m_pSerializer->singleElementNS( XML_w, XML_i, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_i, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::CharShadow( const SvxShadowedItem& rShadow ) +{ + if ( rShadow.GetValue() ) + m_pSerializer->singleElementNS( XML_w, XML_shadow, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_shadow, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline ) +{ + const char *pUnderline; + + switch ( rUnderline.GetLineStyle() ) + { + case UNDERLINE_SINGLE: pUnderline = "single"; break; + case UNDERLINE_BOLD: pUnderline = "thick"; break; + case UNDERLINE_DOUBLE: pUnderline = "double"; break; + case UNDERLINE_DOTTED: pUnderline = "dotted"; break; + case UNDERLINE_DASH: pUnderline = "dash"; break; + case UNDERLINE_DASHDOT: pUnderline = "dotDash"; break; + case UNDERLINE_DASHDOTDOT: pUnderline = "dotDotDash"; break; + case UNDERLINE_WAVE: pUnderline = "wave"; break; + case UNDERLINE_BOLDDOTTED: pUnderline = "dottedHeavy"; break; + case UNDERLINE_BOLDDASH: pUnderline = "dashedHeavy"; break; + case UNDERLINE_LONGDASH: pUnderline = "dashLongHeavy"; break; + case UNDERLINE_BOLDLONGDASH: pUnderline = "dashLongHeavy"; break; + case UNDERLINE_BOLDDASHDOT: pUnderline = "dashDotHeavy"; break; + case UNDERLINE_BOLDDASHDOTDOT: pUnderline = "dashDotDotHeavy"; break; + case UNDERLINE_BOLDWAVE: pUnderline = "wavyHeavy"; break; + case UNDERLINE_DOUBLEWAVE: pUnderline = "wavyDouble"; break; + case UNDERLINE_NONE: // fall through + default: pUnderline = "none"; break; + } + + m_pSerializer->singleElementNS( XML_w, XML_u, FSNS( XML_w, XML_val ), pUnderline, FSEND ); +} + +void DocxAttributeOutput::CharWeight( const SvxWeightItem& rWeight ) +{ + if ( rWeight.GetWeight() == WEIGHT_BOLD ) + m_pSerializer->singleElementNS( XML_w, XML_b, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_b, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::CharAutoKern( const SvxAutoKernItem& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::CharAutoKern()\n" ); +#endif +} + +void DocxAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink ) +{ + if ( rBlink.GetValue() ) + m_pSerializer->singleElementNS(XML_w, XML_effect, FSNS( XML_w, XML_val ), "blinkBackground", FSEND ); + else + m_pSerializer->singleElementNS(XML_w, XML_effect, FSNS( XML_w, XML_val ), "none", FSEND ); +} + +void DocxAttributeOutput::CharBackground( const SvxBrushItem& rBrush ) +{ + m_pSerializer->singleElementNS( XML_w, XML_shd, + FSNS( XML_w, XML_fill ), impl_ConvertColor( rBrush.GetColor() ).getStr(), FSEND ); +} + +void DocxAttributeOutput::CharFontCJK( const SvxFontItem& rFont ) +{ + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); + OUString sFontName(rFont.GetFamilyName()); + OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8); + m_pFontsAttrList->add(FSNS(XML_w, XML_eastAsia), sFontNameUtf8); +} + +void DocxAttributeOutput::CharPostureCJK( const SvxPostureItem& rPosture ) +{ + if ( rPosture.GetPosture() != ITALIC_NONE ) + m_pSerializer->singleElementNS( XML_w, XML_i, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_i, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::CharWeightCJK( const SvxWeightItem& rWeight ) +{ + if ( rWeight.GetWeight() == WEIGHT_BOLD ) + m_pSerializer->singleElementNS( XML_w, XML_b, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_b, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::CharFontCTL( const SvxFontItem& rFont ) +{ + if (!m_pFontsAttrList) + m_pFontsAttrList = m_pSerializer->createAttrList(); + OUString sFontName(rFont.GetFamilyName()); + OString sFontNameUtf8 = OUStringToOString(sFontName, RTL_TEXTENCODING_UTF8); + m_pFontsAttrList->add(FSNS(XML_w, XML_cs), sFontNameUtf8); + +} + +void DocxAttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture) +{ + if ( rPosture.GetPosture() != ITALIC_NONE ) + m_pSerializer->singleElementNS( XML_w, XML_iCs, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_iCs, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight ) +{ + if ( rWeight.GetWeight() == WEIGHT_BOLD ) + m_pSerializer->singleElementNS( XML_w, XML_bCs, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_bCs, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::CharRotate( const SvxCharRotateItem& rRotate) +{ + if ( !rRotate.GetValue() ) + return; + + if (!m_pEastAsianLayoutAttrList) + m_pEastAsianLayoutAttrList = m_pSerializer->createAttrList(); + OString sTrue((sal_Char *)"true"); + m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_vert), sTrue); + + if (rRotate.IsFitToLine()) + m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_vertCompress), sTrue); +} + +void DocxAttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark ) +{ + const char *pEmphasis; + + switch ( rEmphasisMark.GetValue() ) + { + case EMPHASISMARK_NONE: pEmphasis = "none"; break; + case EMPHASISMARK_SIDE_DOTS: pEmphasis = "dot"; break; + case EMPHASISMARK_CIRCLE_ABOVE: pEmphasis = "circle"; break; + case EMPHASISMARK_DOTS_BELOW: pEmphasis = "underDot"; break; + default: pEmphasis = "comma"; break; + } + + m_pSerializer->singleElementNS( XML_w, XML_em, FSNS( XML_w, XML_val ), pEmphasis, FSEND ); +} + +void DocxAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines ) +{ + if ( !rTwoLines.GetValue() ) + return; + + if (!m_pEastAsianLayoutAttrList) + m_pEastAsianLayoutAttrList = m_pSerializer->createAttrList(); + OString sTrue((sal_Char *)"true"); + m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_combine), sTrue); + + sal_Unicode cStart = rTwoLines.GetStartBracket(); + sal_Unicode cEnd = rTwoLines.GetEndBracket(); + + if (!cStart && !cEnd) + return; + + OString sBracket; + if ((cStart == '{') || (cEnd == '}')) + sBracket = (sal_Char *)"curly"; + else if ((cStart == '<') || (cEnd == '>')) + sBracket = (sal_Char *)"angle"; + else if ((cStart == '[') || (cEnd == ']')) + sBracket = (sal_Char *)"square"; + else + sBracket = (sal_Char *)"round"; + m_pEastAsianLayoutAttrList->add(FSNS(XML_w, XML_combineBrackets), sBracket); +} + +void DocxAttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth ) +{ + m_pSerializer->singleElementNS( XML_w, XML_w, + FSNS( XML_w, XML_val ), rtl::OString::valueOf( sal_Int32( rScaleWidth.GetValue() ) ).getStr(), FSEND ); +} + +void DocxAttributeOutput::CharRelief( const SvxCharReliefItem& rRelief ) +{ + switch ( rRelief.GetValue() ) + { + case RELIEF_EMBOSSED: + m_pSerializer->singleElementNS( XML_w, XML_emboss, FSEND ); + break; + case RELIEF_ENGRAVED: + m_pSerializer->singleElementNS( XML_w, XML_imprint, FSEND ); + break; + default: + m_pSerializer->singleElementNS( XML_w, XML_emboss, FSNS( XML_w, XML_val ), "off", FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_imprint, FSNS( XML_w, XML_val ), "off", FSEND ); + break; + } +} + +void DocxAttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden ) +{ + if ( rHidden.GetValue() ) + m_pSerializer->singleElementNS( XML_w, XML_vanish, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_vanish, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +void DocxAttributeOutput::TextINetFormat( const SwFmtINetFmt& rLink ) +{ + const SwTxtINetFmt* pINetFmt = rLink.GetTxtINetFmt(); + const SwCharFmt* pCharFmt = pINetFmt->GetCharFmt(); + + OString aStyleId( "style" ); + aStyleId += OString::valueOf( sal_Int32( m_rExport.GetId( *pCharFmt ) ) ); + + m_pSerializer->singleElementNS( XML_w, XML_rStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND ); +} + +void DocxAttributeOutput::TextCharFormat( const SwFmtCharFmt& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::TextCharFormat()\n" ); +#endif +} + +void DocxAttributeOutput::RefField( const SwField& rFld, const String& rRef ) +{ + USHORT nType = rFld.GetTyp( )->Which( ); + if ( nType == RES_GETEXPFLD ) + { + String sCmd = FieldString( ww::eREF ); + sCmd.APPEND_CONST_ASC( "\"" ); + sCmd += rRef; + sCmd.APPEND_CONST_ASC( "\" " ); + + m_rExport.OutputField( &rFld, ww::eREF, sCmd ); + } + + // There is nothing to do here for the set fields +} + +void DocxAttributeOutput::HiddenField( const SwField& /*rFld*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::HiddenField()\n" ); +#endif +} + +void DocxAttributeOutput::PostitField( const SwField* /* pFld*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::PostitField()\n" ); +#endif +} + +bool DocxAttributeOutput::DropdownField( const SwField* pFld ) +{ + bool bExpand = false; + + ww::eField eType = ww::eFORMDROPDOWN; + String sCmd = FieldString( eType ); + GetExport( ).OutputField( pFld, eType, sCmd ); + + return bExpand; +} + +void DocxAttributeOutput::SetField( const SwField& rFld, ww::eField eType, const String& rCmd ) +{ + // field bookmarks are handled in the EndRun method + GetExport().OutputField(&rFld, eType, rCmd ); +} + +void DocxAttributeOutput::WriteExpand( const SwField* pFld ) +{ + // Will be written in the next End Run + String sCmd; + m_rExport.OutputField( pFld, ww::eUNKNOWN, sCmd ); +} + +void DocxAttributeOutput::WriteField_Impl( const SwField* pFld, ww::eField eType, const String& rFldCmd, BYTE nMode ) +{ + struct FieldInfos infos; + infos.pField = pFld; + infos.sCmd = rFldCmd; + infos.eType = eType; + infos.bClose = WRITEFIELD_CLOSE & nMode; + infos.bOpen = WRITEFIELD_START & nMode; + + m_Fields.push_back( infos ); + + if ( pFld ) + { + USHORT nType = pFld->GetTyp( )->Which( ); + USHORT nSubType = pFld->GetSubType(); + + // TODO Any other field types here ? + if ( ( nType == RES_SETEXPFLD ) && ( nSubType & nsSwGetSetExpType::GSE_STRING ) ) + { + const SwSetExpField *pSet = ( const SwSetExpField* )( pFld ); + m_sFieldBkm = pSet->GetPar1( ); + } + else if ( nType == RES_DROPDOWN ) + { + const SwDropDownField* pDropDown = ( const SwDropDownField* )( pFld ); + m_sFieldBkm = pDropDown->GetName( ); + } + } +} + +void DocxAttributeOutput::WriteBookmarks_Impl( std::vector< OUString >& rStarts, + std::vector< OUString >& rEnds ) +{ + for ( std::vector< OUString >::const_iterator it = rStarts.begin(), end = rStarts.end(); it < end; ++it ) + { + OString rName = OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr( ); + m_rMarksStart.push_back( rName ); + } + rStarts.clear(); + + for ( std::vector< OUString >::const_iterator it = rEnds.begin(), end = rEnds.end(); it < end; ++it ) + { + OString rName = OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr( ); + m_rMarksEnd.push_back( rName ); + } + rEnds.clear(); +} + +void DocxAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote ) +{ + const SwEndNoteInfo& rInfo = rFootnote.IsEndNote()? + m_rExport.pDoc->GetEndNoteInfo(): m_rExport.pDoc->GetFtnInfo(); + + // footnote/endnote run properties + const SwCharFmt* pCharFmt = rInfo.GetAnchorCharFmt( *m_rExport.pDoc ); + + OString aStyleId( "style" ); + aStyleId += OString::valueOf( sal_Int32( m_rExport.GetId( *pCharFmt ) ) ); + + m_pSerializer->singleElementNS( XML_w, XML_rStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND ); + + // remember the footnote/endnote to + // 1) write the footnoteReference/endnoteReference in EndRunProperties() + // 2) be able to dump them all to footnotes.xml/endnotes.xml + if ( !rFootnote.IsEndNote() ) + m_pFootnotesList->add( rFootnote ); + else + m_pEndnotesList->add( rFootnote ); +} + +void DocxAttributeOutput::FootnoteEndnoteReference() +{ + sal_Int32 nId; + const SwFmtFtn *pFootnote = m_pFootnotesList->getCurrent( nId ); + + // both cannot be set at the same time - if they are, it's a bug + if ( !pFootnote ) + pFootnote = m_pEndnotesList->getCurrent( nId ); + + if ( !pFootnote ) + return; + + sal_Int32 nToken = pFootnote->IsEndNote()? XML_endnoteReference: XML_footnoteReference; + + // write it + if ( pFootnote->GetNumStr().Len() == 0 ) + { + // autonumbered + m_pSerializer->singleElementNS( XML_w, nToken, + FSNS( XML_w, XML_id ), ::rtl::OString::valueOf( nId ).getStr(), + FSEND ); + } + else + { + // not autonumbered + m_pSerializer->singleElementNS( XML_w, nToken, + FSNS( XML_w, XML_customMarkFollows ), "1", + FSNS( XML_w, XML_id ), ::rtl::OString::valueOf( nId ).getStr(), + FSEND ); + + RunText( pFootnote->GetNumStr() ); + } +} + +void DocxAttributeOutput::FootnotesEndnotes( bool bFootnotes ) +{ + const FootnotesVector& rVector = bFootnotes? m_pFootnotesList->getVector(): m_pEndnotesList->getVector(); + + sal_Int32 nBody = bFootnotes? XML_footnotes: XML_endnotes; + sal_Int32 nItem = bFootnotes? XML_footnote: XML_endnote; + + m_pSerializer->startElementNS( XML_w, nBody, + FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + FSEND ); + + sal_Int32 nIndex = 0; + + // separator + m_pSerializer->startElementNS( XML_w, nItem, + FSNS( XML_w, XML_id ), OString::valueOf( nIndex++ ).getStr(), + FSNS( XML_w, XML_type ), "separator", + FSEND ); + m_pSerializer->startElementNS( XML_w, XML_p, FSEND ); + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_separator, FSEND ); + m_pSerializer->endElementNS( XML_w, XML_r ); + m_pSerializer->endElementNS( XML_w, XML_p ); + m_pSerializer->endElementNS( XML_w, nItem ); + + // separator + m_pSerializer->startElementNS( XML_w, nItem, + FSNS( XML_w, XML_id ), OString::valueOf( nIndex++ ).getStr(), + FSNS( XML_w, XML_type ), "continuationSeparator", + FSEND ); + m_pSerializer->startElementNS( XML_w, XML_p, FSEND ); + m_pSerializer->startElementNS( XML_w, XML_r, FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_continuationSeparator, FSEND ); + m_pSerializer->endElementNS( XML_w, XML_r ); + m_pSerializer->endElementNS( XML_w, XML_p ); + m_pSerializer->endElementNS( XML_w, nItem ); + + // footnotes/endnotes themselves + for ( FootnotesVector::const_iterator i = rVector.begin(); i != rVector.end(); ++i, ++nIndex ) + { + m_pSerializer->startElementNS( XML_w, nItem, + FSNS( XML_w, XML_id ), OString::valueOf( nIndex ).getStr(), + FSEND ); + + const SwNodeIndex* pIndex = (*i)->GetTxtFtn()->GetStartNode(); + + m_rExport.WriteSpecialText( pIndex->GetIndex() + 1, + pIndex->GetNode().EndOfSectionIndex(), + bFootnotes? TXT_FTN: TXT_EDN ); + + m_pSerializer->endElementNS( XML_w, nItem ); + } + + m_pSerializer->endElementNS( XML_w, nBody ); + +} + +void DocxAttributeOutput::ParaLineSpacing_Impl( short nSpace, short /*nMulti*/ ) +{ + if ( !m_pSpacingAttrList ) + m_pSpacingAttrList = m_pSerializer->createAttrList(); + + if ( nSpace < 0 ) + { + m_pSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "exact" ); + m_pSpacingAttrList->add( FSNS( XML_w, XML_line ), OString::valueOf( sal_Int32( -nSpace ) ) ); + } + else if ( nSpace > 0 ) + { + m_pSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "atLeast" ); + m_pSpacingAttrList->add( FSNS( XML_w, XML_line ), OString::valueOf( sal_Int32( nSpace ) ) ); + } + else + m_pSpacingAttrList->add( FSNS( XML_w, XML_lineRule ), "auto" ); +} + +void DocxAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) +{ + const char *pAdjustString; + + switch ( rAdjust.GetAdjust() ) + { + case SVX_ADJUST_LEFT: + pAdjustString = "left"; + break; + case SVX_ADJUST_RIGHT: + pAdjustString = "right"; + break; + case SVX_ADJUST_BLOCKLINE: + case SVX_ADJUST_BLOCK: + pAdjustString = "both"; + break; + case SVX_ADJUST_CENTER: + pAdjustString = "center"; + break; + default: + return; // not supported attribute + } + m_pSerializer->singleElementNS( XML_w, XML_jc, FSNS( XML_w, XML_val ), pAdjustString, FSEND ); +} + +void DocxAttributeOutput::ParaSplit( const SvxFmtSplitItem& rSplit ) +{ + if (rSplit.GetValue()) + m_pSerializer->singleElementNS( XML_w, XML_keepLines, FSNS( XML_w, XML_val ), "off", FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_keepLines, FSEND ); +} + +void DocxAttributeOutput::ParaWidows( const SvxWidowsItem& rWidows ) +{ + if (rWidows.GetValue()) + m_pSerializer->singleElementNS( XML_w, XML_widowControl, FSEND ); + else + m_pSerializer->singleElementNS( XML_w, XML_widowControl, FSNS( XML_w, XML_val ), "off", FSEND ); +} + +static void impl_WriteTabElement( FSHelperPtr pSerializer, + const SvxTabStop& rTab, long nCurrentLeft ) +{ + FastAttributeList *pTabElementAttrList = pSerializer->createAttrList(); + + switch (rTab.GetAdjustment()) + { + case SVX_TAB_ADJUST_RIGHT: + pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( (sal_Char *)"right") ); + break; + case SVX_TAB_ADJUST_DECIMAL: + pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( (sal_Char *)"decimal") ); + break; + case SVX_TAB_ADJUST_CENTER: + pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( (sal_Char *)"center") ); + break; + case SVX_TAB_ADJUST_DEFAULT: + case SVX_TAB_ADJUST_LEFT: + default: + pTabElementAttrList->add( FSNS( XML_w, XML_val ), OString( (sal_Char *)"left") ); + break; + } + + pTabElementAttrList->add( FSNS( XML_w, XML_pos ), OString::valueOf( rTab.GetTabPos() + nCurrentLeft ) ); + + sal_Unicode cFillChar = rTab.GetFill(); + + if (sal_Unicode('.') == cFillChar ) + pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "dot" ) ); + else if ( sal_Unicode('-') == cFillChar ) + pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "hyphen" ) ); + else if ( sal_Unicode(0xB7) == cFillChar ) // middle dot + pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "middleDot" ) ); + else if ( sal_Unicode('_') == cFillChar ) + pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "underscore" ) ); + else + pTabElementAttrList->add( FSNS( XML_w, XML_leader ), OString( (sal_Char *) "none" ) ); + + pSerializer->singleElementNS( XML_w, XML_tab, pTabElementAttrList ); +} + +void DocxAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop ) +{ + const SfxPoolItem* pLR = m_rExport.HasItem( RES_LR_SPACE ); + long nCurrentLeft = pLR ? ((const SvxLRSpaceItem*)pLR)->GetTxtLeft() : 0; + + m_pSerializer->startElementNS( XML_w, XML_tabs, FSEND ); + + sal_uInt16 nCount = rTabStop.Count(); + for (sal_uInt16 i = 0; i < nCount; i++ ) + impl_WriteTabElement( m_pSerializer, rTabStop[i], nCurrentLeft ); + + m_pSerializer->endElementNS( XML_w, XML_tabs ); +} + +void DocxAttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone ) +{ + m_pSerializer->singleElementNS( XML_w, XML_suppressAutoHyphens, + FSNS( XML_w, XML_val ), rHyphenZone.IsHyphen( ) ? "false" : "true" , + FSEND ); +} + +void DocxAttributeOutput::ParaNumRule_Impl( const SwTxtNode* /*pTxtNd*/, sal_Int32 nLvl, sal_Int32 nNumId ) +{ + if ( USHRT_MAX != nNumId && 0 != nNumId ) + { + m_pSerializer->startElementNS( XML_w, XML_numPr, FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_ilvl, FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nLvl )).getStr(), FSEND ); + m_pSerializer->singleElementNS( XML_w, XML_numId, FSNS( XML_w, XML_val ), OString::valueOf( sal_Int32( nNumId )).getStr(), FSEND ); + m_pSerializer->endElementNS( XML_w, XML_numPr ); + } +} + +void DocxAttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace ) +{ + USHORT nXmlElement = 0; + + switch ( rScriptSpace.Which( ) ) + { + case RES_PARATR_SCRIPTSPACE: + nXmlElement = XML_autoSpaceDE; + break; + case RES_PARATR_HANGINGPUNCTUATION: + nXmlElement = XML_overflowPunct; + break; + case RES_PARATR_FORBIDDEN_RULES: + nXmlElement = XML_kinsoku; + break; + } + + if ( nXmlElement ) + { + m_pSerializer->singleElementNS( XML_w, nXmlElement, + FSNS( XML_w, XML_val ), rScriptSpace.GetValue( ) ? "true": "false", + FSEND ); + } +} + +void DocxAttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign ) +{ + const char *pAlignString; + + switch ( rAlign.GetValue() ) + { + case SvxParaVertAlignItem::BASELINE: + pAlignString = "baseline"; + break; + case SvxParaVertAlignItem::TOP: + pAlignString = "top"; + break; + case SvxParaVertAlignItem::CENTER: + pAlignString = "center"; + break; + case SvxParaVertAlignItem::BOTTOM: + pAlignString = "bottom"; + break; + case SvxParaVertAlignItem::AUTOMATIC: + pAlignString = "auto"; + break; + default: + return; // not supported attribute + } + m_pSerializer->singleElementNS( XML_w, XML_textAlignment, FSNS( XML_w, XML_val ), pAlignString, FSEND ); +} + +void DocxAttributeOutput::ParaSnapToGrid( const SvxParaGridItem& rGrid ) +{ + m_pSerializer->singleElementNS( XML_w, XML_snapToGrid, + FSNS( XML_w, XML_val ), rGrid.GetValue( ) ? "true": "false", + FSEND ); +} + +void DocxAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize ) +{ + if ( m_rExport.bOutFlyFrmAttrs ) + { + #if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FormatFrameSize() - Fly frames\n" ); + #endif + } + else if ( m_rExport.bOutPageDescs ) + { + FastAttributeList *attrList = m_pSerializer->createAttrList( ); + if ( m_rExport.pAktPageDesc->GetLandscape( ) ) + attrList->add( FSNS( XML_w, XML_orient ), "landscape" ); + + + attrList->add( FSNS( XML_w, XML_w ), OString::valueOf( rSize.GetWidth( ) ) ); + attrList->add( FSNS( XML_w, XML_h ), OString::valueOf( rSize.GetHeight( ) ) ); + + XFastAttributeListRef xAttrList( attrList ); + attrList = NULL; + + m_pSerializer->singleElementNS( XML_w, XML_pgSz, xAttrList ); + } +} + +void DocxAttributeOutput::FormatPaperBin( const SvxPaperBinItem& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FormatPaperBin()\n" ); +#endif +} + +void DocxAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace ) +{ + if ( m_rExport.bOutFlyFrmAttrs ) + { +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "DocxAttributeOutput::FormatLRSpace() - Fly frames\n" ); +#endif + } + else if ( m_rExport.bOutPageDescs ) + { + if ( !m_pSpacingAttrList ) + m_pSpacingAttrList = m_pSerializer->createAttrList(); + + + USHORT nLDist, nRDist; + const SfxPoolItem* pItem = m_rExport.HasItem( RES_BOX ); + if ( pItem ) + { + nRDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_LEFT ); + nLDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_RIGHT ); + } + else + nLDist = nRDist = 0; + nLDist = nLDist + (USHORT)rLRSpace.GetLeft(); + nRDist = nRDist + (USHORT)rLRSpace.GetRight(); + + m_pSpacingAttrList->add( FSNS( XML_w, XML_left ), OString::valueOf( sal_Int32( nLDist ) ) ); + m_pSpacingAttrList->add( FSNS( XML_w, XML_right ), OString::valueOf( sal_Int32( nRDist ) ) ); + } + else + { + FastAttributeList *pLRSpaceAttrList = m_pSerializer->createAttrList(); + + pLRSpaceAttrList->add( FSNS( XML_w, XML_left ), OString::valueOf( (sal_Int32) rLRSpace.GetTxtLeft() ) ); + pLRSpaceAttrList->add( FSNS( XML_w, XML_right ), OString::valueOf( (sal_Int32) rLRSpace.GetRight() ) ); + + sal_Int32 nFirstLineAdjustment = rLRSpace.GetTxtFirstLineOfst(); + if (nFirstLineAdjustment > 0) + pLRSpaceAttrList->add( FSNS( XML_w, XML_firstLine ), OString::valueOf( nFirstLineAdjustment ) ); + else + pLRSpaceAttrList->add( FSNS( XML_w, XML_hanging ), OString::valueOf( - nFirstLineAdjustment ) ); + m_pSerializer->singleElementNS( XML_w, XML_ind, pLRSpaceAttrList ); + } +} + +void DocxAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace ) +{ + if (!m_pSpacingAttrList) + m_pSpacingAttrList = m_pSerializer->createAttrList(); + + if ( m_rExport.bOutFlyFrmAttrs ) + { + } + else if (m_rExport.bOutPageDescs ) + { + ASSERT( m_rExport.GetCurItemSet(), "Impossible" ); + if ( !m_rExport.GetCurItemSet() ) + return; + + HdFtDistanceGlue aDistances( *m_rExport.GetCurItemSet() ); + + if ( aDistances.HasHeader() ) + { + // Header top + m_pSpacingAttrList->add( FSNS( XML_w, XML_header ), + OString::valueOf( sal_Int32( aDistances.dyaHdrTop ) ) ); + } + + // Page top + m_pSpacingAttrList->add( FSNS( XML_w, XML_top ), + OString::valueOf( sal_Int32( aDistances.dyaTop ) ) ); + + if ( aDistances.HasFooter() ) + { + // Footer bottom + m_pSpacingAttrList->add( FSNS( XML_w, XML_footer ), + OString::valueOf( sal_Int32( aDistances.dyaHdrBottom ) ) ); + } + + // Page Bottom + m_pSpacingAttrList->add( FSNS( XML_w, XML_bottom ), + OString::valueOf( sal_Int32( aDistances.dyaBottom ) ) ); + + } + else + { + m_pSpacingAttrList->add( FSNS( XML_w, XML_before ), + OString::valueOf( (sal_Int32)rULSpace.GetUpper() ) ); + m_pSpacingAttrList->add( FSNS( XML_w, XML_after ), + OString::valueOf( (sal_Int32)rULSpace.GetLower() ) ); + } +} + +void DocxAttributeOutput::FormatSurround( const SwFmtSurround& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FormatSurround()\n" ); +#endif +} + +void DocxAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FormatVertOrientation()\n" ); +#endif +} + +void DocxAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FormatHorizOrientation()\n" ); +#endif +} + +void DocxAttributeOutput::FormatAnchor( const SwFmtAnchor& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FormatAnchor()\n" ); +#endif +} + +void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) +{ + if ( !m_rExport.bOutPageDescs ) + { + OString sColor = impl_ConvertColor( rBrush.GetColor( ) ); + m_pSerializer->singleElementNS( XML_w, XML_shd, + FSNS( XML_w, XML_fill ), sColor.getStr( ), + FSEND ); + } + +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FormatBackground()\n" ); +#endif +} + +void DocxAttributeOutput::FormatBox( const SvxBoxItem& rBox ) +{ + + if ( !m_bOpenedSectPr ) + { + // Normally open the borders tag for paragraphs + m_pSerializer->startElementNS( XML_w, XML_pBdr, FSEND ); + } + + impl_pageBorders( m_pSerializer, rBox ); + + if ( m_bOpenedSectPr ) + { + // Special handling for pgBorder + m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND ); + m_pSerializer->mergeTopMarks( ); + } + else + { + // Normally close the borders tag for paragraphs + m_pSerializer->endElementNS( XML_w, XML_pBdr ); + } +} + +void DocxAttributeOutput::FormatColumns_Impl( USHORT nCols, const SwFmtCol& rCol, bool bEven, SwTwips nPageSize ) +{ + // Get the columns attributes + FastAttributeList *pColsAttrList = m_pSerializer->createAttrList(); + + pColsAttrList->add( FSNS( XML_w, XML_num ), + OString::valueOf( sal_Int32( nCols ) ). getStr( ) ); + + const char* pEquals = "false"; + if ( bEven ) + { + USHORT nWidth = rCol.GetGutterWidth( true ); + pColsAttrList->add( FSNS( XML_w, XML_space ), + OString::valueOf( sal_Int32( nWidth ) ).getStr( ) ); + + pEquals = "true"; + } + + pColsAttrList->add( FSNS( XML_w, XML_equalWidth ), pEquals ); + + bool bHasSep = COLADJ_NONE == rCol.GetLineAdj( ); + pColsAttrList->add( FSNS( XML_w, XML_sep ), bHasSep ? "true" : "false" ); + + // Write the element + m_pSerializer->startElementNS( XML_w, XML_cols, pColsAttrList ); + + // Write the columns width if non-equals + const SwColumns & rColumns = rCol.GetColumns( ); + if ( !bEven ) + { + for ( USHORT n = 0; n < nCols; ++n ) + { + FastAttributeList *pColAttrList = m_pSerializer->createAttrList(); + USHORT nWidth = rCol.CalcPrtColWidth( n, ( USHORT ) nPageSize ); + pColAttrList->add( FSNS( XML_w, XML_w ), + OString::valueOf( sal_Int32( nWidth ) ).getStr( ) ); + + if ( n + 1 != nCols ) + { + USHORT nSpacing = rColumns[n]->GetRight( ) + rColumns[n + 1]->GetLeft( ); + pColAttrList->add( FSNS( XML_w, XML_space ), + OString::valueOf( sal_Int32( nSpacing ) ).getStr( ) ); + } + + m_pSerializer->singleElementNS( XML_w, XML_col, pColAttrList ); + } + } + + m_pSerializer->endElementNS( XML_w, XML_cols ); +} + +void DocxAttributeOutput::FormatKeep( const SvxFmtKeepItem& ) +{ + m_pSerializer->singleElementNS( XML_w, XML_keepNext, FSEND ); +} + +void DocxAttributeOutput::FormatTextGrid( const SwTextGridItem& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxAttributeOutput::FormatTextGrid()\n" ); +#endif +} + +void DocxAttributeOutput::FormatLineNumbering( const SwFmtLineNumber& rNumbering ) +{ + if ( !rNumbering.IsCount( ) ) + m_pSerializer->singleElementNS( XML_w, XML_suppressLineNumbers, FSEND ); +} + +void DocxAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection ) +{ + OString sTextFlow; + bool bBiDi = false; + short nDir = rDirection.GetValue(); + + if ( nDir == FRMDIR_ENVIRONMENT ) + nDir = GetExport( ).GetDefaultFrameDirection( ); + + switch ( nDir ) + { + default: + case FRMDIR_HORI_LEFT_TOP: + sTextFlow = OString( "lrTb" ); + break; + case FRMDIR_HORI_RIGHT_TOP: + sTextFlow = OString( "lrTb" ); + bBiDi = true; + break; + case FRMDIR_VERT_TOP_LEFT: // many things but not this one + case FRMDIR_VERT_TOP_RIGHT: + sTextFlow = OString( "tbRl" ); + break; + } + + if ( m_rExport.bOutPageDescs ) + { + m_pSerializer->singleElementNS( XML_w, XML_textDirection, + FSNS( XML_w, XML_val ), sTextFlow.getStr( ), + FSEND ); + if ( bBiDi ) + m_pSerializer->singleElementNS( XML_w, XML_bidi, FSEND ); + } + else if ( !m_rExport.bOutFlyFrmAttrs ) + { + if ( bBiDi ) + m_pSerializer->singleElementNS( XML_w, XML_bidi, FSEND ); + } +} + +DocxAttributeOutput::DocxAttributeOutput( DocxExport &rExport, FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML ) + : m_rExport( rExport ), + m_pSerializer( pSerializer ), + m_rDrawingML( *pDrawingML ), + m_pFontsAttrList( NULL ), + m_pEastAsianLayoutAttrList( NULL ), + m_pCharLangAttrList( NULL ), + m_pSpacingAttrList( NULL ), + m_pHyperlinkAttrList( NULL ), + m_pFootnotesList( new ::docx::FootnotesList() ), + m_pEndnotesList( new ::docx::FootnotesList() ), + m_pSectionInfo( NULL ), + m_pRedlineData( NULL ), + m_nRedlineId( 0 ), + m_bOpenedSectPr( false ), + m_sFieldBkm( ), + m_nNextMarkId( 0 ), + m_pTableWrt( NULL ), + m_bTableCellOpen( false ), + m_nTableDepth( 0 ), + m_bParagraphOpened( false ), + m_nColBreakStatus( COLBRK_NONE ) +{ +} + +DocxAttributeOutput::~DocxAttributeOutput() +{ + delete m_pFontsAttrList, m_pFontsAttrList = NULL; + delete m_pEastAsianLayoutAttrList, m_pEastAsianLayoutAttrList = NULL; + delete m_pCharLangAttrList, m_pCharLangAttrList = NULL; + delete m_pSpacingAttrList, m_pSpacingAttrList = NULL; + delete m_pHyperlinkAttrList, m_pHyperlinkAttrList = NULL; + + delete m_pFootnotesList, m_pFootnotesList = NULL; + delete m_pEndnotesList, m_pEndnotesList = NULL; + + delete m_pTableWrt, m_pTableWrt = NULL; +} + +MSWordExportBase& DocxAttributeOutput::GetExport() +{ + return m_rExport; +} + +bool DocxAttributeOutput::HasFootnotes() +{ + return !m_pFootnotesList->isEmpty(); +} + +bool DocxAttributeOutput::HasEndnotes() +{ + return !m_pEndnotesList->isEmpty(); +} diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx new file mode 100644 index 0000000000..d751e6cf7a --- /dev/null +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -0,0 +1,613 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DOCXATTRIBUTEOUTPUT_HXX_ +#define _DOCXATTRIBUTEOUTPUT_HXX_ + +#include "attributeoutputbase.hxx" +#include "fields.hxx" + +#include <sax/fshelper.hxx> +#include <sax/fastattribs.hxx> +#include <vcl/vclenum.hxx> + +#include <fldbas.hxx> + +#include <vector> + +class DocxExport; + +class SwGrfNode; + +namespace docx { class FootnotesList; } +namespace oox { namespace drawingml { class DrawingML; } } + +struct FieldInfos +{ + const SwField* pField; + ww::eField eType; + bool bOpen; + bool bClose; + String sCmd; +}; + +enum DocxColBreakStatus +{ + COLBRK_NONE, + COLBRK_POSTPONE, + COLBRK_WRITE +}; + +class DocxAttributeOutput : public AttributeOutputBase +{ +public: + /// Export the state of RTL/CJK. + virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ); + + /// Start of the paragraph. + virtual void StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo ); + + /// End of the paragraph. + virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ); + + /// Empty paragraph. + virtual void EmptyParagraph(); + + /// Called before we start outputting the attributes. + virtual void StartParagraphProperties( const SwTxtNode& rNode ); + + /// Called after we end outputting the attributes. + virtual void EndParagraphProperties(); + + /// Start of the text run. + virtual void StartRun( const SwRedlineData* pRedlineData ); + + /// End of the text run. + virtual void EndRun(); + + /// Called before we start outputting the attributes. + virtual void StartRunProperties(); + + /// Called after we end outputting the attributes. + virtual void EndRunProperties( const SwRedlineData* pRedlineData ); + + /// Output text (inside a run). + virtual void RunText( const String& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8 ); + + /// Output text (without markup). + virtual void RawText( const String& rText, bool bForceUnicode, rtl_TextEncoding eCharSet ); + + /// Output ruby start. + virtual void StartRuby( const SwTxtNode& rNode, const SwFmtRuby& rRuby ); + + /// Output ruby end. + virtual void EndRuby(); + + /// Output URL start. + virtual bool StartURL( const String& rUrl, const String& rTarget ); + + /// Output URL end. + virtual bool EndURL(); + + virtual void FieldVanish( const String& rTxt, ww::eField eType ); + + /// Output redlining. + /// + /// The common attribute that can be among the run properties. + virtual void Redline( const SwRedlineData* pRedline ); + + /// Output redlining. + /// + /// Start of the tag that encloses the run, fills the info according to + /// the value of m_pRedlineData. + void StartRedline( const SwRedlineData* pRedlineData ); + + /// Output redlining. + /// + /// End of the tag that encloses the run. + void EndRedline(); + + virtual void FormatDrop( const SwTxtNode& rNode, const SwFmtDrop& rSwFmtDrop, USHORT nStyle, ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ); + + /// Output style. + virtual void ParagraphStyle( USHORT nStyle ); + + virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t pNodeInfo ); + + virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ); + + virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableRowEnd( sal_uInt32 nDepth = 1 ); + + /// Start of the styles table. + virtual void StartStyles(); + + /// End of the styles table. + virtual void EndStyles( USHORT nNumberOfStyles ); + + /// Write default style. + virtual void DefaultStyle( USHORT nStyle ); + + /// Start of a style in the styles table. + virtual void StartStyle( const String& rName, bool bPapFmt, + USHORT nBase, USHORT nNext, USHORT nWwId, USHORT nId ); + + /// End of a style in the styles table. + virtual void EndStyle(); + + /// Start of (paragraph or run) properties of a style. + virtual void StartStyleProperties( bool bParProp, USHORT nStyle ); + + /// End of (paragraph or run) properties of a style. + virtual void EndStyleProperties( bool bParProp ); + + /// Numbering rule and Id. + virtual void OutlineNumbering( BYTE nLvl, const SwNumFmt &rNFmt, const SwFmt &rFmt ); + + /// Page break + /// As a paragraph property - the paragraph should be on the next page. + virtual void PageBreakBefore( bool bBreak ); + + /// Write a section break + /// msword::ColumnBreak or msword::PageBreak + virtual void SectionBreak( BYTE nC, const WW8_SepInfo* pSectionInfo = NULL ); + + /// Start of the section properties. + virtual void StartSection(); + + /// End of the section properties. + virtual void EndSection(); + + /// Protection of forms. + virtual void SectionFormProtection( bool bProtected ); + + /// Numbering of the lines in the document. + virtual void SectionLineNumbering( ULONG nRestartNo, const SwLineNumberInfo& rLnNumInfo ); + + /// Has different headers/footers for the title page. + virtual void SectionTitlePage(); + + /// Description of the page borders. + virtual void SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* pFirstPageFmt ); + + /// Columns populated from right/numbers on the right side? + virtual void SectionBiDi( bool bBiDi ); + + /// The style of the page numbers. + /// + /// nPageRestartNumberr being 0 means no restart. + virtual void SectionPageNumbering( USHORT nNumType, USHORT nPageRestartNumber ); + + /// The type of breaking. + virtual void SectionType( BYTE nBreakCode ); + + /// Start the font. + void StartFont( const String& rFamilyName ) const; + + /// End the font. + void EndFont() const; + + /// Alternate name for the font. + void FontAlternateName( const String& rName ) const; + + /// Font charset. + void FontCharset( sal_uInt8 nCharSet ) const; + + /// Font family. + void FontFamilyType( FontFamily eFamily ) const; + + /// Font pitch. + void FontPitchType( FontPitch ePitch ) const; + + /// Definition of a numbering instance. + virtual void NumberingDefinition( USHORT nId, const SwNumRule &rRule ); + + /// Start of the abstract numbering definition instance. + virtual void StartAbstractNumbering( USHORT nId ); + + /// End of the abstract numbering definition instance. + virtual void EndAbstractNumbering(); + + /// All the numbering level information. + virtual void NumberingLevel( BYTE nLevel, + USHORT nStart, + USHORT nNumberingType, + SvxAdjust eAdjust, + const BYTE *pNumLvlPos, + BYTE nFollow, + const wwFont *pFont, + const SfxItemSet *pOutSet, + sal_Int16 nIndentAt, + sal_Int16 nFirstLineIndex, + sal_Int16 nListTabPos, + const String &rNumberingString ); + + void WriteField_Impl( const SwField* pFld, ww::eField eType, const String& rFldCmd, BYTE nMode ); + + void WriteBookmarks_Impl( std::vector< rtl::OUString >& rStarts, std::vector< rtl::OUString >& rEnds ); + +private: + /// Initialize the structures where we are going to collect some of the paragraph properties. + /// + /// Some of the properties have to be collected from more sources, and are + /// actually not written between StartParagraphProperties and + /// EndParagraphProperties. They are output in this method, which is + /// supposed to be called just before outputting </rPr> whenever it is done. + void InitCollectedParagraphProperties(); + + /// Output what we collected during the run properties output. + /// + /// @see WriteCollectedParagrapProperties(). + void WriteCollectedParagraphProperties(); + + /// Initialize the structures where we are going to collect some of the run properties. + /// + /// This is an equivalent of InitCollectedParagraphProperties(), resp. + /// WriteCollectectedParagraphProperties(). + /// + /// @see InitCollectedParagraphProperties(). + void InitCollectedRunProperties(); + + /// Output what we collected during the run properties output. + /// + /// @see InitCollectedRunProperies(), WriteCollectedParagraphProperties() + void WriteCollectedRunProperties(); + + /// Output graphic fly frames. + void FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize ); + + void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + void StartTable( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + void StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + void StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + void TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + void EndTableCell( ); + + void EndTableRow( ); + + void EndTable(); + + /// End cell, row, and even the entire table if necessary. + void FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool bForceEmptyParagraph = false ); + +protected: + + /// Output frames - the implementation. + virtual void OutputFlyFrame_Impl( const sw::Frame& rFmt, const Point& rNdTopLeft ); + + /// Sfx item Sfx item RES_CHRATR_CASEMAP + virtual void CharCaseMap( const SvxCaseMapItem& rCaseMap ); + + /// Sfx item Sfx item RES_CHRATR_COLOR + virtual void CharColor( const SvxColorItem& rColor); + + /// Sfx item Sfx item RES_CHRATR_CONTOUR + virtual void CharContour( const SvxContourItem& rContour ); + + /// Sfx item RES_CHRATR_CROSSEDOUT + virtual void CharCrossedOut( const SvxCrossedOutItem& rCrossedOut ); + + /// Sfx item RES_CHRATR_ESCAPEMENT + virtual void CharEscapement( const SvxEscapementItem& rEscapement ); + + /// Sfx item RES_CHRATR_FONT + virtual void CharFont( const SvxFontItem& rFont ); + + /// Sfx item RES_CHRATR_FONTSIZE + virtual void CharFontSize( const SvxFontHeightItem& rFontSize ); + + /// Sfx item RES_CHRATR_KERNING + virtual void CharKerning( const SvxKerningItem& rKerning ); + + /// Sfx item RES_CHRATR_LANGUAGE + virtual void CharLanguage( const SvxLanguageItem& rLanguage ); + + /// Sfx item RES_CHRATR_POSTURE + virtual void CharPosture( const SvxPostureItem& rPosture ); + + /// Sfx item RES_CHRATR_SHADOWED + virtual void CharShadow( const SvxShadowedItem& rShadow ); + + /// Sfx item RES_CHRATR_UNDERLINE + virtual void CharUnderline( const SvxUnderlineItem& rUnderline ); + + /// Sfx item RES_CHRATR_WEIGHT + virtual void CharWeight( const SvxWeightItem& rWeight ); + + /// Sfx item RES_CHRATR_AUTOKERN + virtual void CharAutoKern( const SvxAutoKernItem& ); + + /// Sfx item RES_CHRATR_BLINK + virtual void CharAnimatedText( const SvxBlinkItem& rBlink ); + + /// Sfx item RES_CHRATR_BACKGROUND + virtual void CharBackground( const SvxBrushItem& rBrush ); + + /// Sfx item RES_CHRATR_CJK_FONT + virtual void CharFontCJK( const SvxFontItem& rFont ); + + /// Sfx item RES_CHRATR_CJK_FONTSIZE + virtual void CharFontSizeCJK( const SvxFontHeightItem& rFontSize ) { CharFontSize( rFontSize ); } + + /// Sfx item RES_CHRATR_CJK_LANGUAGE + virtual void CharLanguageCJK( const SvxLanguageItem& rLanguageItem ) { CharLanguage( rLanguageItem ); } + + /// Sfx item RES_CHRATR_CJK_POSTURE + virtual void CharPostureCJK( const SvxPostureItem& rPosture ); + + /// Sfx item RES_CHRATR_CJK_WEIGHT + virtual void CharWeightCJK( const SvxWeightItem& rWeight ); + + /// Sfx item RES_CHRATR_CTL_FONT + virtual void CharFontCTL( const SvxFontItem& rFont ); + + /// Sfx item RES_CHRATR_CTL_FONTSIZE + virtual void CharFontSizeCTL( const SvxFontHeightItem& rFontSize ) { CharFontSize( rFontSize ); } + + /// Sfx item RES_CHRATR_CTL_LANGUAGE + virtual void CharLanguageCTL( const SvxLanguageItem& rLanguageItem ) { CharLanguage( rLanguageItem); } + + /// Sfx item RES_CHRATR_CTL_POSTURE + virtual void CharPostureCTL( const SvxPostureItem& rWeight ); + + /// Sfx item RES_CHRATR_CTL_WEIGHT + virtual void CharWeightCTL( const SvxWeightItem& rWeight ); + + /// Sfx item RES_CHRATR_ROTATE + virtual void CharRotate( const SvxCharRotateItem& rRotate ); + + /// Sfx item RES_CHRATR_EMPHASIS_MARK + virtual void CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark ); + + /// Sfx item RES_CHRATR_TWO_LINES + virtual void CharTwoLines( const SvxTwoLinesItem& rTwoLines ); + + /// Sfx item RES_CHRATR_SCALEW + virtual void CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth ); + + /// Sfx item RES_CHRATR_RELIEF + virtual void CharRelief( const SvxCharReliefItem& rRelief); + + /// Sfx item RES_CHRATR_HIDDEN + virtual void CharHidden( const SvxCharHiddenItem& rHidden ); + + /// Sfx item RES_TXTATR_INETFMT + virtual void TextINetFormat( const SwFmtINetFmt& ); + + /// Sfx item RES_TXTATR_CHARFMT + virtual void TextCharFormat( const SwFmtCharFmt& ); + + /// Sfx item RES_TXTATR_FTN + virtual void TextFootnote_Impl( const SwFmtFtn& ); + + /// Output the footnote/endnote reference (if there's one to output). + void FootnoteEndnoteReference(); + + /// Sfx item RES_PARATR_LINESPACING + virtual void ParaLineSpacing_Impl( short nSpace, short nMulti ); + + /// Sfx item RES_PARATR_ADJUST + virtual void ParaAdjust( const SvxAdjustItem& rAdjust ); + + /// Sfx item RES_PARATR_SPLIT + virtual void ParaSplit( const SvxFmtSplitItem& rSplit ); + + /// Sfx item RES_PARATR_WIDOWS + virtual void ParaWidows( const SvxWidowsItem& rWidows ); + + /// Sfx item RES_PARATR_TABSTOP + virtual void ParaTabStop( const SvxTabStopItem& rTabStop ); + + /// Sfx item RES_PARATR_HYPHENZONE + virtual void ParaHyphenZone( const SvxHyphenZoneItem& ); + + /// Sfx item RES_PARATR_NUMRULE + virtual void ParaNumRule_Impl( const SwTxtNode *pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId ); + + /// Sfx item RES_PARATR_SCRIPTSPACE + virtual void ParaScriptSpace( const SfxBoolItem& ); + + /// Sfx item RES_PARATR_VERTALIGN + virtual void ParaVerticalAlign( const SvxParaVertAlignItem& rAlign ); + + /// Sfx item RES_PARATR_SNAPTOGRID + virtual void ParaSnapToGrid( const SvxParaGridItem& ); + + /// Sfx item RES_FRM_SIZE + virtual void FormatFrameSize( const SwFmtFrmSize& ); + + /// Sfx item RES_PAPER_BIN + virtual void FormatPaperBin( const SvxPaperBinItem& ); + + /// Sfx item RES_LR_SPACE + virtual void FormatLRSpace( const SvxLRSpaceItem& rLRSpace ); + + /// Sfx item RES_UL_SPACE + virtual void FormatULSpace( const SvxULSpaceItem& rULSpace ); + + /// Sfx item RES_SURROUND + virtual void FormatSurround( const SwFmtSurround& ); + + /// Sfx item RES_VERT_ORIENT + virtual void FormatVertOrientation( const SwFmtVertOrient& ); + + /// Sfx item RES_HORI_ORIENT + virtual void FormatHorizOrientation( const SwFmtHoriOrient& ); + + /// Sfx item RES_ANCHOR + virtual void FormatAnchor( const SwFmtAnchor& ); + + /// Sfx item RES_BACKGROUND + virtual void FormatBackground( const SvxBrushItem& ); + + /// Sfx item RES_BOX + virtual void FormatBox( const SvxBoxItem& ); + + /// Sfx item RES_COL + virtual void FormatColumns_Impl( USHORT nCols, const SwFmtCol & rCol, bool bEven, SwTwips nPageSize ); + + /// Sfx item RES_KEEP + virtual void FormatKeep( const SvxFmtKeepItem& ); + + /// Sfx item RES_TEXTGRID + virtual void FormatTextGrid( const SwTextGridItem& ); + + /// Sfx item RES_LINENUMBER + virtual void FormatLineNumbering( const SwFmtLineNumber& ); + + /// Sfx item RES_FRAMEDIR + virtual void FormatFrameDirection( const SvxFrameDirectionItem& ); + + /// Write the expanded field + virtual void WriteExpand( const SwField* pFld ); + + virtual void RefField( const SwField& rFld, const String& rRef ); + virtual void HiddenField( const SwField& rFld ); + virtual void SetField( const SwField& rFld, ww::eField eType, const String& rCmd ); + virtual void PostitField( const SwField* pFld ); + virtual bool DropdownField( const SwField* pFld ); + + virtual bool AnalyzeURL( const String& rURL, const String& rTarget, String* pLinkURL, String* pMark ); + + /// Reference to the export, where to get the data from + DocxExport &m_rExport; + + /// Fast serializer to output the data + ::sax_fastparser::FSHelperPtr m_pSerializer; + + /// DrawingML access + oox::drawingml::DrawingML &m_rDrawingML; + +private: + + void DoWriteBookmarks( ); + + void StartField_Impl( FieldInfos& rInfos, sal_Bool bWriteRun = sal_False ); + void DoWriteCmd( String& rCmd ); + void CmdField_Impl( FieldInfos& rInfos ); + void EndField_Impl( FieldInfos& rInfos ); + + ::sax_fastparser::FastAttributeList *m_pFontsAttrList, *m_pEastAsianLayoutAttrList; + ::sax_fastparser::FastAttributeList *m_pCharLangAttrList; + ::sax_fastparser::FastAttributeList *m_pSpacingAttrList; + ::sax_fastparser::FastAttributeList *m_pHyperlinkAttrList; + + ::docx::FootnotesList *m_pFootnotesList; + ::docx::FootnotesList *m_pEndnotesList; + + const WW8_SepInfo *m_pSectionInfo; + + /// Redline data to remember in the text run. + const SwRedlineData *m_pRedlineData; + + /// Id of the redline + sal_Int32 m_nRedlineId; + + /// Flag indicating that the section properties are being written + sal_Bool m_bOpenedSectPr; + + /// Field data to remember in the text run + std::vector< FieldInfos > m_Fields; + String m_sFieldBkm; + sal_Int32 m_nNextMarkId; + + /// Bookmarks to output + std::vector<rtl::OString> m_rMarksStart; + std::vector<rtl::OString> m_rMarksEnd; + + /// Maps of the bookmarks ids + std::map<rtl::OString, USHORT> m_rOpenedMarksIds; + + /// The current table helper + SwWriteTable *m_pTableWrt; + + /// Remember if we are in an open cell, or not. + bool m_bTableCellOpen; + + /// Remember the current table depth. + sal_uInt32 m_nTableDepth; + + bool m_bParagraphOpened; + + // Remember that a column break has to be opened at the + // beginning of the next paragraph + DocxColBreakStatus m_nColBreakStatus; + +public: + DocxAttributeOutput( DocxExport &rExport, ::sax_fastparser::FSHelperPtr pSerializer, oox::drawingml::DrawingML* pDrawingML ); + + virtual ~DocxAttributeOutput(); + + /// Return the right export class. + virtual MSWordExportBase& GetExport(); + + /// For eg. the output of the styles, we need to switch the serializer to enother one. + void SetSerializer( ::sax_fastparser::FSHelperPtr pSerializer ) { m_pSerializer = pSerializer; } + + /// Occasionnaly need to use this serializer from the outside + ::sax_fastparser::FSHelperPtr GetSerializer( ) { return m_pSerializer; } + + /// Do we have any footnotes? + bool HasFootnotes(); + + /// Do we have any endnotes? + bool HasEndnotes(); + + /// Output the content of the footnotes.xml resp. endnotes.xml + void FootnotesEndnotes( bool bFootnotes ); +}; + +#endif // _DOCXATTRIBUTEOUTPUT_HXX_ + +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx new file mode 100644 index 0000000000..694f75a18c --- /dev/null +++ b/sw/source/filter/ww8/docxexport.cxx @@ -0,0 +1,812 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "docxexport.hxx" +#include "docxexportfilter.hxx" + +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> +#include <com/sun/star/document/XDocumentProperties.hpp> +#include <com/sun/star/i18n/ScriptType.hdl> + +#include <oox/core/tokens.hxx> +#include <oox/export/drawingml.hxx> +#include <oox/export/vmlexport.hxx> + +#include <map> +#include <algorithm> + +#include <IMark.hxx> +#include <docsh.hxx> +#include <ndtxt.hxx> +#include <wrtww8.hxx> +#include <fltini.hxx> +#include <fmtline.hxx> +#include <fmtpdsc.hxx> +#include <frmfmt.hxx> +#include <section.hxx> + +#include <docary.hxx> +#include <numrule.hxx> +#include <charfmt.hxx> + +#include "ww8par.hxx" +#include "ww8scan.hxx" + +#include <comphelper/string.hxx> +#include <rtl/ustrbuf.hxx> +#include <vcl/font.hxx> + +using namespace ::comphelper; +using namespace ::com::sun::star; + +using oox::vml::VMLExport; + +using rtl::OUString; +using rtl::OUStringBuffer; + +using sw::mark::IMark; + +#define S( x ) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) ) + +AttributeOutputBase& DocxExport::AttrOutput() const +{ + return *m_pAttrOutput; +} + +MSWordSections& DocxExport::Sections() const +{ + return *m_pSections; +} + +bool DocxExport::CollapseScriptsforWordOk( USHORT nScript, USHORT nWhich ) +{ + // TODO FIXME is this actually true for docx? - this is ~copied from WW8 + if ( nScript == i18n::ScriptType::ASIAN ) + { + // for asian in ww8, there is only one fontsize + // and one fontstyle (posture/weight) + switch ( nWhich ) + { + case RES_CHRATR_FONTSIZE: + case RES_CHRATR_POSTURE: + case RES_CHRATR_WEIGHT: + return false; + default: + break; + } + } + else if ( nScript != i18n::ScriptType::COMPLEX ) + { + // for western in ww8, there is only one fontsize + // and one fontstyle (posture/weight) + switch ( nWhich ) + { + case RES_CHRATR_CJK_FONTSIZE: + case RES_CHRATR_CJK_POSTURE: + case RES_CHRATR_CJK_WEIGHT: + return false; + default: + break; + } + } + return true; +} + +bool DocxExport::GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt, + xub_StrLen nEnd, IMarkVector& rArr ) +{ + IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); + ULONG nNd = rNd.GetIndex( ); + + const sal_Int32 nMarks = pMarkAccess->getMarksCount(); + for ( sal_Int32 i = 0; i < nMarks; i++ ) + { + IMark* pMark = ( pMarkAccess->getMarksBegin() + i )->get(); + + // Only keep the bookmarks starting or ending in this node + if ( pMark->GetMarkStart().nNode == nNd || + pMark->GetMarkEnd().nNode == nNd ) + { + xub_StrLen nBStart = pMark->GetMarkStart().nContent.GetIndex(); + xub_StrLen nBEnd = pMark->GetMarkEnd().nContent.GetIndex(); + + // Keep only the bookmars starting or ending in the snippet + bool bIsStartOk = ( nBStart >= nStt ) && ( nBStart <= nEnd ); + bool bIsEndOk = ( nBEnd >= nStt ) && ( nBEnd <= nEnd ); + + if ( bIsStartOk || bIsEndOk ) + rArr.push_back( pMark ); + } + } + return ( rArr.size() > 0 ); +} + +class CompareMarksEnd : public std::binary_function < const IMark *, const IMark *, bool > +{ +public: + inline bool operator() ( const IMark * pOneB, const IMark * pTwoB ) const + { + xub_StrLen nOEnd = pOneB->GetMarkEnd().nContent.GetIndex(); + xub_StrLen nTEnd = pTwoB->GetMarkEnd().nContent.GetIndex(); + + return nOEnd < nTEnd; + } +}; + +bool DocxExport::NearestBookmark( xub_StrLen& rNearest ) +{ + bool bHasBookmark = false; + + if ( m_rSortedMarksStart.size( ) > 0 ) + { + IMark* pMarkStart = m_rSortedMarksStart.front(); + rNearest = pMarkStart->GetMarkStart().nContent.GetIndex(); + bHasBookmark = true; + } + + if ( m_rSortedMarksEnd.size( ) > 0 ) + { + IMark* pMarkEnd = m_rSortedMarksEnd[0]; + if ( !bHasBookmark ) + rNearest = pMarkEnd->GetMarkEnd().nContent.GetIndex(); + else + rNearest = std::min( rNearest, pMarkEnd->GetMarkEnd().nContent.GetIndex() ); + bHasBookmark = true; + } + + return bHasBookmark; +} + +xub_StrLen DocxExport::GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos ) +{ + // Get the bookmarks for the normal run + xub_StrLen nNextPos = MSWordExportBase::GetNextPos( pAttrIter, rNode, nAktPos ); + + GetSortedBookmarks( rNode, nAktPos, nNextPos - nAktPos ); + + xub_StrLen nNextBookmark = nNextPos; + NearestBookmark( nNextPos ); + + return std::min( nNextPos, nNextBookmark ); +} + +void DocxExport::UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd ) +{ + xub_StrLen nNextPos; + + // either no bookmark, or it is not at the current position + if ( !NearestBookmark( nNextPos ) || nNextPos > nAktPos ) + { + MSWordExportBase::UpdatePosition( pAttrIter, nAktPos, nEnd ); + } +} + +void DocxExport::GetSortedBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen ) +{ + IMarkVector aMarksStart; + if ( GetBookmarks( rNode, nAktPos, nAktPos + nLen, aMarksStart ) ) + { + IMarkVector aSortedEnd; + IMarkVector aSortedStart; + for ( IMarkVector::const_iterator it = aMarksStart.begin(), end = aMarksStart.end(); + it < end; ++it ) + { + IMark* pMark = (*it); + + // Remove the positions egals to the current pos + xub_StrLen nStart = pMark->GetMarkStart().nContent.GetIndex(); + xub_StrLen nEnd = pMark->GetMarkEnd().nContent.GetIndex(); + + if ( nStart > nAktPos ) + aSortedStart.push_back( pMark ); + + if ( nEnd > nAktPos ) + aSortedEnd.push_back( pMark ); + } + + // Sort the bookmarks by end position + std::sort( aSortedEnd.begin(), aSortedEnd.end(), CompareMarksEnd() ); + + m_rSortedMarksStart.swap( aSortedStart ); + m_rSortedMarksEnd.swap( aSortedEnd ); + } + else + { + m_rSortedMarksStart.clear( ); + m_rSortedMarksEnd.clear( ); + } +} + +void DocxExport::AppendBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen ) +{ + std::vector< OUString > aStarts; + std::vector< OUString > aEnds; + + IMarkVector aMarks; + if ( GetBookmarks( rNode, nAktPos, nAktPos + nLen, aMarks ) ) + { + for ( IMarkVector::const_iterator it = aMarks.begin(), end = aMarks.end(); + it < end; ++it ) + { + IMark* pMark = (*it); + + xub_StrLen nStart = pMark->GetMarkStart().nContent.GetIndex(); + xub_StrLen nEnd = pMark->GetMarkEnd().nContent.GetIndex(); + + if ( nStart == nAktPos ) + aStarts.push_back( pMark->GetName() ); + + if ( nEnd == nAktPos ) + aEnds.push_back( pMark->GetName() ); + } + } + + m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds ); +} + +void DocxExport::AppendBookmark( const OUString& rName, bool /*bSkip*/ ) +{ + std::vector< OUString > aStarts; + std::vector< OUString > aEnds; + + aStarts.push_back( rName ); + aEnds.push_back( rName ); + + m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds ); +} + +::rtl::OString DocxExport::AddRelation( const OUString& rType, const OUString& rTarget, const OUString& rMode ) +{ + OUString sId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + rType, rTarget, rMode ); + + return ::rtl::OUStringToOString( sId, RTL_TEXTENCODING_UTF8 ); +} + +bool DocxExport::DisallowInheritingOutlineNumbering( const SwFmt& rFmt ) +{ + bool bRet( false ); + + if (SFX_ITEM_SET != rFmt.GetItemState(RES_PARATR_NUMRULE, false)) + { + if (const SwFmt *pParent = rFmt.DerivedFrom()) + { + if (((const SwTxtFmtColl*)pParent)->IsAssignedToListLevelOfOutlineStyle()) + { + ::sax_fastparser::FSHelperPtr pSerializer = m_pAttrOutput->GetSerializer( ); + // Level 9 disables the outline + pSerializer->singleElementNS( XML_w, XML_outlineLvl, + FSNS( XML_w, XML_val ), "9" , + FSEND ); + + bRet = true; + } + } + } + + return bRet; +} + +void DocxExport::WriteHeadersFooters( BYTE nHeadFootFlags, + const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt ) +{ + // headers + if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_EVEN ) + WriteHeaderFooter( rLeftFmt, true, "even" ); + + if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD ) + WriteHeaderFooter( rFmt, true, "default" ); + + if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_FIRST ) + WriteHeaderFooter( rFirstPageFmt, true, "first" ); + + // footers + if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_EVEN ) + WriteHeaderFooter( rLeftFmt, false, "even" ); + + if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD ) + WriteHeaderFooter( rFmt, false, "default" ); + + if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_FIRST ) + WriteHeaderFooter( rFirstPageFmt, false, "first" ); +} + +void DocxExport::OutputField( const SwField* pFld, ww::eField eFldType, const String& rFldCmd, BYTE nMode ) +{ + m_pAttrOutput->WriteField_Impl( pFld, eFldType, rFldCmd, nMode ); +} + +void DocxExport::WriteFormData( const ::sw::mark::IFieldmark& /*rFieldmark*/ ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxExport::WriteFormData()\n" ); +#endif +} + +void DocxExport::DoComboBox(const rtl::OUString& rName, + const rtl::OUString& rHelp, + const rtl::OUString& rToolTip, + const rtl::OUString& rSelected, + uno::Sequence<rtl::OUString>& rListItems) +{ + m_pDocumentFS->startElementNS( XML_w, XML_ffData, FSEND ); + + m_pDocumentFS->singleElementNS( XML_w, XML_name, + FSNS( XML_w, XML_val ), OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); + + m_pDocumentFS->singleElementNS( XML_w, XML_enabled, FSEND ); + + if ( rHelp.getLength( ) > 0 ) + m_pDocumentFS->singleElementNS( XML_w, XML_helpText, + FSNS( XML_w, XML_val ), OUStringToOString( rHelp, RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); + + if ( rToolTip.getLength( ) > 0 ) + m_pDocumentFS->singleElementNS( XML_w, XML_statusText, + FSNS( XML_w, XML_val ), OUStringToOString( rToolTip, RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); + + m_pDocumentFS->startElementNS( XML_w, XML_ddList, FSEND ); + + // Output the 0-based index of the selected value + sal_uInt32 nListItems = rListItems.getLength(); + sal_Int32 nId = 0; + sal_uInt32 nI = 0; + while ( ( nI < nListItems ) && ( nId == 0 ) ) + { + if ( rListItems[nI] == rSelected ) + nId = nI; + nI++; + } + + m_pDocumentFS->singleElementNS( XML_w, XML_result, + FSNS( XML_w, XML_val ), rtl::OString::valueOf( nId ).getStr( ), + FSEND ); + + // Loop over the entries + + for (sal_uInt32 i = 0; i < nListItems; i++) + { + m_pDocumentFS->singleElementNS( XML_w, XML_listEntry, + FSNS( XML_w, XML_val ), OUStringToOString( rListItems[i], RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); + } + + m_pDocumentFS->endElementNS( XML_w, XML_ddList ); + + m_pDocumentFS->endElementNS( XML_w, XML_ffData ); +} + +void DocxExport::DoFormText(const SwInputField* /*pFld*/) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxExport::ForFormText()\n" ); +#endif +} + +void DocxExport::ExportDocument_Impl() +{ + InitStyles(); + + // init sections + m_pSections = new MSWordSections( *this ); + + WriteMainText(); + + WriteFootnotesEndnotes(); + + WriteNumbering(); + + WriteFonts(); + + delete pStyles, pStyles = NULL; + delete m_pSections, m_pSections = NULL; +} + +void DocxExport::OutputPageSectionBreaks( const SwTxtNode& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxExport::OutputPageSectionBreaks( const SwTxtNode& )\n" ); +#endif +} + + +void DocxExport::AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum ) +{ + AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() ); + m_pSections->AppendSep( pPageDesc, pFmt, nLnNum ); +} + +void DocxExport::OutputEndNode( const SwEndNode& rEndNode ) +{ + MSWordExportBase::OutputEndNode( rEndNode ); + + if ( TXT_MAINTEXT == nTxtTyp && rEndNode.StartOfSectionNode()->IsSectionNode() ) + { + // this originally comes from WW8Export::WriteText(), and looks like it + // could have some code common with SectionNode()... + + const SwSection& rSect = rEndNode.StartOfSectionNode()->GetSectionNode()->GetSection(); + if ( bStartTOX && TOX_CONTENT_SECTION == rSect.GetType() ) + bStartTOX = false; + + SwNodeIndex aIdx( rEndNode, 1 ); + const SwNode& rNd = aIdx.GetNode(); + if ( rNd.IsEndNode() && rNd.StartOfSectionNode()->IsSectionNode() ) + return; + + if ( !rNd.IsSectionNode() && !bIsInTable ) // No sections in table + { + const SwSectionFmt* pParentFmt = rSect.GetFmt()->GetParent(); + if( !pParentFmt ) + pParentFmt = (SwSectionFmt*)0xFFFFFFFF; + + ULONG nRstLnNum; + if( rNd.IsCntntNode() ) + nRstLnNum = const_cast< SwCntntNode* >( rNd.GetCntntNode() )->GetSwAttrSet().GetLineNumber().GetStartValue(); + else + nRstLnNum = 0; + + AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo( ) ); + m_pSections->AppendSep( pAktPageDesc, pParentFmt, nRstLnNum ); + } + } +} + +void DocxExport::OutputTableNode( const SwTableNode& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxExport::OutputTableNode( const SwTableNode& )\n" ); +#endif +} + +void DocxExport::OutputGrfNode( const SwGrfNode& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxExport::OutputGrfNode( const SwGrfNode& )\n" ); +#endif +} + +void DocxExport::OutputOLENode( const SwOLENode& ) +{ +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "TODO DocxExport::OutputOLENode( const SwOLENode& )\n" ); +#endif +} + +ULONG DocxExport::ReplaceCr( BYTE ) +{ + // Completely unused for Docx export... only here for code sharing + // purpose with binary export + return 0; +} + +void DocxExport::PrepareNewPageDesc( const SfxItemSet* pSet, + const SwNode& rNd, const SwFmtPageDesc* pNewPgDescFmt, + const SwPageDesc* pNewPgDesc ) +{ + // tell the attribute output that we are ready to write the section + // break [has to be output inside paragraph properties] + AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() ); + + const SwSectionFmt* pFmt = GetSectionFormat( rNd ); + const ULONG nLnNm = GetSectionLineNo( pSet, rNd ); + + ASSERT( pNewPgDescFmt || pNewPgDesc, "Neither page desc format nor page desc provided." ); + + if ( pNewPgDescFmt ) + { + m_pSections->AppendSep( *pNewPgDescFmt, rNd, pFmt, nLnNm ); + } + else if ( pNewPgDesc ) + { + m_pSections->AppendSep( pNewPgDesc, rNd, pFmt, nLnNm ); + } + +} + +void DocxExport::InitStyles() +{ + pStyles = new MSWordStyles( *this ); + + // setup word/styles.xml and the relations + content type + m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" ), + S( "styles.xml" ) ); + + ::sax_fastparser::FSHelperPtr pStylesFS = + m_pFilter->openOutputStreamWithSerializer( S( "word/styles.xml" ), + S( "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml" ) ); + + // switch the serializer to redirect the output to word/styles.xml + m_pAttrOutput->SetSerializer( pStylesFS ); + + // do the work + pStyles->OutputStylesTable(); + + // switch the serializer back + m_pAttrOutput->SetSerializer( m_pDocumentFS ); +} + +void DocxExport::WriteFootnotesEndnotes() +{ + if ( m_pAttrOutput->HasFootnotes() ) + { + // setup word/styles.xml and the relations + content type + m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes" ), + S( "footnotes.xml" ) ); + + ::sax_fastparser::FSHelperPtr pFootnotesFS = + m_pFilter->openOutputStreamWithSerializer( S( "word/footnotes.xml" ), + S( "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml" ) ); + + // switch the serializer to redirect the output to word/footnotes.xml + m_pAttrOutput->SetSerializer( pFootnotesFS ); + + // do the work + m_pAttrOutput->FootnotesEndnotes( true ); + + // switch the serializer back + m_pAttrOutput->SetSerializer( m_pDocumentFS ); + } + + if ( m_pAttrOutput->HasEndnotes() ) + { + // setup word/styles.xml and the relations + content type + m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes" ), + S( "endnotes.xml" ) ); + + ::sax_fastparser::FSHelperPtr pEndnotesFS = + m_pFilter->openOutputStreamWithSerializer( S( "word/endnotes.xml" ), + S( "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml" ) ); + + // switch the serializer to redirect the output to word/endnotes.xml + m_pAttrOutput->SetSerializer( pEndnotesFS ); + + // do the work + m_pAttrOutput->FootnotesEndnotes( false ); + + // switch the serializer back + m_pAttrOutput->SetSerializer( m_pDocumentFS ); + } +} + +void DocxExport::WriteNumbering() +{ + if ( !pUsedNumTbl ) + return; // no numbering is used + + m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" ), + S( "numbering.xml" ) ); + + ::sax_fastparser::FSHelperPtr pNumberingFS = m_pFilter->openOutputStreamWithSerializer( S( "word/numbering.xml" ), + S( "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml" ) ); + + // switch the serializer to redirect the output to word/nubering.xml + m_pAttrOutput->SetSerializer( pNumberingFS ); + + pNumberingFS->startElementNS( XML_w, XML_numbering, + FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + FSEND ); + + AbstractNumberingDefinitions(); + + NumberingDefinitions(); + + pNumberingFS->endElementNS( XML_w, XML_numbering ); + + // switch the serializer back + m_pAttrOutput->SetSerializer( m_pDocumentFS ); +} + +void DocxExport::WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char* pType ) +{ + // setup the xml stream + OUString aRelId; + ::sax_fastparser::FSHelperPtr pFS; + if ( bHeader ) + { + OUString aName( OUStringBuffer().appendAscii( "header" ).append( ++m_nHeaders ).appendAscii( ".xml" ).makeStringAndClear() ); + + aRelId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header" ), + aName ); + + pFS = m_pFilter->openOutputStreamWithSerializer( OUStringBuffer().appendAscii( "word/" ).append( aName ).makeStringAndClear(), + S( "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml" ) ); + + pFS->startElementNS( XML_w, XML_hdr, + FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + FSEND ); + } + else + { + OUString aName( OUStringBuffer().appendAscii( "footer" ).append( ++m_nFooters ).appendAscii( ".xml" ).makeStringAndClear() ); + + aRelId = m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer" ), + aName ); + + pFS = m_pFilter->openOutputStreamWithSerializer( OUStringBuffer().appendAscii( "word/" ).append( aName ).makeStringAndClear(), + S( "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml" ) ); + + pFS->startElementNS( XML_w, XML_ftr, + FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + FSEND ); + } + + // switch the serializer to redirect the output to word/styles.xml + m_pAttrOutput->SetSerializer( pFS ); + + // do the work + WriteHeaderFooterText( rFmt, bHeader ); + + // switch the serializer back + m_pAttrOutput->SetSerializer( m_pDocumentFS ); + + // close the tag + sal_Int32 nReference; + if ( bHeader ) + { + pFS->endElementNS( XML_w, XML_hdr ); + nReference = XML_headerReference; + } + else + { + pFS->endElementNS( XML_w, XML_ftr ); + nReference = XML_footerReference; + } + + // and write the reference + m_pDocumentFS->singleElementNS( XML_w, nReference, + FSNS( XML_w, XML_type ), pType, + FSNS( XML_r, XML_id ), rtl::OUStringToOString( aRelId, RTL_TEXTENCODING_UTF8 ).getStr(), + FSEND ); +} + +void DocxExport::WriteFonts() +{ + m_pFilter->addRelation( m_pDocumentFS->getOutputStream(), + S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" ), + S( "fontTable.xml" ) ); + + ::sax_fastparser::FSHelperPtr pFS = m_pFilter->openOutputStreamWithSerializer( + S( "word/fontTable.xml" ), + S( "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml" ) ); + + pFS->startElementNS( XML_w, XML_fonts, + FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + FSEND ); + + // switch the serializer to redirect the output to word/styles.xml + m_pAttrOutput->SetSerializer( pFS ); + + // do the work + maFontHelper.WriteFontTable( *m_pAttrOutput ); + + // switch the serializer back + m_pAttrOutput->SetSerializer( m_pDocumentFS ); + + pFS->endElementNS( XML_w, XML_fonts ); +} + + +void DocxExport::WriteProperties( ) +{ + // Write the core properties + SwDocShell* pDocShell( pDoc->GetDocShell( ) ); + uno::Reference<document::XDocumentProperties> xDocProps; + if ( pDocShell ) + { + uno::Reference<document::XDocumentPropertiesSupplier> xDPS( + pDocShell->GetModel( ), uno::UNO_QUERY ); + xDocProps = xDPS->getDocumentProperties(); + } + + m_pFilter->exportDocumentProperties( xDocProps ); +} + +VMLExport& DocxExport::VMLExporter() +{ + return *m_pVMLExport; +} + +void DocxExport::WriteMainText() +{ + // setup the namespaces + m_pDocumentFS->startElementNS( XML_w, XML_document, + FSNS( XML_xmlns, XML_o ), "urn:schemas-microsoft-com:office:office", + FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + FSNS( XML_xmlns, XML_v ), "urn:schemas-microsoft-com:vml", + FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + FSNS( XML_xmlns, XML_w10 ), "urn:schemas-microsoft-com:office:word", + FSNS( XML_xmlns, XML_wp ), "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", + FSEND ); + + // body + m_pDocumentFS->startElementNS( XML_w, XML_body, FSEND ); + + pCurPam->GetPoint()->nNode = pDoc->GetNodes().GetEndOfContent().StartOfSectionNode()->GetIndex(); + + // the text + WriteText(); + + // the last section info + const WW8_SepInfo *pSectionInfo = m_pSections? m_pSections->CurrentSectionInfo(): NULL; + if ( pSectionInfo ) + SectionProperties( *pSectionInfo ); + + // finish body and document + m_pDocumentFS->endElementNS( XML_w, XML_body ); + m_pDocumentFS->endElementNS( XML_w, XML_document ); +} + +DocxExport::DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam ) + : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ), + m_pFilter( pFilter ), + m_pAttrOutput( NULL ), + m_pSections( NULL ), + m_nHeaders( 0 ), + m_nFooters( 0 ), + m_pVMLExport( NULL ) +{ + // Write the document properies + WriteProperties( ); + + // relations for the document + m_pFilter->addRelation( S( "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" ), + S( "word/document.xml" ) ); + + // the actual document + m_pDocumentFS = m_pFilter->openOutputStreamWithSerializer( S( "word/document.xml" ), + S( "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml" ) ); + + // the DrawingML access + m_pDrawingML = new oox::drawingml::DrawingML( m_pDocumentFS, m_pFilter, oox::drawingml::DrawingML::DOCUMENT_DOCX ); + + // the attribute output for the document + m_pAttrOutput = new DocxAttributeOutput( *this, m_pDocumentFS, m_pDrawingML ); + + // the related VMLExport + m_pVMLExport = new VMLExport( m_pDocumentFS ); +} + +DocxExport::~DocxExport() +{ + delete m_pVMLExport, m_pVMLExport = NULL; + delete m_pAttrOutput, m_pAttrOutput = NULL; + delete m_pDrawingML, m_pDrawingML = NULL; +} + +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx new file mode 100644 index 0000000000..5b4031992e --- /dev/null +++ b/sw/source/filter/ww8/docxexport.hxx @@ -0,0 +1,228 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DOCXEXPORT_HXX_ +#define _DOCXEXPORT_HXX_ + +#include "docxattributeoutput.hxx" +#include "wrtww8.hxx" + +#include <sax/fshelper.hxx> +#include <rtl/ustring.hxx> + +#include <cstdio> +#include <vector> + +class DocxExportFilter; +class SwNode; +class SwEndNode; +class SwTableNode; +class SwTxtNode; +class SwGrfNode; +class SwOLENode; +class SwSectionNode; +class SwNumRuleTbl; + +namespace oox { + namespace drawingml { class DrawingML; } + namespace vml { class VMLExport; } +} + +/// The class that does all the actual DOCX export-related work. +class DocxExport : public MSWordExportBase +{ + /// Pointer to the filter that owns us. + DocxExportFilter *m_pFilter; + + /// Fast serializer for the document output. + ::sax_fastparser::FSHelperPtr m_pDocumentFS; + + /// Access to the DrawingML writer. + oox::drawingml::DrawingML *m_pDrawingML; + + /// Attribute output for document. + DocxAttributeOutput *m_pAttrOutput; + + /// Sections/headers/footers + MSWordSections *m_pSections; + + /// Header counter. + sal_Int32 m_nHeaders; + + /// Footer counter. + sal_Int32 m_nFooters; + + /// Used to split the runs according to the bookmarks start and ends + typedef std::vector< ::sw::mark::IMark* > IMarkVector; + IMarkVector m_rSortedMarksStart; + IMarkVector m_rSortedMarksEnd; + + /// Exporter of the VML shapes. + oox::vml::VMLExport *m_pVMLExport; + +public: + /// Access to the attribute output class. + virtual AttributeOutputBase& AttrOutput() const; + + /// Access to the sections/headers/footres. + virtual MSWordSections& Sections() const; + + /// Hack, unfortunately necessary at some places for now. + /// FIXME remove it when possible. + virtual bool HackIsWW8OrHigher() const { return true; } + + /// Guess the script (asian/western). + virtual bool CollapseScriptsforWordOk( USHORT nScript, USHORT nWhich ); + + virtual void AppendBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen ); + + virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false ); + + /// Returns the relationd id + rtl::OString AddRelation( const rtl::OUString& rType, const rtl::OUString& rTarget, const rtl::OUString& rMode ); + + virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/ ) { /* FIXME no-op for docx, most probably should not even be in MSWordExportBase */ } + virtual void WriteChar( sal_Unicode ) { /* FIXME */ fprintf( stderr, "HACK! WriteChar() has nothing to do for docx.\n" ); } + + /// Return value indicates if an inherited outline numbering is suppressed. + virtual bool DisallowInheritingOutlineNumbering( const SwFmt &rFmt ); + + /// Output the actual headers and footers. + virtual void WriteHeadersFooters( BYTE nHeadFootFlags, + const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt ); + + /// Write the field + virtual void OutputField( const SwField* pFld, ww::eField eFldType, + const String& rFldCmd, BYTE nMode = nsFieldFlags::WRITEFIELD_ALL ); + + /// Write the data of the form field + virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ); + + virtual void DoComboBox(const rtl::OUString &rName, + const rtl::OUString &rHelp, + const rtl::OUString &ToolTip, + const rtl::OUString &rSelected, + com::sun::star::uno::Sequence<rtl::OUString> &rListItems); + + virtual void DoFormText(const SwInputField * pFld); + + virtual ULONG ReplaceCr( BYTE nChar ); + +protected: + /// Format-dependant part of the actual export. + virtual void ExportDocument_Impl(); + + /// Output page/section breaks + virtual void OutputPageSectionBreaks( const SwTxtNode& ); + + /// Output SwEndNode + virtual void OutputEndNode( const SwEndNode& ); + + /// Output SwTableNode + virtual void OutputTableNode( const SwTableNode& ); + + /// Output SwGrfNode + virtual void OutputGrfNode( const SwGrfNode& ); + + /// Output SwOLENode + virtual void OutputOLENode( const SwOLENode& ); + + + virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum ); + + virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ) {} + + /// Get ready for a new section. + virtual void PrepareNewPageDesc( const SfxItemSet* pSet, + const SwNode& rNd, + const SwFmtPageDesc* pNewPgDescFmt = 0, + const SwPageDesc* pNewPgDesc = 0 ); + + /// Get the next position in the text node to output + virtual xub_StrLen GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos ); + + /// Update the information for GetNextPos(). + virtual void UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd ); + +private: + /// Find the nearest bookmark from the current position. + /// + /// Returns false when there is no bookmark. + bool NearestBookmark( xub_StrLen& rNearest ); + + void GetSortedBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, + xub_StrLen nLen ); + + bool GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt, xub_StrLen nEnd, + IMarkVector& rArr ); + + /// Setup pStyles and write styles.xml + void InitStyles(); + + /// Write footnotes.xml and endnotes.xml. + void WriteFootnotesEndnotes(); + + /// Write the numbering table. + virtual void WriteNumbering(); + + /// Write reference to a header/foorter + the actual xml containing the text. + void WriteHeaderFooter( const SwFmt& rFmt, bool bHeader, const char* pType ); + + /// Write word/fontTable.xml. + void WriteFonts(); + + /// Write docProps/core.xml + void WriteProperties(); + +public: + /// FIXME this is temporary, remotely reminding the method of the same + /// name in WW8Export. + void WriteMainText(); + + /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class. + DocxExport( DocxExportFilter *pFilter, SwDoc *pDocument, + SwPaM *pCurrentPam, SwPaM *pOriginalPam ); + + /// Destructor. + virtual ~DocxExport(); + + /// Reference to the VMLExport instance for the main document. + oox::vml::VMLExport& VMLExporter(); + +private: + /// No copying. + DocxExport( const DocxExport& ); + + /// No copying. + DocxExport& operator=( const DocxExport& ); +}; + +#endif // _DOCXEXPORT_HXX_ +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxexportfilter.cxx b/sw/source/filter/ww8/docxexportfilter.cxx new file mode 100644 index 0000000000..990b6e7306 --- /dev/null +++ b/sw/source/filter/ww8/docxexportfilter.cxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "docxexportfilter.hxx" +#include "docxexport.hxx" + +#include <docsh.hxx> +#include <pam.hxx> +#include <unotxdoc.hxx> + +#include <cppuhelper/factory.hxx> + +using namespace ::comphelper; +using namespace ::com::sun::star; +using ::rtl::OUString; + +#define S( x ) OUString( RTL_CONSTASCII_USTRINGPARAM( x ) ) + +DocxExportFilter::DocxExportFilter( const uno::Reference< lang::XMultiServiceFactory >& rMSF ) + : oox::core::XmlFilterBase( rMSF ) +{ +} + +bool DocxExportFilter::exportDocument() +{ + fprintf( stderr, "DocxExportFilter::exportDocument()\n" ); // DEBUG remove me + + // get SwDoc* + uno::Reference< uno::XInterface > xIfc( getModel(), uno::UNO_QUERY ); + SwXTextDocument *pTxtDoc = dynamic_cast< SwXTextDocument * >( xIfc.get() ); + if ( !pTxtDoc ) + return false; + + SwDoc *pDoc = pTxtDoc->GetDocShell()->GetDoc(); + if ( !pDoc ) + return false; + + // get SwPaM* + // FIXME so far we get SwPaM for the entire document; probably we should + // be able to output just the selection as well - though no idea how to + // get the correct SwPaM* then... + SwPaM aPam( pDoc->GetNodes().GetEndOfContent() ); + aPam.SetMark(); + aPam.Move( fnMoveBackward, fnGoDoc ); + + SwPaM *pCurPam = new SwPaM( *aPam.End(), *aPam.Start() ); + + // export the document + // (in a separate block so that it's destructed before the commit) + { + DocxExport aExport( this, pDoc, pCurPam, &aPam ); + aExport.ExportDocument( true ); // FIXME support exporting selection only + } + + commit(); + + // delete the pCurPam + if ( pCurPam ) + { + while ( pCurPam->GetNext() != pCurPam ) + delete pCurPam->GetNext(); + delete pCurPam; + } + + return true; +} + +////////////////////////////////////////////////////////////////////////// +// UNO stuff so that the filter is registered +////////////////////////////////////////////////////////////////////////// + +#define IMPL_NAME "com.sun.star.comp.Writer.DocxExport" + +OUString DocxExport_getImplementationName() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPL_NAME ) ); +} + +OUString DocxExportFilter::implGetImplementationName() const +{ + return DocxExport_getImplementationName(); +} + +uno::Sequence< OUString > SAL_CALL DocxExport_getSupportedServiceNames() throw() +{ + const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.ExportFilter" ) ); + const uno::Sequence< OUString > aSeq( &aServiceName, 1 ); + return aSeq; +} + +uno::Reference< uno::XInterface > SAL_CALL DocxExport_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception ) +{ + return (cppu::OWeakObject*) new DocxExportFilter( rSMgr ); +} + +#ifdef __cplusplus +extern "C" +{ +#endif + +SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( void* /* pServiceManager */, void* pRegistryKey ) +{ + sal_Bool bRet = sal_False; + + if( pRegistryKey ) + { + try + { + uno::Reference< registry::XRegistryKey > xNewKey1( + static_cast< registry::XRegistryKey* >( pRegistryKey )->createKey( + OUString::createFromAscii( IMPL_NAME "/UNO/SERVICES/" ) ) ); + xNewKey1->createKey( DocxExport_getSupportedServiceNames().getConstArray()[0] ); + + bRet = sal_True; + } + catch( registry::InvalidRegistryException& ) + { + OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + } + } + + return bRet; +} + +// ------------------------ +// - component_getFactory - +// ------------------------ + +SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ ) +{ + uno::Reference< lang::XSingleServiceFactory > xFactory; + void* pRet = 0; + + if ( rtl_str_compare( pImplName, IMPL_NAME ) == 0 ) + { + const OUString aServiceName( OUString::createFromAscii( IMPL_NAME ) ); + + xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory( + reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ), + DocxExport_getImplementationName(), + DocxExport_createInstance, + DocxExport_getSupportedServiceNames() ) ); + } + + if ( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + + return pRet; +} + +#ifdef __cplusplus +} +#endif + +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxexportfilter.hxx b/sw/source/filter/ww8/docxexportfilter.hxx new file mode 100644 index 0000000000..e1e6fde181 --- /dev/null +++ b/sw/source/filter/ww8/docxexportfilter.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DOCXEXPORTFILTER_HXX_ +#define _DOCXEXPORTFILTER_HXX_ + +#include <oox/core/xmlfilterbase.hxx> +#include <oox/drawingml/chart/chartconverter.hxx> +#include <oox/vml/drawing.hxx> + +#include <com/sun/star/beans/PropertyValue.hpp> + +/// The physical access to the DOCX document (for writing). +class DocxExportFilter : public oox::core::XmlFilterBase +{ +public: + DocxExportFilter( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rMSF ); + + // FIXME these should not even exist for the export-only filter! + // For now, let's just do empty implementations of those. + virtual bool importDocument() { return false; } + virtual const ::oox::drawingml::Theme* getCurrentTheme() const { return NULL; } + virtual sal_Int32 getSchemeClr( sal_Int32 ) const { return 0; } + virtual const ::oox::vml::DrawingPtr getDrawings() { return ::oox::vml::DrawingPtr(); } + virtual ::oox::drawingml::chart::ChartConverter& getChartConverter() { static ::oox::drawingml::chart::ChartConverter aConverter; return aConverter; } + virtual const ::oox::drawingml::table::TableStyleListPtr getTableStyles() { return ::oox::drawingml::table::TableStyleListPtr(); } + + // Actual export of the DOCX document + virtual bool exportDocument(); + +private: + + /// Implementatio of the filter abstract method. + virtual ::rtl::OUString implGetImplementationName() const; +}; + +#endif // _DOCXEXPORTFILTER_HXX_ +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxfootnotes.hxx b/sw/source/filter/ww8/docxfootnotes.hxx new file mode 100644 index 0000000000..b594f88f58 --- /dev/null +++ b/sw/source/filter/ww8/docxfootnotes.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _DOCXFOOTNOTES_HXX_ +#define _DOCXFOOTNOTES_HXX_ + +#include <fmtftn.hxx> + +#include <oox/core/tokens.hxx> +#include <rtl/string.hxx> +#include <rtl/ustring.hxx> +#include <sax/fshelper.hxx> + +#include <vector> + +namespace docx { + +typedef ::std::vector< const SwFmtFtn* > FootnotesVector; + +/** Remember footnotes/endnotes so that we can dump them in one go. + + Also rememeber the last added footnote Id to be able to write it in the + DocxAttributeOutput::EndRunProperties() method. +*/ +class FootnotesList { + /// The current footnote, that was not written yet. + sal_Int32 m_nCurrent; + + /// List of the footnotes. + FootnotesVector m_aFootnotes; + +public: + FootnotesList() : m_nCurrent( -1 ) {} + + void add( const SwFmtFtn& rFootnote ) + { + m_aFootnotes.push_back( &rFootnote ); + m_nCurrent = m_aFootnotes.size() - 1; + } + + /// Return the current footnote/endnote and clear the 'current' state. + const SwFmtFtn* getCurrent( sal_Int32& rId ) + { + // skip ids 0 and 1 - they are reserved for separator and + // continuationSeparator + rId = m_nCurrent + 2; + + // anything to write at all? + if ( m_nCurrent < 0 ) + { + rId = -1; + return NULL; + } + + const SwFmtFtn *pFootnote = m_aFootnotes[m_nCurrent]; + m_nCurrent = -1; + + return pFootnote; + } + + /// Return all the footnotes/endnotes. + const FootnotesVector& getVector() const + { + return m_aFootnotes; + } + + /// Do we have any footnotes/endnotes at all? + bool isEmpty() const + { + return m_aFootnotes.empty(); + } +}; + +} // namespace docx + +#endif // _DOCXFOOTNOTES_HXX_ diff --git a/sw/source/filter/ww8/dump/ww8scan.hxx b/sw/source/filter/ww8/dump/ww8scan.hxx index d00a0735e8..abec5069e7 100644 --- a/sw/source/filter/ww8/dump/ww8scan.hxx +++ b/sw/source/filter/ww8/dump/ww8scan.hxx @@ -811,7 +811,8 @@ public: - +/** FIB - File Information Block +*/ class WW8Fib { public: @@ -1267,7 +1268,9 @@ public: }; -class WW8Dop // Document Properties +/** Document Properties +*/ +class WW8Dop { public: /* diff --git a/sw/source/filter/ww8/escher.hxx b/sw/source/filter/ww8/escher.hxx index d8e0319de8..6cd2f9b280 100644 --- a/sw/source/filter/ww8/escher.hxx +++ b/sw/source/filter/ww8/escher.hxx @@ -96,7 +96,7 @@ class SwBasicEscherEx : public EscherEx private: void Init(); protected: - SwWW8Writer& rWrt; + WW8Export& rWrt; SvStream* pEscherStrm; SvStream* pPictStrm; long mnEmuMul, mnEmuDiv; @@ -121,7 +121,7 @@ protected: SdrLayerID GetInvisibleHellId() const; public: - SwBasicEscherEx(SvStream* pStrm, SwWW8Writer& rWrt, UINT32 nDrawings = 1); + SwBasicEscherEx(SvStream* pStrm, WW8Export& rWrt, UINT32 nDrawings = 1); INT32 WriteGrfFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId); INT32 WriteOLEFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId); void WriteEmptyFlyFrame(const SwFrmFmt& rFmt, UINT32 nShapeId); @@ -161,7 +161,7 @@ private: virtual void SetPicId(const SdrObject &rSdrObj, UINT32 nShapeId, EscherPropertyContainer &rPropOpt); public: - SwEscherEx( SvStream* pStrm, SwWW8Writer& rWW8Wrt ); + SwEscherEx( SvStream* pStrm, WW8Export& rWW8Wrt ); virtual ~SwEscherEx(); void FinishEscher(); virtual void WritePictures(); diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index f42115c5c5..861587ff6e 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -164,20 +164,6 @@ namespace return aRet; } - /* - Utility to extract flyfmts from a document, potentially from a - selection, and with bAll off ignores the drawing objects - */ - sw::Frames GetFrames(const SwDoc &rDoc, SwPaM *pPaM, bool /*bAll*/) - { - SwPosFlyFrms aFlys; - rDoc.GetAllFlyFmts(aFlys, pPaM, true); - sw::Frames aRet(SwPosFlyFrmsToFrames(aFlys)); - for (USHORT i = aFlys.Count(); i > 0;) - delete aFlys[--i]; - return aRet; - } - //Utility to test if a frame is anchored at a given node index class anchoredto: public std::unary_function<const sw::Frame&, bool> { @@ -570,14 +556,18 @@ namespace sw } // <-- - Frames GetAllFrames(const SwDoc &rDoc, SwPaM *pPaM) - { - return GetFrames(rDoc, pPaM, true); - } - - Frames GetNonDrawingFrames(const SwDoc &rDoc, SwPaM *pPaM) - { - return GetFrames(rDoc, pPaM, false); + /* + Utility to extract flyfmts from a document, potentially from a + selection. + */ + Frames GetFrames(const SwDoc &rDoc, SwPaM *pPaM /*, bool bAll*/) + { + SwPosFlyFrms aFlys; + rDoc.GetAllFlyFmts(aFlys, pPaM, true); + sw::Frames aRet(SwPosFlyFrmsToFrames(aFlys)); + for (USHORT i = aFlys.Count(); i > 0;) + delete aFlys[--i]; + return aRet; } Frames GetFramesBetweenNodes(const Frames &rFrames, diff --git a/sw/source/filter/ww8/writerhelper.hxx b/sw/source/filter/ww8/writerhelper.hxx index fa8a17fd53..18e73b1e2d 100644 --- a/sw/source/filter/ww8/writerhelper.hxx +++ b/sw/source/filter/ww8/writerhelper.hxx @@ -39,13 +39,14 @@ #include <com/sun/star/embed/XEmbeddedObject.hpp> #include <sfx2/objsh.hxx> -# include "types.hxx" -# include <svtools/itempool.hxx> //SfxItemPool -# include <svtools/itemset.hxx> //SfxItemSet -# include <format.hxx> //SwFmt -# include <node.hxx> //SwCntntNode -# include <pam.hxx> //SwPaM -# include <tools/poly.hxx> //Polygon, PolyPolygon +#include "types.hxx" +#include <svtools/itempool.hxx> //SfxItemPool +#include <svtools/itemset.hxx> //SfxItemSet +#include <format.hxx> //SwFmt +#include <node.hxx> //SwCntntNode +#include <pam.hxx> //SwPaM +#include <tools/poly.hxx> //Polygon, PolyPolygon +#include <doc.hxx> //SwDoc //Uncomment to dump debugging streams of graphics #if OSL_DEBUG_LEVEL > 1 @@ -633,8 +634,6 @@ namespace sw need them to have something to be anchored to. So this method returns all the floating elements in a document as a STL container of sw::Frames which are guaranteed to have an appropiate anchor. - This will include drawing objects, use GetNonDrawingFrames if - you are not interested in the drawing objects. @param rDoc The SwDoc document to get the styles from @@ -648,31 +647,7 @@ namespace sw @author <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> */ - Frames GetAllFrames(const SwDoc &rDoc, SwPaM *pPaM = 0); - - /** Get the Floating elements in a SwDoc - - Writer's FrmFmts may or may not be anchored to some text content, - e.g. Page Anchored elements will not be. For the winword export we - need them to have something to be anchored to. So this method - returns all the floating elements in a document as a STL container - of sw::Frames which are guaranteed to have an appropiate anchor. - This will not include drawing objects, use GetAllFrames if you - are interested in the drawing objects. - - @param rDoc - The SwDoc document to get the styles from - - @param pPaM - The SwPam to describe the selection in the document to get the - elements from. 0 means the entire document. - - @return A Frames containing the selections Floating elements - - @author - <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> - */ - Frames GetNonDrawingFrames(const SwDoc &rDoc, SwPaM *pPaM = 0); + Frames GetFrames(const SwDoc &rDoc, SwPaM *pPaM = 0); /** Get the Frames anchored to a given node diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx index e91e2aeb18..8c77c6a3c7 100644 --- a/sw/source/filter/ww8/writerwordglue.cxx +++ b/sw/source/filter/ww8/writerwordglue.cxx @@ -548,8 +548,8 @@ namespace sw using namespace ::com::sun::star::i18n; sal_uInt16 nScript = i18n::ScriptType::LATIN; - if (rTxt.Len() && pBreakIt && pBreakIt->xBreak.is()) - nScript = pBreakIt->xBreak->getScriptType(rTxt, 0); + if (rTxt.Len() && pBreakIt && pBreakIt->GetBreakIter().is()) + nScript = pBreakIt->GetBreakIter()->getScriptType(rTxt, 0); rtl_TextEncoding eChrSet = ItemGet<SvxFontItem>(rTxtNd, GetWhichOfScript(RES_CHRATR_FONT, nScript)).GetCharSet(); @@ -635,20 +635,20 @@ namespace sw using sw::types::writer_cast; - if (pBreakIt && pBreakIt->xBreak.is()) + if (pBreakIt && pBreakIt->GetBreakIter().is()) { xub_StrLen nLen = rTxt.Len(); xub_StrLen nPos = 0; while (nPos < nLen) { - sal_Int32 nEnd2 = pBreakIt->xBreak->endOfScript(rTxt, nPos, + sal_Int32 nEnd2 = pBreakIt->GetBreakIter()->endOfScript(rTxt, nPos, nScript); if (nEnd2 < 0) break; // nPos = writer_cast<xub_StrLen>(nEnd2); nPos = static_cast< xub_StrLen >(nEnd2); aScripts.push_back(ScriptEntry(nPos, nScript)); - nScript = pBreakIt->xBreak->getScriptType(rTxt, nPos); + nScript = pBreakIt->GetBreakIter()->getScriptType(rTxt, nPos); } } diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 3efbc0d783..a23f68f813 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -99,9 +99,8 @@ #include <pagedesc.hxx> #include <ww8par.hxx> #include <breakit.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif +#include "ww8attributeoutput.hxx" #include "writerhelper.hxx" #include "writerwordglue.hxx" #include "wrtww8.hxx" @@ -117,7 +116,7 @@ using namespace sw::types; using namespace nsFieldFlags; //#110185# get a part fix for this type of element -bool SwWW8Writer::MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt) +bool WW8Export::MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt) { ASSERT(bWrtWW8, "Not allowed"); if (!bWrtWW8) @@ -149,7 +148,7 @@ bool SwWW8Writer::MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt) } -void SwWW8Writer::DoComboBox(uno::Reference<beans::XPropertySet> xPropSet) +void WW8Export::DoComboBox(uno::Reference<beans::XPropertySet> xPropSet) { rtl::OUString sSelected; uno::Sequence<rtl::OUString> aListItems; @@ -191,7 +190,7 @@ void SwWW8Writer::DoComboBox(uno::Reference<beans::XPropertySet> xPropSet) DoComboBox(sName, sHelp, sToolTip, sSelected, aListItems); } -void SwWW8Writer::DoComboBox(const rtl::OUString &rName, +void WW8Export::DoComboBox(const rtl::OUString &rName, const rtl::OUString &rHelp, const rtl::OUString &rToolTip, const rtl::OUString &rSelected, @@ -200,7 +199,7 @@ void SwWW8Writer::DoComboBox(const rtl::OUString &rName, ASSERT(bWrtWW8, "Not allowed"); if (!bWrtWW8) return; - OutField(0, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN), + OutputField(0, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN), WRITEFIELD_START | WRITEFIELD_CMD_START); // write the refence to the "picture" structure ULONG nDataStt = pDataStrm->Tell(); @@ -220,7 +219,7 @@ void SwWW8Writer::DoComboBox(const rtl::OUString &rName, pChpPlc->AppendFkpEntry(Strm().Tell(), sizeof(aArr1), aArr1); - OutField(0, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN), + OutputField(0, ww::eFORMDROPDOWN, FieldString(ww::eFORMDROPDOWN), WRITEFIELD_CLOSE); ::sw::WW8FFData aFFData; @@ -240,15 +239,14 @@ void SwWW8Writer::DoComboBox(const rtl::OUString &rName, } aFFData.Write(pDataStrm); - } -void SwWW8Writer::DoCheckBox(uno::Reference<beans::XPropertySet> xPropSet) +void WW8Export::DoCheckBox(uno::Reference<beans::XPropertySet> xPropSet) { uno::Reference<beans::XPropertySetInfo> xPropSetInfo = xPropSet->getPropertySetInfo(); - OutField(0, ww::eFORMCHECKBOX, FieldString(ww::eFORMCHECKBOX), + OutputField(0, ww::eFORMCHECKBOX, FieldString(ww::eFORMCHECKBOX), WRITEFIELD_START | WRITEFIELD_CMD_START); // write the refence to the "picture" structure ULONG nDataStt = pDataStrm->Tell(); @@ -318,12 +316,12 @@ void SwWW8Writer::DoCheckBox(uno::Reference<beans::XPropertySet> xPropSet) aFFData.Write(pDataStrm); - OutField(0, ww::eFORMCHECKBOX, aEmptyStr, WRITEFIELD_CLOSE); + OutputField(0, ww::eFORMCHECKBOX, aEmptyStr, WRITEFIELD_CLOSE); } -void SwWW8Writer::DoFormText(const SwInputField * pFld) +void WW8Export::DoFormText(const SwInputField * pFld) { - OutField(0, ww::eFORMTEXT, FieldString(ww::eFORMTEXT), + OutputField(0, ww::eFORMTEXT, FieldString(ww::eFORMTEXT), WRITEFIELD_START | WRITEFIELD_CMD_START); // write the refence to the "picture" structure ULONG nDataStt = pDataStrm->Tell(); @@ -351,7 +349,7 @@ void SwWW8Writer::DoFormText(const SwInputField * pFld) aFFData.setStatus(pFld->GetToolTip()); aFFData.Write(pDataStrm); - OutField(0, ww::eFORMTEXT, aEmptyStr, WRITEFIELD_CMD_END); + OutputField(0, ww::eFORMTEXT, aEmptyStr, WRITEFIELD_CMD_END); SwWW8Writer::WriteString16(Strm(), pFld->Expand(), false); @@ -366,7 +364,7 @@ void SwWW8Writer::DoFormText(const SwInputField * pFld) pChpPlc->AppendFkpEntry(Strm().Tell(), sizeof( aArr2 ), aArr2 ); - OutField(0, ww::eFORMTEXT, aEmptyStr, WRITEFIELD_CLOSE); + OutputField(0, ww::eFORMTEXT, aEmptyStr, WRITEFIELD_CLOSE); } PlcDrawObj::~PlcDrawObj() @@ -429,7 +427,7 @@ bool RTLDrawingsHack(long &rLeft, long /*nWidth*/, return bRet; } -bool SwWW8Writer::MiserableRTLFrmFmtHack(SwTwips &rLeft, SwTwips &rRight, +bool WW8Export::MiserableRTLFrmFmtHack(SwTwips &rLeft, SwTwips &rRight, const sw::Frame &rFrmFmt) { //Require nasty bidi swap @@ -465,7 +463,7 @@ bool SwWW8Writer::MiserableRTLFrmFmtHack(SwTwips &rLeft, SwTwips &rRight, return bRet; } -void PlcDrawObj::WritePlc(SwWW8Writer& rWrt) const +void PlcDrawObj::WritePlc( WW8Export& rWrt ) const { if (8 > rWrt.pFib->nVersion) // Cannot export drawobject in vers 7- return; @@ -690,8 +688,8 @@ DrawObj& DrawObj::operator=(const DrawObj& rOther) return *this; } -bool PlcDrawObj::Append(SwWW8Writer& rWrt, WW8_CP nCp, const sw::Frame& rFmt, - const Point& rNdTopLeft) +bool PlcDrawObj::Append( WW8Export& rWrt, WW8_CP nCp, const sw::Frame& rFmt, + const Point& rNdTopLeft ) { bool bRet = false; const SwFrmFmt &rFormat = rFmt.GetFrmFmt(); @@ -722,7 +720,7 @@ void DrawObj::SetShapeDetails(UINT32 nId, INT32 nThick) mnThick = nThick; } -bool WW8_WrPlcTxtBoxes::WriteTxt(SwWW8Writer& rWrt) +bool WW8_WrPlcTxtBoxes::WriteTxt( WW8Export& rWrt ) { bool bRet = false; rWrt.bInWriteEscher = true; @@ -756,7 +754,7 @@ const SvULongs* WW8_WrPlcTxtBoxes::GetShapeIdArr() const /* */ -UINT32 SwWW8Writer::GetSdrOrdNum( const SwFrmFmt& rFmt ) const +UINT32 WW8Export::GetSdrOrdNum( const SwFrmFmt& rFmt ) const { UINT32 nOrdNum; const SdrObject* pObj = rFmt.FindRealSdrObject(); @@ -775,7 +773,7 @@ UINT32 SwWW8Writer::GetSdrOrdNum( const SwFrmFmt& rFmt ) const return nOrdNum; } -void SwWW8Writer::AppendFlyInFlys(const sw::Frame& rFrmFmt, +void WW8Export::AppendFlyInFlys(const sw::Frame& rFrmFmt, const Point& rNdTopLeft) { ASSERT(bWrtWW8, "this has gone horribly wrong"); @@ -790,7 +788,7 @@ void SwWW8Writer::AppendFlyInFlys(const sw::Frame& rFrmFmt, if (rFrmFmt.IsInline()) { - OutField(0, ww::eSHAPE, FieldString(ww::eSHAPE), + OutputField(0, ww::eSHAPE, FieldString(ww::eSHAPE), WRITEFIELD_START | WRITEFIELD_CMD_START | WRITEFIELD_CMD_END); } @@ -818,10 +816,10 @@ void SwWW8Writer::AppendFlyInFlys(const sw::Frame& rFrmFmt, } if (rFrmFmt.IsInline()) - OutField(0, ww::eSHAPE, aEmptyStr, WRITEFIELD_CLOSE); + OutputField(0, ww::eSHAPE, aEmptyStr, WRITEFIELD_CLOSE); } -class WW8_SdrAttrIter : public WW8_AttrIter +class WW8_SdrAttrIter : public MSWordAttrIter { private: const EditTextObject* pEditObj; @@ -843,8 +841,8 @@ private: WW8_SdrAttrIter(const WW8_SdrAttrIter&); WW8_SdrAttrIter& operator=(const WW8_SdrAttrIter&); public: - WW8_SdrAttrIter(SwWW8Writer& rWr, const EditTextObject& rEditObj, - BYTE nType); + WW8_SdrAttrIter( WW8Export& rWr, const EditTextObject& rEditObj, + BYTE nType ); void NextPara( USHORT nPar ); void OutParaAttr(bool bCharAttr); void OutEEField(const SfxPoolItem& rHt); @@ -863,9 +861,9 @@ public: }; -WW8_SdrAttrIter::WW8_SdrAttrIter(SwWW8Writer& rWr, - const EditTextObject& rEditObj, BYTE nTyp) - : WW8_AttrIter( rWr ), pEditObj(&rEditObj), pEditPool(0), +WW8_SdrAttrIter::WW8_SdrAttrIter( WW8Export& rWr, + const EditTextObject& rEditObj, BYTE nTyp ) + : MSWordAttrIter( rWr ), pEditObj(&rEditObj), pEditPool(0), aTxtAtrArr( 0, 4 ), aChrTxtAtrArr( 0, 4 ), aChrSetArr( 0, 4 ), mnTyp(nTyp) { @@ -886,8 +884,8 @@ void WW8_SdrAttrIter::NextPara( USHORT nPar ) pEditPool = aSet.GetPool(); eNdChrSet = ItemGet<SvxFontItem>(aSet,EE_CHAR_FONTINFO).GetCharSet(); - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( pEditObj->GetText(nPara), 0); + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( pEditObj->GetText(nPara), 0); else nScript = i18n::ScriptType::LATIN; @@ -978,16 +976,16 @@ void WW8_SdrAttrIter::OutEEField(const SfxPoolItem& rHt) const SvxFieldData *pFld = rField.GetField(); if (pFld && pFld->ISA(SvxURLField)) { - BYTE nOldTxtTyp = rWrt.nTxtTyp; - rWrt.nTxtTyp = mnTyp; + BYTE nOldTxtTyp = m_rExport.nTxtTyp; + m_rExport.nTxtTyp = mnTyp; const SvxURLField *pURL = (const SvxURLField *)pFld; - StartURL(pURL->GetURL(), pURL->GetTargetFrame()); + m_rExport.AttrOutput().StartURL( pURL->GetURL(), pURL->GetTargetFrame() ); const String &rStr = pURL->GetRepresentation(); - rWrt.OutSwString(rStr, 0, rStr.Len(), true, GetNodeCharSet()); + m_rExport.AttrOutput().RawText( rStr, true, GetNodeCharSet() ); // FIXME kendy: is the 'true' actually correct here? It was here before, but... ;-) - EndURL(); - rWrt.nTxtTyp = nOldTxtTyp; + m_rExport.AttrOutput().EndURL(); + m_rExport.nTxtTyp = nOldTxtTyp; } } @@ -997,15 +995,14 @@ void WW8_SdrAttrIter::OutAttr( xub_StrLen nSwPos ) if( aTxtAtrArr.Count() ) { - const SwModify* pOldMod = rWrt.pOutFmtNode; - rWrt.pOutFmtNode = 0; + const SwModify* pOldMod = m_rExport.pOutFmtNode; + m_rExport.pOutFmtNode = 0; const SfxItemPool* pSrcPool = pEditPool; - const SfxItemPool& rDstPool = rWrt.pDoc->GetAttrPool(); + const SfxItemPool& rDstPool = m_rExport.pDoc->GetAttrPool(); nTmpSwPos = nSwPos; USHORT i, nWhich, nSlotId; - FnAttrOut pOut; for( i = 0; i < aTxtAtrArr.Count(); i++ ) { const EECharAttrib& rHt = aTxtAtrArr[ i ]; @@ -1019,7 +1016,7 @@ void WW8_SdrAttrIter::OutAttr( xub_StrLen nSwPos ) } else if (nWhich == EE_FEATURE_TAB) { - rWrt.WriteChar(0x9); + m_rExport.WriteChar(0x9); continue; } nSlotId = pSrcPool->GetSlotId(nWhich); @@ -1029,16 +1026,13 @@ void WW8_SdrAttrIter::OutAttr( xub_StrLen nSwPos ) nWhich = rDstPool.GetWhich(nSlotId); if (nWhich && nWhich != nSlotId && nWhich < RES_UNKNOWNATR_BEGIN && - 0 != (pOut = aWW8AttrFnTab[nWhich - RES_CHRATR_BEGIN])) + m_rExport.CollapseScriptsforWordOk(nScript,nWhich)) { - if (rWrt.CollapseScriptsforWordOk(nScript,nWhich)) - { - // use always the SW-Which Id ! - SfxPoolItem* pI = rHt.pAttr->Clone(); - pI->SetWhich( nWhich ); - (*pOut)( rWrt, *pI ); - delete pI; - } + // use always the SW-Which Id ! + SfxPoolItem* pI = rHt.pAttr->Clone(); + pI->SetWhich( nWhich ); + m_rExport.AttrOutput().OutputItem( *pI ); + delete pI; } } } @@ -1048,7 +1042,7 @@ void WW8_SdrAttrIter::OutAttr( xub_StrLen nSwPos ) } nTmpSwPos = 0; // HasTextItem nur in dem obigen Bereich erlaubt - rWrt.pOutFmtNode = pOldMod; + m_rExport.pOutFmtNode = pOldMod; } } @@ -1081,7 +1075,7 @@ const SfxPoolItem* WW8_SdrAttrIter::HasTextItem(USHORT nWhich) const { const SfxPoolItem* pRet = 0; nWhich = sw::hack::TransformWhichBetweenPools(*pEditPool, - rWrt.pDoc->GetAttrPool(), nWhich); + m_rExport.pDoc->GetAttrPool(), nWhich); if (nWhich) { for (USHORT i = 0; i < aTxtAtrArr.Count(); ++i) @@ -1109,7 +1103,7 @@ const SfxPoolItem& WW8_SdrAttrIter::GetItem( USHORT nWhich ) const if (!pRet) { SfxItemSet aSet(pEditObj->GetParaAttribs(nPara)); - nWhich = GetSetWhichFromSwDocWhich(aSet, *rWrt.pDoc, nWhich); + nWhich = GetSetWhichFromSwDocWhich(aSet, *m_rExport.pDoc, nWhich); ASSERT(nWhich, "Impossible, catastrophic failure imminent"); pRet = &aSet.Get(nWhich); } @@ -1121,42 +1115,38 @@ void WW8_SdrAttrIter::OutParaAttr(bool bCharAttr) SfxItemSet aSet( pEditObj->GetParaAttribs( nPara )); if( aSet.Count() ) { - const SfxItemSet* pOldSet = rWrt.GetCurItemSet(); - rWrt.SetCurItemSet( &aSet ); + const SfxItemSet* pOldSet = m_rExport.GetCurItemSet(); + m_rExport.SetCurItemSet( &aSet ); SfxItemIter aIter( aSet ); const SfxPoolItem* pItem = aIter.GetCurItem(); - FnAttrOut pOut; const SfxItemPool* pSrcPool = pEditPool, - * pDstPool = &rWrt.pDoc->GetAttrPool(); + * pDstPool = &m_rExport.pDoc->GetAttrPool(); do { - USHORT nWhich = pItem->Which(), - nSlotId = pSrcPool->GetSlotId( nWhich ); - if( nSlotId && nWhich != nSlotId && - 0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) && - nWhich != nSlotId && - ( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN - && nWhich < RES_TXTATR_END) - : (nWhich >= RES_PARATR_BEGIN - && nWhich < RES_FRMATR_END) ) && - 0 != ( pOut = aWW8AttrFnTab[ nWhich - RES_CHRATR_BEGIN ] ) ) - { - // use always the SW-Which Id ! - SfxPoolItem* pI = pItem->Clone(); - pI->SetWhich( nWhich ); - if (rWrt.CollapseScriptsforWordOk(nScript,nWhich)) - (*pOut)( rWrt, *pI ); - delete pI; - } - + USHORT nWhich = pItem->Which(), + nSlotId = pSrcPool->GetSlotId( nWhich ); + + if ( nSlotId && nWhich != nSlotId && + 0 != ( nWhich = pDstPool->GetWhich( nSlotId ) ) && + nWhich != nSlotId && + ( bCharAttr ? ( nWhich >= RES_CHRATR_BEGIN && nWhich < RES_TXTATR_END ) + : ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END ) ) ) + { + // use always the SW-Which Id ! + SfxPoolItem* pI = pItem->Clone(); + pI->SetWhich( nWhich ); + if (m_rExport.CollapseScriptsforWordOk(nScript,nWhich)) + m_rExport.AttrOutput().OutputItem( *pI ); + delete pI; + } } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) ); - rWrt.SetCurItemSet( pOldSet ); + m_rExport.SetCurItemSet( pOldSet ); } } -void SwWW8Writer::WriteSdrTextObj(const SdrObject& rObj, BYTE nTyp) +void WW8Export::WriteSdrTextObj(const SdrObject& rObj, BYTE nTyp) { const SdrTextObj* pTxtObj = PTR_CAST(SdrTextObj, &rObj); ASSERT(pTxtObj, "That is no SdrTextObj!"); @@ -1189,7 +1179,7 @@ void SwWW8Writer::WriteSdrTextObj(const SdrObject& rObj, BYTE nTyp) } } -void SwWW8Writer::WriteOutliner(const OutlinerParaObject& rParaObj, BYTE nTyp) +void WW8Export::WriteOutliner(const OutlinerParaObject& rParaObj, BYTE nTyp) { bool bAnyWrite = false; const EditTextObject& rEditObj = rParaObj.GetTextObject(); @@ -1290,7 +1280,7 @@ void WinwordAnchoring::WriteData( EscherEx& rEx ) const /* */ -void SwWW8Writer::CreateEscher() +void WW8Export::CreateEscher() { SfxItemState eBackSet = (const_cast<const SwDoc*>(pDoc))->GetPageDesc(0).GetMaster(). @@ -1304,7 +1294,7 @@ void SwWW8Writer::CreateEscher() } } -void SwWW8Writer::WriteEscher() +void WW8Export::WriteEscher() { if (pEscher) { @@ -1339,7 +1329,7 @@ void SwEscherEx::WritePictures() // Output- Routines for Escher Export -SwBasicEscherEx::SwBasicEscherEx(SvStream* pStrm, SwWW8Writer& rWW8Wrt, +SwBasicEscherEx::SwBasicEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt, UINT32 nDrawings) : EscherEx(*pStrm, nDrawings), rWrt(rWW8Wrt), pEscherStrm(pStrm), pPictStrm(0) @@ -1938,7 +1928,7 @@ void SwBasicEscherEx::WritePictures() } } -SwEscherEx::SwEscherEx(SvStream* pStrm, SwWW8Writer& rWW8Wrt) +SwEscherEx::SwEscherEx(SvStream* pStrm, WW8Export& rWW8Wrt) : SwBasicEscherEx(pStrm, rWW8Wrt, rWW8Wrt.pHFSdrObjs->size() ? 2 : 1), pTxtBxs(0) { @@ -2824,10 +2814,8 @@ UINT32 SwEscherEx::QueryTextID( return nId; } -bool SwMSConvertControls::ExportControl(Writer &rWrt, const SdrObject *pObj) +bool SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrObject *pObj) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - if (!rWW8Wrt.bWrtWW8) return false; @@ -2846,7 +2834,7 @@ bool SwMSConvertControls::ExportControl(Writer &rWrt, const SdrObject *pObj) aSize.Height = TWIPS_TO_MM(aRect.Bottom()); //Open the ObjectPool - SvStorageRef xObjPool = rWW8Wrt.GetStorage().OpenSotStorage( + SvStorageRef xObjPool = rWW8Wrt.GetWriter().GetStorage().OpenSotStorage( CREATE_CONST_ASC(SL::aObjectPool), STREAM_READWRITE | STREAM_SHARE_DENYALL); @@ -2879,13 +2867,13 @@ bool SwMSConvertControls::ExportControl(Writer &rWrt, const SdrObject *pObj) sFld += sName; sFld.APPEND_CONST_ASC(".1 \\s "); - rWW8Wrt.OutField(0, ww::eCONTROL, sFld, + rWW8Wrt.OutputField(0, ww::eCONTROL, sFld, WRITEFIELD_START|WRITEFIELD_CMD_START|WRITEFIELD_CMD_END); rWW8Wrt.pChpPlc->AppendFkpEntry(rWW8Wrt.Strm().Tell(),sizeof(aSpecOLE), aSpecOLE); rWW8Wrt.WriteChar( 0x1 ); - rWW8Wrt.OutField(0, ww::eCONTROL, aEmptyStr, WRITEFIELD_END | WRITEFIELD_CLOSE); + rWW8Wrt.OutputField(0, ww::eCONTROL, aEmptyStr, WRITEFIELD_END | WRITEFIELD_CLOSE); return true; } diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 18d75d5826..7ef0640ed1 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -32,7 +32,6 @@ #include "precompiled_sw.hxx" /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ - #include <vector> #include <list> #include <utility> @@ -53,9 +52,7 @@ #include <svx/ulspitem.hxx> #include <svx/brkitem.hxx> #include <svx/frmdiritem.hxx> -#ifndef _SVX_TSTPITEM_HXX #include <svx/tstpitem.hxx> -#endif #include "svtools/urihelper.hxx" #include <svtools/whiter.hxx> #include <fmtpdsc.hxx> @@ -93,18 +90,21 @@ #include <txtatr.hxx> #include <fmtsrnd.hxx> #include <fmtrowsplt.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif -#ifndef _COM_SUN_STAR_I18N_WORDTYPE_HDL_ #include <com/sun/star/i18n/WordType.hpp> -#endif + +#include <writerfilter/doctok/sprmids.hxx> + #include "writerhelper.hxx" #include "writerwordglue.hxx" #include <numrule.hxx> #include "wrtww8.hxx" #include "ww8par.hxx" #include <IMark.hxx> +#include "ww8attributeoutput.hxx" + +#include <ndgrf.hxx> +#include <ndole.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::i18n; @@ -114,18 +114,18 @@ using namespace nsFieldFlags; /* */ -WW8_AttrIter::WW8_AttrIter(SwWW8Writer& rWr) - : pOld(rWr.pChpIter), rWrt(rWr) +MSWordAttrIter::MSWordAttrIter( MSWordExportBase& rExport ) + : pOld( rExport.pChpIter ), m_rExport( rExport ) { - rWrt.pChpIter = this; + m_rExport.pChpIter = this; } -WW8_AttrIter::~WW8_AttrIter() +MSWordAttrIter::~MSWordAttrIter() { - rWrt.pChpIter = pOld; + m_rExport.pChpIter = pOld; } -// Die Klasse WW8_SwAttrIter ist eine Hilfe zum Aufbauen der Fkp.chpx. +// Die Klasse SwAttrIter ist eine Hilfe zum Aufbauen der Fkp.chpx. // Dabei werden nur Zeichen-Attribute beachtet; Absatz-Attribute brauchen // diese Behandlung nicht. // Die Absatz- und Textattribute des Writers kommen rein, und es wird @@ -135,7 +135,7 @@ WW8_AttrIter::~WW8_AttrIter() // Mit OutAttr() werden die Attribute an der angegebenen SwPos // ausgegeben. -class WW8_SwAttrIter : public WW8_AttrIter +class SwAttrIter : public MSWordAttrIter { private: const SwTxtNode& rNd; @@ -161,18 +161,15 @@ private: xub_StrLen SearchNext( xub_StrLen nStartPos ); void FieldVanish( const String& rTxt ); - void OutSwFmtINetFmt(const SwFmtINetFmt& rAttr, bool bStart); void OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool bStart); - void OutSwTOXMark(const SwTOXMark& rAttr, bool bStart); - void OutSwFmtRuby(const SwFmtRuby& rRuby, bool bStart); void IterToCurrent(); //No copying - WW8_SwAttrIter(const WW8_SwAttrIter&); - WW8_SwAttrIter& operator=(const WW8_SwAttrIter&); + SwAttrIter(const SwAttrIter&); + SwAttrIter& operator=(const SwAttrIter&); public: - WW8_SwAttrIter( SwWW8Writer& rWr, const SwTxtNode& rNd ); + SwAttrIter( MSWordExportBase& rWr, const SwTxtNode& rNd ); bool IsTxtAttr( xub_StrLen nSwPos ); bool IsRedlineAtEnd( xub_StrLen nPos ) const; @@ -185,7 +182,7 @@ public: virtual const SfxPoolItem* HasTextItem( USHORT nWhich ) const; virtual const SfxPoolItem& GetItem( USHORT nWhich ) const; int OutAttrWithRange(xub_StrLen nPos); - void OutRedlines(xub_StrLen nPos); + const SwRedlineData* GetRedline( xub_StrLen nPos ); void OutFlys(xub_StrLen nSwPos); xub_StrLen WhereNext() const { return nAktSwPos; } @@ -198,24 +195,6 @@ public: const SwFmtDrop& GetSwFmtDrop() const { return mrSwFmtDrop; } }; -void SwWW8Writer::push_charpropstart(xub_StrLen nPos) -{ - maCurrentCharPropStarts.push(nPos); -} - -void SwWW8Writer::pop_charpropstart() -{ - ASSERT(!maCurrentCharPropStarts.empty(), "cannot be empty!"); - if (!maCurrentCharPropStarts.empty()) - maCurrentCharPropStarts.pop(); -} - -xub_StrLen SwWW8Writer::top_charpropstart() const -{ - ASSERT(!maCurrentCharPropStarts.empty(), "cannot be empty!"); - return maCurrentCharPropStarts.empty() ? 0 : maCurrentCharPropStarts.top(); -} - class sortswflys : public std::binary_function<const sw::Frame&, const sw::Frame&, bool> { @@ -226,7 +205,7 @@ public: } }; -void WW8_SwAttrIter::IterToCurrent() +void SwAttrIter::IterToCurrent() { ASSERT(maCharRuns.begin() != maCharRuns.end(), "Impossible"); mnScript = maCharRunIter->mnScript; @@ -234,10 +213,10 @@ void WW8_SwAttrIter::IterToCurrent() mbCharIsRTL = maCharRunIter->mbRTL; } -WW8_SwAttrIter::WW8_SwAttrIter(SwWW8Writer& rWr, const SwTxtNode& rTxtNd) : - WW8_AttrIter(rWr), +SwAttrIter::SwAttrIter(MSWordExportBase& rWr, const SwTxtNode& rTxtNd) : + MSWordAttrIter(rWr), rNd(rTxtNd), - maCharRuns(GetPseudoCharRuns(rTxtNd, 0, !rWr.bWrtWW8)), + maCharRuns(GetPseudoCharRuns(rTxtNd, 0, !rWr.HackIsWW8OrHigher())), pCurRedline(0), nAktSwPos(0), nCurRedlinePos(USHRT_MAX), @@ -260,14 +239,13 @@ WW8_SwAttrIter::WW8_SwAttrIter(SwWW8Writer& rWr, const SwTxtNode& rTxtNd) : maFlyFrms = GetFramesInNode(rWr.maFrames, rNd); std::sort(maFlyFrms.begin(), maFlyFrms.end(), sortswflys()); - /* #i18480# If we are inside a frame then anything anchored inside this frame can only be supported by word anchored inline ("as character"), so force this in the supportable case. */ - if (rWr.bWrtWW8 && rWr.bInWriteEscher) + if (rWr.HackIsWW8OrHigher() && rWr.bInWriteEscher) { std::for_each(maFlyFrms.begin(), maFlyFrms.end(), std::mem_fun_ref(&sw::Frame::ForceTreatAsInline)); @@ -275,16 +253,16 @@ WW8_SwAttrIter::WW8_SwAttrIter(SwWW8Writer& rWr, const SwTxtNode& rTxtNd) : maFlyIter = maFlyFrms.begin(); - if (rWrt.pDoc->GetRedlineTbl().Count()) + if ( m_rExport.pDoc->GetRedlineTbl().Count() ) { SwPosition aPosition( rNd, SwIndex( (SwTxtNode*)&rNd ) ); - pCurRedline = rWrt.pDoc->GetRedline( aPosition, &nCurRedlinePos ); + pCurRedline = m_rExport.pDoc->GetRedline( aPosition, &nCurRedlinePos ); } nAktSwPos = SearchNext(1); } -xub_StrLen WW8_SwAttrIter::SearchNext( xub_StrLen nStartPos ) +xub_StrLen SwAttrIter::SearchNext( xub_StrLen nStartPos ) { xub_StrLen nPos; xub_StrLen nMinPos = STRING_MAXLEN; @@ -309,16 +287,16 @@ xub_StrLen WW8_SwAttrIter::SearchNext( xub_StrLen nStartPos ) nMinPos = i; } - if( nCurRedlinePos < rWrt.pDoc->GetRedlineTbl().Count() ) + if ( nCurRedlinePos < m_rExport.pDoc->GetRedlineTbl().Count() ) { // nCurRedlinePos point to the next redline nPos = nCurRedlinePos; if( pCurRedline ) ++nPos; - for( ; nPos < rWrt.pDoc->GetRedlineTbl().Count(); ++nPos ) + for ( ; nPos < m_rExport.pDoc->GetRedlineTbl().Count(); ++nPos ) { - const SwRedline* pRedl = rWrt.pDoc->GetRedlineTbl()[ nPos ]; + const SwRedline* pRedl = m_rExport.pDoc->GetRedlineTbl()[ nPos ]; const SwPosition* pStt = pRedl->Start(); const SwPosition* pEnd = pStt == pRedl->GetPoint() @@ -366,9 +344,9 @@ xub_StrLen WW8_SwAttrIter::SearchNext( xub_StrLen nStartPos ) if( nPos >= nStartPos && nPos <= nMinPos ) nMinPos = nPos; } - else + if (pHt->HasDummyChar()) { - // Attr ohne Ende Laenge 1 wegen CH_TXTATR im Text + // pos + 1 because of CH_TXTATR in Text nPos = *pHt->GetStart() + 1; if( nPos >= nStartPos && nPos <= nMinPos ) nMinPos = nPos; @@ -417,28 +395,16 @@ xub_StrLen WW8_SwAttrIter::SearchNext( xub_StrLen nStartPos ) return nMinPos; } -void WW8_SwAttrIter::OutAttr(xub_StrLen nSwPos) +void SwAttrIter::OutAttr( xub_StrLen nSwPos ) { - if (rWrt.bWrtWW8 && IsCharRTL()) - { - rWrt.InsUInt16(0x85a); - rWrt.pO->Insert((BYTE)1, rWrt.pO->Count()); - } - - // #i46087# patch from james_clark; complex texts needs the undocumented SPRM 0x0882 with param 0x81. - if (rWrt.bWrtWW8 && GetScript() == i18n::ScriptType::COMPLEX && !IsCharRTL()) - { - rWrt.InsUInt16(0x882); - rWrt.pO->Insert((BYTE)0x81, rWrt.pO->Count()); - rWrt.pDop->bUseThaiLineBreakingRules=true; - } + m_rExport.AttrOutput().RTLAndCJKState( IsCharRTL(), GetScript() ); /* Depending on whether text is in CTL/CJK or Western, get the id of that script, the idea is that the font that is actually in use to render this range of text ends up in pFont */ - sal_uInt16 nFontId = GetWhichOfScript(RES_CHRATR_FONT, GetScript()); + sal_uInt16 nFontId = GetWhichOfScript( RES_CHRATR_FONT, GetScript() ); const SvxFontItem &rParentFont = ItemGet<SvxFontItem>( (const SwTxtFmtColl&)rNd.GetAnyFmtColl(), nFontId); @@ -508,34 +474,34 @@ void WW8_SwAttrIter::OutAttr(xub_StrLen nSwPos) this for us like writer does */ const SwFmtCharFmt *pCharFmtItem = - HasItem<SwFmtCharFmt>(aRangeItems, RES_TXTATR_CHARFMT); - if (pCharFmtItem) - ClearOverridesFromSet(*pCharFmtItem, aExportSet); + HasItem< SwFmtCharFmt >( aRangeItems, RES_TXTATR_CHARFMT ); + if ( pCharFmtItem ) + ClearOverridesFromSet( *pCharFmtItem, aExportSet ); sw::PoolItems aExportItems; - GetPoolItems(aExportSet, aExportItems); + GetPoolItems( aExportSet, aExportItems ); sw::cPoolItemIter aEnd = aRangeItems.end(); - for (sw::cPoolItemIter aI = aRangeItems.begin(); aI != aEnd; ++aI) + for ( sw::cPoolItemIter aI = aRangeItems.begin(); aI != aEnd; ++aI ) aExportItems[aI->first] = aI->second; - if (!aExportItems.empty()) + if ( !aExportItems.empty() ) { - const SwModify* pOldMod = rWrt.pOutFmtNode; - rWrt.pOutFmtNode = &rNd; - rWrt.push_charpropstart(nSwPos); + const SwModify* pOldMod = m_rExport.pOutFmtNode; + m_rExport.pOutFmtNode = &rNd; + m_rExport.m_aCurrentCharPropStarts.push( nSwPos ); - rWrt.ExportPoolItemsToCHP(aExportItems, GetScript()); + m_rExport.ExportPoolItemsToCHP( aExportItems, GetScript() ); // HasTextItem nur in dem obigen Bereich erlaubt - rWrt.pop_charpropstart(); - rWrt.pOutFmtNode = pOldMod; + m_rExport.m_aCurrentCharPropStarts.pop(); + m_rExport.pOutFmtNode = pOldMod; } - ASSERT(pFont, "must be *some* font associated with this txtnode"); - if (pFont) + ASSERT( pFont, "must be *some* font associated with this txtnode" ); + if ( pFont ) { - SvxFontItem aFont(*pFont); + SvxFontItem aFont( *pFont ); /* If we are a nonunicode aware format then we set the charset we want to @@ -547,48 +513,45 @@ void WW8_SwAttrIter::OutAttr(xub_StrLen nSwPos) this makes older nonunicode aware versions of word display the correct characters. */ - if (!rWrt.bWrtWW8) + if ( !m_rExport.HackIsWW8OrHigher() ) aFont.GetCharSet() = GetCharSet(); - if (rParentFont != aFont) - Out(aWW8AttrFnTab, aFont, rWrt); + if ( rParentFont != aFont ) + m_rExport.AttrOutput().OutputItem( aFont ); } - - OutRedlines(nSwPos); } -void WW8_SwAttrIter::OutFlys(xub_StrLen nSwPos) +void SwAttrIter::OutFlys(xub_StrLen nSwPos) { /* #i2916# May have an anchored graphic to be placed, loop through sorted array and output all at this position */ - while (maFlyIter != maFlyFrms.end()) + while ( maFlyIter != maFlyFrms.end() ) { const SwPosition &rAnchor = maFlyIter->GetPosition(); xub_StrLen nPos = rAnchor.nContent.GetIndex(); - if (nPos != nSwPos) + if ( nPos != nSwPos ) break; else { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - rWrtWW8.OutFlyFrm(*maFlyIter); + m_rExport.AttrOutput().OutputFlyFrame( *maFlyIter ); ++maFlyIter; } } } -bool WW8_SwAttrIter::IsTxtAttr( xub_StrLen nSwPos ) +bool SwAttrIter::IsTxtAttr( xub_StrLen nSwPos ) { - // search for attrs without end position + // search for attrs with CH_TXTATR if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { for (USHORT i = 0; i < pTxtAttrs->Count(); ++i) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; - if( !pHt->GetEnd() && *pHt->GetStart() == nSwPos ) + if ( pHt->HasDummyChar() && (*pHt->GetStart() == nSwPos) ) return true; } } @@ -596,7 +559,7 @@ bool WW8_SwAttrIter::IsTxtAttr( xub_StrLen nSwPos ) return false; } -bool WW8_SwAttrIter::IsDropCap( int nSwPos ) +bool SwAttrIter::IsDropCap( int nSwPos ) { // see if the current position falls on a DropCap int nDropChars = mrSwFmtDrop.GetChars(); @@ -615,14 +578,14 @@ bool WW8_SwAttrIter::IsDropCap( int nSwPos ) return false; } -bool WW8_SwAttrIter::RequiresImplicitBookmark() +bool SwAttrIter::RequiresImplicitBookmark() { - SwImplBookmarksIter bkmkIterEnd = rWrt.maImplicitBookmarks.end(); - for (SwImplBookmarksIter aIter = rWrt.maImplicitBookmarks.begin(); aIter != bkmkIterEnd; ++aIter) + SwImplBookmarksIter bkmkIterEnd = m_rExport.maImplicitBookmarks.end(); + for ( SwImplBookmarksIter aIter = m_rExport.maImplicitBookmarks.begin(); aIter != bkmkIterEnd; ++aIter ) { ULONG sample = aIter->second; - if(sample == rNd.GetIndex()) + if ( sample == rNd.GetIndex() ) return true; } return false; @@ -634,11 +597,11 @@ bool WW8_SwAttrIter::RequiresImplicitBookmark() // Attribut-Anfangposition fragen kann. // Es koennen nur Attribute mit Ende abgefragt werden. // Es wird mit bDeep gesucht -const SfxPoolItem* WW8_SwAttrIter::HasTextItem( USHORT nWhich ) const +const SfxPoolItem* SwAttrIter::HasTextItem( USHORT nWhich ) const { const SfxPoolItem* pRet = 0; const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); - xub_StrLen nTmpSwPos = rWrt.top_charpropstart(); + xub_StrLen nTmpSwPos = m_rExport.m_aCurrentCharPropStarts.top(); if (pTxtAttrs) { for (USHORT i = 0; i < pTxtAttrs->Count(); ++i) @@ -660,162 +623,152 @@ const SfxPoolItem* WW8_SwAttrIter::HasTextItem( USHORT nWhich ) const return pRet; } -void SwWW8Writer::GetCurrentItems(WW8Bytes& rItems) const +void WW8Export::GetCurrentItems(WW8Bytes& rItems) const { USHORT nEnd = pO ? pO->Count() : 0; for (USHORT nI = 0; nI < nEnd; ++nI) rItems.Insert((*pO)[nI], rItems.Count()); } -const SfxPoolItem& WW8_SwAttrIter::GetItem(USHORT nWhich) const +const SfxPoolItem& SwAttrIter::GetItem(USHORT nWhich) const { const SfxPoolItem* pRet = HasTextItem(nWhich); return pRet ? *pRet : rNd.SwCntntNode::GetAttr(nWhich); } -void WW8_SwAttrIter::OutSwFmtRuby(const SwFmtRuby& rRuby, bool bStart) +void WW8AttributeOutput::StartRuby( const SwTxtNode& rNode, const SwFmtRuby& rRuby ) { - if (bStart) - { - String aStr(FieldString(ww::eEQ)); - aStr.APPEND_CONST_ASC("\\* jc"); - sal_Int32 nJC=0; - sal_Char cDirective=0; - switch(rRuby.GetAdjustment()) - { - case 0: - nJC = 3; - cDirective = 'l'; - break; - case 1: - //defaults to 0 - break; - case 2: - nJC = 4; - cDirective = 'r'; - break; - case 3: - nJC = 1; - cDirective = 'd'; - break; - case 4: - nJC = 2; - cDirective = 'd'; - break; - default: - ASSERT(!this,"Unhandled Ruby justication code"); - break; - } - aStr += String::CreateFromInt32(nJC); - - /* - MS needs to know the name and size of the font used in the ruby item, - but we coud have written it in a mixture of asian and western - scripts, and each of these can be a different font and size than the - other, so we make a guess based upon the first character of the text, - defaulting to asian. - */ - USHORT nRubyScript; - if( pBreakIt->xBreak.is() ) - nRubyScript = pBreakIt->xBreak->getScriptType( rRuby.GetText(), 0); - else - nRubyScript = i18n::ScriptType::ASIAN; - - const SwTxtRuby* pRubyTxt = rRuby.GetTxtRuby(); - const SwCharFmt* pFmt = pRubyTxt ? pRubyTxt->GetCharFmt() : 0; - String sFamilyName; - long nHeight; - if (pFmt) - { - const SvxFontItem &rFont = ItemGet<SvxFontItem>(*pFmt, - GetWhichOfScript(RES_CHRATR_FONT,nRubyScript)); - sFamilyName = rFont.GetFamilyName(); + String aStr( FieldString( ww::eEQ ) ); + aStr.APPEND_CONST_ASC( "\\* jc" ); + sal_Int32 nJC = 0; + sal_Char cDirective = 0; + switch ( rRuby.GetAdjustment() ) + { + case 0: + nJC = 3; + cDirective = 'l'; + break; + case 1: + //defaults to 0 + break; + case 2: + nJC = 4; + cDirective = 'r'; + break; + case 3: + nJC = 1; + cDirective = 'd'; + break; + case 4: + nJC = 2; + cDirective = 'd'; + break; + default: + ASSERT( !this,"Unhandled Ruby justication code" ); + break; + } + aStr += String::CreateFromInt32( nJC ); - const SvxFontHeightItem &rHeight = ItemGet<SvxFontHeightItem>(*pFmt, - GetWhichOfScript(RES_CHRATR_FONTSIZE,nRubyScript)); - nHeight = rHeight.GetHeight(); - } - else - { - /*Get defaults if no formatting on ruby text*/ + /* + MS needs to know the name and size of the font used in the ruby item, + but we coud have written it in a mixture of asian and western + scripts, and each of these can be a different font and size than the + other, so we make a guess based upon the first character of the text, + defaulting to asian. + */ + USHORT nRubyScript; + if( pBreakIt->GetBreakIter().is() ) + nRubyScript = pBreakIt->GetBreakIter()->getScriptType( rRuby.GetText(), 0); + else + nRubyScript = i18n::ScriptType::ASIAN; - const SfxItemPool *pPool = rNd.GetSwAttrSet().GetPool(); - const SfxItemPool &rPool = - pPool ? *pPool : rWrt.pDoc->GetAttrPool(); + const SwTxtRuby* pRubyTxt = rRuby.GetTxtRuby(); + const SwCharFmt* pFmt = pRubyTxt ? pRubyTxt->GetCharFmt() : 0; + String sFamilyName; + long nHeight; + if ( pFmt ) + { + const SvxFontItem &rFont = ItemGet< SvxFontItem >( *pFmt, + GetWhichOfScript(RES_CHRATR_FONT,nRubyScript) ); + sFamilyName = rFont.GetFamilyName(); - const SvxFontItem &rFont = DefaultItemGet<SvxFontItem>(rPool, - GetWhichOfScript(RES_CHRATR_FONT,nRubyScript)); - sFamilyName = rFont.GetFamilyName(); + const SvxFontHeightItem &rHeight = ItemGet< SvxFontHeightItem >( *pFmt, + GetWhichOfScript( RES_CHRATR_FONTSIZE, nRubyScript ) ); + nHeight = rHeight.GetHeight(); + } + else + { + /*Get defaults if no formatting on ruby text*/ - const SvxFontHeightItem &rHeight = DefaultItemGet<SvxFontHeightItem> - (rPool, GetWhichOfScript(RES_CHRATR_FONTSIZE,nRubyScript)); - nHeight = rHeight.GetHeight(); - } - nHeight = (nHeight + 5)/10; - - aStr.APPEND_CONST_ASC(" \\* \"Font:"); - aStr.Append(sFamilyName); - aStr.APPEND_CONST_ASC("\" \\* hps"); - aStr += String::CreateFromInt32(nHeight); - aStr.APPEND_CONST_ASC(" \\o"); - if (cDirective) - { - aStr.APPEND_CONST_ASC("\\a"); - aStr.Append(cDirective); - } - aStr.APPEND_CONST_ASC("(\\s\\up "); + const SfxItemPool *pPool = rNode.GetSwAttrSet().GetPool(); + const SfxItemPool &rPool = pPool ? *pPool : m_rWW8Export.pDoc->GetAttrPool(); + const SvxFontItem &rFont = DefaultItemGet< SvxFontItem >( rPool, + GetWhichOfScript( RES_CHRATR_FONT,nRubyScript ) ); + sFamilyName = rFont.GetFamilyName(); - if( pBreakIt->xBreak.is() ) - nRubyScript = pBreakIt->xBreak->getScriptType( rNd.GetTxt(), - *(pRubyTxt->GetStart())); - else - nRubyScript = i18n::ScriptType::ASIAN; - - const SwAttrSet& rSet = rNd.GetSwAttrSet(); - const SvxFontHeightItem &rHeightItem = - (const SvxFontHeightItem&)rSet.Get( - GetWhichOfScript(RES_CHRATR_FONTSIZE,nRubyScript)); - nHeight = (rHeightItem.GetHeight() + 10)/20-1; - aStr += String::CreateFromInt32(nHeight); - aStr += '('; - aStr += rRuby.GetText(); - aStr.APPEND_CONST_ASC(");"); - rWrt.OutField(0, ww::eEQ, aStr, - WRITEFIELD_START | WRITEFIELD_CMD_START); + const SvxFontHeightItem &rHeight = DefaultItemGet< SvxFontHeightItem > + ( rPool, GetWhichOfScript( RES_CHRATR_FONTSIZE, nRubyScript ) ); + nHeight = rHeight.GetHeight(); } - else + nHeight = (nHeight + 5)/10; + + aStr.APPEND_CONST_ASC( " \\* \"Font:" ); + aStr.Append( sFamilyName ); + aStr.APPEND_CONST_ASC( "\" \\* hps" ); + aStr += String::CreateFromInt32( nHeight ); + aStr.APPEND_CONST_ASC( " \\o" ); + if ( cDirective ) { - rWrt.WriteChar(')'); - rWrt.OutField(0, ww::eEQ, aEmptyStr, WRITEFIELD_END | WRITEFIELD_CLOSE); + aStr.APPEND_CONST_ASC( "\\a" ); + aStr.Append( cDirective ); } + aStr.APPEND_CONST_ASC( "(\\s\\up " ); + + + if ( pBreakIt->GetBreakIter().is() ) + nRubyScript = pBreakIt->GetBreakIter()->getScriptType( rNode.GetTxt(), + *( pRubyTxt->GetStart() ) ); + else + nRubyScript = i18n::ScriptType::ASIAN; + + const SwAttrSet& rSet = rNode.GetSwAttrSet(); + const SvxFontHeightItem &rHeightItem = + ( const SvxFontHeightItem& )rSet.Get( + GetWhichOfScript( RES_CHRATR_FONTSIZE, nRubyScript ) ); + nHeight = (rHeightItem.GetHeight() + 10)/20-1; + aStr += String::CreateFromInt32(nHeight); + aStr += '('; + aStr += rRuby.GetText(); + aStr.APPEND_CONST_ASC( ");" ); + m_rWW8Export.OutputField( 0, ww::eEQ, aStr, + WRITEFIELD_START | WRITEFIELD_CMD_START ); } -void WW8_SwAttrIter::OutSwFmtINetFmt(const SwFmtINetFmt& rINet, bool bStart) +void WW8AttributeOutput::EndRuby() { - if( bStart ) - StartURL(rINet.GetValue(), rINet.GetTargetFrame()); - else - EndURL(); + m_rWW8Export.WriteChar( ')' ); + m_rWW8Export.OutputField( 0, ww::eEQ, aEmptyStr, WRITEFIELD_END | WRITEFIELD_CLOSE ); } /*#i15387# Better ideas welcome*/ -String &TruncateBookmark(String &rRet) +String &TruncateBookmark( String &rRet ) { - if (rRet.Len() > 40) - rRet.Erase(40); - ASSERT(rRet.Len() <= 40, "Word cannot have bookmarks longer than 40 chars"); + if ( rRet.Len() > 40 ) + rRet.Erase( 40 ); + ASSERT( rRet.Len() <= 40, "Word cannot have bookmarks longer than 40 chars" ); return rRet; } -void WW8_AttrIter::StartURL(const String &rUrl, const String &rTarget) +bool AttributeOutputBase::AnalyzeURL( const String& rUrl, const String& /*rTarget*/, String* pLinkURL, String* pMark ) { bool bBookMarkOnly = false; - INetURLObject aURL(rUrl); - String sURL; + + INetURLObject aURL( rUrl ); String sMark; + String sURL; - if (rUrl.Len() > 1 && rUrl.GetChar(0) == INET_MARK_TOKEN) + if ( rUrl.Len() > 1 && rUrl.GetChar(0) == INET_MARK_TOKEN ) { sMark = BookmarkToWriter( rUrl.Copy(1) ); @@ -825,58 +778,92 @@ void WW8_AttrIter::StartURL(const String &rUrl, const String &rTarget) sRefType.EraseAllChars(); // i21465 Only interested in outline references - if(sRefType.EqualsAscii( pMarkToOutline ) ) + if ( sRefType.EqualsAscii( pMarkToOutline ) ) { String sLink = sMark.Copy(0, nPos); - SwImplBookmarksIter bkmkIterEnd = rWrt.maImplicitBookmarks.end(); - for (SwImplBookmarksIter aIter = rWrt.maImplicitBookmarks.begin(); aIter != bkmkIterEnd; ++aIter) + SwImplBookmarksIter bkmkIterEnd = GetExport().maImplicitBookmarks.end(); + for ( SwImplBookmarksIter aIter = GetExport().maImplicitBookmarks.begin(); aIter != bkmkIterEnd; ++aIter ) { String bkmkName = aIter->first; - if(bkmkName == sLink) + if ( bkmkName == sLink ) { - sMark = String(RTL_CONSTASCII_STRINGPARAM("_toc")); - sMark += String::CreateFromInt32(aIter->second); + sMark = String( RTL_CONSTASCII_STRINGPARAM( "_toc" ) ); + sMark += String::CreateFromInt32( aIter->second ); } } } } else { - sURL = aURL.GetURLNoMark(INetURLObject::DECODE_UNAMBIGUOUS); - sMark = aURL.GetMark(INetURLObject::DECODE_UNAMBIGUOUS); + sURL = aURL.GetURLNoMark( INetURLObject::DECODE_UNAMBIGUOUS ); + sMark = aURL.GetMark( INetURLObject::DECODE_UNAMBIGUOUS ); - sURL = URIHelper::simpleNormalizedMakeRelative(rWrt.GetBaseURL(), - sURL); } - if (sMark.Len() && !sURL.Len()) + if ( sMark.Len() && !sURL.Len() ) bBookMarkOnly = true; - if (bBookMarkOnly) - sURL = FieldString(ww::eHYPERLINK); + + + *pMark = sMark; + *pLinkURL = sURL; + return bBookMarkOnly; +} + +bool WW8AttributeOutput::AnalyzeURL( const String& rUrl, const String& rTarget, String* pLinkURL, String* pMark ) +{ + bool bBookMarkOnly = AttributeOutputBase::AnalyzeURL( rUrl, rTarget, pLinkURL, pMark ); + + String sURL = *pLinkURL; + String sMark = *pMark; + + if ( sURL.Len() ) + sURL = URIHelper::simpleNormalizedMakeRelative( m_rWW8Export.GetWriter().GetBaseURL(), sURL ); + + if ( bBookMarkOnly ) + sURL = FieldString( ww::eHYPERLINK ); else { - String sFld(FieldString(ww::eHYPERLINK)); - sFld.APPEND_CONST_ASC("\""); - sURL.Insert(sFld, 0); + String sFld( FieldString( ww::eHYPERLINK ) ); + sFld.APPEND_CONST_ASC( "\"" ); + sURL.Insert( sFld, 0 ); sURL += '\"'; } - if (sMark.Len()) - (( sURL.APPEND_CONST_ASC(" \\l \"") ) += sMark) += '\"'; + if ( sMark.Len() ) + ( ( sURL.APPEND_CONST_ASC( " \\l \"" ) ) += sMark ) += '\"'; + + if ( rTarget.Len() ) + ( sURL.APPEND_CONST_ASC( " \\n " ) ) += rTarget; + + *pLinkURL = sURL; + *pMark = sMark; + + return bBookMarkOnly; +} + +bool WW8AttributeOutput::StartURL( const String &rUrl, const String &rTarget ) +{ + // hyperlinks only in WW8 + if ( !m_rWW8Export.bWrtWW8 ) + return false; + + INetURLObject aURL( rUrl ); + String sURL; + String sMark; + + bool bBookMarkOnly = AnalyzeURL( rUrl, rTarget, &sURL, &sMark ); - if (rTarget.Len()) - (sURL.APPEND_CONST_ASC(" \\n ")) += rTarget; - rWrt.OutField(0, ww::eHYPERLINK, sURL, WRITEFIELD_START | WRITEFIELD_CMD_START); + m_rWW8Export.OutputField( 0, ww::eHYPERLINK, sURL, WRITEFIELD_START | WRITEFIELD_CMD_START ); // write the refence to the "picture" structure - ULONG nDataStt = rWrt.pDataStrm->Tell(); - rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell() ); + ULONG nDataStt = m_rWW8Export.pDataStrm->Tell(); + m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell() ); // WinWord 2000 doesn't write this - so its a temp solution by W97 ? - rWrt.WriteChar( 0x01 ); + m_rWW8Export.WriteChar( 0x01 ); static BYTE aArr1[] = { 0x03, 0x6a, 0,0,0,0, // sprmCPicLocation @@ -888,9 +875,9 @@ void WW8_AttrIter::StartURL(const String &rUrl, const String &rTarget) BYTE* pDataAdr = aArr1 + 2; Set_UInt32( pDataAdr, nDataStt ); - rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), sizeof( aArr1 ), aArr1 ); + m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), sizeof( aArr1 ), aArr1 ); - rWrt.OutField(0, ww::eHYPERLINK, sURL, WRITEFIELD_CMD_END); + m_rWW8Export.OutputField( 0, ww::eHYPERLINK, sURL, WRITEFIELD_CMD_END ); // now write the picture structur sURL = aURL.GetURLNoMark(); @@ -913,22 +900,24 @@ void WW8_AttrIter::StartURL(const String &rUrl, const String &rTarget) 0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B }; - rWrt.pDataStrm->Write( aURLData1, sizeof(aURLData1) ); - BYTE nAnchor=0x00; - if( sMark.Len() ) - nAnchor=0x08; - rWrt.pDataStrm->Write( &nAnchor, 1 ); - rWrt.pDataStrm->Write( MAGIC_A, sizeof(MAGIC_A) ); - SwWW8Writer::WriteLong( *rWrt.pDataStrm, 0x00000002); + m_rWW8Export.pDataStrm->Write( aURLData1, sizeof( aURLData1 ) ); + BYTE nAnchor = 0x00; + if ( sMark.Len() ) + nAnchor = 0x08; + m_rWW8Export.pDataStrm->Write( &nAnchor, 1 ); + m_rWW8Export.pDataStrm->Write( MAGIC_A, sizeof(MAGIC_A) ); + SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 0x00000002); UINT32 nFlag = bBookMarkOnly ? 0 : 0x01; - if (bAbsolute) nFlag |= 0x02; - if( sMark.Len() ) nFlag |= 0x08; - SwWW8Writer::WriteLong( *rWrt.pDataStrm, nFlag ); + if ( bAbsolute ) + nFlag |= 0x02; + if ( sMark.Len() ) + nFlag |= 0x08; + SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, nFlag ); INetProtocol eProto = aURL.GetProtocol(); - if (eProto == INET_PROT_FILE) + if ( eProto == INET_PROT_FILE ) { -// version 1 (for a document) + // version 1 (for a document) static BYTE __READONLY_DATA MAGIC_C[] = { 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -943,7 +932,7 @@ void WW8_AttrIter::StartURL(const String &rUrl, const String &rTarget) }; // save the links to files as relative - sURL = URIHelper::simpleNormalizedMakeRelative( rWrt.GetBaseURL(), sURL ); + sURL = URIHelper::simpleNormalizedMakeRelative( m_rWW8Export.GetWriter().GetBaseURL(), sURL ); if ( sURL.EqualsAscii( "/", 0, 1 ) ) sURL = aURL.PathToFileName(); @@ -958,18 +947,18 @@ void WW8_AttrIter::StartURL(const String &rUrl, const String &rTarget) sURL.SearchAndReplaceAll( '/', '\\' ); } - rWrt.pDataStrm->Write( MAGIC_C, sizeof(MAGIC_C) ); - SwWW8Writer::WriteLong( *rWrt.pDataStrm, sURL.Len()+1 ); - SwWW8Writer::WriteString8( *rWrt.pDataStrm, sURL, true, + m_rWW8Export.pDataStrm->Write( MAGIC_C, sizeof(MAGIC_C) ); + SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, sURL.Len()+1 ); + SwWW8Writer::WriteString8( *m_rWW8Export.pDataStrm, sURL, true, RTL_TEXTENCODING_MS_1252 ); - rWrt.pDataStrm->Write( MAGIC_D, sizeof( MAGIC_D) ); + m_rWW8Export.pDataStrm->Write( MAGIC_D, sizeof( MAGIC_D ) ); - SwWW8Writer::WriteLong( *rWrt.pDataStrm, 2*sURL.Len()+6); - SwWW8Writer::WriteLong( *rWrt.pDataStrm, 2*sURL.Len()); - SwWW8Writer::WriteShort( *rWrt.pDataStrm, 3 ); - SwWW8Writer::WriteString16(*rWrt.pDataStrm, sURL, false); + SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 2*sURL.Len() + 6 ); + SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 2*sURL.Len() ); + SwWW8Writer::WriteShort( *m_rWW8Export.pDataStrm, 3 ); + SwWW8Writer::WriteString16( *m_rWW8Export.pDataStrm, sURL, false ); } - else if (eProto != INET_PROT_NOT_VALID) + else if ( eProto != INET_PROT_NOT_VALID ) { // version 2 (simple url) // an write some data to the data stream, but dont ask @@ -981,23 +970,31 @@ void WW8_AttrIter::StartURL(const String &rUrl, const String &rTarget) 0x8C,0x82,0x00,0xAA,0x00,0x4B,0xA9,0x0B }; - rWrt.pDataStrm->Write( MAGIC_B, sizeof(MAGIC_B) ); - SwWW8Writer::WriteLong( *rWrt.pDataStrm, 2 * (sURL.Len()+1) ); - SwWW8Writer::WriteString16( *rWrt.pDataStrm, sURL, true); + m_rWW8Export.pDataStrm->Write( MAGIC_B, sizeof(MAGIC_B) ); + SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, 2 * ( sURL.Len() + 1 ) ); + SwWW8Writer::WriteString16( *m_rWW8Export.pDataStrm, sURL, true ); } - if (sMark.Len()) + if ( sMark.Len() ) { - SwWW8Writer::WriteLong( *rWrt.pDataStrm, sMark.Len()+1 ); - SwWW8Writer::WriteString16( *rWrt.pDataStrm, sMark, true); + SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, sMark.Len()+1 ); + SwWW8Writer::WriteString16( *m_rWW8Export.pDataStrm, sMark, true ); } - SwWW8Writer::WriteLong( *rWrt.pDataStrm, nDataStt, - rWrt.pDataStrm->Tell() - nDataStt ); + SwWW8Writer::WriteLong( *m_rWW8Export.pDataStrm, nDataStt, + m_rWW8Export.pDataStrm->Tell() - nDataStt ); + + return true; } -void WW8_AttrIter::EndURL() +bool WW8AttributeOutput::EndURL() { - rWrt.OutField(0, ww::eHYPERLINK, aEmptyStr, WRITEFIELD_CLOSE); + // hyperlinks only in WW8 + if ( !m_rWW8Export.bWrtWW8 ) + return false; + + m_rWW8Export.OutputField( 0, ww::eHYPERLINK, aEmptyStr, WRITEFIELD_CLOSE ); + + return true; } String BookmarkToWord(const String &rBookmark) @@ -1014,21 +1011,21 @@ String BookmarkToWriter(const String &rBookmark) INetURLObject::DECODE_UNAMBIGUOUS, RTL_TEXTENCODING_ASCII_US); } -void WW8_SwAttrIter::OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool) +void SwAttrIter::OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool) { - if( rWrt.HasRefToObject( REF_SETREFATTR, &rAttr.GetRefName(), 0 )) - rWrt.AppendBookmark( rWrt.GetBookmarkName( REF_SETREFATTR, + if ( m_rExport.HasRefToObject( REF_SETREFATTR, &rAttr.GetRefName(), 0 ) ) + m_rExport.AppendBookmark( m_rExport.GetBookmarkName( REF_SETREFATTR, &rAttr.GetRefName(), 0 )); } -void WW8_SwAttrIter::FieldVanish( const String& rTxt ) +void WW8AttributeOutput::FieldVanish( const String& rTxt, ww::eField /*eType*/ ) { WW8Bytes aItems; - rWrt.GetCurrentItems(aItems); + m_rWW8Export.GetCurrentItems( aItems ); // sprmCFFldVanish - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( aItems, 0x802 ); + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFFldVanish ); else aItems.Insert( 67, aItems.Count() ); aItems.Insert( 1, aItems.Count() ); @@ -1036,158 +1033,153 @@ void WW8_SwAttrIter::FieldVanish( const String& rTxt ) USHORT nStt_sprmCFSpec = aItems.Count(); // sprmCFSpec -- fSpec-Attribut true - if( rWrt.bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) SwWW8Writer::InsUInt16( aItems, 0x855 ); else aItems.Insert( 117, aItems.Count() ); aItems.Insert( 1, aItems.Count() ); - rWrt.WriteChar( '\x13' ); - rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), aItems.Count(), + m_rWW8Export.WriteChar( '\x13' ); + m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), aItems.Count(), aItems.GetData() ); - rWrt.OutSwString( rTxt, 0, rTxt.Len(), rWrt.IsUnicode(), + m_rWW8Export.OutSwString( rTxt, 0, rTxt.Len(), m_rWW8Export.IsUnicode(), RTL_TEXTENCODING_MS_1252 ); - rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), nStt_sprmCFSpec, + m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), nStt_sprmCFSpec, aItems.GetData() ); - rWrt.WriteChar( '\x15' ); - rWrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), aItems.Count(), + m_rWW8Export.WriteChar( '\x15' ); + m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), aItems.Count(), aItems.GetData() ); } -void WW8_SwAttrIter::OutSwTOXMark(const SwTOXMark& rAttr, - bool -#ifndef PRODUCT - bStart -#endif - ) +void AttributeOutputBase::TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAttr ) { // its a field; so get the Text form the Node and build the field -#ifndef PRODUCT - ASSERT( bStart, "calls only with the startposition!" ); -#endif String sTxt; + ww::eField eType = ww::eNONE; const SwTxtTOXMark& rTxtTOXMark = *rAttr.GetTxtTOXMark(); const xub_StrLen* pTxtEnd = rTxtTOXMark.GetEnd(); - if( pTxtEnd ) // has range? - sTxt = rNd.GetExpandTxt( *rTxtTOXMark.GetStart(), - *pTxtEnd - *rTxtTOXMark.GetStart() ); + if ( pTxtEnd ) // has range? + { + sTxt = rNode.GetExpandTxt( *rTxtTOXMark.GetStart(), + *pTxtEnd - *rTxtTOXMark.GetStart() ); + } else sTxt = rAttr.GetAlternativeText(); - switch( rAttr.GetTOXType()->GetType() ) + switch ( rAttr.GetTOXType()->GetType() ) { - case TOX_INDEX: - if( rAttr.GetPrimaryKey().Len() ) - { - if ( rAttr.GetSecondaryKey( ).Len( ) ) + case TOX_INDEX: + eType = ww::eXE; + if ( rAttr.GetPrimaryKey().Len() ) { + if ( rAttr.GetSecondaryKey().Len() ) + { + sTxt.Insert( ':', 0 ); + sTxt.Insert( rAttr.GetSecondaryKey(), 0 ); + } + sTxt.Insert( ':', 0 ); - sTxt.Insert( rAttr.GetSecondaryKey(), 0 ); + sTxt.Insert( rAttr.GetPrimaryKey(), 0 ); } + sTxt.InsertAscii( " XE \"", 0 ); + sTxt.InsertAscii( "\" " ); + break; - sTxt.Insert( ':', 0 ); - sTxt.Insert( rAttr.GetPrimaryKey(), 0 ); - } - sTxt.InsertAscii( " XE \"", 0 ); - sTxt.InsertAscii( "\" " ); - break; - - case TOX_USER: - ( sTxt.APPEND_CONST_ASC( "\" \\f \"" )) - += (sal_Char)( 'A' + rWrt.GetId( *rAttr.GetTOXType() )); - // kein break; - case TOX_CONTENT: - { - sTxt.InsertAscii( " TC \"", 0 ); - USHORT nLvl = rAttr.GetLevel(); - if (nLvl > WW8ListManager::nMaxLevel) - nLvl = WW8ListManager::nMaxLevel; - - ((sTxt.APPEND_CONST_ASC( "\" \\l " )) - += String::CreateFromInt32( nLvl )) += ' '; - } - break; - default: - ASSERT(!this, "Unhandled option for toc export"); - break; + case TOX_USER: + ( sTxt.APPEND_CONST_ASC( "\" \\f \"" ) ) + += (sal_Char)( 'A' + GetExport( ).GetId( *rAttr.GetTOXType() ) ); + // fall through - no break; + case TOX_CONTENT: + { + eType = ww::eTC; + sTxt.InsertAscii( " TC \"", 0 ); + USHORT nLvl = rAttr.GetLevel(); + if (nLvl > WW8ListManager::nMaxLevel) + nLvl = WW8ListManager::nMaxLevel; + + ((sTxt.APPEND_CONST_ASC( "\" \\l " )) + += String::CreateFromInt32( nLvl )) += ' '; + } + break; + default: + ASSERT( !this, "Unhandled option for toc export" ); + break; } - if( sTxt.Len() ) - FieldVanish( sTxt ); + if ( sTxt.Len() ) + FieldVanish( sTxt, eType ); } -int WW8_SwAttrIter::OutAttrWithRange(xub_StrLen nPos) +int SwAttrIter::OutAttrWithRange(xub_StrLen nPos) { int nRet = 0; - if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) + if ( const SwpHints* pTxtAttrs = rNd.GetpSwpHints() ) { - rWrt.push_charpropstart(nPos); + m_rExport.m_aCurrentCharPropStarts.push( nPos ); const xub_StrLen* pEnd; - for (USHORT i = 0; i < pTxtAttrs->Count(); ++i ) + for ( USHORT i = 0; i < pTxtAttrs->Count(); ++i ) { const SwTxtAttr* pHt = (*pTxtAttrs)[i]; const SfxPoolItem* pItem = &pHt->GetAttr(); - switch( pItem->Which() ) + switch ( pItem->Which() ) { - case RES_TXTATR_INETFMT: - if( rWrt.bWrtWW8 ) // nur WW8 kann Hyperlinks - { - if( nPos == *pHt->GetStart() ) + case RES_TXTATR_INETFMT: + if ( nPos == *pHt->GetStart() ) + { + const SwFmtINetFmt *rINet = static_cast< const SwFmtINetFmt* >( pItem ); + if ( m_rExport.AttrOutput().StartURL( rINet->GetValue(), rINet->GetTargetFrame() ) ) + ++nRet; + } + if ( 0 != ( pEnd = pHt->GetEnd() ) && nPos == *pEnd ) + { + if ( m_rExport.AttrOutput().EndURL() ) + --nRet; + } + break; + case RES_TXTATR_REFMARK: + if ( nPos == *pHt->GetStart() ) { - OutSwFmtINetFmt((SwFmtINetFmt&)*pItem, true); + OutSwFmtRefMark( *static_cast< const SwFmtRefMark* >( pItem ), true ); ++nRet; } - if( 0 != ( pEnd = pHt->GetEnd() ) && nPos == *pEnd ) + if ( 0 != ( pEnd = pHt->GetEnd() ) && nPos == *pEnd ) { - OutSwFmtINetFmt((SwFmtINetFmt&)*pItem, false); + OutSwFmtRefMark( *static_cast< const SwFmtRefMark* >( pItem ), false ); --nRet; } - } - break; - case RES_TXTATR_REFMARK: - if( nPos == *pHt->GetStart() ) - { - OutSwFmtRefMark((SwFmtRefMark&)*pItem, true); - ++nRet; - } - if( 0 != ( pEnd = pHt->GetEnd() ) && nPos == *pEnd ) - { - OutSwFmtRefMark((SwFmtRefMark&)*pItem, false); - --nRet; - } - break; - case RES_TXTATR_TOXMARK: - if (nPos == *pHt->GetStart()) - OutSwTOXMark((SwTOXMark&)*pItem, true); - break; - case RES_TXTATR_CJK_RUBY: - if( nPos == *pHt->GetStart() ) - { - OutSwFmtRuby((SwFmtRuby&)*pItem, true); - ++nRet; - } - if( 0 != ( pEnd = pHt->GetEnd() ) && nPos == *pEnd ) - { - OutSwFmtRuby((SwFmtRuby&)*pItem, false); - --nRet; - } - break; + break; + case RES_TXTATR_TOXMARK: + if ( nPos == *pHt->GetStart() ) + m_rExport.AttrOutput().TOXMark( rNd, *static_cast< const SwTOXMark* >( pItem ) ); + break; + case RES_TXTATR_CJK_RUBY: + if ( nPos == *pHt->GetStart() ) + { + m_rExport.AttrOutput().StartRuby( rNd, *static_cast< const SwFmtRuby* >( pItem ) ); + ++nRet; + } + if ( 0 != ( pEnd = pHt->GetEnd() ) && nPos == *pEnd ) + { + m_rExport.AttrOutput().EndRuby(); + --nRet; + } + break; } } - rWrt.pop_charpropstart();//HasTextItem nur in dem obigen Bereich erlaubt + m_rExport.m_aCurrentCharPropStarts.pop(); // HasTextItem nur in dem obigen Bereich erlaubt } return nRet; } -bool WW8_SwAttrIter::IsRedlineAtEnd( xub_StrLen nEnd ) const +bool SwAttrIter::IsRedlineAtEnd( xub_StrLen nEnd ) const { bool bRet = false; // search next Redline for( USHORT nPos = nCurRedlinePos; - nPos < rWrt.pDoc->GetRedlineTbl().Count(); ++nPos ) + nPos < m_rExport.pDoc->GetRedlineTbl().Count(); ++nPos ) { - const SwPosition* pEnd = rWrt.pDoc->GetRedlineTbl()[ nPos ]->End(); + const SwPosition* pEnd = m_rExport.pDoc->GetRedlineTbl()[ nPos ]->End(); if( pEnd->nNode == rNd ) { if( pEnd->nContent.GetIndex() == nEnd ) @@ -1202,7 +1194,7 @@ bool WW8_SwAttrIter::IsRedlineAtEnd( xub_StrLen nEnd ) const return bRet; } -void WW8_SwAttrIter::OutRedlines( xub_StrLen nPos ) +const SwRedlineData* SwAttrIter::GetRedline( xub_StrLen nPos ) { if( pCurRedline ) { @@ -1214,17 +1206,19 @@ void WW8_SwAttrIter::OutRedlines( xub_StrLen nPos ) ++nCurRedlinePos; } else + { // write data of current redline - rWrt.OutRedline( pCurRedline->GetRedlineData() ); + return &( pCurRedline->GetRedlineData() ); + } } if( !pCurRedline ) { // search next Redline - for( ; nCurRedlinePos < rWrt.pDoc->GetRedlineTbl().Count(); + for( ; nCurRedlinePos < m_rExport.pDoc->GetRedlineTbl().Count(); ++nCurRedlinePos ) { - const SwRedline* pRedl = rWrt.pDoc->GetRedlineTbl()[ nCurRedlinePos ]; + const SwRedline* pRedl = m_rExport.pDoc->GetRedlineTbl()[ nCurRedlinePos ]; const SwPosition* pStt = pRedl->Start(); const SwPosition* pEnd = pStt == pRedl->GetPoint() @@ -1239,7 +1233,7 @@ void WW8_SwAttrIter::OutRedlines( xub_StrLen nPos ) { // write data of this redline pCurRedline = pRedl; - rWrt.OutRedline( pCurRedline->GetRedlineData() ); + return &( pCurRedline->GetRedlineData() ); } break; } @@ -1255,34 +1249,62 @@ void WW8_SwAttrIter::OutRedlines( xub_StrLen nPos ) } } } + return NULL; } /* */ -short SwWW8Writer::GetCurrentPageDirection() const +short MSWordExportBase::GetCurrentPageDirection() const { const SwFrmFmt &rFmt = pAktPageDesc ? pAktPageDesc->GetMaster() - : const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetMaster(); + : const_cast<const SwDoc *>( pDoc )->GetPageDesc( 0 ).GetMaster(); return rFmt.GetFrmDir().GetValue(); } -short SwWW8Writer::TrueFrameDirection(const SwFrmFmt &rFlyFmt) const +short MSWordExportBase::GetDefaultFrameDirection( ) const +{ + short nDir = FRMDIR_ENVIRONMENT; + + if ( bOutPageDescs ) + nDir = GetCurrentPageDirection( ); + else if ( pOutFmtNode ) + { + if ( bOutFlyFrmAttrs ) //frame + { + nDir = TrueFrameDirection( *( const SwFrmFmt * ) pOutFmtNode ); + } + else if ( pOutFmtNode->ISA( SwCntntNode ) ) //pagagraph + { + const SwCntntNode *pNd = ( const SwCntntNode * ) pOutFmtNode; + SwPosition aPos( *pNd ); + nDir = pDoc->GetTextDirection( aPos ); + } + else if ( pOutFmtNode->ISA( SwTxtFmtColl ) ) + nDir = FRMDIR_HORI_LEFT_TOP; //what else can we do :-( + } + + if ( nDir == FRMDIR_ENVIRONMENT ) + nDir = FRMDIR_HORI_LEFT_TOP; //Set something + + return nDir; +} + +short MSWordExportBase::TrueFrameDirection( const SwFrmFmt &rFlyFmt ) const { const SwFrmFmt *pFlyFmt = &rFlyFmt; const SvxFrameDirectionItem* pItem = 0; - while (pFlyFmt) + while ( pFlyFmt ) { pItem = &pFlyFmt->GetFrmDir(); - if (FRMDIR_ENVIRONMENT == pItem->GetValue()) + if ( FRMDIR_ENVIRONMENT == pItem->GetValue() ) { pItem = 0; const SwFmtAnchor* pAnchor = &pFlyFmt->GetAnchor(); - if (FLY_PAGE != pAnchor->GetAnchorId() && - pAnchor->GetCntntAnchor()) + if ( FLY_PAGE != pAnchor->GetAnchorId() && + pAnchor->GetCntntAnchor() ) { - pFlyFmt = - pAnchor->GetCntntAnchor()->nNode.GetNode().GetFlyFmt(); + pFlyFmt = pAnchor->GetCntntAnchor()->nNode.GetNode().GetFlyFmt(); } else pFlyFmt = 0; @@ -1292,16 +1314,16 @@ short SwWW8Writer::TrueFrameDirection(const SwFrmFmt &rFlyFmt) const } short nRet; - if (pItem) + if ( pItem ) nRet = pItem->GetValue(); else nRet = GetCurrentPageDirection(); - ASSERT(nRet != FRMDIR_ENVIRONMENT, "leaving with environment direction"); + ASSERT( nRet != FRMDIR_ENVIRONMENT, "leaving with environment direction" ); return nRet; } -const SvxBrushItem* SwWW8Writer::GetCurrentPageBgBrush() const +const SvxBrushItem* WW8Export::GetCurrentPageBgBrush() const { const SwFrmFmt &rFmt = pAktPageDesc ? pAktPageDesc->GetMaster() @@ -1320,7 +1342,7 @@ const SvxBrushItem* SwWW8Writer::GetCurrentPageBgBrush() const return pRet; } -SvxBrushItem SwWW8Writer::TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const +SvxBrushItem WW8Export::TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const { const SwFrmFmt *pFlyFmt = &rFlyFmt; const SvxBrushItem* pRet = 0; @@ -1367,7 +1389,7 @@ Convert characters that need to be converted, the basic replacements and the ridicously complicated title case attribute mapping to hardcoded upper case because word doesn't have the feature */ -String WW8_SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, +String SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, xub_StrLen nLen) const { String aSnippet(rStr, nAktPos, nLen); @@ -1381,14 +1403,14 @@ String WW8_SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, aSnippet.SearchAndReplaceAll(CHAR_HARDHYPHEN, 0x1e); aSnippet.SearchAndReplaceAll(CHAR_SOFTHYPHEN, 0x1f); - rWrt.push_charpropstart(nAktPos); + m_rExport.m_aCurrentCharPropStarts.push( nAktPos ); const SfxPoolItem &rItem = GetItem(RES_CHRATR_CASEMAP); if (SVX_CASEMAP_TITEL == ((const SvxCaseMapItem&)rItem).GetValue()) { sal_uInt16 nScriptType = i18n::ScriptType::LATIN; - if (pBreakIt->xBreak.is()) - nScriptType = pBreakIt->xBreak->getScriptType(aSnippet, 0); + if (pBreakIt->GetBreakIter().is()) + nScriptType = pBreakIt->GetBreakIter()->getScriptType(aSnippet, 0); LanguageType nLanguage; switch (nScriptType) @@ -1413,14 +1435,14 @@ String WW8_SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, //If we weren't at the begin of a word undo the case change. //not done before doing the casemap because the sequence might start //with whitespace - if (pBreakIt->xBreak.is() && !pBreakIt->xBreak->isBeginWord( + if (pBreakIt->GetBreakIter().is() && !pBreakIt->GetBreakIter()->isBeginWord( rStr, nAktPos, pBreakIt->GetLocale(nLanguage), i18n::WordType::ANYWORD_IGNOREWHITESPACES ) ) { aSnippet.SetChar(0, rStr.GetChar(nAktPos)); } } - rWrt.pop_charpropstart(); + m_rExport.m_aCurrentCharPropStarts.pop(); return aSnippet; } @@ -1431,14 +1453,13 @@ String WW8_SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, the track changes have to be analysed. A deletion, starting in paragraph A with style A, ending in paragraph B with style B, needs a hack. */ - -SwTxtFmtColl& lcl_getFormatCollection( Writer& rWrt, SwTxtNode* pTxtNode ) +static SwTxtFmtColl& lcl_getFormatCollection( MSWordExportBase& rExport, const SwTxtNode* pTxtNode ) { USHORT nPos = 0; - USHORT nMax = rWrt.pDoc->GetRedlineTbl().Count(); + USHORT nMax = rExport.pDoc->GetRedlineTbl().Count(); while( nPos < nMax ) { - const SwRedline* pRedl = rWrt.pDoc->GetRedlineTbl()[ nPos++ ]; + const SwRedline* pRedl = rExport.pDoc->GetRedlineTbl()[ nPos++ ]; const SwPosition* pStt = pRedl->Start(); const SwPosition* pEnd = pStt == pRedl->GetPoint() ? pRedl->GetMark() @@ -1456,47 +1477,162 @@ SwTxtFmtColl& lcl_getFormatCollection( Writer& rWrt, SwTxtNode* pTxtNode ) return static_cast<SwTxtFmtColl&>( pTxtNode->GetAnyFmtColl() ); } -Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) +void WW8AttributeOutput::FormatDrop( const SwTxtNode& rNode, const SwFmtDrop &rSwFmtDrop, USHORT nStyle, + ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) { -#ifdef DEBUG - ::std::clog << "<OutWW8_SwTxtNode>" << ::std::endl; + short nDropLines = rSwFmtDrop.GetLines(); + short nDistance = rSwFmtDrop.GetDistance(); + int rFontHeight, rDropHeight, rDropDescent; + + SVBT16 nSty; + ShortToSVBT16( nStyle, nSty ); + m_rWW8Export.pO->Insert( (BYTE*)&nSty, 2, m_rWW8Export.pO->Count() ); // Style # + + if ( m_rWW8Export.bWrtWW8 ) + { + m_rWW8Export.InsUInt16( NS_sprm::LN_PPc ); // Alignment (sprmPPc) + m_rWW8Export.pO->Insert( 0x20, m_rWW8Export.pO->Count() ); + + m_rWW8Export.InsUInt16( NS_sprm::LN_PWr ); // Wrapping (sprmPWr) + m_rWW8Export.pO->Insert( 0x02, m_rWW8Export.pO->Count() ); + + m_rWW8Export.InsUInt16( NS_sprm::LN_PDcs ); // Dropcap (sprmPDcs) + int nDCS = ( nDropLines << 3 ) | 0x01; + m_rWW8Export.InsUInt16( static_cast< UINT16 >( nDCS ) ); + + m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaFromText ); // Distance from text (sprmPDxaFromText) + m_rWW8Export.InsUInt16( nDistance ); + + if ( rNode.GetDropSize( rFontHeight, rDropHeight, rDropDescent ) ) + { + m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaLine ); // Line spacing + m_rWW8Export.InsUInt16( static_cast< UINT16 >( -rDropHeight ) ); + m_rWW8Export.InsUInt16( 0 ); + } + } + else + { + m_rWW8Export.pO->Insert( 29, m_rWW8Export.pO->Count() ); // Alignment (sprmPPc) + m_rWW8Export.pO->Insert( 0x20, m_rWW8Export.pO->Count() ); + + m_rWW8Export.pO->Insert( 37, m_rWW8Export.pO->Count() ); // Wrapping (sprmPWr) + m_rWW8Export.pO->Insert( 0x02, m_rWW8Export.pO->Count() ); + + m_rWW8Export.pO->Insert( 46, m_rWW8Export.pO->Count() ); // Dropcap (sprmPDcs) + int nDCS = ( nDropLines << 3 ) | 0x01; + m_rWW8Export.InsUInt16( static_cast< UINT16 >( nDCS ) ); + + m_rWW8Export.pO->Insert( 49, m_rWW8Export.pO->Count() ); // Distance from text (sprmPDxaFromText) + m_rWW8Export.InsUInt16( nDistance ); + + if (rNode.GetDropSize(rFontHeight, rDropHeight, rDropDescent)) + { + m_rWW8Export.pO->Insert( 20, m_rWW8Export.pO->Count() ); // Line spacing + m_rWW8Export.InsUInt16( static_cast< UINT16 >( -rDropHeight ) ); + m_rWW8Export.InsUInt16( 0 ); + } + } + + m_rWW8Export.WriteCR( pTextNodeInfoInner ); + + if ( pTextNodeInfo.get() != NULL ) + { +#ifdef DEBUG + ::std::clog << pTextNodeInfo->toString() << ::std::endl; #endif - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - SwTxtNode* pNd = &((SwTxtNode&)rNode); + TableInfoCell( pTextNodeInfoInner ); + } - bool bFlyInTable = rWW8Wrt.mpParentFrame && rWW8Wrt.bIsInTable; + m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), m_rWW8Export.pO->GetData() ); + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); - // akt. Style - if( !bFlyInTable ) + if ( rNode.GetDropSize( rFontHeight, rDropHeight, rDropDescent ) ) { - rWW8Wrt.nStyleBeforeFly - = rWW8Wrt.GetId( lcl_getFormatCollection( rWrt, pNd ) ); + if ( m_rWW8Export.bWrtWW8 ) + { + const SwCharFmt *pSwCharFmt = rSwFmtDrop.GetCharFmt(); + if ( pSwCharFmt ) + { + m_rWW8Export.InsUInt16( NS_sprm::LN_CIstd ); + m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *pSwCharFmt ) ); + } + + m_rWW8Export.InsUInt16( NS_sprm::LN_CHpsPos ); // Lower the chars + m_rWW8Export.InsUInt16( static_cast< UINT16 >( -((nDropLines - 1)*rDropDescent) / 10 ) ); + + m_rWW8Export.InsUInt16( NS_sprm::LN_CHps ); // Font Size + m_rWW8Export.InsUInt16( static_cast< UINT16 >( rFontHeight / 10 ) ); + } + else + { + const SwCharFmt *pSwCharFmt = rSwFmtDrop.GetCharFmt(); + if ( pSwCharFmt ) + { + m_rWW8Export.InsUInt16( 80 ); + m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *pSwCharFmt ) ); + } + + m_rWW8Export.pO->Insert( 101, m_rWW8Export.pO->Count() ); // Lower the chars + m_rWW8Export.InsUInt16( static_cast< UINT16 >( -((nDropLines - 1)*rDropDescent) / 10 ) ); + + m_rWW8Export.pO->Insert( 99, m_rWW8Export.pO->Count() ); // Font Size + m_rWW8Export.InsUInt16( static_cast< UINT16 >( rFontHeight / 10 ) ); + } } - SVBT16 nSty; - ShortToSVBT16( rWW8Wrt.nStyleBeforeFly, nSty ); + m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), m_rWW8Export.pO->GetData() ); + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); +} + +xub_StrLen MSWordExportBase::GetNextPos( SwAttrIter* aAttrIter, const SwTxtNode& /*rNode*/, xub_StrLen /*nAktPos*/ ) +{ + return aAttrIter->WhereNext(); +} + +void MSWordExportBase::UpdatePosition( SwAttrIter* aAttrIter, xub_StrLen /*nAktPos*/, xub_StrLen /*nEnd*/ ) +{ + aAttrIter->NextPos(); +} + +void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode ) +{ +#ifdef DEBUG + ::std::clog << "<OutWW8_SwTxtNode>" << ::std::endl; +#endif + + ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo( mpTableInfo->getTableNodeInfo( &rNode ) ); + + AttrOutput().StartParagraph( pTextNodeInfo ); + + bool bFlyInTable = mpParentFrame && bIsInTable; - WW8Bytes* pO = rWW8Wrt.pO; - WW8_SwAttrIter aAttrIter( rWW8Wrt, *pNd ); + if ( !bFlyInTable ) + nStyleBeforeFly = GetId( lcl_getFormatCollection( *this, &rNode ) ); + + // nStyleBeforeFly may change when we recurse into another node, so we + // have to remember it in nStyle + USHORT nStyle = nStyleBeforeFly; + + SwAttrIter aAttrIter( *this, rNode ); rtl_TextEncoding eChrSet = aAttrIter.GetCharSet(); - if( rWW8Wrt.bStartTOX ) + if ( bStartTOX ) { // ignore TOX header section const SwSectionNode* pSectNd = rNode.FindSectionNode(); - if( TOX_CONTENT_SECTION == pSectNd->GetSection().GetType() ) + if ( pSectNd && TOX_CONTENT_SECTION == pSectNd->GetSection().GetType() ) { - rWW8Wrt.StartTOX( pSectNd->GetSection() ); - rWW8Wrt.push_charpropstart(0); + AttrOutput().StartTOX( pSectNd->GetSection() ); + m_aCurrentCharPropStarts.push( 0 ); } } const SwSection* pTOXSect = 0; - if( rWW8Wrt.bInWriteTOX ) + if( bInWriteTOX ) { // check for end of TOX - SwNodeIndex aIdx( *pNd, 1 ); + SwNodeIndex aIdx( rNode, 1 ); if( !aIdx.GetNode().IsTxtNode() ) { const SwSectionNode* pTOXSectNd = rNode.FindSectionNode(); @@ -1508,349 +1644,221 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) } } - if (aAttrIter.RequiresImplicitBookmark()) + if ( aAttrIter.RequiresImplicitBookmark() ) { - String sBkmkName = String(RTL_CONSTASCII_STRINGPARAM("_toc")); - sBkmkName += String::CreateFromInt32(pNd->GetIndex()); - rWW8Wrt.AddBookmark(sBkmkName); + String sBkmkName = String( RTL_CONSTASCII_STRINGPARAM( "_toc" ) ); + sBkmkName += String::CreateFromInt32( rNode.GetIndex() ); + AppendWordBookmark( sBkmkName ); } - ASSERT( !pO->Count(), " pO ist am Zeilenanfang nicht leer" ); - - String aStr( pNd->GetTxt() ); + //Would need to move into WW8Export, probably not worth it + //ASSERT( pO->Count(), " pO ist am Zeilenanfang nicht leer" ); - ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo(rWW8Wrt.mpTableInfo->getTableNodeInfo(pNd)); - ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner; - - if (pTextNodeInfo.get() != NULL) - pTextNodeInfoInner = pTextNodeInfo->getFirstInner(); + String aStr( rNode.GetTxt() ); xub_StrLen nAktPos = 0; xub_StrLen nEnd = aStr.Len(); - bool bUnicode = rWW8Wrt.bWrtWW8, bRedlineAtEnd = false; + bool bRedlineAtEnd = false; int nOpenAttrWithRange = 0; + ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner; + if ( pTextNodeInfo.get() != NULL ) + pTextNodeInfoInner = pTextNodeInfo->getFirstInner(); + do { - xub_StrLen nNextAttr = aAttrIter.WhereNext(); + const SwRedlineData* pRedlineData = aAttrIter.GetRedline( nAktPos ); + + AttrOutput().StartRun( pRedlineData ); + + xub_StrLen nNextAttr = GetNextPos( &aAttrIter, rNode, nAktPos ); if( nNextAttr > nEnd ) nNextAttr = nEnd; - aAttrIter.OutFlys(nAktPos); + aAttrIter.OutFlys( nAktPos ); //Append bookmarks in this range after flys, exclusive of final //position of this range - rWW8Wrt.AppendBookmarks( *pNd, nAktPos, nNextAttr - nAktPos ); + AppendBookmarks( rNode, nAktPos, nNextAttr - nAktPos ); bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos ); nOpenAttrWithRange += aAttrIter.OutAttrWithRange(nAktPos); xub_StrLen nLen = nNextAttr - nAktPos; - if (!bTxtAtr && nLen) - { - sal_Unicode ch=aStr.GetChar(nAktPos); - int ofs=(ch==CH_TXT_ATR_FIELDSTART || ch==CH_TXT_ATR_FIELDEND || ch==CH_TXT_ATR_FORMELEMENT?1:0); - IDocumentMarkAccess* const pMarkAccess = rWW8Wrt.pDoc->getIDocumentMarkAccess(); - if(ch==CH_TXT_ATR_FIELDSTART) - { - SwPosition aPosition(*pNd, SwIndex((SwTxtNode*)pNd, nAktPos+1)); - ::sw::mark::IFieldmark const * const pFieldmark=pMarkAccess->getFieldmarkFor(aPosition); - OSL_ENSURE(pFieldmark, - "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??"); - if(pFieldmark) - rWW8Wrt.AppendBookmark(pFieldmark->GetName(), 1); - rWW8Wrt.OutField(NULL, ww::eFORMTEXT, String::CreateFromAscii(" FORMTEXT "), WRITEFIELD_START | WRITEFIELD_CMD_START); - if(pFieldmark) - rWW8Wrt.WriteFormData(*pFieldmark); - rWW8Wrt.OutField(NULL, ww::eFORMTEXT, String(), WRITEFIELD_CMD_END); - } - else if (ch==CH_TXT_ATR_FIELDEND) - { - SwPosition aPosition(*pNd, SwIndex((SwTxtNode*)pNd, nAktPos)); - ::sw::mark::IFieldmark const * const pFieldmark=pMarkAccess->getFieldmarkFor(aPosition); - OSL_ENSURE(pFieldmark, - "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??"); - rWW8Wrt.OutField(NULL, ww::eFORMTEXT, String(), WRITEFIELD_CLOSE); - if (pFieldmark) - rWW8Wrt.AppendBookmark(pFieldmark->GetName(), 0); - } - else if (ch==CH_TXT_ATR_FORMELEMENT) - { - SwPosition aPosition(*pNd, SwIndex((SwTxtNode*)pNd, nAktPos)); - ::sw::mark::IFieldmark const * const pFieldmark=pMarkAccess->getFieldmarkFor(aPosition); - OSL_ENSURE(pFieldmark, - "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??"); - if(pFieldmark) - rWW8Wrt.AppendBookmark(pFieldmark->GetName(), 1); - rWW8Wrt.OutField(NULL, ww::eFORMCHECKBOX, String::CreateFromAscii(" FORMCHECKBOX "), WRITEFIELD_START | WRITEFIELD_CMD_START); - if(pFieldmark) - rWW8Wrt.WriteFormData(*pFieldmark); - rWW8Wrt.OutField(NULL, ww::eFORMCHECKBOX, String(), WRITEFIELD_CMD_END | WRITEFIELD_CLOSE); - if(pFieldmark) - rWW8Wrt.AppendBookmark(pFieldmark->GetName(), 0); - } - nLen-=static_cast<USHORT>(ofs); - String aSnippet(aAttrIter.GetSnippet(aStr, nAktPos+static_cast<USHORT>(ofs), nLen)); - if ((rWW8Wrt.nTxtTyp == TXT_EDN || rWW8Wrt.nTxtTyp == TXT_FTN) && nAktPos ==0 && nLen>0) - { - // Insert tab for aesthetic puposes #i24762# - if (aSnippet.GetChar(0) != 0x09) - { - nLen++; - aSnippet.Insert(0x09,0); - } - } - rWW8Wrt.OutSwString(aSnippet, 0, nLen, bUnicode, eChrSet); - } - - if (aAttrIter.IsDropCap(nNextAttr)) + if ( !bTxtAtr && nLen ) { + sal_Unicode ch = aStr.GetChar( nAktPos ); + int ofs = ( ch == CH_TXT_ATR_FIELDSTART || ch == CH_TXT_ATR_FIELDEND || ch == CH_TXT_ATR_FORMELEMENT? 1: 0 ); - const SwFmtDrop &rSwFmtDrop = aAttrIter.GetSwFmtDrop(); - short nDropLines = rSwFmtDrop.GetLines(); - short nDistance = rSwFmtDrop.GetDistance(); - int rFontHeight, rDropHeight, rDropDescent; - - pO->Insert( (BYTE*)&nSty, 2, pO->Count() ); // Style # - - if (rWW8Wrt.bWrtWW8) + IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess(); + if ( ch == CH_TXT_ATR_FIELDSTART ) { - rWW8Wrt.InsUInt16( 0x261b ); // Alignment (sprmPPc) - rWW8Wrt.pO->Insert( 0x20, rWW8Wrt.pO->Count() ); - - rWW8Wrt.InsUInt16( 0x2423 ); // Wrapping (sprmPWr) - rWW8Wrt.pO->Insert( 0x02, rWW8Wrt.pO->Count() ); - - rWW8Wrt.InsUInt16( 0x442c ); // Dropcap (sprmPDcs) - int nDCS = (nDropLines << 3) | 0x01; - rWW8Wrt.InsUInt16( static_cast< UINT16 >(nDCS) ); - - rWW8Wrt.InsUInt16( 0x842F ); // Distance from text (sprmPDxaFromText) - rWW8Wrt.InsUInt16( nDistance ); - - if (pNd->GetDropSize(rFontHeight, rDropHeight, rDropDescent)) - { - rWW8Wrt.InsUInt16( 0x6412 ); // Line spacing - rWW8Wrt.InsUInt16( static_cast< UINT16 >(-rDropHeight) ); - rWW8Wrt.InsUInt16( 0 ); - } + SwPosition aPosition( rNode, SwIndex( const_cast< SwTxtNode* >( &rNode ), nAktPos + 1 ) ); + ::sw::mark::IFieldmark const * const pFieldmark = pMarkAccess->getFieldmarkFor( aPosition ); + OSL_ENSURE( pFieldmark, "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??" ); + + if ( pFieldmark ) + AppendBookmark( pFieldmark->GetName(), true ); + OutputField( NULL, ww::eFORMTEXT, String::CreateFromAscii( " FORMTEXT " ), WRITEFIELD_START | WRITEFIELD_CMD_START ); + if ( pFieldmark ) + WriteFormData( *pFieldmark ); + OutputField( NULL, ww::eFORMTEXT, String(), WRITEFIELD_CMD_END ); } - else + else if ( ch == CH_TXT_ATR_FIELDEND ) { - rWW8Wrt.pO->Insert( 29, rWW8Wrt.pO->Count() ); // Alignment (sprmPPc) - rWW8Wrt.pO->Insert( 0x20, rWW8Wrt.pO->Count() ); - - rWW8Wrt.pO->Insert( 37, rWW8Wrt.pO->Count() ); // Wrapping (sprmPWr) - rWW8Wrt.pO->Insert( 0x02, rWW8Wrt.pO->Count() ); - - rWW8Wrt.pO->Insert( 46, rWW8Wrt.pO->Count() ); // Dropcap (sprmPDcs) - int nDCS = (nDropLines << 3) | 0x01; - rWW8Wrt.InsUInt16( static_cast< UINT16 >(nDCS) ); + SwPosition aPosition( rNode, SwIndex( const_cast< SwTxtNode* >( &rNode ), nAktPos ) ); + ::sw::mark::IFieldmark const * const pFieldmark = pMarkAccess->getFieldmarkFor( aPosition ); + OSL_ENSURE( pFieldmark, "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??" ); - rWW8Wrt.pO->Insert( 49, rWW8Wrt.pO->Count() ); // Distance from text (sprmPDxaFromText) - rWW8Wrt.InsUInt16( nDistance ); - - if (pNd->GetDropSize(rFontHeight, rDropHeight, rDropDescent)) - { - rWW8Wrt.pO->Insert( 20, rWW8Wrt.pO->Count() ); // Line spacing - rWW8Wrt.InsUInt16( static_cast< UINT16 >(-rDropHeight) ); - rWW8Wrt.InsUInt16( 0 ); - } + OutputField( NULL, ww::eFORMTEXT, String(), WRITEFIELD_CLOSE ); + if ( pFieldmark ) + AppendBookmark( pFieldmark->GetName(), false ); } - - rWW8Wrt.WriteCR(pTextNodeInfoInner); - - if (pTextNodeInfo.get() != NULL) + else if ( ch == CH_TXT_ATR_FORMELEMENT ) { -#ifdef DEBUG - ::std::clog << pTextNodeInfo->toString() << ::std::endl; -#endif - - rWW8Wrt.OutWW8TableInfoCell(pTextNodeInfoInner); + SwPosition aPosition( rNode, SwIndex( const_cast< SwTxtNode* >( &rNode ), nAktPos ) ); + ::sw::mark::IFieldmark const * const pFieldmark = pMarkAccess->getFieldmarkFor( aPosition ); + OSL_ENSURE( pFieldmark, "Looks like this doc is broken...; where is the Fieldmark for the FIELDSTART??" ); + + if ( pFieldmark ) + AppendBookmark( pFieldmark->GetName(), true ); + OutputField( NULL, ww::eFORMCHECKBOX, String::CreateFromAscii( " FORMCHECKBOX " ), WRITEFIELD_START | WRITEFIELD_CMD_START ); + if ( pFieldmark ) + WriteFormData( *pFieldmark ); + OutputField( NULL, ww::eFORMCHECKBOX, String(), WRITEFIELD_CMD_END | WRITEFIELD_CLOSE ); + if ( pFieldmark ) + AppendBookmark( pFieldmark->GetName(), false ); } + nLen -= static_cast< USHORT >( ofs ); - rWW8Wrt.pPapPlc->AppendFkpEntry( rWrt.Strm().Tell(), pO->Count(), - pO->GetData() ); - pO->Remove( 0, pO->Count() ); - - if(pNd->GetDropSize(rFontHeight, rDropHeight, rDropDescent)) + String aSnippet( aAttrIter.GetSnippet( aStr, nAktPos + static_cast< USHORT >( ofs ), nLen ) ); + if ( ( nTxtTyp == TXT_EDN || nTxtTyp == TXT_FTN ) && nAktPos == 0 && nLen > 0 ) { - if (rWW8Wrt.bWrtWW8) - { - const SwCharFmt *pSwCharFmt = rSwFmtDrop.GetCharFmt(); - if(pSwCharFmt) - { - rWW8Wrt.InsUInt16( 0x4A30 ); - rWW8Wrt.InsUInt16( rWW8Wrt.GetId( *pSwCharFmt ) ); - } - - rWW8Wrt.InsUInt16( 0x4845 ); // Lower the chars - rWW8Wrt.InsUInt16( static_cast< UINT16 >(-((nDropLines - 1)*rDropDescent) / 10 )); - - rWW8Wrt.InsUInt16( 0x4a43 ); // Font Size - rWW8Wrt.InsUInt16( static_cast< UINT16 >(rFontHeight / 10) ); - } - else - { - const SwCharFmt *pSwCharFmt = rSwFmtDrop.GetCharFmt(); - if(pSwCharFmt) - { - rWW8Wrt.InsUInt16( 80 ); - rWW8Wrt.InsUInt16( rWW8Wrt.GetId( *pSwCharFmt ) ); - } - - rWW8Wrt.pO->Insert(101, rWW8Wrt.pO->Count() ); // Lower the chars - rWW8Wrt.InsUInt16( static_cast< UINT16 >(-((nDropLines - 1)*rDropDescent) / 10) ); - - rWW8Wrt.pO->Insert( 99, rWW8Wrt.pO->Count() ); // Font Size - rWW8Wrt.InsUInt16( static_cast< UINT16 >(rFontHeight / 10) ); - } + // Insert tab for aesthetic puposes #i24762# + if ( aSnippet.GetChar( 0 ) != 0x09 ) + aSnippet.Insert( 0x09, 0 ); } - - rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), - pO->Count(), pO->GetData() ); - pO->Remove( 0, pO->Count() ); + AttrOutput().RunText( aSnippet, eChrSet ); } - // Am Zeilenende werden die Attribute bis ueber das CR aufgezogen. - // Ausnahme: Fussnoten am Zeilenende - if (nNextAttr == nEnd) + if ( aAttrIter.IsDropCap( nNextAttr ) ) + AttrOutput().FormatDrop( rNode, aAttrIter.GetSwFmtDrop(), nStyle, pTextNodeInfo, pTextNodeInfoInner ); + + // At the end of line, output the attributes until the CR. + // Exception: footnotes at the end of line + if ( nNextAttr == nEnd ) { - ASSERT(nOpenAttrWithRange >= 0, - "odd to see this happening, expected >= 0"); - if (!bTxtAtr && nOpenAttrWithRange <= 0) + ASSERT( nOpenAttrWithRange >= 0, "odd to see this happening, expected >= 0" ); + if ( !bTxtAtr && nOpenAttrWithRange <= 0 ) { - if (aAttrIter.IsRedlineAtEnd(nEnd)) + if ( aAttrIter.IsRedlineAtEnd( nEnd ) ) bRedlineAtEnd = true; else { - //insert final graphic anchors if any before CR - aAttrIter.OutFlys(nEnd); - //insert final bookmarks if any before CR and after flys - rWW8Wrt.AppendBookmarks( *pNd, nEnd, 1 ); - if (pTOXSect) + // insert final graphic anchors if any before CR + aAttrIter.OutFlys( nEnd ); + // insert final bookmarks if any before CR and after flys + AppendBookmarks( rNode, nEnd, 1 ); + if ( pTOXSect ) { - rWW8Wrt.pop_charpropstart(); - rWW8Wrt.EndTOX(*pTOXSect); + m_aCurrentCharPropStarts.pop(); + AttrOutput().EndTOX( *pTOXSect ); } - rWW8Wrt.WriteCR(pTextNodeInfoInner); // CR danach + WriteCR( pTextNodeInfoInner ); } } } - - WW8_WrPlcFld* pCurrentFields = rWW8Wrt.CurrentFieldPlc(); - USHORT nOldFieldResults = pCurrentFields ? pCurrentFields->ResultCount() : 0; - - // Export of Character attributes - aAttrIter.OutAttr( nAktPos ); // nAktPos - 1 ?? - - pCurrentFields = rWW8Wrt.CurrentFieldPlc(); - USHORT nNewFieldResults = pCurrentFields ? pCurrentFields->ResultCount() : 0; - - bool bExportedFieldResult = nOldFieldResults != nNewFieldResults; - //If we have exported a field result, then we will have been forced to - //split up the text into a 0x13, 0x14, <result> 0x15 sequence with the - //properties forced out at the end of the result, so the 0x15 itself - //should remain clean of all other attributes to avoid #iXXXXX# - if (!bExportedFieldResult) - { - rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), - pO->Count(), pO->GetData() ); - } - pO->Remove( 0, pO->Count() ); // erase - - // Ausnahme: Fussnoten am Zeilenende - if (nNextAttr == nEnd) + + // Output the character attributes + AttrOutput().StartRunProperties(); + aAttrIter.OutAttr( nAktPos ); // nAktPos - 1 ?? + AttrOutput().EndRunProperties( pRedlineData ); + + // Exception: footnotes at the end of line + if ( nNextAttr == nEnd ) { ASSERT(nOpenAttrWithRange >= 0, "odd to see this happening, expected >= 0"); bool bAttrWithRange = (nOpenAttrWithRange > 0); - if (nAktPos != nEnd) + if ( nAktPos != nEnd ) { nOpenAttrWithRange += aAttrIter.OutAttrWithRange(nEnd); ASSERT(nOpenAttrWithRange == 0, "odd to see this happening, expected 0"); } - if(pO->Count()) - { - rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), - pO->Count(), pO->GetData() ); - pO->Remove(0, pO->Count()); // leeren - } + AttrOutput().OutputFKP(); - if( bTxtAtr || bAttrWithRange || bRedlineAtEnd ) + if ( bTxtAtr || bAttrWithRange || bRedlineAtEnd ) { - //insert final graphic anchors if any before CR - aAttrIter.OutFlys(nEnd); - //insert final bookmarks if any before CR and after flys - rWW8Wrt.AppendBookmarks( *pNd, nEnd, 1 ); + // insert final graphic anchors if any before CR + aAttrIter.OutFlys( nEnd ); + // insert final bookmarks if any before CR and after flys + AppendBookmarks( rNode, nEnd, 1 ); - if (pTOXSect) + if ( pTOXSect ) { - rWW8Wrt.pop_charpropstart(); - rWW8Wrt.EndTOX( *pTOXSect ); + m_aCurrentCharPropStarts.pop(); + AttrOutput().EndTOX( *pTOXSect ); } - rWW8Wrt.WriteCR(pTextNodeInfoInner); // CR danach + WriteCR( pTextNodeInfoInner ); - if( bRedlineAtEnd ) + if ( bRedlineAtEnd ) { - aAttrIter.OutRedlines( nEnd ); - if( pO->Count() ) - { - rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), - pO->Count(), pO->GetData() ); - pO->Remove( 0, pO->Count() ); // delete - } + AttrOutput().Redline( aAttrIter.GetRedline( nEnd ) ); + AttrOutput().OutputFKP(); } } } + + AttrOutput().EndRun(); + nAktPos = nNextAttr; - aAttrIter.NextPos(); + UpdatePosition( &aAttrIter, nAktPos, nEnd ); eChrSet = aAttrIter.GetCharSet(); } - while( nAktPos < nEnd ); + while ( nAktPos < nEnd ); - ASSERT( !pO->Count(), " pO ist am ZeilenEnde nicht leer" ); + AttrOutput().StartParagraphProperties( rNode ); + + AttrOutput().ParagraphStyle( nStyle ); - pO->Insert( (BYTE*)&nSty, 2, pO->Count() ); // Style # + if ( mpParentFrame && !bIsInTable ) // Fly-Attrs + OutputFormat( mpParentFrame->GetFrmFmt(), false, false, true ); - if (rWW8Wrt.mpParentFrame && !rWW8Wrt.bIsInTable) // Fly-Attrs - rWW8Wrt.Out_SwFmt(rWW8Wrt.mpParentFrame->GetFrmFmt(), false, false, true); - - if (pTextNodeInfo.get() != NULL) + if ( pTextNodeInfo.get() != NULL ) { #ifdef DEBUG ::std::clog << pTextNodeInfo->toString() << ::std::endl; #endif - rWW8Wrt.OutWW8TableInfoCell(pTextNodeInfoInner); - } - - if( !bFlyInTable ) + AttrOutput().TableInfoCell( pTextNodeInfoInner ); + } + + if ( !bFlyInTable ) { SfxItemSet* pTmpSet = 0; - const BYTE nPrvNxtNd = pNd->HasPrevNextLayNode(); + const BYTE nPrvNxtNd = rNode.HasPrevNextLayNode(); if( (ND_HAS_PREV_LAYNODE|ND_HAS_NEXT_LAYNODE ) != nPrvNxtNd ) { const SfxPoolItem* pItem; - if( SFX_ITEM_SET == pNd->GetSwAttrSet().GetItemState( + if( SFX_ITEM_SET == rNode.GetSwAttrSet().GetItemState( RES_UL_SPACE, true, &pItem ) && ( ( !( ND_HAS_PREV_LAYNODE & nPrvNxtNd ) && ((SvxULSpaceItem*)pItem)->GetUpper()) || ( !( ND_HAS_NEXT_LAYNODE & nPrvNxtNd ) && ((SvxULSpaceItem*)pItem)->GetLower()) )) { - pTmpSet = new SfxItemSet( pNd->GetSwAttrSet() ); + pTmpSet = new SfxItemSet( rNode.GetSwAttrSet() ); SvxULSpaceItem aUL( *(SvxULSpaceItem*)pItem ); // OD, MMAHER 2004-03-01 #i25901#- consider compatibility option - if (!rWrt.pDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES)) + if (!pDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES)) { if( !(ND_HAS_PREV_LAYNODE & nPrvNxtNd )) aUL.SetUpper( 0 ); } // OD, MMAHER 2004-03-01 #i25901# - consider compatibility option - if (!rWrt.pDoc->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS)) + if (!pDoc->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS)) { if( !(ND_HAS_NEXT_LAYNODE & nPrvNxtNd )) aUL.SetLower( 0 ); @@ -1861,20 +1869,20 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) BOOL bParaRTL = FALSE; const SvxFrameDirectionItem* pItem = (const SvxFrameDirectionItem*) - pNd->GetSwAttrSet().GetItem(RES_FRAMEDIR); + rNode.GetSwAttrSet().GetItem(RES_FRAMEDIR); if ( aAttrIter.IsParaRTL()) bParaRTL = TRUE; - if( pNd->IsNumbered()) + if( rNode.IsNumbered()) { - const SwNumRule* pRule = pNd->GetNumRule(); - BYTE nLvl = static_cast< BYTE >(pNd->GetActualListLevel()); + const SwNumRule* pRule = rNode.GetNumRule(); + BYTE nLvl = static_cast< BYTE >( rNode.GetActualListLevel() ); const SwNumFmt* pFmt = pRule->GetNumFmt( nLvl ); if( !pFmt ) pFmt = &pRule->Get( nLvl ); if( !pTmpSet ) - pTmpSet = new SfxItemSet( pNd->GetSwAttrSet() ); + pTmpSet = new SfxItemSet( rNode.GetSwAttrSet() ); SvxLRSpaceItem aLR(ItemGet<SvxLRSpaceItem>(*pTmpSet, RES_LR_SPACE)); // --> OD 2008-06-03 #i86652# @@ -1885,16 +1893,16 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) } // <-- - if( pNd->IsNumbered() && pNd->IsCountedInList() ) + if( rNode.IsNumbered() && rNode.IsCountedInList() ) { // --> OD 2008-06-03 #i86652# if ( pFmt->GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { if (bParaRTL) - aLR.SetTxtFirstLineOfstValue(pFmt->GetAbsLSpace() - pFmt->GetFirstLineOffset()); + aLR.SetTxtFirstLineOfstValue(pFmt->GetAbsLSpace() - pFmt->GetFirstLineOffset()); else - aLR.SetTxtFirstLineOfst(GetWordFirstLineOffset(*pFmt)); + aLR.SetTxtFirstLineOfst(GetWordFirstLineOffset(*pFmt)); } // <-- @@ -1913,7 +1921,7 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) // indent values are not applicable. if ( pFmt->GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT && - !pNd->AreListLevelIndentsApplicable() ) + !rNode.AreListLevelIndentsApplicable() ) { pTmpSet->Put( aLR ); } @@ -1935,7 +1943,7 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) aItem.Insert(aTabStop); pTmpSet->Put(aItem); - SwWW8Writer::CorrTabStopInSet(*pTmpSet, pFmt->GetAbsLSpace()); + MSWordExportBase::CorrectTabStopInSet(*pTmpSet, pFmt->GetAbsLSpace()); } } @@ -1945,14 +1953,14 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) default. Otherwise we must add a RTL attribute to our export list */ pItem = (const SvxFrameDirectionItem*) - pNd->GetSwAttrSet().GetItem(RES_FRAMEDIR); + rNode.GetSwAttrSet().GetItem(RES_FRAMEDIR); if ( (!pItem || pItem->GetValue() == FRMDIR_ENVIRONMENT) && aAttrIter.IsParaRTL() ) { if ( !pTmpSet ) - pTmpSet = new SfxItemSet(pNd->GetSwAttrSet()); + pTmpSet = new SfxItemSet(rNode.GetSwAttrSet()); pTmpSet->Put(SvxFrameDirectionItem(FRMDIR_HORI_RIGHT_TOP, RES_FRAMEDIR)); } @@ -1962,17 +1970,17 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) // is found in <pTmpSet> // #i44815# adjust numbering/indents for numbered paragraphs // without number (NO_NUMLEVEL) - // #i47013# need to check pNd->GetNumRule()!=NULL as well. - if ( ! pNd->IsCountedInList() && pNd->GetNumRule()!=NULL ) + // #i47013# need to check rNode.GetNumRule()!=NULL as well. + if ( ! rNode.IsCountedInList() && rNode.GetNumRule()!=NULL ) { // WW8 does not know numbered paragraphs without number - // (NO_NUMLEVEL). In OutWW8_SwNumRuleItem, we will export + // (NO_NUMLEVEL). In WW8AttributeOutput::ParaNumRule(), we will export // the RES_PARATR_NUMRULE as list-id 0, which in WW8 means // no numbering. Here, we will adjust the indents to match // visually. if ( !pTmpSet ) - pTmpSet = new SfxItemSet(pNd->GetSwAttrSet()); + pTmpSet = new SfxItemSet(rNode.GetSwAttrSet()); // create new LRSpace item, based on the current (if present) const SfxPoolItem* pPoolItem = NULL; @@ -1983,8 +1991,8 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) : *static_cast<const SvxLRSpaceItem*>( pPoolItem ) ); // new left margin = old left + label space - const SwNumRule* pRule = pNd->GetNumRule(); - const SwNumFmt& rNumFmt = pRule->Get( static_cast< USHORT >(pNd->GetActualListLevel()) ); + const SwNumRule* pRule = rNode.GetNumRule(); + const SwNumFmt& rNumFmt = pRule->Get( static_cast< USHORT >(rNode.GetActualListLevel()) ); // --> OD 2008-06-03 #i86652# if ( rNumFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) @@ -2010,38 +2018,36 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) // --> OD 2007-04-24 #i75457# // Export page break after attribute from paragraph style. + // If page break attribute at the text node exist, an existing page + // break after at the paragraph style hasn't got to be considered. + if ( !rNode.GetpSwAttrSet() || + SFX_ITEM_SET != rNode.GetpSwAttrSet()->GetItemState(RES_BREAK, false) ) { - // If page break attribute at the text node exist, an existing page - // break after at the paragraph style hasn't got to be considered. - if ( !pNd->GetpSwAttrSet() || - SFX_ITEM_SET != pNd->GetpSwAttrSet()->GetItemState(RES_BREAK, false) ) + const SvxFmtBreakItem* pBreakAtParaStyle = + &(ItemGet<SvxFmtBreakItem>(rNode.GetSwAttrSet(), RES_BREAK)); + if ( pBreakAtParaStyle && + pBreakAtParaStyle->GetBreak() == SVX_BREAK_PAGE_AFTER ) { - const SvxFmtBreakItem* pBreakAtParaStyle = - &(ItemGet<SvxFmtBreakItem>(pNd->GetSwAttrSet(), RES_BREAK)); - if ( pBreakAtParaStyle && - pBreakAtParaStyle->GetBreak() == SVX_BREAK_PAGE_AFTER ) + if ( !pTmpSet ) { - if ( !pTmpSet ) - { - pTmpSet = new SfxItemSet(pNd->GetSwAttrSet()); - } - pTmpSet->Put( *pBreakAtParaStyle ); - } - else if( pTmpSet ) - { // Even a pagedesc item is set, the break item can be set 'NONE', - // this has to be overruled. - const SwFmtPageDesc& rPageDescAtParaStyle = - ItemGet<SwFmtPageDesc>( *pNd, RES_PAGEDESC ); - if( rPageDescAtParaStyle.GetRegisteredIn() ) - pTmpSet->ClearItem( RES_BREAK ); + pTmpSet = new SfxItemSet(rNode.GetSwAttrSet()); } + pTmpSet->Put( *pBreakAtParaStyle ); + } + else if( pTmpSet ) + { // Even a pagedesc item is set, the break item can be set 'NONE', + // this has to be overruled. + const SwFmtPageDesc& rPageDescAtParaStyle = + ItemGet<SwFmtPageDesc>( rNode, RES_PAGEDESC ); + if( rPageDescAtParaStyle.GetRegisteredIn() ) + pTmpSet->ClearItem( RES_BREAK ); } } // --> FME 2007-05-30 #i76520# Emulate non-splitting tables - if ( rWW8Wrt.bOutTable ) + if ( bOutTable ) { - const SwTableNode* pTableNode = pNd->FindTableNode(); + const SwTableNode* pTableNode = rNode.FindTableNode(); if ( pTableNode ) { @@ -2057,7 +2063,7 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) // bKeep: set keep at first paragraphs in all lines // bDontSplit : set keep at first paragraphs in all lines except from last line // but only for non-complex tables - const SwTableBox* pBox = pNd->GetTblBox(); + const SwTableBox* pBox = rNode.GetTblBox(); const SwTableLine* pLine = pBox ? pBox->GetUpper() : 0; if ( pLine && !pLine->GetUpper() ) @@ -2066,7 +2072,7 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) if ( 0 == pLine->GetTabBoxes().GetPos( pBox ) && pBox->GetSttNd() ) { // check if paragraph is first in that line: - if ( 1 == ( pNd->GetIndex() - pBox->GetSttNd()->GetIndex() ) ) + if ( 1 == ( rNode.GetIndex() - pBox->GetSttNd()->GetIndex() ) ) { bool bSetAtPara = false; if ( bKeep ) @@ -2081,7 +2087,7 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) if ( bSetAtPara ) { if ( !pTmpSet ) - pTmpSet = new SfxItemSet(pNd->GetSwAttrSet()); + pTmpSet = new SfxItemSet(rNode.GetSwAttrSet()); const SvxFmtKeepItem aKeepItem( TRUE, RES_KEEP ); pTmpSet->Put( aKeepItem ); @@ -2094,76 +2100,57 @@ Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ) } // <-- - const SfxItemSet* pNewSet = pTmpSet ? pTmpSet : pNd->GetpSwAttrSet(); + const SfxItemSet* pNewSet = pTmpSet ? pTmpSet : rNode.GetpSwAttrSet(); if( pNewSet ) { // Para-Attrs - rWW8Wrt.pStyAttr = &pNd->GetAnyFmtColl().GetAttrSet(); + pStyAttr = &rNode.GetAnyFmtColl().GetAttrSet(); - const SwModify* pOldMod = rWW8Wrt.pOutFmtNode; - rWW8Wrt.pOutFmtNode = pNd; + const SwModify* pOldMod = pOutFmtNode; + pOutFmtNode = &rNode; // Pap-Attrs, so script is not necessary - rWW8Wrt.Out_SfxItemSet( *pNewSet, true, false, - i18n::ScriptType::LATIN); + OutputItemSet( *pNewSet, true, false, i18n::ScriptType::LATIN); - rWW8Wrt.pStyAttr = 0; - rWW8Wrt.pOutFmtNode = pOldMod; + pStyAttr = 0; + pOutFmtNode = pOldMod; - if( pNewSet != pNd->GetpSwAttrSet() ) + if( pNewSet != rNode.GetpSwAttrSet() ) delete pNewSet; } } - rWW8Wrt.pPapPlc->AppendFkpEntry( rWrt.Strm().Tell(), pO->Count(), - pO->GetData() ); - pO->Remove( 0, pO->Count() ); // leeren + AttrOutput().EndParagraphProperties(); - if (pTextNodeInfoInner.get() != NULL) - { - if (pTextNodeInfoInner->isEndOfLine()) - { - rWW8Wrt.WriteRowEnd(pTextNodeInfoInner->getDepth()); - - pO->Insert( (BYTE*)&nSty, 2, pO->Count() ); // Style # - rWW8Wrt.OutWW8TableInfoRow(pTextNodeInfoInner); - rWW8Wrt.pPapPlc->AppendFkpEntry( rWrt.Strm().Tell(), pO->Count(), - pO->GetData() ); - pO->Remove( 0, pO->Count() ); // leeren - } - } + AttrOutput().EndParagraph( pTextNodeInfoInner ); #ifdef DEBUG ::std::clog << "</OutWW8_SwTxtNode>" << ::std::endl; #endif - - return rWrt; } -void SwWW8Writer::OutWW8TableNodeInfo(ww8::WW8TableNodeInfo::Pointer_t pNodeInfo) +void WW8AttributeOutput::TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t pNodeInfo ) { SVBT16 nSty; - ShortToSVBT16( nStyleBeforeFly, nSty ); + ShortToSVBT16( GetExport().nStyleBeforeFly, nSty ); - ww8::WW8TableNodeInfo::Inners_t::const_iterator aIt - (pNodeInfo->getInners().begin()); - ww8::WW8TableNodeInfo::Inners_t::const_iterator aItEnd - (pNodeInfo->getInners().end()); + ww8::WW8TableNodeInfo::Inners_t::const_iterator aIt( pNodeInfo->getInners().begin() ); + ww8::WW8TableNodeInfo::Inners_t::const_iterator aItEnd( pNodeInfo->getInners().end() ); while (aIt != aItEnd) { ww8::WW8TableNodeInfoInner::Pointer_t pInner = aIt->second; - if (pInner->isEndOfCell()) + if ( pInner->isEndOfCell() ) { - WriteRowEnd(pInner->getDepth()); + TableRowEnd( pInner->getDepth() ); - pO->Insert( (BYTE*)&nSty, 2, pO->Count() ); // Style # - OutWW8TableInfoRow(pInner); - pPapPlc->AppendFkpEntry( Strm().Tell(), pO->Count(), - pO->GetData() ); - pO->Remove( 0, pO->Count() ); // leeren + m_rWW8Export.pO->Insert( (BYTE*)&nSty, 2, m_rWW8Export.pO->Count() ); // Style # + TableInfoRow( pInner ); + m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), + m_rWW8Export.pO->GetData() ); + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren } - if (pInner->isEndOfLine()) + if ( pInner->isEndOfLine() ) { } @@ -2174,13 +2161,11 @@ void SwWW8Writer::OutWW8TableNodeInfo(ww8::WW8TableNodeInfo::Pointer_t pNodeInfo #if 0 /* */ -USHORT SwWW8Writer::StartTableFromFrmFmt(WW8Bytes &rAt, const SwFrmFmt *pFmt, - SwTwips &rTblOffset) - +USHORT WW8Export::StartTableFromFrmFmt( WW8Bytes &rAt, const SwFrmFmt *pFmt ) { - //Tell the undocumented table hack that everything between here and - //the last table position is nontable text - if (WW8_CP nPos = Fc2Cp(Strm().Tell())) + // Tell the undocumented table hack that everything between here and + // the last table position is nontable text + if ( WW8_CP nPos = Fc2Cp( Strm().Tell() ) ) pMagicTable->Append(nPos,0); // sprmPDxaFromText10 @@ -2201,8 +2186,8 @@ USHORT SwWW8Writer::StartTableFromFrmFmt(WW8Bytes &rAt, const SwFrmFmt *pFmt, rAt.Insert( aTabLineAttr, sizeof( aTabLineAttr ), rAt.Count() ); } - ASSERT(pFmt, "No pFmt!"); - if (pFmt) + ASSERT( pFmt, "No pFmt!" ); + if ( pFmt ) { const SwFmtHoriOrient &rHori = pFmt->GetHoriOrient(); const SwFmtVertOrient &rVert = pFmt->GetVertOrient(); @@ -2220,29 +2205,12 @@ USHORT SwWW8Writer::StartTableFromFrmFmt(WW8Bytes &rAt, const SwFrmFmt *pFmt, case text::HoriOrientation::CENTER: case text::HoriOrientation::RIGHT: if( bWrtWW8 ) - InsUInt16( rAt, 0x5400 ); + SwWW8Writer::InsUInt16( rAt, NS_sprm::LN_TJc ); else rAt.Insert( 182, rAt.Count() ); - InsUInt16( rAt, (text::HoriOrientation::RIGHT == eHOri ? 2 : 1 )); + SwWW8Writer::InsUInt16( rAt, (text::HoriOrientation::RIGHT == eHOri ? 2 : 1 )); break; default: -#if 1 -#if 1 - rTblOffset = rHori.GetPos(); - const SvxLRSpaceItem& rLRSp = pFmt->GetLRSpace(); - rTblOffset += rLRSp.GetLeft(); -#else - Point aOffset = pFmt->FindLayoutRect(true).Pos(); - rTblOffset = aOffset.X(); -#endif - -#else - { - const SvxLRSpaceItem& rLRSp = pFmt->GetLRSpace(); - rTblOffset = rLRSp.GetLeft(); - rPageSize -= rTblOffset + rLRSp.GetRight(); - } -#endif break; } } @@ -2251,23 +2219,23 @@ USHORT SwWW8Writer::StartTableFromFrmFmt(WW8Bytes &rAt, const SwFrmFmt *pFmt, } //See #i19484# for why we need this -bool CellContainsProblematicGraphic(const SwWriteTableCell *pCell, - const SwWW8Writer &rWr) +static bool CellContainsProblematicGraphic( const SwWriteTableCell *pCell, + const MSWordExportBase &rExport ) { const SwNode *pStart = pCell ? pCell->GetBox()->GetSttNd() : 0; const SwNode *pEnd = pStart ? pStart->EndOfSectionNode() : 0; - ASSERT(pStart && pEnd, "No start or end?"); - if (!(pStart && pEnd)) + ASSERT( pStart && pEnd, "No start or end?" ); + if ( !pStart || !pEnd ) return false; bool bHasGraphic = false; - sw::Frames aFrames(GetFramesBetweenNodes(rWr.maFrames, *pStart, *pEnd)); + sw::Frames aFrames( GetFramesBetweenNodes( rExport.maFrames, *pStart, *pEnd ) ); sw::FrameIter aEnd = aFrames.end(); - for (sw::FrameIter aIter = aFrames.begin(); aIter != aEnd; ++aIter) + for ( sw::FrameIter aIter = aFrames.begin(); aIter != aEnd; ++aIter ) { const SwFrmFmt &rEntry = aIter->GetFrmFmt(); - if (rEntry.GetSurround().GetSurround() == SURROUND_THROUGHT) + if ( rEntry.GetSurround().GetSurround() == SURROUND_THROUGHT ) { bHasGraphic = true; break; @@ -2276,13 +2244,13 @@ bool CellContainsProblematicGraphic(const SwWriteTableCell *pCell, return bHasGraphic; } -bool RowContainsProblematicGraphic(const SwWriteTableCellPtr *pRow, - USHORT nCols, const SwWW8Writer &rWr) +static bool RowContainsProblematicGraphic( const SwWriteTableCellPtr *pRow, + USHORT nCols, const MSWordExportBase &rExport ) { bool bHasGraphic = false; - for (USHORT nI = 0; nI < nCols; ++nI) + for ( USHORT nI = 0; nI < nCols; ++nI ) { - if (CellContainsProblematicGraphic(pRow[nI], rWr)) + if ( CellContainsProblematicGraphic( pRow[nI], rExport ) ) { bHasGraphic = true; break; @@ -2295,7 +2263,12 @@ bool RowContainsProblematicGraphic(const SwWriteTableCellPtr *pRow, // Tabellen //--------------------------------------------------------------------------- -bool SwWW8Writer::NoPageBreakSection(const SfxItemSet* pSet) +void WW8AttributeOutput::EmptyParagraph() +{ + m_rWW8Export.WriteStringAsPara( aEmptyStr ); +} + +bool MSWordExportBase::NoPageBreakSection( const SfxItemSet* pSet ) { bool bRet = false; const SfxPoolItem* pI; @@ -2333,23 +2306,22 @@ bool SwWW8Writer::NoPageBreakSection(const SfxItemSet* pSet) /* */ -Writer& OutWW8_SwSectionNode( Writer& rWrt, SwSectionNode& rSectionNode ) +void MSWordExportBase::OutputSectionNode( const SwSectionNode& rSectionNode ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; const SwSection& rSection = rSectionNode.GetSection(); SwNodeIndex aIdx( rSectionNode, 1 ); const SwNode& rNd = aIdx.GetNode(); - if (!rNd.IsSectionNode() && !rWW8Wrt.bIsInTable) //No sections in table + if ( !rNd.IsSectionNode() && !bIsInTable ) //No sections in table { // Bug 74245 - if the first Node inside the section has an own // PageDesc or PageBreak attribut, then dont write // here the section break ULONG nRstLnNum = 0; const SfxItemSet* pSet; - if( rNd.IsTableNode() ) + if ( rNd.IsTableNode() ) pSet = &rNd.GetTableNode()->GetTable().GetFrmFmt()->GetAttrSet(); - else if( rNd.IsCntntNode() ) + else if ( rNd.IsCntntNode() ) { pSet = &rNd.GetCntntNode()->GetSwAttrSet(); nRstLnNum = ((SwFmtLineNumber&)pSet->Get( @@ -2358,30 +2330,34 @@ Writer& OutWW8_SwSectionNode( Writer& rWrt, SwSectionNode& rSectionNode ) else pSet = 0; - if( pSet && SwWW8Writer::NoPageBreakSection(pSet)) + if ( pSet && NoPageBreakSection( pSet ) ) pSet = 0; - if( !pSet ) + if ( !pSet ) { // new Section with no own PageDesc/-Break // -> write follow section break; const SwSectionFmt& rFmt = *rSection.GetFmt(); - rWW8Wrt.ReplaceCr( (char)0xc ); // Indikator fuer Page/Section-Break + ReplaceCr( msword::PageBreak ); // Indikator fuer Page/Section-Break //Get the page in use at the top of this section SwNodeIndex aIdxTmp(rSectionNode, 1); const SwPageDesc *pCurrent = SwPageDesc::GetPageDescOfNode(aIdxTmp.GetNode()); if (!pCurrent) - pCurrent = rWW8Wrt.pAktPageDesc; + pCurrent = pAktPageDesc; - rWW8Wrt.pSepx->AppendSep(rWW8Wrt.Fc2Cp(rWrt.Strm().Tell()), - pCurrent, &rFmt, nRstLnNum); + AppendSection( pCurrent, &rFmt, nRstLnNum ); } } - if( TOX_CONTENT_SECTION == rSection.GetType() ) - rWW8Wrt.bStartTOX = true; - return rWrt; + if ( TOX_CONTENT_SECTION == rSection.GetType() ) + bStartTOX = true; +} + + +void WW8Export::AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum ) +{ + pSepx->AppendSep(Fc2Cp(Strm().Tell()), pPageDesc, pFmt, nLnNum); } /* */ @@ -2390,9 +2366,11 @@ Writer& OutWW8_SwSectionNode( Writer& rWrt, SwSectionNode& rSectionNode ) // Flys //--------------------------------------------------------------------------- -void SwWW8Writer::OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd ) +void WW8Export::OutWW6FlyFrmsInCntnt( const SwTxtNode& rNd ) { ASSERT(!bWrtWW8, "I shouldn't be needed for Word >=8"); + if ( bWrtWW8 ) + return; if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) { @@ -2421,15 +2399,17 @@ void SwWW8Writer::OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd ) aOffset = aFlyRect.Pos() - aParentRect.Pos(); // PaM umsetzen: auf Inhalt des Fly-Frameformats - WW8SaveData aSaveData( *this, nStt, nEnd ); + SaveData( nStt, nEnd ); - // wird in Out_SwFmt() ausgewertet + // wird in OutputFormat() ausgewertet pFlyOffset = &aOffset; eNewAnchorType = rFlyFrmFmt.GetAnchor().GetAnchorId(); sw::Frame aFrm(rFlyFrmFmt, SwPosition(rNd)); mpParentFrame = &aFrm; // Ok, rausschreiben: WriteText(); + + RestoreData(); } } } @@ -2437,15 +2417,14 @@ void SwWW8Writer::OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd ) } } - -void SwWW8Writer::OutWW8FlyFrm(const sw::Frame& rFmt, const Point& rNdTopLeft) +void WW8AttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFmt, const Point& rNdTopLeft ) { const SwFrmFmt &rFrmFmt = rFmt.GetFrmFmt(); const SwFmtAnchor& rAnch = rFrmFmt.GetAnchor(); - bool bUseEscher = bWrtWW8; + bool bUseEscher = m_rWW8Export.bWrtWW8; - if (bWrtWW8 && rFmt.IsInline()) + if ( m_rWW8Export.bWrtWW8 && rFmt.IsInline() ) { sw::Frame::WriterSource eType = rFmt.GetWriterType(); if ((eType == sw::Frame::eGraphic) || (eType == sw::Frame::eOle)) @@ -2460,16 +2439,16 @@ void SwWW8Writer::OutWW8FlyFrm(const sw::Frame& rFmt, const Point& rNdTopLeft) */ if ((bUseEscher == true) && (eType == sw::Frame::eFormControl)) { - if (MiserableFormFieldExportHack(rFrmFmt)) + if ( m_rWW8Export.MiserableFormFieldExportHack( rFrmFmt ) ) return ; } } if (bUseEscher) { - ASSERT(bWrtWW8, "this has gone horribly wrong"); + ASSERT( m_rWW8Export.bWrtWW8, "this has gone horribly wrong" ); // write as escher - AppendFlyInFlys(rFmt, rNdTopLeft); + m_rWW8Export.AppendFlyInFlys(rFmt, rNdTopLeft); } else { @@ -2484,11 +2463,11 @@ void SwWW8Writer::OutWW8FlyFrm(const sw::Frame& rFmt, const Point& rNdTopLeft) if( nStt >= nEnd ) // kein Bereich, also kein gueltiger Node return; - if (!bIsInTable && rFmt.IsInline()) + if ( !m_rWW8Export.bIsInTable && rFmt.IsInline() ) { //Test to see if this textbox contains only a single graphic/ole SwTxtNode* pParTxtNode = rAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); - if( pParTxtNode && !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() ) + if ( pParTxtNode && !m_rWW8Export.pDoc->GetNodes()[ nStt ]->IsNoTxtNode() ) bDone = true; } if( !bDone ) @@ -2501,53 +2480,53 @@ void SwWW8Writer::OutWW8FlyFrm(const sw::Frame& rFmt, const Point& rNdTopLeft) // nFlyHeight = rS.GetHeight(); // <-- - { - WW8SaveData aSaveData( *this, nStt, nEnd ); + m_rWW8Export.SaveData( nStt, nEnd ); - Point aOffset; - if (mpParentFrame) - { - /* - #90804# - Munge flys in fly into absolutely positioned elements for - word 6 - */ - const SwTxtNode* pParTxtNode = rAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); - const SwRect aPageRect = pParTxtNode->FindPageFrmRect( FALSE, 0, FALSE ); - - aOffset = rFrmFmt.FindLayoutRect().Pos(); - aOffset -= aPageRect.Pos(); - - pFlyOffset = &aOffset; - eNewAnchorType = FLY_PAGE; - } + Point aOffset; + if ( m_rWW8Export.mpParentFrame ) + { + /* + #90804# + Munge flys in fly into absolutely positioned elements for + word 6 + */ + const SwTxtNode* pParTxtNode = rAnch.GetCntntAnchor()->nNode.GetNode().GetTxtNode(); + const SwRect aPageRect = pParTxtNode->FindPageFrmRect( FALSE, 0, FALSE ); + + aOffset = rFrmFmt.FindLayoutRect().Pos(); + aOffset -= aPageRect.Pos(); + + m_rWW8Export.pFlyOffset = &aOffset; + m_rWW8Export.eNewAnchorType = FLY_PAGE; + } - mpParentFrame = &rFmt; - if ( - bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) && - !pDoc->GetNodes()[ nStt ]->IsNoTxtNode() - ) - { - // Beachten: Flag bOutTable wieder setzen, - // denn wir geben ja ganz normalen Content der - // Tabelenzelle aus und keinen Rahmen - // (Flag wurde oben in aSaveData() geloescht) - bOutTable = true; - const String& rName = rFrmFmt.GetName(); - StartCommentOutput(rName); - WriteText(); - EndCommentOutput(rName); - } - else - WriteText(); + m_rWW8Export.mpParentFrame = &rFmt; + if ( + m_rWW8Export.bIsInTable && (FLY_PAGE != rAnch.GetAnchorId()) && + !m_rWW8Export.pDoc->GetNodes()[ nStt ]->IsNoTxtNode() + ) + { + // Beachten: Flag bOutTable wieder setzen, + // denn wir geben ja ganz normalen Content der + // Tabelenzelle aus und keinen Rahmen + // (Flag wurde oben in aSaveData() geloescht) + m_rWW8Export.bOutTable = true; + const String& rName = rFrmFmt.GetName(); + m_rWW8Export.StartCommentOutput(rName); + m_rWW8Export.WriteText(); + m_rWW8Export.EndCommentOutput(rName); } + else + m_rWW8Export.WriteText(); + + m_rWW8Export.RestoreData(); } } } -void SwWW8Writer::OutFlyFrm(const sw::Frame& rFmt) +void AttributeOutputBase::OutputFlyFrame( const sw::Frame& rFmt ) { - if (!rFmt.GetCntntNode()) + if ( !rFmt.GetCntntNode() ) return; const SwCntntNode &rNode = *rFmt.GetCntntNode(); @@ -2555,10 +2534,10 @@ void SwWW8Writer::OutFlyFrm(const sw::Frame& rFmt) Point* pLayPos; bool bValidNdPos = false, bValidPgPos = false; - if (FLY_PAGE == rFmt.GetFrmFmt().GetAnchor().GetAnchorId()) + if ( FLY_PAGE == rFmt.GetFrmFmt().GetAnchor().GetAnchorId() ) { // get the Layout Node-Position. - if (!bValidPgPos) + if ( !bValidPgPos ) { aPgPos = rNode.FindPageFrmRect(false, &aPgPos).Pos(); bValidPgPos = true; @@ -2568,7 +2547,7 @@ void SwWW8Writer::OutFlyFrm(const sw::Frame& rFmt) else { // get the Layout Node-Position. - if (!bValidNdPos) + if ( !bValidNdPos ) { aNdPos = rNode.FindLayoutRect(false, &aNdPos).Pos(); bValidNdPos = true; @@ -2576,27 +2555,30 @@ void SwWW8Writer::OutFlyFrm(const sw::Frame& rFmt) pLayPos = &aNdPos; } - OutWW8FlyFrm(rFmt, *pLayPos); + OutputFlyFrame_Impl( rFmt, *pLayPos ); } // write data of any redline -void SwWW8Writer::OutRedline( const SwRedlineData& rRedline ) +void WW8AttributeOutput::Redline( const SwRedlineData* pRedline ) { - if( rRedline.Next() ) - OutRedline( *rRedline.Next() ); + if ( !pRedline ) + return; + + if ( pRedline->Next() ) + Redline( pRedline->Next() ); static USHORT __READONLY_DATA aSprmIds[ 2 * 2 * 3 ] = { // Ids for insert - 0x0801, 0x4804, 0x6805, // for WW8 + NS_sprm::LN_CFRMark, NS_sprm::LN_CIbstRMark, NS_sprm::LN_CDttmRMark, // for WW8 0x0042, 0x0045, 0x0046, // for WW6 // Ids for delete - 0x0800, 0x4863, 0x6864, // for WW8 + NS_sprm::LN_CFRMarkDel, NS_sprm::LN_CIbstRMarkDel, NS_sprm::LN_CDttmRMarkDel, // for WW8 0x0041, 0x0045, 0x0046 // for WW6 }; const USHORT* pSprmIds = 0; - switch( rRedline.GetType() ) + switch( pRedline->GetType() ) { case nsRedlineType_t::REDLINE_INSERT: pSprmIds = aSprmIds; @@ -2607,13 +2589,13 @@ void SwWW8Writer::OutRedline( const SwRedlineData& rRedline ) break; case nsRedlineType_t::REDLINE_FORMAT: - if( bWrtWW8 ) + if( m_rWW8Export.bWrtWW8 ) { - InsUInt16( 0xca57 ); - pO->Insert( 7, pO->Count() ); // len - pO->Insert( 1, pO->Count() ); - InsUInt16( AddRedlineAuthor( rRedline.GetAuthor() ) ); - InsUInt32( sw::ms::DateTime2DTTM( rRedline.GetTimeStamp() )); + m_rWW8Export.InsUInt16( NS_sprm::LN_CPropRMark ); + m_rWW8Export.pO->Insert( 7, m_rWW8Export.pO->Count() ); // len + m_rWW8Export.pO->Insert( 1, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( m_rWW8Export.AddRedlineAuthor( pRedline->GetAuthor() ) ); + m_rWW8Export.InsUInt32( sw::ms::DateTime2DTTM( pRedline->GetTimeStamp() )); } break; default: @@ -2621,37 +2603,52 @@ void SwWW8Writer::OutRedline( const SwRedlineData& rRedline ) break; } - if( pSprmIds ) + if ( pSprmIds ) { - if( !bWrtWW8 ) + if ( !m_rWW8Export.bWrtWW8 ) pSprmIds += 3; - if( bWrtWW8 ) - InsUInt16( pSprmIds[0] ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( pSprmIds[0] ); else - pO->Insert(msword_cast<sal_uInt8>(pSprmIds[0]), pO->Count()); - pO->Insert( 1, pO->Count() ); + m_rWW8Export.pO->Insert( msword_cast<sal_uInt8>(pSprmIds[0]), m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( 1, m_rWW8Export.pO->Count() ); - if( bWrtWW8 ) - InsUInt16( pSprmIds[1] ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( pSprmIds[1] ); else - pO->Insert(msword_cast<sal_uInt8>(pSprmIds[1]), pO->Count()); - InsUInt16( AddRedlineAuthor( rRedline.GetAuthor() ) ); + m_rWW8Export.pO->Insert( msword_cast<sal_uInt8>(pSprmIds[1]), m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( m_rWW8Export.AddRedlineAuthor( pRedline->GetAuthor() ) ); - if( bWrtWW8 ) - InsUInt16( pSprmIds[2] ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( pSprmIds[2] ); else - pO->Insert(msword_cast<sal_uInt8>(pSprmIds[2]), pO->Count()); - InsUInt32( sw::ms::DateTime2DTTM( rRedline.GetTimeStamp() )); + m_rWW8Export.pO->Insert( msword_cast<sal_uInt8>(pSprmIds[2]), m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt32( sw::ms::DateTime2DTTM( pRedline->GetTimeStamp() )); } } /* */ -SwNodeFnTab aWW8NodeFnTab = { -/* RES_TXTNODE */ OutWW8_SwTxtNode, -/* RES_GRFNODE */ OutWW8_SwGrfNode, -/* RES_OLENODE */ OutWW8_SwOleNode, -}; +void MSWordExportBase::OutputContentNode( const SwCntntNode& rNode ) +{ + switch ( rNode.GetNodeType() ) + { + case ND_TEXTNODE: + OutputTextNode( *rNode.GetTxtNode() ); + break; + case ND_GRFNODE: + OutputGrfNode( *rNode.GetGrfNode() ); + break; + case ND_OLENODE: + OutputOLENode( *rNode.GetOLENode() ); + break; + default: +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "Unhandled node, type == %d\n", rNode.GetNodeType() ); +#endif + break; + } +} /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx index e222bc4984..9f30ac7f2b 100644 --- a/sw/source/filter/ww8/wrtw8num.cxx +++ b/sw/source/filter/ww8/wrtw8num.cxx @@ -33,7 +33,6 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ - #include <hintids.hxx> #include <vcl/font.hxx> #include <svx/fontitem.hxx> @@ -44,9 +43,11 @@ #include <paratr.hxx> #include <charfmt.hxx> #include <ndtxt.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif + +#include <writerfilter/doctok/sprmids.hxx> + +#include "ww8attributeoutput.hxx" #include "writerhelper.hxx" #include "writerwordglue.hxx" #include "wrtww8.hxx" @@ -61,56 +62,51 @@ using namespace ::com::sun::star; using namespace sw::types; using namespace sw::util; -USHORT SwWW8Writer::DupNumRuleWithLvlStart(const SwNumRule *pRule,BYTE nLvl, - USHORT nVal) +USHORT MSWordExportBase::DuplicateNumRule( const SwNumRule *pRule, BYTE nLevel, USHORT nVal ) { - //List is set to restart at a particular value so for export make a - //completely new list based on this one and export that instead, - //which duplicates words behaviour in this respect. USHORT nNumId = USHRT_MAX; - String sPrefix(CREATE_CONST_ASC("WW8TempExport")); + String sPrefix( CREATE_CONST_ASC( "WW8TempExport" ) ); sPrefix += String::CreateFromInt32( nUniqueList++ ); // --> OD 2008-02-11 #newlistlevelattrs# SwNumRule* pMyNumRule = - new SwNumRule( pDoc->GetUniqueNumRuleName(&sPrefix), + new SwNumRule( pDoc->GetUniqueNumRuleName( &sPrefix ), SvxNumberFormat::LABEL_WIDTH_AND_POSITION ); // <-- pUsedNumTbl->Insert( pMyNumRule, pUsedNumTbl->Count() ); - for (USHORT i=0;i<MAXLEVEL;i++) + for ( USHORT i = 0; i < MAXLEVEL; i++ ) { const SwNumFmt& rSubRule = pRule->Get(i); pMyNumRule->Set( i, rSubRule ); } - SwNumFmt aNumFmt(pMyNumRule->Get(nLvl)); - aNumFmt.SetStart(nVal); - pMyNumRule->Set(nLvl,aNumFmt); + SwNumFmt aNumFmt( pMyNumRule->Get( nLevel ) ); + aNumFmt.SetStart( nVal ); + pMyNumRule->Set( nLevel, aNumFmt ); nNumId = GetId( *pMyNumRule ); //Map the old list to our new list - aRuleDuplicates[GetId(*pRule)] = nNumId; + aRuleDuplicates[GetId( *pRule )] = nNumId; return nNumId; } -USHORT SwWW8Writer::GetId( const SwNumRule& rNumRule ) const +USHORT MSWordExportBase::GetId( const SwNumRule& rNumRule ) { - if( !pUsedNumTbl ) + if ( !pUsedNumTbl ) { - SwWW8Writer* pThis = (SwWW8Writer*)this; - pThis->pUsedNumTbl = new SwNumRuleTbl; - pThis->pUsedNumTbl->Insert( &pDoc->GetNumRuleTbl(), 0 ); + pUsedNumTbl = new SwNumRuleTbl; + pUsedNumTbl->Insert( &pDoc->GetNumRuleTbl(), 0 ); // --> OD 2005-10-17 #126238# - Check, if the outline rule is // already inserted into <pUsedNumTbl>. If yes, do not insert it again. bool bOutlineRuleAdded( false ); - for( USHORT n = pUsedNumTbl->Count(); n; ) + for ( USHORT n = pUsedNumTbl->Count(); n; ) { const SwNumRule& rRule = *pUsedNumTbl->GetObject( --n ); if ( !pDoc->IsUsed( rRule ) ) { - pThis->pUsedNumTbl->Remove( n ); + pUsedNumTbl->Remove( n ); } else if ( &rRule == pDoc->GetOutlineNumRule() ) { @@ -122,7 +118,7 @@ USHORT SwWW8Writer::GetId( const SwNumRule& rNumRule ) const { // jetzt noch die OutlineRule einfuegen SwNumRule* pR = (SwNumRule*)pDoc->GetOutlineNumRule(); - pThis->pUsedNumTbl->Insert( pR, pUsedNumTbl->Count() ); + pUsedNumTbl->Insert( pR, pUsedNumTbl->Count() ); } // <-- } @@ -160,58 +156,174 @@ sal_Int16 GetWordFirstLineOffset(const SwNumFmt &rFmt) return nFirstLineOffset; } -void SwWW8Writer::OutListTab() +void WW8Export::WriteNumbering() { - if( !pUsedNumTbl ) - return ; // no numbering is used - - USHORT nCount = pUsedNumTbl->Count(); - USHORT n; + if ( !pUsedNumTbl ) + return; // no numbering is used + // list formats - LSTF pFib->fcPlcfLst = pTableStrm->Tell(); - SwWW8Writer::WriteShort( *pTableStrm, nCount ); + SwWW8Writer::WriteShort( *pTableStrm, pUsedNumTbl->Count() ); + NumberingDefinitions(); + // set len to FIB + pFib->lcbPlcfLst = pTableStrm->Tell() - pFib->fcPlcfLst; - // First Loop - write static data of SwNumRule - LSTF - for( n = 0; n < nCount; ++n ) + // list formats - LVLF + AbstractNumberingDefinitions(); + + // list formats - LFO + OutOverrideListTab(); + + // list formats - ListNames + OutListNamesTab(); +} + +void WW8AttributeOutput::NumberingDefinition( USHORT nId, const SwNumRule &rRule ) +{ + SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, nId ); + SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, nId ); + + // mit keinen Styles verbunden + for ( int i = 0; i < WW8ListManager::nMaxLevel; ++i ) + SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, 0xFFF ); + + BYTE nFlags = 0, nDummy = 0; + if ( rRule.IsContinusNum() ) + nFlags |= 0x1; + + *m_rWW8Export.pTableStrm << nFlags << nDummy; +} + +void MSWordExportBase::NumberingDefinitions() +{ + if ( !pUsedNumTbl ) + return; // no numbering is used + + USHORT nCount = pUsedNumTbl->Count(); + + // Write static data of SwNumRule - LSTF + for ( USHORT n = 0; n < nCount; ++n ) { const SwNumRule& rRule = *pUsedNumTbl->GetObject( n ); - SwWW8Writer::WriteLong( *pTableStrm, n + 1 ); - SwWW8Writer::WriteLong( *pTableStrm, n + 1 ); + AttrOutput().NumberingDefinition( n + 1, rRule ); + } +} - // mit keinen Styles verbunden - for( int i = 0; i < WW8ListManager::nMaxLevel; ++i ) - SwWW8Writer::WriteShort( *pTableStrm, 0xFFF ); +void WW8AttributeOutput::NumberingLevel( BYTE /*nLevel*/, + USHORT nStart, + USHORT nNumberingType, + SvxAdjust eAdjust, + const BYTE *pNumLvlPos, + BYTE nFollow, + const wwFont *pFont, + const SfxItemSet *pOutSet, + sal_Int16 nIndentAt, + sal_Int16 nFirstLineIndex, + sal_Int16 nListTabPos, + const String &rNumberingString + ) +{ + // Start value + SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, nStart ); - BYTE nFlags = 0, nDummy = 0; - if( rRule.IsContinusNum() ) - nFlags |= 0x1; - *pTableStrm << nFlags << nDummy; + // Type + *m_rWW8Export.pTableStrm << WW8Export::GetNumId( nNumberingType ); + + // Justification + BYTE nAlign; + switch ( eAdjust ) + { + case SVX_ADJUST_CENTER: nAlign = 1; break; + default: nAlign = 0; break; } + *m_rWW8Export.pTableStrm << nAlign; + + // Write the rgbxchNums[9], positions of placeholders for paragraph + // numbers in the text + m_rWW8Export.pTableStrm->Write( pNumLvlPos, WW8ListManager::nMaxLevel ); + + // Type of the character between the bullet and the text + *m_rWW8Export.pTableStrm << nFollow; + + // dxaSoace/dxaIndent (Word 6 compatibility) + SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, 0 ); + SwWW8Writer::WriteLong( *m_rWW8Export.pTableStrm, 0 ); + + // cbGrpprlChpx + WW8Bytes aCharAtrs; + if ( pOutSet ) + { + WW8Bytes* pOldpO = m_rWW8Export.pO; + m_rWW8Export.pO = &aCharAtrs; + if ( pFont ) + { + USHORT nFontID = m_rWW8Export.maFontHelper.GetId( *pFont ); - // set len to FIB - pFib->lcbPlcfLst = pTableStrm->Tell() - pFib->fcPlcfLst; + if ( m_rWW8Export.bWrtWW8 ) + { + m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc0 ); + m_rWW8Export.InsUInt16( nFontID ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc2 ); + } + else + m_rWW8Export.pO->Insert( 93, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( nFontID ); + } - // second Loop - write all Levels for all SwNumRules - LVLF + m_rWW8Export.OutputItemSet( *pOutSet, false, true, i18n::ScriptType::LATIN ); - // prepare the NodeNum to generate the NumString - SwNumberTree::tNumberVector aNumVector; - for (n = 0; n < WW8ListManager::nMaxLevel; ++n) - aNumVector.push_back(n); + m_rWW8Export.pO = pOldpO; + } + *m_rWW8Export.pTableStrm << BYTE( aCharAtrs.Count() ); + // cbGrpprlPapx BYTE aPapSprms [] = { 0x5e, 0x84, 0, 0, // sprmPDxaLeft 0x60, 0x84, 0, 0, // sprmPDxaLeft1 0x15, 0xc6, 0x05, 0x00, 0x01, 0, 0, 0x06 }; + *m_rWW8Export.pTableStrm << BYTE( sizeof( aPapSprms ) ); + + // reserved + SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, 0 ); + + // pap sprms + BYTE* pData = aPapSprms + 2; + Set_UInt16( pData, nIndentAt ); + pData += 2; + Set_UInt16( pData, nFirstLineIndex ); + pData += 5; + Set_UInt16( pData, nListTabPos ); + + m_rWW8Export.pTableStrm->Write( aPapSprms, sizeof( aPapSprms )); + + // write Chpx + if( aCharAtrs.Count() ) + m_rWW8Export.pTableStrm->Write( aCharAtrs.GetData(), aCharAtrs.Count() ); + + // write the num string + SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, rNumberingString.Len() ); + SwWW8Writer::WriteString16( *m_rWW8Export.pTableStrm, rNumberingString, false ); +} + +void MSWordExportBase::AbstractNumberingDefinitions() +{ + USHORT nCount = pUsedNumTbl->Count(); + USHORT n; + + // prepare the NodeNum to generate the NumString + SwNumberTree::tNumberVector aNumVector; + for ( n = 0; n < WW8ListManager::nMaxLevel; ++n ) + aNumVector.push_back( n ); StarSymbolToMSMultiFont *pConvert = 0; for( n = 0; n < nCount; ++n ) { + AttrOutput().StartAbstractNumbering( n + 1 ); + const SwNumRule& rRule = *pUsedNumTbl->GetObject( n ); BYTE nLvl; - BYTE nFlags = 0; - BYTE nAlign; BYTE nLevels = static_cast< BYTE >(rRule.IsContinusNum() ? WW8ListManager::nMinLevel : WW8ListManager::nMaxLevel); for( nLvl = 0; nLvl < nLevels; ++nLvl ) @@ -220,49 +332,37 @@ void SwWW8Writer::OutListTab() BYTE aNumLvlPos[WW8ListManager::nMaxLevel] = { 0,0,0,0,0,0,0,0,0 }; const SwNumFmt& rFmt = rRule.Get( nLvl ); - SwWW8Writer::WriteLong( *pTableStrm, rFmt.GetStart() ); - *pTableStrm << SwWW8Writer::GetNumId( rFmt.GetNumberingType() ); - - switch( rFmt.GetNumAdjust() ) - { - case SVX_ADJUST_CENTER: - nAlign = 1; - break; - default: - nAlign = 0; - break; - } - *pTableStrm << nAlign; + BYTE nFollow = 0; // --> OD 2008-06-03 #i86652# - if ( rFmt.GetPositionAndSpaceMode() == - SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) + if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - nFlags = 2; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing + nFollow = 2; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing } - else if ( rFmt.GetPositionAndSpaceMode() == - SvxNumberFormat::LABEL_ALIGNMENT ) + else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { switch ( rFmt.GetLabelFollowedBy() ) { case SvxNumberFormat::LISTTAB: { - nFlags = 0; + // 0 (tab) unless there would be no content before the tab, in which case 2 (nothing) + nFollow = (SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType()) ? 0 : 2; } break; case SvxNumberFormat::SPACE: { - nFlags = 1; + // 1 (space) unless there would be no content before the space in which case 2 (nothing) + nFollow = (SVX_NUM_NUMBER_NONE != rFmt.GetNumberingType()) ? 1 : 2; } break; case SvxNumberFormat::NOTHING: { - nFlags = 2; + nFollow = 2; } break; default: { - nFlags = 0; + nFollow = 0; ASSERT( false, "unknown GetLabelFollowedBy() return value" ); } @@ -293,19 +393,19 @@ void SwWW8Writer::OutListTab() sFontName = pBulletFont->GetName(); eFamily = pBulletFont->GetFamily(); - if (sw::util::IsStarSymbol(sFontName)) - SubstituteBullet(sNumStr,eChrSet,sFontName); + if ( sw::util::IsStarSymbol( sFontName ) ) + SubstituteBullet( sNumStr, eChrSet, sFontName ); // --> OD 2008-06-03 #i86652# if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { // --> OD 2007-07-23 #148661# - // <nFlags = 2>, if minimum label width equals 0 and + // <nFollow = 2>, if minimum label width equals 0 and // minimum distance between label and text equals 0 - nFlags = ( rFmt.GetFirstLineOffset() == 0 && - rFmt.GetCharTextDistance() == 0 ) - ? 2 : 0; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing + nFollow = ( rFmt.GetFirstLineOffset() == 0 && + rFmt.GetCharTextDistance() == 0 ) + ? 2 : 0; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing // <-- } // <-- @@ -337,11 +437,11 @@ void SwWW8Writer::OutListTab() SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { // --> OD 2007-07-23 #148661# - // <nFlags = 2>, if minimum label width equals 0 and + // <nFollow = 2>, if minimum label width equals 0 and // minimum distance between label and text equals 0 - nFlags = ( rFmt.GetFirstLineOffset() == 0 && - rFmt.GetCharTextDistance() == 0 ) - ? 2 : 0; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing + nFollow = ( rFmt.GetFirstLineOffset() == 0 && + rFmt.GetCharTextDistance() == 0 ) + ? 2 : 0; // ixchFollow: 0 - tab, 1 - blank, 2 - nothing // <-- } // <-- @@ -352,113 +452,70 @@ void SwWW8Writer::OutListTab() sNumStr += rFmt.GetSuffix(); } - // write the rgbxchNums[9] - pTableStrm->Write(aNumLvlPos, WW8ListManager::nMaxLevel); - - *pTableStrm << nFlags; - // dxaSoace/dxaIndent (Word 6 compatibility) - SwWW8Writer::WriteLong( *pTableStrm, 0 ); - SwWW8Writer::WriteLong( *pTableStrm, 0 ); + // Attributes of the numbering + wwFont *pPseudoFont = NULL; + const SfxItemSet* pOutSet = NULL; // cbGrpprlChpx - WW8Bytes aCharAtrs; - if( rFmt.GetCharFmt() || bWriteBullet ) + SfxItemSet aSet( pDoc->GetAttrPool(), RES_CHRATR_BEGIN, + RES_CHRATR_END ); + if ( rFmt.GetCharFmt() || bWriteBullet ) { - WW8Bytes* pOldpO = pO; - pO = &aCharAtrs; - SfxItemSet aSet( pDoc->GetAttrPool(), RES_CHRATR_BEGIN, - RES_CHRATR_END ); - const SfxItemSet* pOutSet; - if (bWriteBullet) + if ( bWriteBullet ) { pOutSet = &aSet; - if (rFmt.GetCharFmt()) + if ( rFmt.GetCharFmt() ) aSet.Put( rFmt.GetCharFmt()->GetAttrSet() ); - aSet.ClearItem(RES_CHRATR_CJK_FONT); - aSet.ClearItem(RES_CHRATR_FONT); + aSet.ClearItem( RES_CHRATR_CJK_FONT ); + aSet.ClearItem( RES_CHRATR_FONT ); - if (!sFontName.Len()) + if ( !sFontName.Len() ) sFontName = pBulletFont->GetName(); - wwFont aPseudoFont(sFontName, pBulletFont->GetPitch(), - eFamily, eChrSet, bWrtWW8); - USHORT nFontID = maFontHelper.GetId(aPseudoFont); - - if (bWrtWW8) - { - InsUInt16(0x4a4f); - InsUInt16(nFontID); - InsUInt16(0x4a51); - } - else - pO->Insert(93, pO->Count()); - InsUInt16(nFontID); + pPseudoFont = new wwFont( sFontName, pBulletFont->GetPitch(), + eFamily, eChrSet, HackIsWW8OrHigher() ); } else pOutSet = &rFmt.GetCharFmt()->GetAttrSet(); - - Out_SfxItemSet(*pOutSet, false, true, i18n::ScriptType::LATIN); - - pO = pOldpO; } - nFlags = (BYTE)aCharAtrs.Count(); - *pTableStrm << nFlags; - - // cbGrpprlPapx - nFlags = sizeof( aPapSprms ); - *pTableStrm << nFlags; - // reserved - SwWW8Writer::WriteShort( *pTableStrm, 0 ); + sal_Int16 nIndentAt = 0; + sal_Int16 nFirstLineIndex = 0; + sal_Int16 nListTabPos = 0; // --> OD 2008-06-03 #i86652# - if ( rFmt.GetPositionAndSpaceMode() == - SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) + if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - const sal_uInt16 nAbsLSpace = rFmt.GetAbsLSpace(); - const sal_Int16 nFirstLineOffset = GetWordFirstLineOffset(rFmt); - - // write Papx - BYTE* pData = aPapSprms + 2; - Set_UInt16( pData, nAbsLSpace ); - pData += 2; - Set_UInt16( pData, nFirstLineOffset ); - pData += 5; - Set_UInt16( pData, nAbsLSpace ); + nIndentAt = nListTabPos = rFmt.GetAbsLSpace(); + nFirstLineIndex = GetWordFirstLineOffset(rFmt); } - else if ( rFmt.GetPositionAndSpaceMode() == - SvxNumberFormat::LABEL_ALIGNMENT ) + else if ( rFmt.GetPositionAndSpaceMode() == SvxNumberFormat::LABEL_ALIGNMENT ) { - const sal_Int16 nIndentAt = static_cast<sal_Int16>(rFmt.GetIndentAt()); - const sal_Int16 nFirstLineIndenx = static_cast<sal_Int16>(rFmt.GetFirstLineIndent()); - const sal_Int16 nListTabPos = - rFmt.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB - ? static_cast<sal_Int16>(rFmt.GetListtabPos()) - : 0; - // write Papx - BYTE* pData = aPapSprms + 2; - Set_UInt16( pData, nIndentAt ); - pData += 2; - Set_UInt16( pData, nFirstLineIndenx ); - pData += 5; - Set_UInt16( pData, nListTabPos ); + nIndentAt = static_cast<sal_Int16>(rFmt.GetIndentAt()); + nFirstLineIndex = static_cast<sal_Int16>(rFmt.GetFirstLineIndent()); + nListTabPos = rFmt.GetLabelFollowedBy() == SvxNumberFormat::LISTTAB? + static_cast<sal_Int16>( rFmt.GetListtabPos() ) : 0; } - pTableStrm->Write( aPapSprms, sizeof( aPapSprms )); - // write Chpx - if( aCharAtrs.Count() ) - pTableStrm->Write( aCharAtrs.GetData(), aCharAtrs.Count() ); - - // write the num string - SwWW8Writer::WriteShort(*pTableStrm, sNumStr.Len()); - SwWW8Writer::WriteString16(*pTableStrm, sNumStr, false); + AttrOutput().NumberingLevel( nLvl, + rFmt.GetStart(), + rFmt.GetNumberingType(), + rFmt.GetNumAdjust(), + aNumLvlPos, + nFollow, + pPseudoFont, pOutSet, + nIndentAt, nFirstLineIndex, nListTabPos, + sNumStr ); + + delete pPseudoFont; } + AttrOutput().EndAbstractNumbering(); } delete pConvert; } -void SwWW8Writer::OutOverrideListTab() +void WW8Export::OutOverrideListTab() { if( !pUsedNumTbl ) return ; // no numbering is used @@ -482,7 +539,7 @@ void SwWW8Writer::OutOverrideListTab() pFib->lcbPlfLfo = pTableStrm->Tell() - pFib->fcPlfLfo; } -void SwWW8Writer::OutListNamesTab() +void WW8Export::OutListNamesTab() { if( !pUsedNumTbl ) return ; // no numbering is used @@ -515,8 +572,11 @@ void SwWW8Writer::OutListNamesTab() // old WW95-Code -void SwWW8Writer::Out_Olst( const SwNumRule& rRule ) +void WW8Export::OutputOlst( const SwNumRule& rRule ) { + if ( bWrtWW8 ) + return; + static BYTE __READONLY_DATA aAnlvBase[] = { // Defaults 1,0,0, // Upper Roman 0x0C, // Hanging Indent, fPrev @@ -545,13 +605,13 @@ void SwWW8Writer::Out_Olst( const SwNumRule& rRule ) } -void SwWW8Writer::Out_WwNumLvl( BYTE nWwLevel ) +void WW8Export::Out_WwNumLvl( BYTE nWwLevel ) { pO->Insert( 13, pO->Count() ); pO->Insert( nWwLevel, pO->Count() ); } -void SwWW8Writer::Out_SwNumLvl( BYTE nSwLevel ) +void WW8Export::Out_SwNumLvl( BYTE nSwLevel ) { // --> OD 2008-04-02 #refactorlists# // ASSERT(IsNum(nSwLevel), "numbered?"); @@ -560,7 +620,7 @@ void SwWW8Writer::Out_SwNumLvl( BYTE nSwLevel ) Out_WwNumLvl( nSwLevel + 1 ); } -void SwWW8Writer::BuildAnlvBulletBase(WW8_ANLV& rAnlv, BYTE*& rpCh, +void WW8Export::BuildAnlvBulletBase(WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen, const SwNumFmt& rFmt) { ByteToSVBT8(11, rAnlv.nfc); @@ -658,8 +718,8 @@ void SwWW8Writer::BuildAnlvBulletBase(WW8_ANLV& rAnlv, BYTE*& rpCh, // <-- } -void SwWW8Writer::SubstituteBullet(String& rNumStr, - rtl_TextEncoding& rChrSet, String& rFontName) const +void MSWordExportBase::SubstituteBullet( String& rNumStr, + rtl_TextEncoding& rChrSet, String& rFontName ) const { StarSymbolToMSMultiFont *pConvert = 0; FontFamily eFamily = FAMILY_DECORATIVE; @@ -686,7 +746,7 @@ void SwWW8Writer::SubstituteBullet(String& rNumStr, rFontName = sFont; rChrSet = RTL_TEXTENCODING_SYMBOL; } - else if ( bWrtWW8 && + else if ( HackIsWW8OrHigher() && (rNumStr.GetChar(0) < 0xE000 || rNumStr.GetChar(0) > 0xF8FF) ) { /* @@ -730,11 +790,11 @@ static void SwWw8_InsertAnlText( const String& rStr, BYTE*& rpCh, ByteToSVBT8( nb, r8Len ); } -void SwWW8Writer::BuildAnlvBase(WW8_ANLV& rAnlv, BYTE*& rpCh, +void WW8Export::BuildAnlvBase(WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen, const SwNumRule& rRul, const SwNumFmt& rFmt, BYTE nSwLevel) { - ByteToSVBT8(SwWW8Writer::GetNumId(rFmt.GetNumberingType()), rAnlv.nfc); + ByteToSVBT8(WW8Export::GetNumId(rFmt.GetNumberingType()), rAnlv.nfc); BYTE nb = 0; switch (rFmt.GetNumAdjust()) @@ -802,7 +862,7 @@ void SwWW8Writer::BuildAnlvBase(WW8_ANLV& rAnlv, BYTE*& rpCh, // <-- } -void SwWW8Writer::Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt, +void WW8Export::Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt, BYTE nSwLevel ) { static BYTE __READONLY_DATA aSprmAnldDefault[54] = { @@ -830,7 +890,7 @@ void SwWW8Writer::Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt, // Return: ist es eine Gliederung ? -bool SwWW8Writer::Out_SwNum(const SwTxtNode* pNd) +bool WW8Export::Out_SwNum(const SwTxtNode* pNd) { int nLevel = pNd->GetActualListLevel(); diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index ddc8846c0d..c6f6ce0b02 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -33,17 +33,10 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ - -#ifndef __SGI_STL_ALGORITHM #include <algorithm> -#endif -#ifndef __SGI_STL_FUNCTIONAL #include <functional> -#endif -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <rtl/tencinfo.h> #include <hintids.hxx> #include <svx/boxitem.hxx> @@ -76,16 +69,22 @@ #include <ftnidx.hxx> #include <fmtclds.hxx> #include <lineinfo.hxx> +#include <fmtline.hxx> +#include <swtable.hxx> #include <msfilter.hxx> -# include "writerhelper.hxx" -# include "writerwordglue.hxx" -# include "../inc/wwstyles.hxx" + +#include <writerfilter/doctok/sprmids.hxx> + +#include "writerhelper.hxx" +#include "writerwordglue.hxx" +#include "../inc/wwstyles.hxx" #include "ww8par.hxx" +#include "ww8attributeoutput.hxx" +#include "docxattributeoutput.hxx" using namespace sw::util; using namespace nsHdFtFlags; - struct WW8_SED { SVBT16 aBits1; // orientation change + internal, Default: 6 @@ -97,13 +96,6 @@ struct WW8_SED // cbSED is 12 (decimal)), C (hex). }; -struct WW8_PdAttrDesc -{ - BYTE* pData; - USHORT nLen; - WW8_FC nSepxFcPos; -}; - SV_IMPL_VARARR( WW8_WrSepInfoPtrs, WW8_SepInfo ) // class WW8_WrPlc0 ist erstmal nur fuer Header / Footer-Positionen, d.h. es @@ -132,89 +124,91 @@ public: // GetId( SwCharFmt ) zur Benutzung im Text -> nil verboten, // "Default Char Style" stattdessen -USHORT SwWW8Writer::GetId( const SwCharFmt& rFmt ) const +USHORT MSWordExportBase::GetId( const SwCharFmt& rFmt ) const { - USHORT nRet = pStyles->Sty_GetWWSlot( rFmt ); + USHORT nRet = pStyles->GetSlot( rFmt ); return ( nRet != 0x0fff ) ? nRet : 10; // Default Char Style } // GetId( SwTxtFmtColl ) zur Benutzung an TextNodes -> nil verboten, // "Standard" stattdessen -USHORT SwWW8Writer::GetId( const SwTxtFmtColl& rColl ) const +USHORT MSWordExportBase::GetId( const SwTxtFmtColl& rColl ) const { - USHORT nRet = pStyles->Sty_GetWWSlot( rColl ); + USHORT nRet = pStyles->GetSlot( rColl ); return ( nRet != 0xfff ) ? nRet : 0; // Default TxtFmtColl } //typedef pFmtT -WW8WrtStyle::WW8WrtStyle( SwWW8Writer& rWr ) - : rWrt( rWr ), nPOPosStdLen1( 0 ), nPOPosStdLen2( 0 ) +MSWordStyles::MSWordStyles( MSWordExportBase& rExport ) + : m_rExport( rExport ) { - rWrt.pO->Remove( 0, rWrt.pO->Count() ); // leeren - SwDoc& rDoc = *rWrt.pDoc; - // if exist any Foot-/End-Notes then get from the EndNoteInfo struct // the CharFormats. They will create it! - if( rDoc.GetFtnIdxs().Count() ) + if ( m_rExport.pDoc->GetFtnIdxs().Count() ) { - rDoc.GetEndNoteInfo().GetAnchorCharFmt( rDoc ); - rDoc.GetEndNoteInfo().GetCharFmt( rDoc ); - rDoc.GetFtnInfo().GetAnchorCharFmt( rDoc ); - rDoc.GetFtnInfo().GetCharFmt( rDoc ); + m_rExport.pDoc->GetEndNoteInfo().GetAnchorCharFmt( *m_rExport.pDoc ); + m_rExport.pDoc->GetEndNoteInfo().GetCharFmt( *m_rExport.pDoc ); + m_rExport.pDoc->GetFtnInfo().GetAnchorCharFmt( *m_rExport.pDoc ); + m_rExport.pDoc->GetFtnInfo().GetCharFmt( *m_rExport.pDoc ); } - USHORT nAlloc = WW8_RESERVED_SLOTS + rDoc.GetCharFmts()->Count() - 1 + - rDoc.GetTxtFmtColls()->Count() - 1; - // etwas grosszuegig ( bis zu 15 frei ) + USHORT nAlloc = WW8_RESERVED_SLOTS + m_rExport.pDoc->GetCharFmts()->Count() - 1 + + m_rExport.pDoc->GetTxtFmtColls()->Count() - 1; + + // etwas grosszuegig ( bis zu 15 frei ) pFmtA = new SwFmt*[ nAlloc ]; memset( pFmtA, 0, nAlloc * sizeof( SwFmt* ) ); - BuildStyleTab(); + + BuildStylesTable(); } -WW8WrtStyle::~WW8WrtStyle() +MSWordStyles::~MSWordStyles() { delete[] pFmtA; - rWrt.pO->Remove( 0, rWrt.pO->Count() ); // leeren } // Sty_SetWWSlot() fuer Abhaengigkeiten der Styles -> nil ist erlaubt -USHORT WW8WrtStyle::Sty_GetWWSlot( const SwFmt& rFmt ) const +USHORT MSWordStyles::GetSlot( const SwFmt& rFmt ) const { USHORT n; - for( n = 0; n < nUsedSlots; n++ ) - if( pFmtA[n] == &rFmt ) + for ( n = 0; n < nUsedSlots; n++ ) + if ( pFmtA[n] == &rFmt ) return n; return 0xfff; // 0xfff: WW: nil } -USHORT WW8WrtStyle::Build_GetWWSlot( const SwFmt& rFmt ) +USHORT MSWordStyles::BuildGetSlot( const SwFmt& rFmt ) { USHORT nRet; - switch( nRet = rFmt.GetPoolFmtId() ) - { - case RES_POOLCOLL_STANDARD: nRet = 0; break; - - case RES_POOLCOLL_HEADLINE1: - case RES_POOLCOLL_HEADLINE2: - case RES_POOLCOLL_HEADLINE3: - case RES_POOLCOLL_HEADLINE4: - case RES_POOLCOLL_HEADLINE5: - case RES_POOLCOLL_HEADLINE6: - case RES_POOLCOLL_HEADLINE7: - case RES_POOLCOLL_HEADLINE8: - case RES_POOLCOLL_HEADLINE9: nRet -= RES_POOLCOLL_HEADLINE1-1; break; - -// case RES_POOLCHR_FOOTNOTE_ANCHOR: nRet = -// case RES_POOLCHR_ENDNOTE_ANCHOR: - default: - nRet = nUsedSlots++; - break; + switch ( nRet = rFmt.GetPoolFmtId() ) + { + case RES_POOLCOLL_STANDARD: + nRet = 0; + break; + + case RES_POOLCOLL_HEADLINE1: + case RES_POOLCOLL_HEADLINE2: + case RES_POOLCOLL_HEADLINE3: + case RES_POOLCOLL_HEADLINE4: + case RES_POOLCOLL_HEADLINE5: + case RES_POOLCOLL_HEADLINE6: + case RES_POOLCOLL_HEADLINE7: + case RES_POOLCOLL_HEADLINE8: + case RES_POOLCOLL_HEADLINE9: + nRet -= RES_POOLCOLL_HEADLINE1-1; + break; + + //case RES_POOLCHR_FOOTNOTE_ANCHOR: nRet = + //case RES_POOLCHR_ENDNOTE_ANCHOR: + default: + nRet = nUsedSlots++; + break; } return nRet; } -USHORT WW8WrtStyle::GetWWId( const SwFmt& rFmt ) const +USHORT MSWordStyles::GetWWId( const SwFmt& rFmt ) const { USHORT nRet = ww::stiUser; // User-Style als default USHORT nPoolId = rFmt.GetPoolFmtId(); @@ -262,45 +256,52 @@ USHORT WW8WrtStyle::GetWWId( const SwFmt& rFmt ) const return nRet; } -void WW8WrtStyle::BuildStyleTab() +void MSWordStyles::BuildStylesTable() { nUsedSlots = WW8_RESERVED_SLOTS; // soviele sind reserviert fuer // Standard und HeadingX u.a. SwFmt* pFmt; USHORT n; - const SvPtrarr& rArr = *rWrt.pDoc->GetCharFmts(); // erst CharFmt - // das Default-ZeichenStyle ( 0 ) wird nicht mit ausgegeben ! + const SvPtrarr& rArr = *m_rExport.pDoc->GetCharFmts(); // erst CharFmt + // das Default-ZeichenStyle ( 0 ) wird nicht mit ausgegeben ! for( n = 1; n < rArr.Count(); n++ ) { pFmt = (SwFmt*)rArr[n]; - pFmtA[ Build_GetWWSlot( *pFmt ) ] = pFmt; + pFmtA[ BuildGetSlot( *pFmt ) ] = pFmt; } - const SvPtrarr& rArr2 = *rWrt.pDoc->GetTxtFmtColls(); // dann TxtFmtColls - // das Default-TextStyle ( 0 ) wird nicht mit ausgegeben ! + + const SvPtrarr& rArr2 = *m_rExport.pDoc->GetTxtFmtColls(); // dann TxtFmtColls + // das Default-TextStyle ( 0 ) wird nicht mit ausgegeben ! for( n = 1; n < rArr2.Count(); n++ ) { pFmt = (SwFmt*)rArr2[n]; - pFmtA[ Build_GetWWSlot( *pFmt ) ] = pFmt; + pFmtA[ BuildGetSlot( *pFmt ) ] = pFmt; } } -void WW8WrtStyle::WriteStyle( SvStream& rStrm ) +/// For WW8 only - extend pO so that the size of pTableStrm is even. +static void impl_SkipOdd( WW8Bytes* pO, sal_Size nTableStrmTell ) +{ + if ( ( nTableStrmTell + pO->Count() ) & 1 ) // Start auf gerader + pO->Insert( (BYTE)0, pO->Count() ); // Adresse +} + +void WW8AttributeOutput::EndStyle() { - WW8Bytes* pO = rWrt.pO; + impl_SkipOdd( m_rWW8Export.pO, m_rWW8Export.pTableStrm->Tell() ); - short nLen = pO->Count() - 2; // Laenge des Styles - BYTE* p = (BYTE*)pO->GetData() + nPOPosStdLen1; + short nLen = m_rWW8Export.pO->Count() - 2; // Laenge des Styles + BYTE* p = (BYTE*)m_rWW8Export.pO->GetData() + nPOPosStdLen1; ShortToSVBT16( nLen, p ); // nachtragen - p = (BYTE*)pO->GetData() + nPOPosStdLen2; + p = (BYTE*)m_rWW8Export.pO->GetData() + nPOPosStdLen2; ShortToSVBT16( nLen, p ); // dito - rStrm.Write( pO->GetData(), pO->Count() ); // ins File damit - pO->Remove( 0, pO->Count() ); // leeren fuer naechsten + m_rWW8Export.pTableStrm->Write( m_rWW8Export.pO->GetData(), m_rWW8Export.pO->Count() ); // ins File damit + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren fuer naechsten } - -void WW8WrtStyle::BuildStd(const String& rName, bool bPapFmt, short nWwBase, - short nWwNext, USHORT nWwId) +void WW8AttributeOutput::StartStyle( const String& rName, bool bPapFmt, USHORT nWwBase, + USHORT nWwNext, USHORT nWwId, USHORT /*nId*/ ) { BYTE aWW8_STD[ sizeof( WW8_STD ) ]; BYTE* pData = aWW8_STD; @@ -320,7 +321,7 @@ void WW8WrtStyle::BuildStd(const String& rName, bool bPapFmt, short nWwBase, pData += sizeof( UINT16 ); // bchUpe - if( rWrt.bWrtWW8 ) + if( m_rWW8Export.bWrtWW8 ) { //-------- jetzt neu: // ab Ver8 gibts zwei Felder mehr: @@ -332,9 +333,9 @@ void WW8WrtStyle::BuildStd(const String& rName, bool bPapFmt, short nWwBase, UINT16 nLen = static_cast< UINT16 >( ( pData - aWW8_STD ) + 1 + - ((rWrt.bWrtWW8 ? 2 : 1 ) * (rName.Len() + 1)) ); // vorlaeufig + ((m_rWW8Export.bWrtWW8 ? 2 : 1 ) * (rName.Len() + 1)) ); // vorlaeufig - WW8Bytes* pO = rWrt.pO; + WW8Bytes* pO = m_rWW8Export.pO; nPOPosStdLen1 = pO->Count(); // Adr1 zum nachtragen der Laenge SwWW8Writer::InsUInt16( *pO, nLen ); @@ -343,7 +344,7 @@ void WW8WrtStyle::BuildStd(const String& rName, bool bPapFmt, short nWwBase, nPOPosStdLen2 = nPOPosStdLen1 + 8; // Adr2 zum nachtragen von "end of upx" // Namen schreiben - if( rWrt.bWrtWW8 ) + if( m_rWW8Export.bWrtWW8 ) { SwWW8Writer::InsUInt16( *pO, rName.Len() ); // Laenge SwWW8Writer::InsAsString16( *pO, rName ); @@ -356,17 +357,10 @@ void WW8WrtStyle::BuildStd(const String& rName, bool bPapFmt, short nWwBase, pO->Insert( (BYTE)0, pO->Count() ); // Trotz P-String 0 am Ende! } -void WW8WrtStyle::SkipOdd() // Ruecke zu gerader Adresse vor +void MSWordStyles::SetStyleDefaults( const SwFmt& rFmt, bool bPap ) { - WW8Bytes* pO = rWrt.pO; - if( ( rWrt.pTableStrm->Tell() + pO->Count() ) & 1 ) // Start auf gerader - pO->Insert( (BYTE)0, pO->Count() ); // Adresse -} - -void WW8WrtStyle::Set1StyleDefaults(const SwFmt& rFmt, bool bPap) -{ - const SwModify* pOldMod = rWrt.pOutFmtNode; - rWrt.pOutFmtNode = &rFmt; + const SwModify* pOldMod = m_rExport.pOutFmtNode; + m_rExport.pOutFmtNode = &rFmt; bool aFlags[ static_cast< USHORT >(RES_FRMATR_END) - RES_CHRATR_BEGIN ]; USHORT nStt, nEnd, n; if( bPap ) @@ -391,95 +385,101 @@ void WW8WrtStyle::Set1StyleDefaults(const SwFmt& rFmt, bool bPap) aFlags[ RES_CHRATR_LANGUAGE - RES_CHRATR_BEGIN ] = 1; } - const SfxItemSet* pOldI = rWrt.GetCurItemSet(); - rWrt.SetCurItemSet( &rFmt.GetAttrSet() ); + const SfxItemSet* pOldI = m_rExport.GetCurItemSet(); + m_rExport.SetCurItemSet( &rFmt.GetAttrSet() ); const bool* pFlags = aFlags + ( nStt - RES_CHRATR_BEGIN ); - for( n = nStt; n < nEnd; ++n, ++pFlags ) + for ( n = nStt; n < nEnd; ++n, ++pFlags ) { - if( *pFlags && SFX_ITEM_SET != rFmt.GetItemState(n, false)) + if ( *pFlags && SFX_ITEM_SET != rFmt.GetItemState(n, false)) { //If we are a character property then see if it is one of the //western/asian ones that must be collapsed together for export to //word. If so default to the western varient. - if ( bPap || rWrt.CollapseScriptsforWordOk( + if ( bPap || m_rExport.CollapseScriptsforWordOk( i18n::ScriptType::LATIN, n) ) { - Out(aWW8AttrFnTab, rFmt.GetFmtAttr(n, true), rWrt); + m_rExport.AttrOutput().OutputItem( rFmt.GetFmtAttr( n, true ) ); } } } - rWrt.SetCurItemSet( pOldI ); - rWrt.pOutFmtNode = pOldMod; + m_rExport.SetCurItemSet( pOldI ); + m_rExport.pOutFmtNode = pOldMod; } -void WW8WrtStyle::BuildUpx(const SwFmt* pFmt, bool bPap, USHORT nPos, - bool bInsDefCharSiz) +void WW8AttributeOutput::StartStyleProperties( bool bParProp, USHORT nStyle ) { - WW8Bytes* pO = rWrt.pO; + WW8Bytes* pO = m_rWW8Export.pO; - SkipOdd(); - UINT16 nLen = ( bPap ) ? 2 : 0; // Default-Laenge - USHORT nLenPos = pO->Count(); // Laenge zum Nachtragen + impl_SkipOdd( pO, m_rWW8Export.pTableStrm->Tell() ); + + UINT16 nLen = ( bParProp ) ? 2 : 0; // Default-Laenge + m_nStyleLenPos = pO->Count(); // Laenge zum Nachtragen // Keinen Pointer merken, da sich bei // _grow der Pointer aendert ! SwWW8Writer::InsUInt16( *pO, nLen ); // Style-Len - UINT16 nStartSiz = pO->Count(); + m_nStyleStartSize = pO->Count(); - if( bPap ) - SwWW8Writer::InsUInt16( *pO, nPos); // Style-Nummer + if ( bParProp ) + SwWW8Writer::InsUInt16( *pO, nStyle ); // Style-Nummer +} - ASSERT(rWrt.pCurrentStyle==NULL, "Current style not NULL"); // set current style before calling out - rWrt.pCurrentStyle=pFmt; +void MSWordStyles::WriteProperties( const SwFmt* pFmt, bool bParProp, USHORT nPos, + bool bInsDefCharSiz ) +{ + m_rExport.AttrOutput().StartStyleProperties( bParProp, nPos ); + + ASSERT( m_rExport.pCurrentStyle == NULL, "Current style not NULL" ); // set current style before calling out + m_rExport.pCurrentStyle = pFmt; - rWrt.Out_SwFmt( *pFmt, bPap, !bPap ); + m_rExport.OutputFormat( *pFmt, bParProp, !bParProp ); - ASSERT(rWrt.pCurrentStyle!=pFmt, "current style was changed"); // reset current style... - rWrt.pCurrentStyle=NULL; + ASSERT( m_rExport.pCurrentStyle != pFmt, "current style was changed" ); // reset current style... + m_rExport.pCurrentStyle = NULL; + + if ( bInsDefCharSiz ) // nicht abgeleitet v. anderem Style + SetStyleDefaults( *pFmt, bParProp ); - if( bInsDefCharSiz ) // nicht abgeleitet v. anderem Style - Set1StyleDefaults( *pFmt, bPap ); + m_rExport.AttrOutput().EndStyleProperties( bParProp ); +} + +void WW8AttributeOutput::EndStyleProperties( bool /*bParProp*/ ) +{ + WW8Bytes* pO = m_rWW8Export.pO; - nLen = pO->Count() - nStartSiz; - BYTE* pUpxLen = (BYTE*)pO->GetData() + nLenPos; // Laenge zum Nachtragen + UINT16 nLen = pO->Count() - m_nStyleStartSize; + BYTE* pUpxLen = (BYTE*)pO->GetData() + m_nStyleLenPos; // Laenge zum Nachtragen ShortToSVBT16( nLen, pUpxLen ); // Default-Laenge eintragen } -// Out1Style geht fuer TxtFmtColls und CharFmts -void WW8WrtStyle::Out1Style( SwFmt* pFmt, USHORT nPos ) +void MSWordStyles::GetStyleData( SwFmt* pFmt, bool& bFmtColl, USHORT& nBase, USHORT& nNext ) { - if( pFmt ) - { - bool bFmtColl = pFmt->Which() == RES_TXTFMTCOLL || - pFmt->Which() == RES_CONDTXTFMTCOLL; - short nWwBase = 0xfff; // Default: none + bFmtColl = pFmt->Which() == RES_TXTFMTCOLL || pFmt->Which() == RES_CONDTXTFMTCOLL; - if( !pFmt->IsDefault() ) // Abgeleitet von ? - nWwBase = Sty_GetWWSlot( *pFmt->DerivedFrom() ); + // Default: none + nBase = 0xfff; - SwFmt* pNext; - if( bFmtColl ) - pNext = &((SwTxtFmtColl*)pFmt)->GetNextTxtFmtColl(); - else - pNext = pFmt; // CharFmt: Naechstes CharFmt == Selbes + // Derived from? + if ( !pFmt->IsDefault() ) + nBase = GetSlot( *pFmt->DerivedFrom() ); - short nWwNext = Sty_GetWWSlot( *pNext ); + SwFmt* pNext; + if ( bFmtColl ) + pNext = &((SwTxtFmtColl*)pFmt)->GetNextTxtFmtColl(); + else + pNext = pFmt; // CharFmt: next CharFmt == self - BuildStd( pFmt->GetName(), bFmtColl, nWwBase, nWwNext, - GetWWId( *pFmt ) ); - if( bFmtColl ) - BuildUpx( pFmt, true, nPos, nWwBase==0xfff ); // UPX.papx - BuildUpx( pFmt, false, nPos, bFmtColl && nWwBase==0xfff ); // UPX.chpx + nNext = GetSlot( *pNext ); +} - SkipOdd(); - WriteStyle( *rWrt.pTableStrm ); - } - else if( nPos == 10 ) // Default Char-Style ( nur WW ) +void WW8AttributeOutput::DefaultStyle( USHORT nStyle ) +{ + if ( nStyle == 10 ) // Default Char-Style ( nur WW ) { - if( rWrt.bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) { static BYTE __READONLY_DATA aDefCharSty[] = { 0x42, 0x00, @@ -492,7 +492,7 @@ void WW8WrtStyle::Out1Style( SwFmt* pFmt, USHORT nPos ) 0x72, 0x00, 0x69, 0x00, 0x66, 0x00, 0x74, 0x00, 0x61, 0x00, 0x72, 0x00, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00 }; - rWrt.pTableStrm->Write( &aDefCharSty, sizeof( aDefCharSty ) ); + m_rWW8Export.pTableStrm->Write( &aDefCharSty, sizeof( aDefCharSty ) ); } else { @@ -503,31 +503,54 @@ void WW8WrtStyle::Out1Style( SwFmt* pFmt, USHORT nPos ) 0x53, 0x74, 0x61, 0x6E, 0x64, 0x61, 0x72, 0x64, 0x73, 0x63, 0x68, 0x72, 0x69, 0x66, 0x74, 0x61, 0x72, 0x74, 0x00, 0x00, 0x00, 0x00 }; - rWrt.pTableStrm->Write( &aDefCharSty, sizeof( aDefCharSty ) ); + m_rWW8Export.pTableStrm->Write( &aDefCharSty, sizeof( aDefCharSty ) ); } } else { UINT16 n = 0; - rWrt.pTableStrm->Write( &n , 2 ); // leerer Style + m_rWW8Export.pTableStrm->Write( &n , 2 ); // leerer Style + } +} + +// OutputStyle geht fuer TxtFmtColls und CharFmts +void MSWordStyles::OutputStyle( SwFmt* pFmt, USHORT nPos ) +{ + if ( !pFmt ) + m_rExport.AttrOutput().DefaultStyle( nPos ); + else + { + bool bFmtColl; + USHORT nBase, nWwNext; + + GetStyleData( pFmt, bFmtColl, nBase, nWwNext ); + + m_rExport.AttrOutput().StartStyle( pFmt->GetName(), bFmtColl, + nBase, nWwNext, GetWWId( *pFmt ), nPos ); + + if ( bFmtColl ) + WriteProperties( pFmt, true, nPos, nBase==0xfff ); // UPX.papx + + WriteProperties( pFmt, false, nPos, bFmtColl && nBase==0xfff ); // UPX.chpx + + m_rExport.AttrOutput().EndStyle(); } } -void WW8WrtStyle::OutStyleTab() +void WW8AttributeOutput::StartStyles() { - WW8Fib& rFib = *rWrt.pFib; + WW8Fib& rFib = *m_rWW8Export.pFib; - ULONG nCurPos = rWrt.pTableStrm->Tell(); - if( nCurPos & 1 ) // Start auf gerader + ULONG nCurPos = m_rWW8Export.pTableStrm->Tell(); + if ( nCurPos & 1 ) // Start auf gerader { - *rWrt.pTableStrm << (char)0; // Adresse + *m_rWW8Export.pTableStrm << (char)0; // Adresse ++nCurPos; } - rWrt.bStyDef = true; rFib.fcStshfOrig = rFib.fcStshf = nCurPos; - ULONG nStyAnzPos = nCurPos + 2; // Anzahl wird nachgetragen + m_nStyAnzPos = nCurPos + 2; // Anzahl wird nachgetragen - if( rWrt.bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) { static BYTE __READONLY_DATA aStShi[] = { 0x12, 0x00, @@ -535,7 +558,7 @@ void WW8WrtStyle::OutStyleTab() 0x0F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - rWrt.pTableStrm->Write( &aStShi, sizeof( aStShi ) ); + m_rWW8Export.pTableStrm->Write( &aStShi, sizeof( aStShi ) ); } else { @@ -543,16 +566,31 @@ void WW8WrtStyle::OutStyleTab() 0x0E, 0x00, 0x0F, 0x00, 0x08, 0x00, 0x01, 0x00, 0x4B, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00 }; - rWrt.pTableStrm->Write( &aStShi, sizeof( aStShi ) ); + m_rWW8Export.pTableStrm->Write( &aStShi, sizeof( aStShi ) ); } +} + +void WW8AttributeOutput::EndStyles( USHORT nNumberOfStyles ) +{ + WW8Fib& rFib = *m_rWW8Export.pFib; + + rFib.lcbStshfOrig = rFib.lcbStshf = m_rWW8Export.pTableStrm->Tell() - rFib.fcStshf; + SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, m_nStyAnzPos, nNumberOfStyles ); +} + +void MSWordStyles::OutputStylesTable() +{ + m_rExport.bStyDef = true; + + m_rExport.AttrOutput().StartStyles(); USHORT n; - for( n = 0; n < nUsedSlots; n++ ) - Out1Style( pFmtA[n], n ); + for ( n = 0; n < nUsedSlots; n++ ) + OutputStyle( pFmtA[n], n ); + + m_rExport.AttrOutput().EndStyles( nUsedSlots ); - rFib.lcbStshfOrig = rFib.lcbStshf = rWrt.pTableStrm->Tell() - rFib.fcStshf; - SwWW8Writer::WriteShort( *rWrt.pTableStrm, nStyAnzPos, nUsedSlots ); - rWrt.bStyDef = false; + m_rExport.bStyDef = false; } /* */ @@ -561,7 +599,7 @@ void WW8WrtStyle::OutStyleTab() // Fonts //--------------------------------------------------------------------------- wwFont::wwFont(const String &rFamilyName, FontPitch ePitch, FontFamily eFamily, - rtl_TextEncoding eChrSet, bool bWrtWW8) : mbAlt(false), mbWrtWW8(bWrtWW8) + rtl_TextEncoding eChrSet, bool bWrtWW8) : mbAlt(false), mbWrtWW8(bWrtWW8), mePitch(ePitch), meFamily(eFamily), meChrSet(eChrSet) { FontMapExport aResult(rFamilyName); msFamilyNm = aResult.msPrimary; @@ -659,6 +697,23 @@ bool wwFont::Write(SvStream *pTableStrm) const return true; } +#ifdef DOCX +void wwFont::WriteDocx( const DocxAttributeOutput* rAttrOutput ) const +{ + // no font embedding, panose id, subsetting, ... implemented + + rAttrOutput->StartFont( msFamilyNm ); + + if ( mbAlt ) + rAttrOutput->FontAlternateName( msAltNm ); + rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ) ); + rAttrOutput->FontFamilyType( meFamily ); + rAttrOutput->FontPitchType( mePitch ); + + rAttrOutput->EndFont(); +} +#endif + bool operator<(const wwFont &r1, const wwFont &r2) { int nRet = memcmp(r1.maWW8_FFN, r2.maWW8_FFN, sizeof(r1.maWW8_FFN)); @@ -727,6 +782,18 @@ USHORT wwFontHelper::GetId(const SvxFontItem& rFont) return GetId(aFont); } +::std::vector< const wwFont* > wwFontHelper::AsVector() const +{ + ::std::vector<const wwFont *> aFontList( maFonts.size() ); + + typedef ::std::map<wwFont, USHORT>::const_iterator myiter; + myiter aEnd = maFonts.end(); + for ( myiter aIter = maFonts.begin(); aIter != aEnd; ++aIter ) + aFontList[aIter->second] = &aIter->first; + + return aFontList; +} + void wwFontHelper::WriteFontTable(SvStream *pTableStream, WW8Fib& rFib) { rFib.fcSttbfffn = pTableStream->Tell(); @@ -742,12 +809,7 @@ void wwFontHelper::WriteFontTable(SvStream *pTableStream, WW8Fib& rFib) * Convert from fast insertion map to linear vector in the order that we * want to write. */ - ::std::vector<const wwFont *> aFontList(maFonts.size()); - - typedef ::std::map<wwFont, USHORT>::iterator myiter; - myiter aEnd = maFonts.end(); - for(myiter aIter = maFonts.begin(); aIter != aEnd; ++aIter) - aFontList[aIter->second] = &aIter->first; + ::std::vector<const wwFont *> aFontList( AsVector() ); /* * Write them all to pTableStream @@ -768,6 +830,16 @@ void wwFontHelper::WriteFontTable(SvStream *pTableStream, WW8Fib& rFib) } } +#ifdef DOCX +void wwFontHelper::WriteFontTable( const DocxAttributeOutput& rAttrOutput ) +{ + ::std::vector<const wwFont *> aFontList( AsVector() ); + + ::std::for_each( aFontList.begin(), aFontList.end(), + ::std::bind2nd( ::std::mem_fun( &wwFont::WriteDocx ), &rAttrOutput ) ); +} +#endif + /* */ WW8_WrPlc0::WW8_WrPlc0( ULONG nOffset ) @@ -795,13 +867,71 @@ void WW8_WrPlc0::Write( SvStream& rStrm ) /* */ //------------------------------------------------------------------------------ -// class WW8_WrPlcSepx : Uebersetzung PageDescs in Sections +// class MSWordSections : Uebersetzung PageDescs in Sections // behandelt auch Header und Footer //------------------------------------------------------------------------------ -WW8_WrPlcSepx::WW8_WrPlcSepx() : - mbDocumentIsProtected(false), aSects(4, 4), aCps(4, 4), pAttrs(0), - pTxtPos(0) +MSWordSections::MSWordSections( MSWordExportBase& rExport ) + : mbDocumentIsProtected( false ), + aSects( 4, 4 ) +{ + const SwSectionFmt *pFmt = 0; + rExport.pAktPageDesc = &const_cast<const SwDoc *>(rExport.pDoc)->GetPageDesc( 0 ); + + const SfxPoolItem* pI; + const SwNode* pNd = rExport.pCurPam->GetCntntNode(); + const SfxItemSet* pSet = pNd ? &((SwCntntNode*)pNd)->GetSwAttrSet() : 0; + + ULONG nRstLnNum = pSet ? ((SwFmtLineNumber&)pSet->Get( RES_LINENUMBER )).GetStartValue() : 0; + + const SwTableNode* pTblNd = rExport.pCurPam->GetNode()->FindTableNode(); + const SwSectionNode* pSectNd; + if ( pTblNd ) + { + pSet = &pTblNd->GetTable().GetFrmFmt()->GetAttrSet(); + pNd = pTblNd; + } + else if ( 0 != ( pSectNd = pNd->FindSectionNode() ) ) + { + if ( TOX_HEADER_SECTION == pSectNd->GetSection().GetType() && + pSectNd->StartOfSectionNode()->IsSectionNode() ) + { + pSectNd = pSectNd->StartOfSectionNode()->GetSectionNode(); + } + + if ( TOX_CONTENT_SECTION == pSectNd->GetSection().GetType() ) + { + pNd = pSectNd; + rExport.pCurPam->GetPoint()->nNode = *pNd; + } + + if ( CONTENT_SECTION == pSectNd->GetSection().GetType() ) + pFmt = pSectNd->GetSection().GetFmt(); + } + + // Hole evtl. Pagedesc des 1. Nodes + if ( pSet && + SFX_ITEM_ON == pSet->GetItemState( RES_PAGEDESC, true, &pI ) && + ( (SwFmtPageDesc*)pI )->GetPageDesc() ) + { + AppendSep( *(SwFmtPageDesc*)pI, *pNd, pFmt, nRstLnNum ); + } + else + AppendSep( rExport.pAktPageDesc, pFmt, nRstLnNum ); +} + +WW8_WrPlcSepx::WW8_WrPlcSepx( MSWordExportBase& rExport ) + : MSWordSections( rExport ), + aCps( 4, 4 ), + pAttrs( 0 ), + pTxtPos( 0 ) +{ + // to be in sync with the AppendSep() call in the MSWordSections + // constructor + aCps.Insert( ULONG( 0 ), aCps.Count() ); +} + +MSWordSections::~MSWordSections() { } @@ -817,79 +947,93 @@ WW8_WrPlcSepx::~WW8_WrPlcSepx() delete pTxtPos; } -sal_uInt16 WW8_WrPlcSepx::CurrentNoColumns(const SwDoc &rDoc) const +sal_uInt16 MSWordSections::CurrentNumberOfColumns( const SwDoc &rDoc ) const { - ASSERT(aSects.Count(), "no segement inserted yet"); - if (!aSects.Count()) + ASSERT( aSects.Count(), "no segement inserted yet" ); + if ( !aSects.Count() ) return 1; - WW8_SepInfo& rInfo = aSects[aSects.Count() - 1]; + return NumberOfColumns( rDoc, aSects[aSects.Count() - 1] ); +} + +sal_uInt16 MSWordSections::NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo ) const +{ const SwPageDesc* pPd = rInfo.pPageDesc; - if (!pPd) - pPd = &rDoc.GetPageDesc(0); + if ( !pPd ) + pPd = &rDoc.GetPageDesc( 0 ); - if (!pPd) + if ( !pPd ) { - ASSERT(pPd, "totally impossible"); + ASSERT( pPd, "totally impossible" ); return 1; } const SfxItemSet &rSet = pPd->GetMaster().GetAttrSet(); - SfxItemSet aSet(*rSet.GetPool(), RES_COL, RES_COL); - aSet.SetParent(&rSet); + SfxItemSet aSet( *rSet.GetPool(), RES_COL, RES_COL ); + aSet.SetParent( &rSet ); //0xffffffff, what the hell is going on with that!, fixme most terribly - if (rInfo.pSectionFmt && (SwSectionFmt*)0xFFFFFFFF != rInfo.pSectionFmt) - aSet.Put(rInfo.pSectionFmt->GetFmtAttr(RES_COL)); + if ( rInfo.pSectionFmt && (SwSectionFmt*)0xFFFFFFFF != rInfo.pSectionFmt ) + aSet.Put( rInfo.pSectionFmt->GetFmtAttr( RES_COL ) ); - const SwFmtCol& rCol = (const SwFmtCol&)aSet.Get(RES_COL); + const SwFmtCol& rCol = (const SwFmtCol&)aSet.Get( RES_COL ); const SwColumns& rColumns = rCol.GetColumns(); return rColumns.Count(); } -void WW8_WrPlcSepx::AppendSep(WW8_CP nStartCp, const SwPageDesc* pPd, - const SwSectionFmt* pSectionFmt, ULONG nLnNumRestartNo) +const WW8_SepInfo* MSWordSections::CurrentSectionInfo() { - aCps.Insert(nStartCp, aCps.Count()); - aSects.Insert(WW8_SepInfo(pPd, pSectionFmt, nLnNumRestartNo), - aSects.Count()); - NeedsDocumentProtected(aSects[aSects.Count()-1]); + if ( aSects.Count() > 0 ) + return &aSects[aSects.Count() - 1]; + + return NULL; +} + +void MSWordSections::AppendSep( const SwPageDesc* pPd, + const SwSectionFmt* pSectionFmt, ULONG nLnNumRestartNo ) +{ + aSects.Insert( WW8_SepInfo( pPd, pSectionFmt, nLnNumRestartNo ), + aSects.Count() ); + NeedsDocumentProtected( aSects[aSects.Count()-1] ); +} + +void WW8_WrPlcSepx::AppendSep( WW8_CP nStartCp, const SwPageDesc* pPd, + const SwSectionFmt* pSectionFmt, ULONG nLnNumRestartNo ) +{ + aCps.Insert( nStartCp, aCps.Count() ); + + MSWordSections::AppendSep( pPd, pSectionFmt, nLnNumRestartNo ); +} + +void MSWordSections::AppendSep( const SwFmtPageDesc& rPD, + const SwNode& rNd, const SwSectionFmt* pSectionFmt, ULONG nLnNumRestartNo ) +{ + WW8_SepInfo aI( rPD.GetPageDesc(), pSectionFmt, nLnNumRestartNo, + rPD.GetNumOffset(), &rNd ); + aSects.Insert( aI, aSects.Count() ); + NeedsDocumentProtected( aI ); } void WW8_WrPlcSepx::AppendSep( WW8_CP nStartCp, const SwFmtPageDesc& rPD, const SwNode& rNd, const SwSectionFmt* pSectionFmt, ULONG nLnNumRestartNo ) { aCps.Insert(nStartCp, aCps.Count()); - WW8_SepInfo aI(rPD.GetPageDesc(), pSectionFmt, nLnNumRestartNo); - aI.nPgRestartNo = rPD.GetNumOffset(); - aI.pPDNd = &rNd; - aSects.Insert(aI, aSects.Count()); - NeedsDocumentProtected(aI); + + MSWordSections::AppendSep( rPD, rNd, pSectionFmt, nLnNumRestartNo ); } -// WW8_WrPlcSepx::SetNum() setzt in jeder Section beim 1. Aufruf den +// MSWordSections::SetNum() setzt in jeder Section beim 1. Aufruf den // Num-Pointer, alle folgenden Aufrufe werden ignoriert. Damit wird // die erste Aufzaehlung einer Section uebernommen. -void WW8_WrPlcSepx::SetNum( const SwTxtNode* pNumNd ) +void MSWordSections::SetNum( const SwTxtNode* pNumNd ) { WW8_SepInfo& rInfo = aSects[ aSects.Count() - 1 ]; - if( !rInfo.pNumNd ) // noch nicht belegt + if ( !rInfo.pNumNd ) // noch nicht belegt rInfo.pNumNd = pNumNd; } -void WW8_WrPlcSepx::WriteOlst( SwWW8Writer& rWrt, USHORT i ) -{ - if( !rWrt.bWrtWW8 ) - { - const SwNumRule* pRule; - const SwTxtNode* pNd = aSects[i].pNumNd; - if( pNd && 0 != ( pRule = pNd->GetNumRule() )) - rWrt.Out_Olst( *pRule ); - } -} - -void WW8_WrPlcSepx::WriteFtnEndTxt( SwWW8Writer& rWrt, ULONG nCpStt ) +void WW8_WrPlcSepx::WriteFtnEndTxt( WW8Export& rWrt, ULONG nCpStt ) { BYTE nInfoFlags = 0; const SwFtnInfo& rInfo = rWrt.pDoc->GetFtnInfo(); @@ -940,19 +1084,19 @@ void WW8_WrPlcSepx::WriteFtnEndTxt( SwWW8Writer& rWrt, ULONG nCpStt ) case FTNNUM_CHAPTER: rDop.rncFtn = 1; break; default: rDop.rncFtn = 0; break; } // rncFtn - rDop.nfcFtnRef = SwWW8Writer::GetNumId( rInfo.aFmt.GetNumberingType() ); + rDop.nfcFtnRef = WW8Export::GetNumId( rInfo.aFmt.GetNumberingType() ); rDop.nFtn = rInfo.nFtnOffset + 1; rDop.fpc = rWrt.bFtnAtTxtEnd ? 2 : 1; // Endnote Info rDop.rncEdn = 0; // rncEdn: Don't Restart const SwEndNoteInfo& rEndInfo = rWrt.pDoc->GetEndNoteInfo(); - rDop.nfcEdnRef = SwWW8Writer::GetNumId( rEndInfo.aFmt.GetNumberingType() ); + rDop.nfcEdnRef = WW8Export::GetNumId( rEndInfo.aFmt.GetNumberingType() ); rDop.nEdn = rEndInfo.nFtnOffset + 1; rDop.epc = rWrt.bEndAtTxtEnd ? 3 : 0; } -void WW8_WrPlcSepx::SetHeaderFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt, +void MSWordSections::SetHeaderFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt, BYTE nFlag ) { const SfxPoolItem* pItem; @@ -962,7 +1106,7 @@ void WW8_WrPlcSepx::SetHeaderFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt, rHeadFootFlags |= nFlag; } -void WW8_WrPlcSepx::SetFooterFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt, +void MSWordSections::SetFooterFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt, BYTE nFlag ) { const SfxPoolItem* pItem; @@ -972,58 +1116,30 @@ void WW8_WrPlcSepx::SetFooterFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt, rHeadFootFlags |= nFlag; } -void WW8_WrPlcSepx::OutHeader( SwWW8Writer& rWrt, const SwFmt& rFmt, - ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag ) +void WW8_WrPlcSepx::OutHeaderFooter( WW8Export& rWrt, bool bHeader, + const SwFmt& rFmt, ULONG& rCpPos, BYTE nHFFlags, + BYTE nFlag, BYTE nBreakCode) { - if( nFlag & nHFFlags ) + if ( nFlag & nHFFlags ) { - rWrt.bHasHdr = true; - const SwFmtHeader& rHd = rFmt.GetHeader(); - ASSERT( rHd.GetHeaderFmt(), "KopfText nicht richtig da" ); - const SwFmtCntnt& rCntnt = rHd.GetHeaderFmt()->GetCntnt(); pTxtPos->Append( rCpPos ); - rWrt.WriteKFTxt1( rCntnt ); + rWrt.WriteHeaderFooterText( rFmt, bHeader); rWrt.WriteStringAsPara( aEmptyStr ); // CR ans Ende ( sonst mault WW ) rCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() ); } - else if( rWrt.bWrtWW8 ) + else if ( rWrt.bWrtWW8 ) { pTxtPos->Append( rCpPos ); - if (rWrt.bHasHdr) + if (rWrt.bHasHdr && nBreakCode!=0) { - rWrt.WriteStringAsPara( aEmptyStr ); // Empty paragraph for empty header - rWrt.WriteStringAsPara( aEmptyStr ); // a CR that WW8 needs for end of the stream - rCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() ); - } - } -} -void WW8_WrPlcSepx::OutFooter( SwWW8Writer& rWrt, const SwFmt& rFmt, - ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag ) -{ - if( nFlag & nHFFlags ) - { - rWrt.bHasFtr = true; - const SwFmtFooter& rFt = rFmt.GetFooter(); - ASSERT( rFt.GetFooterFmt(), "KopfText nicht richtig da" ); - const SwFmtCntnt& rCntnt = rFt.GetFooterFmt()->GetCntnt(); - pTxtPos->Append( rCpPos ); - rWrt.WriteKFTxt1( rCntnt ); - rWrt.WriteStringAsPara( aEmptyStr ); // CR ans Ende ( sonst mault WW ) - rCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() ); - } - else if( rWrt.bWrtWW8 ) - { - pTxtPos->Append( rCpPos ); - if (rWrt.bHasFtr) - { - rWrt.WriteStringAsPara( aEmptyStr ); // Empty paragraph for empty footer + rWrt.WriteStringAsPara( aEmptyStr ); // Empty paragraph for empty header/footer rWrt.WriteStringAsPara( aEmptyStr ); // a CR that WW8 needs for end of the stream rCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() ); } } } -void WW8_WrPlcSepx::NeedsDocumentProtected(const WW8_SepInfo &rInfo) +void MSWordSections::NeedsDocumentProtected(const WW8_SepInfo &rInfo) { if (rInfo.IsProtected()) mbDocumentIsProtected = true; @@ -1047,7 +1163,7 @@ bool WW8_SepInfo::IsProtected() const } -void WW8_WrPlcSepx::CheckForFacinPg( SwWW8Writer& rWrt ) const +void MSWordSections::CheckForFacinPg( WW8Export& rWrt ) const { // 2 Werte werden gesetzt // Dop.fFacingPages == Kopf-/Fusszeilen unterschiedlich @@ -1099,7 +1215,7 @@ void WW8_WrPlcSepx::CheckForFacinPg( SwWW8Writer& rWrt ) const } } -int WW8_WrPlcSepx::HasBorderItem( const SwFmt& rFmt ) +int MSWordSections::HasBorderItem( const SwFmt& rFmt ) { const SfxPoolItem* pItem; return SFX_ITEM_SET == rFmt.GetItemState(RES_BOX, true, &pItem) && @@ -1109,447 +1225,495 @@ int WW8_WrPlcSepx::HasBorderItem( const SwFmt& rFmt ) ((SvxBoxItem*)pItem)->GetRight() ); } +void WW8AttributeOutput::StartSection() +{ + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren +} -bool WW8_WrPlcSepx::WriteKFTxt(SwWW8Writer& rWrt) +void WW8AttributeOutput::SectionFormProtection( bool bProtected ) { - pAttrs = new WW8_PdAttrDesc[ aSects.Count() ]; - WW8Bytes* pO = rWrt.pO; - ULONG nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() ); - bool bOldPg = rWrt.bOutPageDescs; - rWrt.bOutPageDescs = true; + //If the document is to be exported as protected, then if a segment + //is not protected, set the unlocked flag + if ( m_rWW8Export.pSepx->DocumentIsProtected() && !bProtected ) + { + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SFProtected ); + else + m_rWW8Export.pO->Insert( 139, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( 1 , m_rWW8Export.pO->Count() ); + } +} - ASSERT( !pTxtPos, "wer hat den Pointer gesetzt?" ); - pTxtPos = new WW8_WrPlc0( nCpStart ); +void WW8AttributeOutput::SectionLineNumbering( ULONG nRestartNo, const SwLineNumberInfo& rLnNumInfo ) +{ + // sprmSNLnnMod - activate Line Numbering and define Modulo + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SNLnnMod ); + else + m_rWW8Export.pO->Insert( 154, m_rWW8Export.pO->Count() ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, (UINT16)rLnNumInfo.GetCountBy() ); - WriteFtnEndTxt( rWrt, nCpStart ); - CheckForFacinPg( rWrt ); + // sprmSDxaLnn - xPosition of Line Number + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SDxaLnn ); + else + m_rWW8Export.pO->Insert( 155, m_rWW8Export.pO->Count() ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, (UINT16)rLnNumInfo.GetPosFromLeft() ); - WW8Bytes aLineNum; - const SwLineNumberInfo& rLnNumInfo = rWrt.pDoc->GetLineNumberInfo(); - if( rLnNumInfo.IsPaintLineNumbers() ) + // sprmSLnc - restart number: 0 per page, 1 per section, 2 never restart + if ( nRestartNo || !rLnNumInfo.IsRestartEachPage() ) { - // sprmSNLnnMod - activate Line Numbering and define Modulo - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( aLineNum, 0x5015 ); + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SLnc ); else - aLineNum.Insert( 154, aLineNum.Count() ); - SwWW8Writer::InsUInt16( aLineNum, (UINT16)rLnNumInfo.GetCountBy() ); + m_rWW8Export.pO->Insert( 152, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( nRestartNo ? 1 : 2, m_rWW8Export.pO->Count() ); + } - // sprmSDxaLnn - xPosition of Line Number - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( aLineNum, 0x9016 ); + // sprmSLnnMin - Restart the Line Number with given value + if ( nRestartNo ) + { + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SLnnMin ); else - aLineNum.Insert( 155, aLineNum.Count() ); - SwWW8Writer::InsUInt16( aLineNum, (UINT16)rLnNumInfo.GetPosFromLeft() ); + m_rWW8Export.pO->Insert( 160, m_rWW8Export.pO->Count() ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, (UINT16)nRestartNo - 1 ); + } +} - // +void WW8AttributeOutput::SectionTitlePage() +{ + // sprmSFTitlePage + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SFTitlePage ); + else + m_rWW8Export.pO->Insert( 143, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( 1, m_rWW8Export.pO->Count() ); +} + +void WW8AttributeOutput::SectionPageBorders( const SwFrmFmt* pPdFmt, const SwFrmFmt* pPdFirstPgFmt ) +{ + if ( m_rWW8Export.bWrtWW8 ) // Seitenumrandung schreiben + { + USHORT nPgBorder = MSWordSections::HasBorderItem( *pPdFmt ) ? 0 : USHRT_MAX; + if ( pPdFmt != pPdFirstPgFmt ) + { + if ( MSWordSections::HasBorderItem( *pPdFirstPgFmt ) ) + { + if ( USHRT_MAX == nPgBorder ) + { + nPgBorder = 1; + // nur die 1. Seite umrandet -> BoxItem aus dem + // richtigen Format besorgen + m_rWW8Export.pISet = &pPdFirstPgFmt->GetAttrSet(); + OutputItem( pPdFirstPgFmt->GetFmtAttr( RES_BOX ) ); + } + } + else if ( !nPgBorder ) + nPgBorder = 2; + } + + if ( USHRT_MAX != nPgBorder ) + { + // Flag und das Border Attribut schreiben + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SPgbProp ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nPgBorder ); + } } +} - unsigned int nOldIndex = rWrt.GetHdFtIndex(); - unsigned int nHdFtGroup = 0; - for (USHORT i = 0; i < aSects.Count(); ++i) +void WW8AttributeOutput::SectionBiDi( bool bBiDi ) +{ + if ( m_rWW8Export.bWrtWW8 ) { - WW8_PdAttrDesc* pA = pAttrs + i; - WW8_SepInfo& rSepInfo = aSects[i]; - const SwPageDesc* pPd = rSepInfo.pPageDesc; + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SFBiDi ); + m_rWW8Export.pO->Insert( bBiDi? 1: 0, m_rWW8Export.pO->Count() ); + } +} - if( rSepInfo.pSectionFmt && !pPd ) - pPd = &const_cast<const SwDoc *>(rWrt.pDoc)->GetPageDesc(0); +void WW8AttributeOutput::SectionPageNumbering( USHORT nNumType, USHORT nPageRestartNumber ) +{ + // sprmSNfcPgn + BYTE nb = WW8Export::GetNumId( nNumType ); + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SNfcPgn ); + else + m_rWW8Export.pO->Insert( 147, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( nb, m_rWW8Export.pO->Count() ); - rWrt.pAktPageDesc = pPd; - pA->nSepxFcPos = 0xffffffff; // Default: none + if ( nPageRestartNumber ) + { + // sprmSFPgnRestart + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SFPgnRestart ); + else + m_rWW8Export.pO->Insert( 150, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( 1, m_rWW8Export.pO->Count() ); - if( !pPd ) - { - pA->pData = 0; - pA->nLen = 0; - continue; - } + // sprmSPgnStart + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SPgnStart ); + else + m_rWW8Export.pO->Insert( 161, m_rWW8Export.pO->Count() ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nPageRestartNumber ); + } +} - pO->Remove( 0, pO->Count() ); // leeren - rWrt.bOutPageDescs = true; +void WW8AttributeOutput::SectionType( BYTE nBreakCode ) +{ + if ( 2 != nBreakCode ) // new page is the default + { + if ( m_rWW8Export.bWrtWW8 ) + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SBkc ); + else + m_rWW8Export.pO->Insert( 142, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( nBreakCode, m_rWW8Export.pO->Count() ); + } +} - //If the document is to be exported as protected, then if a segment - //is not protected, set the unlocked flag - if (mbDocumentIsProtected && !rSepInfo.IsProtected()) +void WW8AttributeOutput::SectionWW6HeaderFooterFlags( BYTE nHeadFootFlags ) +{ + if ( nHeadFootFlags && !m_rWW8Export.bWrtWW8 ) + { + BYTE nTmpFlags = nHeadFootFlags; + if ( m_rWW8Export.pDop->fFacingPages ) { - if (rWrt.bWrtWW8) - SwWW8Writer::InsUInt16(*pO, 0x3006); - else - pO->Insert(139, pO->Count()); - pO->Insert(1 , pO->Count()); + if ( !(nTmpFlags & WW8_FOOTER_EVEN) && (nTmpFlags & WW8_FOOTER_ODD ) ) + nTmpFlags |= WW8_FOOTER_EVEN; + + if ( !(nTmpFlags & WW8_HEADER_EVEN) && (nTmpFlags & WW8_HEADER_ODD ) ) + nTmpFlags |= WW8_HEADER_EVEN; } - if( aLineNum.Count() ) - { - pO->Insert( &aLineNum, pO->Count() ); + // sprmSGprfIhdt, wird nur noch im WW95 benoetigt + m_rWW8Export.pO->Insert( 153, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( nTmpFlags, m_rWW8Export.pO->Count() ); + } +} - // sprmSLnc - restart number: 0 per page, 1 per section, 2 never restart - if( rSepInfo.nLnNumRestartNo || !rLnNumInfo.IsRestartEachPage() ) - { - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( *pO, 0x3013 ); - else - pO->Insert( 152, pO->Count() ); - pO->Insert( rSepInfo.nLnNumRestartNo ? 1 : 2, pO->Count() ); - } +void WW8Export::SetupSectionPositions( WW8_PdAttrDesc* pA ) +{ + if ( !pA ) + return; + + if ( pO->Count() ) + { // waren Attrs vorhanden ? + pA->nLen = pO->Count(); + pA->pData = new BYTE [pO->Count()]; + memcpy( pA->pData, pO->GetData(), pO->Count() ); // -> merken + pO->Remove( 0, pO->Count() ); // leeren fuer HdFt-Text + } + else + { // keine Attrs da + pA->pData = 0; + pA->nLen = 0; + } +} - // sprmSLnnMin - Restart the Line Number with given value - if( rSepInfo.nLnNumRestartNo ) - { - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( *pO, 0x501B ); - else - pO->Insert( 160, pO->Count() ); - SwWW8Writer::InsUInt16( *pO, (UINT16)rSepInfo.nLnNumRestartNo - 1 ); - } - } +void WW8Export::WriteHeadersFooters( BYTE nHeadFootFlags, + const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, BYTE nBreakCode ) +{ + ULONG nCpPos = Fc2Cp( Strm().Tell() ); + IncrementHdFtIndex(); + if ( !(nHeadFootFlags & WW8_HEADER_EVEN) && pDop->fFacingPages ) + pSepx->OutHeaderFooter( *this, true, rFmt, nCpPos, nHeadFootFlags, WW8_HEADER_ODD, nBreakCode ); + else + pSepx->OutHeaderFooter( *this, true, rLeftFmt, nCpPos, nHeadFootFlags, WW8_HEADER_EVEN, nBreakCode ); + IncrementHdFtIndex(); + pSepx->OutHeaderFooter( *this, true, rFmt, nCpPos, nHeadFootFlags, WW8_HEADER_ODD, nBreakCode ); - /* sprmSBkc, break code: 0 No break, 1 New column - 2 New page, 3 Even page, 4 Odd page + IncrementHdFtIndex(); + if ( !(nHeadFootFlags & WW8_FOOTER_EVEN) && pDop->fFacingPages ) + pSepx->OutHeaderFooter( *this, false, rFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD, nBreakCode ); + else + pSepx->OutHeaderFooter( *this, false, rLeftFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_EVEN, nBreakCode ); + IncrementHdFtIndex(); + pSepx->OutHeaderFooter( *this, false, rFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD, nBreakCode ); + + //#i24344# Drawing objects cannot be directly shared between main hd/ft + //and title hd/ft so we need to differenciate them + IncrementHdFtIndex(); + pSepx->OutHeaderFooter( *this, true, rFirstPageFmt, nCpPos, nHeadFootFlags, WW8_HEADER_FIRST, nBreakCode ); + pSepx->OutHeaderFooter( *this, false, rFirstPageFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_FIRST, nBreakCode ); +} + +void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAttrDesc* pA ) +{ + const SwPageDesc* pPd = rSepInfo.pPageDesc; + + if ( rSepInfo.pSectionFmt && !pPd ) + pPd = &const_cast<const SwDoc *>( pDoc )->GetPageDesc( 0 ); + + pAktPageDesc = pPd; + + if ( !pPd ) + return; + + bool bOldPg = bOutPageDescs; + bOutPageDescs = true; + + AttrOutput().StartSection(); + + // forms + AttrOutput().SectionFormProtection( rSepInfo.IsProtected() ); + + // line numbers + const SwLineNumberInfo& rLnNumInfo = pDoc->GetLineNumberInfo(); + if ( rLnNumInfo.IsPaintLineNumbers() ) + AttrOutput().SectionLineNumbering( rSepInfo.nLnNumRestartNo, rLnNumInfo ); + + /* sprmSBkc, break code: 0 No break, 1 New column + 2 New page, 3 Even page, 4 Odd page */ - BYTE nBreakCode = 2; // default neue Seite beginnen - bool bOutPgDscSet = true, bLeftRightPgChain = false; - const SwFrmFmt* pPdFmt = &pPd->GetMaster(); - const SwFrmFmt* pPdFirstPgFmt = pPdFmt; - if( rSepInfo.pSectionFmt ) - { - // ist pSectionFmt gesetzt, dann gab es einen SectionNode - // gueltiger Pointer -> Section beginnt, - // 0xfff -> Section wird beendet - nBreakCode = 0; // fortlaufender Abschnitt + BYTE nBreakCode = 2; // default neue Seite beginnen + bool bOutPgDscSet = true, bLeftRightPgChain = false; + const SwFrmFmt* pPdFmt = &pPd->GetMaster(); + const SwFrmFmt* pPdFirstPgFmt = pPdFmt; + if ( rSepInfo.pSectionFmt ) + { + // ist pSectionFmt gesetzt, dann gab es einen SectionNode + // gueltiger Pointer -> Section beginnt, + // 0xfff -> Section wird beendet + nBreakCode = 0; // fortlaufender Abschnitt - if (rSepInfo.pPDNd && rSepInfo.pPDNd->IsCntntNode()) + if ( rSepInfo.pPDNd && rSepInfo.pPDNd->IsCntntNode() ) + { + if ( !NoPageBreakSection( &rSepInfo.pPDNd->GetCntntNode()->GetSwAttrSet() ) ) { - if (!(SwWW8Writer::NoPageBreakSection( - &rSepInfo.pPDNd->GetCntntNode()->GetSwAttrSet()))) - { - nBreakCode = 2; - } + nBreakCode = 2; } + } - if( (SwSectionFmt*)0xFFFFFFFF != rSepInfo.pSectionFmt ) - { - if (nBreakCode == 0) - bOutPgDscSet = false; - - // Itemset erzeugen, das das PgDesk-AttrSet beerbt: - // als Nachkomme wird bei 'deep'-Out_SfxItemSet - // auch der Vorfahr abgeklappert - const SfxItemSet* pPdSet = &pPdFmt->GetAttrSet(); - SfxItemSet aSet( *pPdSet->GetPool(), pPdSet->GetRanges() ); - aSet.SetParent( pPdSet ); - - // am Nachkommen NUR die Spaltigkeit gemaess Sect-Attr. - // umsetzen - aSet.Put(rSepInfo.pSectionFmt->GetFmtAttr(RES_COL)); - - const SvxLRSpaceItem &rSectionLR = - ItemGet<SvxLRSpaceItem>(*(rSepInfo.pSectionFmt), - RES_LR_SPACE); - const SvxLRSpaceItem &rPageLR = - ItemGet<SvxLRSpaceItem>(*pPdFmt,RES_LR_SPACE); - - SvxLRSpaceItem aResultLR(rPageLR.GetLeft() + + if ( (SwSectionFmt*)0xFFFFFFFF != rSepInfo.pSectionFmt ) + { + if ( nBreakCode == 0 ) + bOutPgDscSet = false; + + // Itemset erzeugen, das das PgDesk-AttrSet beerbt: + // als Nachkomme wird bei 'deep'-OutputItemSet + // auch der Vorfahr abgeklappert + const SfxItemSet* pPdSet = &pPdFmt->GetAttrSet(); + SfxItemSet aSet( *pPdSet->GetPool(), pPdSet->GetRanges() ); + aSet.SetParent( pPdSet ); + + // am Nachkommen NUR die Spaltigkeit gemaess Sect-Attr. + // umsetzen + aSet.Put( rSepInfo.pSectionFmt->GetFmtAttr( RES_COL ) ); + + const SvxLRSpaceItem &rSectionLR = + ItemGet<SvxLRSpaceItem>( *(rSepInfo.pSectionFmt), RES_LR_SPACE ); + const SvxLRSpaceItem &rPageLR = + ItemGet<SvxLRSpaceItem>( *pPdFmt, RES_LR_SPACE ); + + SvxLRSpaceItem aResultLR( rPageLR.GetLeft() + rSectionLR.GetLeft(), rPageLR.GetRight() + - rSectionLR.GetRight(), 0, 0, RES_LR_SPACE); - - aSet.Put(aResultLR); - - // und raus damit ins WW-File - const SfxItemSet* pOldI = rWrt.pISet; - rWrt.pISet = &aSet; - // --> OD 2007-06-12 #TESTING# - // Switch off test on default item values, if page description - // set (value of <bOutPgDscSet>) isn't written. - Out_SfxItemSet( aWW8AttrFnTab, rWrt, aSet, true, bOutPgDscSet ); - // <-- - - //Cannot export as normal page framedir, as continous sections - //cannot contain any grid settings like proper sections - if (rWrt.bWrtWW8) - { - BYTE nDir; - SwWW8Writer::InsUInt16(*pO, 0x3228); - if (FRMDIR_HORI_RIGHT_TOP == - rWrt.TrueFrameDirection(*rSepInfo.pSectionFmt)) - { - nDir = 1; - } - else - nDir = 0; - pO->Insert( nDir, pO->Count() ); - } + rSectionLR.GetRight(), 0, 0, RES_LR_SPACE ); - rWrt.pISet = pOldI; - } + aSet.Put( aResultLR ); + + // und raus damit ins WW-File + const SfxItemSet* pOldI = pISet; + pISet = &aSet; + // --> OD 2007-06-12 #TESTING# + // Switch off test on default item values, if page description + // set (value of <bOutPgDscSet>) isn't written. + AttrOutput().OutputStyleItemSet( aSet, true, bOutPgDscSet ); + // <-- + + //Cannot export as normal page framedir, as continous sections + //cannot contain any grid settings like proper sections + AttrOutput().SectionBiDi( FRMDIR_HORI_RIGHT_TOP == TrueFrameDirection( *rSepInfo.pSectionFmt ) ); + + pISet = pOldI; } + } - if( bOutPgDscSet ) + if ( bOutPgDscSet ) + { + // es ist ein Follow gesetzt und dieser zeigt nicht auf sich + // selbst, so liegt eine Seitenverkettung vor. + // Falls damit eine "Erste Seite" simuliert werden soll, so + // koennen wir das auch als solches schreiben. + // Anders sieht es mit Links/Rechts wechseln aus. Dafuer muss + // erkannt werden, wo der Seitenwechsel statt findet. Hier ist + // es aber dafuer zuspaet! + if ( pPd->GetFollow() && pPd != pPd->GetFollow() && + pPd->GetFollow()->GetFollow() == pPd->GetFollow() && + ( !rSepInfo.pPDNd || pPd->IsFollowNextPageOfNode( *rSepInfo.pPDNd ) ) ) { - // es ist ein Follow gesetzt und dieser zeigt nicht auf sich - // selbst, so liegt eine Seitenverkettung vor. - // Falls damit eine "Erste Seite" simuliert werden soll, so - // koennen wir das auch als solches schreiben. - // Anders sieht es mit Links/Rechts wechseln aus. Dafuer muss - // erkannt werden, wo der Seitenwechsel statt findet. Hier ist - // es aber dafuer zuspaet! - if ( - pPd->GetFollow() && pPd != pPd->GetFollow() && - pPd->GetFollow()->GetFollow() == pPd->GetFollow() && - ( - !rSepInfo.pPDNd || - pPd->IsFollowNextPageOfNode( *rSepInfo.pPDNd ) - ) - ) + const SwPageDesc *pFollow = pPd->GetFollow(); + const SwFrmFmt& rFollowFmt = pFollow->GetMaster(); + if ( sw::util::IsPlausableSingleWordSection( *pPdFmt, rFollowFmt ) ) { - const SwPageDesc *pFollow = pPd->GetFollow(); - const SwFrmFmt& rFollowFmt = pFollow->GetMaster(); - if (sw::util::IsPlausableSingleWordSection(*pPdFmt, rFollowFmt)) - { - if (rSepInfo.pPDNd) - pPdFirstPgFmt = pPd->GetPageFmtOfNode(*rSepInfo.pPDNd); - else - pPdFirstPgFmt = &pPd->GetMaster(); - - rWrt.pAktPageDesc = pPd = pFollow; - pPdFmt = &rFollowFmt; - - // sprmSFTitlePage - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( *pO, 0x300A ); - else - pO->Insert( 143, pO->Count() ); - pO->Insert( 1, pO->Count() ); - } - } - - const SfxItemSet* pOldI = rWrt.pISet; + if (rSepInfo.pPDNd) + pPdFirstPgFmt = pPd->GetPageFmtOfNode( *rSepInfo.pPDNd ); + else + pPdFirstPgFmt = &pPd->GetMaster(); - if( rWrt.bWrtWW8 ) // Seitenumrandung schreiben - { - USHORT nPgBorder = HasBorderItem( *pPdFmt ) ? 0 : USHRT_MAX; - if( pPdFmt != pPdFirstPgFmt ) - { - if( HasBorderItem( *pPdFirstPgFmt )) - { - if( USHRT_MAX == nPgBorder ) - { - nPgBorder = 1; - // nur die 1. Seite umrandet -> BoxItem aus dem - // richtigen Format besorgen - rWrt.pISet = &pPdFirstPgFmt->GetAttrSet(); - Out( aWW8AttrFnTab, pPdFirstPgFmt->GetFmtAttr( - RES_BOX ), rWrt ); - } - } - else if( !nPgBorder ) - nPgBorder = 2; - } + pAktPageDesc = pPd = pFollow; + pPdFmt = &rFollowFmt; - if( USHRT_MAX != nPgBorder ) - { - // Flag und das Border Attribut schreiben - SwWW8Writer::InsUInt16( *pO, 0x522F ); - SwWW8Writer::InsUInt16( *pO, nPgBorder ); - } + // has different headers/footers for the title page + AttrOutput().SectionTitlePage(); } + } - const SfxPoolItem* pItem; - if( pPdFmt != pPdFirstPgFmt && SFX_ITEM_SET == - pPdFirstPgFmt->GetItemState(RES_PAPER_BIN, true, &pItem)) - { - rWrt.pISet = &pPdFirstPgFmt->GetAttrSet(); - rWrt.bOutFirstPage = true; - Out( aWW8AttrFnTab, *pItem, rWrt ); - rWrt.bOutFirstPage = false; - } + const SfxItemSet* pOldI = pISet; + AttrOutput().SectionPageBorders( pPdFmt, pPdFirstPgFmt ); - // left-/right chain of pagedescs ? - if( pPd->GetFollow() && pPd != pPd->GetFollow() && + const SfxPoolItem* pItem; + if ( pPdFmt != pPdFirstPgFmt && SFX_ITEM_SET == + pPdFirstPgFmt->GetItemState( RES_PAPER_BIN, true, &pItem ) ) + { + pISet = &pPdFirstPgFmt->GetAttrSet(); + bOutFirstPage = true; + AttrOutput().OutputItem( *pItem ); + bOutFirstPage = false; + } + + + // left-/right chain of pagedescs ? + if ( pPd->GetFollow() && pPd != pPd->GetFollow() && pPd->GetFollow()->GetFollow() == pPd && (( nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) && nsUseOnPage::PD_RIGHT == ( nsUseOnPage::PD_ALL & pPd->GetFollow()->ReadUseOn() )) || ( nsUseOnPage::PD_RIGHT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) && nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->GetFollow()->ReadUseOn() )) )) - { - bLeftRightPgChain = true; + { + bLeftRightPgChain = true; - // welches ist der Bezugspunkt ????? (links oder rechts?) - // annahme die rechte Seite! - if( nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() )) - { - nBreakCode = 3; - pPd = pPd->GetFollow(); - pPdFmt = &pPd->GetMaster(); - } - else - nBreakCode = 4; + // welches ist der Bezugspunkt ????? (links oder rechts?) + // annahme die rechte Seite! + if ( nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) ) + { + nBreakCode = 3; + pPd = pPd->GetFollow(); + pPdFmt = &pPd->GetMaster(); } - - rWrt.pISet = &pPdFmt->GetAttrSet(); - Out_SfxItemSet(aWW8AttrFnTab, rWrt, pPdFmt->GetAttrSet(), - true, false); - rWrt.pISet = pOldI; - - // dann noch die restlichen Einstellungen aus dem PageDesc - - // sprmSNfcPgn - BYTE nb = SwWW8Writer::GetNumId( pPd->GetNumType().GetNumberingType() ); - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( *pO, 0x300E ); else - pO->Insert( 147, pO->Count() ); - pO->Insert( nb, pO->Count() ); + nBreakCode = 4; + } -//??? const SwPageFtnInfo& rFtnInfo = pPd->GetFtnInfo(); + pISet = &pPdFmt->GetAttrSet(); + AttrOutput().OutputStyleItemSet( pPdFmt->GetAttrSet(), true, false ); + pISet = pOldI; - if( rSepInfo.nPgRestartNo ) - { - // sprmSFPgnRestart - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( *pO, 0x3011 ); - else - pO->Insert( 150, pO->Count() ); - pO->Insert( 1, pO->Count() ); - // sprmSPgnStart - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( *pO, 0x501C ); - else - pO->Insert( 161, pO->Count() ); - SwWW8Writer::InsUInt16( *pO, rSepInfo.nPgRestartNo ); - } + // dann noch die restlichen Einstellungen aus dem PageDesc - // werden es nur linke oder nur rechte Seiten? - if( 2 == nBreakCode ) - { - if( nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() )) - nBreakCode = 3; - else if( nsUseOnPage::PD_RIGHT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() )) - nBreakCode = 4; - } - } + AttrOutput().SectionPageNumbering( pPd->GetNumType().GetNumberingType(), rSepInfo.nPgRestartNo ); - if( 2 != nBreakCode ) // neue Seite ist default + // werden es nur linke oder nur rechte Seiten? + if ( 2 == nBreakCode ) { - if( rWrt.bWrtWW8 ) - SwWW8Writer::InsUInt16( *pO, 0x3009 ); - else - pO->Insert( 142, pO->Count() ); - pO->Insert( nBreakCode, pO->Count() ); + if ( nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) ) + nBreakCode = 3; + else if ( nsUseOnPage::PD_RIGHT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) ) + nBreakCode = 4; } + } - WriteOlst( rWrt, i ); + AttrOutput().SectionType( nBreakCode ); + const SwTxtNode* pNd = rSepInfo.pNumNd; + if ( pNd ) + { + const SwNumRule* pRule = pNd->GetNumRule(); + if ( pRule ) + OutputOlst( *pRule ); + } - // Header oder Footer - BYTE nHeadFootFlags = 0; + // Header oder Footer + BYTE nHeadFootFlags = 0; - const SwFrmFmt* pPdLeftFmt = bLeftRightPgChain - ? &pPd->GetFollow()->GetMaster() - : &pPd->GetLeft(); + const SwFrmFmt* pPdLeftFmt = bLeftRightPgChain + ? &pPd->GetFollow()->GetMaster() + : &pPd->GetLeft(); - if (nBreakCode != 0) - { - SetHeaderFlag( nHeadFootFlags, *pPdFmt, WW8_HEADER_ODD ); - SetFooterFlag( nHeadFootFlags, *pPdFmt, WW8_FOOTER_ODD ); - if( !pPd->IsHeaderShared() || bLeftRightPgChain ) - SetHeaderFlag( nHeadFootFlags, *pPdLeftFmt, WW8_HEADER_EVEN ); - if( !pPd->IsFooterShared() || bLeftRightPgChain ) - SetFooterFlag( nHeadFootFlags, *pPdLeftFmt, WW8_FOOTER_EVEN ); - if( pPdFmt != pPdFirstPgFmt ) - { - // es gibt eine ErsteSeite: - SetHeaderFlag( nHeadFootFlags, *pPdFirstPgFmt, WW8_HEADER_FIRST ); - SetFooterFlag( nHeadFootFlags, *pPdFirstPgFmt, WW8_FOOTER_FIRST ); - } + if ( nBreakCode != 0 ) + { + MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdFmt, WW8_HEADER_ODD ); + MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdFmt, WW8_FOOTER_ODD ); - if( nHeadFootFlags && !rWrt.bWrtWW8 ) - { - BYTE nTmpFlags = nHeadFootFlags; - if( rWrt.pDop->fFacingPages ) - { - if( !(nTmpFlags & WW8_FOOTER_EVEN) && - (nTmpFlags & WW8_FOOTER_ODD ) ) - nTmpFlags |= WW8_FOOTER_EVEN; + if ( !pPd->IsHeaderShared() || bLeftRightPgChain ) + MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdLeftFmt, WW8_HEADER_EVEN ); - if( !(nTmpFlags & WW8_HEADER_EVEN) && - (nTmpFlags & WW8_HEADER_ODD ) ) - nTmpFlags |= WW8_HEADER_EVEN; - } + if ( !pPd->IsFooterShared() || bLeftRightPgChain ) + MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdLeftFmt, WW8_FOOTER_EVEN ); - // sprmSGprfIhdt, wird nur noch im WW95 benoetigt - pO->Insert( 153, pO->Count() ); - pO->Insert( nTmpFlags, pO->Count() ); - } + if ( pPdFmt != pPdFirstPgFmt ) + { + // es gibt eine ErsteSeite: + MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdFirstPgFmt, WW8_HEADER_FIRST ); + MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdFirstPgFmt, WW8_FOOTER_FIRST ); } - if( pO->Count() ) - { // waren Attrs vorhanden ? - pA->nLen = pO->Count(); - pA->pData = new BYTE [pO->Count()]; - memcpy( pA->pData, pO->GetData(), pO->Count() ); // -> merken - pO->Remove( 0, pO->Count() ); // leeren fuer HdFt-Text - } - else - { // keine Attrs da - pA->pData = 0; - pA->nLen = 0; - } + AttrOutput().SectionWW6HeaderFooterFlags( nHeadFootFlags ); + } -/* -!!!!!!!!!!! - // Umrandungen an Kopf- und Fusstexten muessten etwa so gehen: - // Dabei muss etwas wie pOut eingebaut werden, - // das bei jeder Spezialtext-Zeile wiederholt wird. - const SwFrmFmt* pFFmt = rFt.GetFooterFmt(); - const SvxBoxItem& rBox = pFFmt->GetBox(false); - OutWW8_SwFmtBox1( rWrt.pOut, rBox, false); -!!!!!!!!!!! - Man koennt daraus Absatzattribute machen, die dann bei jedem Absatz - beachtet werden. Gilt fuer Hintergrund/Umrandung -!!!!!!!!!!! -*/ - - const SwTxtNode *pOldPageRoot = rWrt.GetHdFtPageRoot(); - rWrt.SetHdFtPageRoot(rSepInfo.pPDNd ? rSepInfo.pPDNd->GetTxtNode() : 0); - - ULONG nCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() ); - - rWrt.SetHdFtIndex(++nHdFtGroup); - if( !(nHeadFootFlags & WW8_HEADER_EVEN) && rWrt.pDop->fFacingPages ) - OutHeader( rWrt, *pPdFmt, nCpPos, nHeadFootFlags, WW8_HEADER_ODD ); - else - OutHeader( rWrt, *pPdLeftFmt, nCpPos, nHeadFootFlags, WW8_HEADER_EVEN ); - rWrt.SetHdFtIndex(++nHdFtGroup); - OutHeader( rWrt, *pPdFmt, nCpPos, nHeadFootFlags, WW8_HEADER_ODD ); + // binary filters only + SetupSectionPositions( pA ); - rWrt.SetHdFtIndex(++nHdFtGroup); - if( !(nHeadFootFlags & WW8_FOOTER_EVEN) && rWrt.pDop->fFacingPages ) - OutFooter( rWrt, *pPdFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD ); - else - OutFooter( rWrt, *pPdLeftFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_EVEN ); - rWrt.SetHdFtIndex(++nHdFtGroup); - OutFooter( rWrt, *pPdFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD ); + /* + !!!!!!!!!!! + // Umrandungen an Kopf- und Fusstexten muessten etwa so gehen: + // Dabei muss etwas wie pOut eingebaut werden, + // das bei jeder Spezialtext-Zeile wiederholt wird. + const SwFrmFmt* pFFmt = rFt.GetFooterFmt(); + const SvxBoxItem& rBox = pFFmt->GetBox(false); + OutWW8_SwFmtBox1( m_rWW8Export.pOut, rBox, false); + !!!!!!!!!!! + Man koennt daraus Absatzattribute machen, die dann bei jedem Absatz + beachtet werden. Gilt fuer Hintergrund/Umrandung + !!!!!!!!!!! + */ + + const SwTxtNode *pOldPageRoot = GetHdFtPageRoot(); + SetHdFtPageRoot( rSepInfo.pPDNd ? rSepInfo.pPDNd->GetTxtNode() : 0 ); + + WriteHeadersFooters( nHeadFootFlags, *pPdFmt, *pPdLeftFmt, *pPdFirstPgFmt, nBreakCode ); + + SetHdFtPageRoot( pOldPageRoot ); + + AttrOutput().EndSection(); + + // outside of the section properties again + bOutPageDescs = bOldPg; +} + +bool WW8_WrPlcSepx::WriteKFTxt( WW8Export& rWrt ) +{ + pAttrs = new WW8_PdAttrDesc[ aSects.Count() ]; + ULONG nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() ); + + ASSERT( !pTxtPos, "wer hat den Pointer gesetzt?" ); + pTxtPos = new WW8_WrPlc0( nCpStart ); + + WriteFtnEndTxt( rWrt, nCpStart ); + CheckForFacinPg( rWrt ); - //#i24344# Drawing objects cannot be directly shared between main hd/ft - //and title hd/ft so we need to differenciate them - rWrt.SetHdFtIndex(++nHdFtGroup); - OutHeader( rWrt, *pPdFirstPgFmt, nCpPos, nHeadFootFlags, WW8_HEADER_FIRST ); - OutFooter( rWrt, *pPdFirstPgFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_FIRST ); - rWrt.SetHdFtPageRoot(pOldPageRoot); + unsigned int nOldIndex = rWrt.GetHdFtIndex(); + rWrt.SetHdFtIndex( 0 ); + for ( USHORT i = 0; i < aSects.Count(); ++i ) + { + WW8_PdAttrDesc* pA = pAttrs + i; + pA->pData = 0; + pA->nLen = 0; + pA->nSepxFcPos = 0xffffffff; // Default: none + + WW8_SepInfo& rSepInfo = aSects[i]; + rWrt.SectionProperties( rSepInfo, pA ); } - rWrt.SetHdFtIndex(nOldIndex); //0 + rWrt.SetHdFtIndex( nOldIndex ); //0 - if( pTxtPos->Count() ) + if ( pTxtPos->Count() ) { // HdFt vorhanden ? ULONG nCpEnd = rWrt.Fc2Cp( rWrt.Strm().Tell() ); pTxtPos->Append( nCpEnd ); // Ende letzter Hd/Ft fuer PlcfHdd - if( nCpEnd > nCpStart ) + if ( nCpEnd > nCpStart ) { ++nCpEnd; pTxtPos->Append( nCpEnd + 1 ); // Ende letzter Hd/Ft fuer PlcfHdd @@ -1562,7 +1726,6 @@ bool WW8_WrPlcSepx::WriteKFTxt(SwWW8Writer& rWrt) else delete pTxtPos, pTxtPos = 0; - rWrt.bOutPageDescs = bOldPg; return rWrt.pFib->ccpHdr != 0; } @@ -1583,7 +1746,7 @@ void WW8_WrPlcSepx::WriteSepx( SvStream& rStrm ) const } } -void WW8_WrPlcSepx::WritePlcSed( SwWW8Writer& rWrt ) const +void WW8_WrPlcSepx::WritePlcSed( WW8Export& rWrt ) const { ASSERT( aCps.Count() == aSects.Count() + 1, "WrPlcSepx: DeSync" ); ULONG nFcStart = rWrt.pTableStrm->Tell(); @@ -1612,7 +1775,7 @@ void WW8_WrPlcSepx::WritePlcSed( SwWW8Writer& rWrt ) const } -void WW8_WrPlcSepx::WritePlcHdd( SwWW8Writer& rWrt ) const +void WW8_WrPlcSepx::WritePlcHdd( WW8Export& rWrt ) const { if( pTxtPos && pTxtPos->Count() ) { @@ -1623,11 +1786,27 @@ void WW8_WrPlcSepx::WritePlcHdd( SwWW8Writer& rWrt ) const } } -void SwWW8Writer::WriteKFTxt1( const SwFmtCntnt& rCntnt ) +void MSWordExportBase::WriteHeaderFooterText( const SwFmt& rFmt, bool bHeader ) { - const SwNodeIndex* pSttIdx = rCntnt.GetCntntIdx(); + const SwFmtCntnt *pCntnt; + if ( bHeader ) + { + bHasHdr = true; + const SwFmtHeader& rHd = rFmt.GetHeader(); + ASSERT( rHd.GetHeaderFmt(), "Header text is not here" ); + pCntnt = &rHd.GetHeaderFmt()->GetCntnt(); + } + else + { + bHasFtr = true; + const SwFmtFooter& rFt = rFmt.GetFooter(); + ASSERT( rFt.GetFooterFmt(), "Footer text is not here" ); + pCntnt = &rFt.GetFooterFmt()->GetCntnt(); + } + + const SwNodeIndex* pSttIdx = pCntnt->GetCntntIdx(); - if (pSttIdx) + if ( pSttIdx ) { SwNodeIndex aIdx( *pSttIdx, 1 ), aEnd( *pSttIdx->GetNode().EndOfSectionNode() ); @@ -1635,7 +1814,7 @@ void SwWW8Writer::WriteKFTxt1( const SwFmtCntnt& rCntnt ) ULONG nEnd = aEnd.GetIndex(); // Bereich also gueltiger Node - if (nStart < nEnd) + if ( nStart < nEnd ) { bool bOldKF = bOutKF; bOutKF = true; @@ -1646,11 +1825,11 @@ void SwWW8Writer::WriteKFTxt1( const SwFmtCntnt& rCntnt ) pSttIdx = 0; } - if (!pSttIdx) + if ( !pSttIdx ) { // es gibt keine Kopf-/Fusszeile, aber ein CR ist immer noch noetig ASSERT( pSttIdx, "K/F-Text nicht richtig da" ); - WriteStringAsPara( aEmptyStr ); // CR ans Ende ( sonst mault WW ) + AttrOutput().EmptyParagraph(); // CR ans Ende ( sonst mault WW ) } } @@ -1684,21 +1863,21 @@ void WW8_WrPlcPostIt::Append( WW8_CP nCp, const SwPostItField& rPostIt ) aCntnt.Insert( p, aCntnt.Count() ); } -bool WW8_WrPlcSubDoc::WriteGenericTxt(SwWW8Writer& rWrt, BYTE nTTyp, - WW8_CP& rCount) +bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, BYTE nTTyp, + WW8_CP& rCount ) { - bool bRet = false; USHORT nLen = aCntnt.Count(); - if( nLen ) - { - ULONG nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() ); - pTxtPos = new WW8_WrPlc0( nCpStart ); - USHORT i; + if ( !nLen ) + return false; - switch( nTTyp ) - { + ULONG nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() ); + pTxtPos = new WW8_WrPlc0( nCpStart ); + USHORT i; + + switch ( nTTyp ) + { case TXT_ATN: - for( i = 0; i < nLen; i++ ) + for ( i = 0; i < nLen; i++ ) { // Anfaenge fuer PlcfAtnTxt pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() )); @@ -1718,7 +1897,7 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt(SwWW8Writer& rWrt, BYTE nTTyp, case TXT_TXTBOX: case TXT_HFTXTBOX: - for( i = 0; i < nLen; i++ ) + for ( i = 0; i < nLen; i++ ) { // textbox - content WW8_CP nCP = rWrt.Fc2Cp( rWrt.Strm().Tell() ); @@ -1744,8 +1923,8 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt(SwWW8Writer& rWrt, BYTE nTTyp, const SwNodeIndex* pNdIdx = pFmt->GetCntnt().GetCntntIdx(); ASSERT( pNdIdx, "wo ist der StartNode der Textbox?" ); rWrt.WriteSpecialText( pNdIdx->GetIndex() + 1, - pNdIdx->GetNode().EndOfSectionIndex(), - nTTyp ); + pNdIdx->GetNode().EndOfSectionIndex(), + nTTyp ); // --> OD 2008-08-07 #156757# { SwNodeIndex aContentIdx = *pNdIdx; @@ -1781,7 +1960,7 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt(SwWW8Writer& rWrt, BYTE nTTyp, case TXT_EDN: case TXT_FTN: - for( i = 0; i < nLen; i++ ) + for ( i = 0; i < nLen; i++ ) { // Anfaenge fuer PlcfFtnTxt/PlcfEdnTxt pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() )); @@ -1799,43 +1978,42 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt(SwWW8Writer& rWrt, BYTE nTTyp, default: ASSERT( !this, "was ist das fuer ein SubDocType?" ); - } + } - pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() )); - // CR ans Ende ( sonst mault WW ) - rWrt.WriteStringAsPara( aEmptyStr ); + pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() )); + // CR ans Ende ( sonst mault WW ) + rWrt.WriteStringAsPara( aEmptyStr ); - WW8_CP nCpEnd = rWrt.Fc2Cp( rWrt.Strm().Tell() ); - pTxtPos->Append( nCpEnd ); - rCount = nCpEnd - nCpStart; - if (rCount) - bRet = true; - } - return bRet; + WW8_CP nCpEnd = rWrt.Fc2Cp( rWrt.Strm().Tell() ); + pTxtPos->Append( nCpEnd ); + rCount = nCpEnd - nCpStart; + + return ( rCount != 0 ); } -void WW8_WrPlcSubDoc::WriteGenericPlc( SwWW8Writer& rWrt, BYTE nTTyp, +void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, BYTE nTTyp, WW8_FC& rTxtStart, sal_Int32& rTxtCount, WW8_FC& rRefStart, sal_Int32& rRefCount ) const { typedef ::std::vector<String>::iterator myiter; ULONG nFcStart = rWrt.pTableStrm->Tell(); USHORT nLen = aCps.Count(); - if( nLen ) - { - ASSERT( aCps.Count() + 2 == pTxtPos->Count(), "WritePlc: DeSync" ); + if ( !nLen ) + return; - ::std::vector<String> aStrArr; - WW8Fib& rFib = *rWrt.pFib; // n+1-te CP-Pos nach Handbuch - USHORT i; - bool bWriteCP = true; + ASSERT( aCps.Count() + 2 == pTxtPos->Count(), "WritePlc: DeSync" ); - switch( nTTyp ) - { + ::std::vector<String> aStrArr; + WW8Fib& rFib = *rWrt.pFib; // n+1-te CP-Pos nach Handbuch + USHORT i; + bool bWriteCP = true; + + switch ( nTTyp ) + { case TXT_ATN: { // then write first the GrpXstAtnOwners - for( i = 0; i < nLen; ++i ) + for ( i = 0; i < nLen; ++i ) { const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ]; aStrArr.push_back(rPFld.GetPar1()); @@ -1846,24 +2024,24 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( SwWW8Writer& rWrt, BYTE nTTyp, myiter aIter = ::std::unique(aStrArr.begin(), aStrArr.end()); aStrArr.erase(aIter, aStrArr.end()); - if( rWrt.bWrtWW8 ) + if ( rWrt.bWrtWW8 ) { - for( i = 0; i < aStrArr.size(); ++i ) + for ( i = 0; i < aStrArr.size(); ++i ) { const String& rStr = aStrArr[i]; SwWW8Writer::WriteShort(*rWrt.pTableStrm, rStr.Len()); SwWW8Writer::WriteString16(*rWrt.pTableStrm, rStr, - false); + false); } } else { - for( i = 0; i < aStrArr.size(); ++i ) + for ( i = 0; i < aStrArr.size(); ++i ) { const String& rStr = aStrArr[i]; *rWrt.pTableStrm << (BYTE)rStr.Len(); SwWW8Writer::WriteString8(*rWrt.pTableStrm, rStr, false, - RTL_TEXTENCODING_MS_1252); + RTL_TEXTENCODING_MS_1252); } } @@ -1904,19 +2082,19 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( SwWW8Writer& rWrt, BYTE nTTyp, ASSERT( pShapeIds, "wo sind die ShapeIds?" ); // nLen = pTxtPos->Count(); - for( i = 0; i < nLen; ++i ) + for ( i = 0; i < nLen; ++i ) { // write textbox story - FTXBXS // is it an writer or sdr - textbox? const SdrObject* pObj = (SdrObject*)aCntnt[ i ]; INT32 nCnt = 1; - if( !pObj->ISA( SdrTextObj ) ) + if ( !pObj->ISA( SdrTextObj ) ) { // find the "highest" SdrObject of this const SwFrmFmt& rFmt = *::FindFrmFmt( pObj ); const SwFmtChain* pChn = &rFmt.GetChain(); - while( pChn->GetNext() ) + while ( pChn->GetNext() ) { // has a chain? // then calc the cur pos in the chain @@ -1934,7 +2112,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( SwWW8Writer& rWrt, BYTE nTTyp, SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 ); // long lid SwWW8Writer::WriteLong( *rWrt.pTableStrm, - (*pShapeIds)[i]); + (*pShapeIds)[i]); // long txidUndo SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 ); } @@ -1942,91 +2120,91 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( SwWW8Writer& rWrt, BYTE nTTyp, bWriteCP = false; } break; - } + } - if( bWriteCP ) - { - // Schreibe CP-Positionen - for( i = 0; i < nLen; i++ ) - SwWW8Writer::WriteLong( *rWrt.pTableStrm, aCps[ i ] ); + if ( bWriteCP ) + { + // Schreibe CP-Positionen + for ( i = 0; i < nLen; i++ ) + SwWW8Writer::WriteLong( *rWrt.pTableStrm, aCps[ i ] ); - // n+1-te CP-Pos nach Handbuch - SwWW8Writer::WriteLong( *rWrt.pTableStrm, + // n+1-te CP-Pos nach Handbuch + SwWW8Writer::WriteLong( *rWrt.pTableStrm, rFib.ccpText + rFib.ccpFtn + rFib.ccpHdr + rFib.ccpEdn + rFib.ccpTxbx + rFib.ccpHdrTxbx + 1 ); - if( TXT_ATN == nTTyp ) + if ( TXT_ATN == nTTyp ) + { + for ( i = 0; i < nLen; ++i ) { - for( i = 0; i < nLen; ++i ) - { - const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ]; + const SwPostItField& rPFld = *(SwPostItField*)aCntnt[ i ]; - //aStrArr is sorted - myiter aIter = ::std::lower_bound(aStrArr.begin(), + //aStrArr is sorted + myiter aIter = ::std::lower_bound(aStrArr.begin(), aStrArr.end(), rPFld.GetPar1()); - ASSERT(aIter != aStrArr.end() && *aIter == rPFld.GetPar1(), + ASSERT(aIter != aStrArr.end() && *aIter == rPFld.GetPar1(), "Impossible"); - sal_uInt16 nFndPos = static_cast< sal_uInt16 >(aIter - aStrArr.begin()); - String sAuthor(*aIter); - BYTE nNameLen = (BYTE)sAuthor.Len(); - if (nNameLen > 9) - { - sAuthor.Erase( 9 ); - nNameLen = 9; - } + sal_uInt16 nFndPos = static_cast< sal_uInt16 >(aIter - aStrArr.begin()); + String sAuthor(*aIter); + BYTE nNameLen = (BYTE)sAuthor.Len(); + if ( nNameLen > 9 ) + { + sAuthor.Erase( 9 ); + nNameLen = 9; + } - // xstUsrInitl[ 10 ] pascal-style String holding initials - // of annotation author - if( rWrt.bWrtWW8 ) - { - SwWW8Writer::WriteShort(*rWrt.pTableStrm, nNameLen); - SwWW8Writer::WriteString16(*rWrt.pTableStrm, sAuthor, + // xstUsrInitl[ 10 ] pascal-style String holding initials + // of annotation author + if ( rWrt.bWrtWW8 ) + { + SwWW8Writer::WriteShort(*rWrt.pTableStrm, nNameLen); + SwWW8Writer::WriteString16(*rWrt.pTableStrm, sAuthor, false); - SwWW8Writer::FillCount( *rWrt.pTableStrm, + SwWW8Writer::FillCount( *rWrt.pTableStrm, (9 - nNameLen) * 2 ); - } - else - { - *rWrt.pTableStrm << nNameLen; - SwWW8Writer::WriteString8(*rWrt.pTableStrm, sAuthor, - false, RTL_TEXTENCODING_MS_1252); - SwWW8Writer::FillCount(*rWrt.pTableStrm, 9 - nNameLen); - } + } + else + { + *rWrt.pTableStrm << nNameLen; + SwWW8Writer::WriteString8(*rWrt.pTableStrm, sAuthor, + false, RTL_TEXTENCODING_MS_1252); + SwWW8Writer::FillCount(*rWrt.pTableStrm, 9 - nNameLen); + } - //SVBT16 ibst; // index into GrpXstAtnOwners - //SVBT16 ak; // not used - //SVBT16 grfbmc; // not used - //SVBT32 ITagBkmk; // when not -1, this tag identifies the + //SVBT16 ibst; // index into GrpXstAtnOwners + //SVBT16 ak; // not used + //SVBT16 grfbmc; // not used + //SVBT32 ITagBkmk; // when not -1, this tag identifies the - SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos ); - SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); - SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); - SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 ); - } + SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos ); + SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); + SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); + SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 ); } - else + } + else + { + USHORT nNo = 0; + for ( i = 0; i < nLen; ++i ) // Schreibe Flags { - USHORT nNo = 0; - for( i = 0; i < nLen; ++i ) // Schreibe Flags - { - const SwFmtFtn* pFtn = (SwFmtFtn*)aCntnt[ i ]; - SwWW8Writer::WriteShort( *rWrt.pTableStrm, - pFtn->GetNumStr().Len() ? 0 : ++nNo ); - } + const SwFmtFtn* pFtn = (SwFmtFtn*)aCntnt[ i ]; + SwWW8Writer::WriteShort( *rWrt.pTableStrm, + pFtn->GetNumStr().Len() ? 0 : ++nNo ); } } - rRefStart = nFcStart; - nFcStart = rWrt.pTableStrm->Tell(); - rRefCount = nFcStart - rRefStart; + } + rRefStart = nFcStart; + nFcStart = rWrt.pTableStrm->Tell(); + rRefCount = nFcStart - rRefStart; - pTxtPos->Write( *rWrt.pTableStrm ); + pTxtPos->Write( *rWrt.pTableStrm ); - switch( nTTyp ) - { + switch ( nTTyp ) + { case TXT_TXTBOX: case TXT_HFTXTBOX: - for( i = 0; i < nLen; ++i ) + for ( i = 0; i < nLen; ++i ) { // write break descriptor (BKD) // short itxbxs @@ -2039,11 +2217,10 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( SwWW8Writer& rWrt, BYTE nTTyp, } SwWW8Writer::FillCount( *rWrt.pTableStrm, 6 ); break; - } - - rTxtStart = nFcStart; - rTxtCount = rWrt.pTableStrm->Tell() - nFcStart; } + + rTxtStart = nFcStart; + rTxtCount = rWrt.pTableStrm->Tell() - nFcStart; } const SvULongs* WW8_WrPlcSubDoc::GetShapeIdArr() const diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 4b2a7f3ccc..4d2eb96d35 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -97,8 +97,12 @@ #include <fmtline.hxx> #include <fmtfsize.hxx> #include <comphelper/extract.hxx> + +#include <writerfilter/doctok/sprmids.hxx> + #include "writerhelper.hxx" #include "writerwordglue.hxx" +#include "ww8attributeoutput.hxx" #include <IDocumentMarkAccess.hxx> @@ -117,6 +121,8 @@ using namespace sw::util; using namespace sw::types; +/** FKP - Formatted disK Page +*/ class WW8_WrFkp { BYTE* pFkp; // gesamter Fkp ( zuerst nur FCs und Sprms ) @@ -197,7 +203,7 @@ public: ~WW8_WrtBookmarks(); void Append( WW8_CP nStartCp, const String& rNm, const ::sw::mark::IMark* pBkmk=NULL ); - void Write( SwWW8Writer& rWrt ); + void Write( WW8Export& rWrt ); void MoveFieldMarks(ULONG nFrom,ULONG nTo); // String GetWWBkmkName( const String& rName ) const; @@ -217,7 +223,7 @@ typedef WW8_WrPc* WW8_WrPcPtr; SV_DECL_PTRARR_DEL( WW8_WrPcPtrs, WW8_WrPcPtr, 4, 4 ) SV_IMPL_PTRARR( WW8_WrPcPtrs, WW8_WrPcPtr ) -static void WriteDop( SwWW8Writer& rWrt ) +static void WriteDop( WW8Export& rWrt ) { WW8Dop& rDop = *rWrt.pDop; @@ -336,7 +342,7 @@ Converts the OOo Asian Typography into a best fit match for Microsoft Asian typography. This structure is actually dumped to disk within the Dop Writer. Assumption is that rTypo is cleared to 0 on entry */ -void SwWW8Writer::ExportDopTypography(WW8DopTypography &rTypo) +void WW8Export::ExportDopTypography(WW8DopTypography &rTypo) { static const sal_Unicode aLangNotBegin[4][WW8DopTypography::nMaxFollowing]= { @@ -507,7 +513,7 @@ void SwWW8Writer::ExportDopTypography(WW8DopTypography &rTypo) (rTypo.cchLeadingPunct+1)*2); } - const IDocumentSettingAccess* pIDocumentSettingAccess = getIDocumentSettingAccess(); + const IDocumentSettingAccess* pIDocumentSettingAccess = GetWriter().getIDocumentSettingAccess(); rTypo.fKerningPunct = pIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION); rTypo.iJustification = pDoc->getCharacterCompressionType(); @@ -517,8 +523,8 @@ void SwWW8Writer::ExportDopTypography(WW8DopTypography &rTypo) // Underline / WordLineMode und Box / Shadow. // Es kann nur etwas gefunden werden, wenn diese Methode innerhalb // der aufgerufenen Methoden WW8_SwAttrIter::OutAttr() und -// SwWW8Writer::Out_SfxItemSet() benutzt wird. -const SfxPoolItem* SwWW8Writer::HasItem( USHORT nWhich ) const +// WW8Export::OutputItemSet() benutzt wird. +const SfxPoolItem* MSWordExportBase::HasItem( USHORT nWhich ) const { const SfxPoolItem* pItem=0; if (pISet) @@ -540,7 +546,7 @@ const SfxPoolItem* SwWW8Writer::HasItem( USHORT nWhich ) const return pItem; } -const SfxPoolItem& SwWW8Writer::GetItem(USHORT nWhich) const +const SfxPoolItem& MSWordExportBase::GetItem(USHORT nWhich) const { const SfxPoolItem* pItem; if (pISet) @@ -624,7 +630,7 @@ void WW8_WrPlc1::Write( SvStream& rStrm ) //------------------------------------------------------------------------------ -bool WW8_WrPlcFld::Write(SwWW8Writer& rWrt) +bool WW8_WrPlcFld::Write( WW8Export& rWrt ) { if( WW8_WrPlc1::Count() <= 1 ) return false; @@ -682,7 +688,7 @@ bool WW8_WrPlcFld::Write(SwWW8Writer& rWrt) return true; } -bool WW8_WrMagicTable::Write(SwWW8Writer& rWrt) +bool WW8_WrMagicTable::Write( WW8Export& rWrt ) { if( WW8_WrPlc1::Count() <= 1 ) return false; @@ -744,7 +750,7 @@ ULONG SwWW8Writer::FillUntil( SvStream& rStrm, ULONG nEndPos ) //-------------------------------------------------------------------------- /* */ -WW8_WrPlcPn::WW8_WrPlcPn( SwWW8Writer& rWr, ePLCFT ePl, WW8_FC nStartFc ) +WW8_WrPlcPn::WW8_WrPlcPn( WW8Export& rWr, ePLCFT ePl, WW8_FC nStartFc ) : rWrt(rWr), nFkpStartPage(0), ePlc(ePl), nMark(0) { WW8_FkpPtr pF = new WW8_WrFkp( ePlc, nStartFc, rWrt.bWrtWW8 ); @@ -1168,7 +1174,7 @@ void WW8_WrPct::AppendPc(WW8_FC nStartFc, bool bIsUnicode) } -void WW8_WrPct::WritePc( SwWW8Writer& rWrt ) +void WW8_WrPct::WritePc( WW8Export& rWrt ) { ULONG nPctStart; ULONG nOldPos, nEndPos; @@ -1277,7 +1283,7 @@ void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const String& rNm, const ::sw:: } -void WW8_WrtBookmarks::Write( SwWW8Writer& rWrt ) +void WW8_WrtBookmarks::Write( WW8Export& rWrt ) { USHORT nCount = aSttCps.Count(), i; if( nCount ) @@ -1358,13 +1364,13 @@ void WW8_WrtBookmarks::MoveFieldMarks(ULONG nFrom, ULONG nTo) } } -void SwWW8Writer::AppendBookmarks( const SwTxtNode& rNd, +void WW8Export::AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen ) { SvPtrarr aArr( 8, 8 ); USHORT nCntnt; xub_StrLen nAktEnd = nAktPos + nLen; - if( GetBookmarks( rNd, nAktPos, nAktEnd, aArr )) + if( GetWriter().GetBookmarks( rNd, nAktPos, nAktEnd, aArr )) { ULONG nNd = rNd.GetIndex(), nSttCP = Fc2Cp( Strm().Tell() ); for( USHORT n = 0; n < aArr.Count(); ++n ) @@ -1402,15 +1408,20 @@ void SwWW8Writer::AppendBookmarks( const SwTxtNode& rNd, } } -void SwWW8Writer::MoveFieldMarks(ULONG nFrom, ULONG nTo) +void WW8Export::MoveFieldMarks(ULONG nFrom, ULONG nTo) { pBkmks->MoveFieldMarks(nFrom, nTo); } -void SwWW8Writer::AppendBookmark(const String& rName, USHORT nOffset) +void WW8Export::AppendBookmark( const rtl::OUString& rName, bool bSkip ) +{ + ULONG nSttCP = Fc2Cp( Strm().Tell() ) + ( bSkip? 1: 0 ); + pBkmks->Append( nSttCP, rName ); +} + +void MSWordExportBase::AppendWordBookmark( const String& rName ) { - ULONG nSttCP = Fc2Cp(Strm().Tell()) + nOffset; - pBkmks->Append(nSttCP, rName); + AppendBookmark( BookmarkToWord( rName ) ); } @@ -1419,12 +1430,12 @@ void SwWW8Writer::AppendBookmark(const String& rName, USHORT nOffset) void WW8_WrtRedlineAuthor::Write( Writer& rWrt ) { - SwWW8Writer & rWW8Wrt = (SwWW8Writer&)rWrt; + WW8Export & rWW8Wrt = *(((SwWW8Writer&)rWrt).m_pExport); rWW8Wrt.WriteAsStringTable(maAuthors, rWW8Wrt.pFib->fcSttbfRMark, rWW8Wrt.pFib->lcbSttbfRMark, rWW8Wrt.bWrtWW8 ? 0 : 2); } -USHORT SwWW8Writer::AddRedlineAuthor( USHORT nId ) +USHORT WW8Export::AddRedlineAuthor( USHORT nId ) { if( !pRedlAuthors ) { @@ -1437,7 +1448,7 @@ USHORT SwWW8Writer::AddRedlineAuthor( USHORT nId ) //-------------------------------------------------------------------------- /* */ -void SwWW8Writer::WriteAsStringTable(const std::vector<String>& rStrings, +void WW8Export::WriteAsStringTable(const std::vector<String>& rStrings, INT32& rfcSttbf, INT32& rlcbSttbf, USHORT nExtraLen) { USHORT n, nCount = static_cast< USHORT >(rStrings.size()); @@ -1612,7 +1623,7 @@ void SwWW8Writer::WriteString8(SvStream& rStrm, const String& rStr, rStrm.Write(&aBytes[0], aBytes.size()); } -void SwWW8Writer::WriteStringAsPara( const String& rTxt, USHORT nStyleId ) +void WW8Export::WriteStringAsPara( const String& rTxt, USHORT nStyleId ) { if( rTxt.Len() ) OutSwString( rTxt, 0, rTxt.Len(), IsUnicode(), RTL_TEXTENCODING_MS_1252 ); @@ -1624,7 +1635,7 @@ void SwWW8Writer::WriteStringAsPara( const String& rTxt, USHORT nStyleId ) { // Tab-Attr // sprmPFInTable if( bWrtWW8 ) - SwWW8Writer::InsUInt16( aArr, 0x2416 ); + SwWW8Writer::InsUInt16( aArr, NS_sprm::LN_PFInTable ); else aArr.Insert( 24, aArr.Count() ); aArr.Insert( 1, aArr.Count() ); @@ -1635,7 +1646,7 @@ void SwWW8Writer::WriteStringAsPara( const String& rTxt, USHORT nStyleId ) pChpPlc->AppendFkpEntry( nPos ); } -void SwWW8Writer::WriteSpecialText( ULONG nStart, ULONG nEnd, BYTE nTTyp ) +void MSWordExportBase::WriteSpecialText( ULONG nStart, ULONG nEnd, BYTE nTTyp ) { BYTE nOldTyp = nTxtTyp; nTxtTyp = nTTyp; @@ -1644,12 +1655,14 @@ void SwWW8Writer::WriteSpecialText( ULONG nStart, ULONG nEnd, BYTE nTTyp ) bool bOldPageDescs = bOutPageDescs; bOutPageDescs = false; // bOutKF wird in WriteKF1 gemerkt / gesetzt - pCurPam = NewSwPaM( *pDoc, nStart, nEnd ); + pCurPam = Writer::NewSwPaM( *pDoc, nStart, nEnd ); // Tabelle in Sonderbereichen erkennen - if( (nStart != pCurPam->GetMark()->nNode.GetIndex()) - && pDoc->GetNodes()[ nStart ]->IsTableNode() ) + if ( ( nStart != pCurPam->GetMark()->nNode.GetIndex() ) && + pDoc->GetNodes()[ nStart ]->IsTableNode() ) + { pCurPam->GetMark()->nNode = nStart; + } pOrigPam = pCurPam; pCurPam->Exchange(); @@ -1663,7 +1676,7 @@ void SwWW8Writer::WriteSpecialText( ULONG nStart, ULONG nEnd, BYTE nTTyp ) nTxtTyp = nOldTyp; } -void SwWW8Writer::OutSwString(const String& rStr, xub_StrLen nStt, +void WW8Export::OutSwString(const String& rStr, xub_StrLen nStt, xub_StrLen nLen, bool bUnicode, rtl_TextEncoding eChrSet) { @@ -1707,7 +1720,7 @@ void SwWW8Writer::OutSwString(const String& rStr, xub_StrLen nStt, #endif } -void SwWW8Writer::WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8Export::WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) { if (pTableTextNodeInfoInner.get() != NULL && pTableTextNodeInfoInner->getDepth() == 1 && pTableTextNodeInfoInner->isEndOfCell()) WriteChar('\007'); @@ -1717,7 +1730,7 @@ void SwWW8Writer::WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeIn pPiece->SetParaBreak(); } -void SwWW8Writer::WriteChar( sal_Unicode c ) +void WW8Export::WriteChar( sal_Unicode c ) { if( pPiece->IsUnicode() ) Strm() << c; @@ -1725,136 +1738,177 @@ void SwWW8Writer::WriteChar( sal_Unicode c ) Strm() << (BYTE)c; } -/* */ -//--------------------------------------------------------------------------- -// Hilfsroutinen fuer Flys -//--------------------------------------------------------------------------- -// Struktur speichert die aktuellen Daten des Writers zwischen, um -// einen anderen Dokument-Teil auszugeben, wie z.B. Header/Footer -WW8SaveData::WW8SaveData( SwWW8Writer& rWriter, ULONG nStt, ULONG nEnd ) - : rWrt( rWriter ), - pOldPam( rWrt.pCurPam ), pOldEnd( rWrt.GetEndPaM() ), - pOldFlyFmt(rWrt.mpParentFrame), pOldPageDesc( rWrt.pAktPageDesc ) - +void MSWordExportBase::SaveData( ULONG nStt, ULONG nEnd ) { - pOldFlyOffset = rWrt.pFlyOffset; - eOldAnchorType = rWrt.eNewAnchorType; - if( rWrt.pO->Count() ) + MSWordSaveData aData; + + // WW8Export only stuff - zeroed here not to issue warnings + aData.pOOld = NULL; + aData.mpTableAtOld = NULL; + aData.mnTableStdAtLenOld = 0; + + // Common stuff + aData.pOldPam = pCurPam; + aData.pOldEnd = pOrigPam; + aData.pOldFlyFmt = mpParentFrame; + aData.pOldPageDesc = pAktPageDesc; + + aData.pOldFlyOffset = pFlyOffset; + aData.eOldAnchorType = eNewAnchorType; + + aData.bOldOutTable = bOutTable; + aData.bOldIsInTable = bIsInTable; + aData.bOldFlyFrmAttrs = bOutFlyFrmAttrs; + aData.bOldStartTOX = bStartTOX; + aData.bOldInWriteTOX = bInWriteTOX; + + pCurPam = Writer::NewSwPaM( *pDoc, nStt, nEnd ); + + // Recognize tables in special cases + if ( nStt != pCurPam->GetMark()->nNode.GetIndex() && + pDoc->GetNodes()[ nStt ]->IsTableNode() ) { - pOOld = rWrt.pO; - rWrt.pO = new WW8Bytes( 128, 128 ); + pCurPam->GetMark()->nNode = nStt; } - else - pOOld = 0; - bOldWriteAll = rWrt.bWriteAll; - bOldOutTable = rWrt.bOutTable; - bOldIsInTable= rWrt.bIsInTable; - bOldFlyFrmAttrs = rWrt.bOutFlyFrmAttrs; - bOldStartTOX = rWrt.bStartTOX; - bOldInWriteTOX = rWrt.bInWriteTOX; - rWrt.pCurPam = rWrt.NewSwPaM( *rWrt.pDoc, nStt, nEnd ); + pOrigPam = pCurPam; + pCurPam->Exchange(); - // Tabelle in Sonderbereichen erkennen - if( nStt != rWrt.pCurPam->GetMark()->nNode.GetIndex() && - rWrt.pDoc->GetNodes()[ nStt ]->IsTableNode() ) - rWrt.pCurPam->GetMark()->nNode = nStt; + bOutTable = false; + // Caution: bIsInTable should not be set here + bOutFlyFrmAttrs = false; +// pAttrSet = 0; + bStartTOX = false; + bInWriteTOX = false; + + maSaveData.push( aData ); +} + +void MSWordExportBase::RestoreData() +{ + MSWordSaveData &rData = maSaveData.top(); + + delete pCurPam; + pCurPam = rData.pOldPam; + pOrigPam = rData.pOldEnd; + + bOutTable = rData.bOldOutTable; + bIsInTable = rData.bOldIsInTable; + bOutFlyFrmAttrs = rData.bOldFlyFrmAttrs; + bStartTOX = rData.bOldStartTOX; + bInWriteTOX = rData.bOldInWriteTOX; + + mpParentFrame = rData.pOldFlyFmt; + pAktPageDesc = rData.pOldPageDesc; + + eNewAnchorType = rData.eOldAnchorType; + pFlyOffset = rData.pOldFlyOffset; - rWrt.SetEndPaM( rWrt.pCurPam ); - rWrt.pCurPam->Exchange( ); - rWrt.bWriteAll = true; - rWrt.bOutTable = false; - // Vorsicht: rWrt.bIsInTable darf hier NICHT veraendert werden! - rWrt.bOutFlyFrmAttrs = false; -// rWrt.pAttrSet = 0; - rWrt.bStartTOX = false; - rWrt.bInWriteTOX = false; + maSaveData.pop(); } +void WW8Export::SaveData( ULONG nStt, ULONG nEnd ) +{ + MSWordExportBase::SaveData( nStt, nEnd ); + + MSWordSaveData &rData = maSaveData.top(); + + if ( pO->Count() ) + { + rData.pOOld = pO; + pO = new WW8Bytes( 128, 128 ); + } + else + rData.pOOld = 0; // reuse pO + + rData.mpTableAtOld = mpTableAt; + mpTableAt = NULL; + rData.mnTableStdAtLenOld = mnTableStdAtLen; + mnTableStdAtLen = 0; + + rData.bOldWriteAll = GetWriter().bWriteAll; + GetWriter().bWriteAll = true; +} -WW8SaveData::~WW8SaveData() +void WW8Export::RestoreData() { - delete rWrt.pCurPam; // Pam wieder loeschen - rWrt.pCurPam = pOldPam; - rWrt.SetEndPaM( pOldEnd ); - rWrt.bWriteAll = bOldWriteAll; - rWrt.bOutTable = bOldOutTable; - rWrt.bIsInTable= bOldIsInTable; - rWrt.bOutFlyFrmAttrs = bOldFlyFrmAttrs; - rWrt.bStartTOX = bOldStartTOX; - rWrt.bInWriteTOX = bOldInWriteTOX; - rWrt.mpParentFrame = pOldFlyFmt; - rWrt.pAktPageDesc = pOldPageDesc; - ASSERT( !rWrt.pO->Count(), " pO ist am Ende von WW8SaveData nicht leer" ); - if( pOOld ) + MSWordSaveData &rData = maSaveData.top(); + + GetWriter().bWriteAll = rData.bOldWriteAll; + + ASSERT( !pO->Count(), "pO is not empty in WW8Export::RestoreData()" ); + if ( rData.pOOld ) { - delete rWrt.pO; - rWrt.pO = pOOld; + delete pO; + pO = rData.pOOld; } - rWrt.eNewAnchorType = eOldAnchorType; - rWrt.pFlyOffset = pOldFlyOffset; + + ASSERT( !mpTableAt || !mpTableAt->Count(), "mpTableAt is not empty in WW8Export::RestoreData()" ); + if ( mpTableAt ) + delete mpTableAt; + mpTableAt = rData.mpTableAtOld; + mnTableStdAtLen = rData.mnTableStdAtLenOld; + + MSWordExportBase::RestoreData(); } -void SwWW8Writer::OutWW8TableInfoCell -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { sal_uInt32 nDepth = pTableTextNodeInfoInner->getDepth(); - if (nDepth > 0) - { + if ( nDepth > 0 ) + { /* Cell */ - InsUInt16(0x2416); - pO->Insert((BYTE)0x1, pO->Count()); - InsUInt16(0x6649); - InsUInt32(nDepth); + m_rWW8Export.InsUInt16( NS_sprm::LN_PFInTable ); + m_rWW8Export.pO->Insert( (BYTE)0x1, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_PTableDepth ); + m_rWW8Export.InsUInt32( nDepth ); - if (nDepth > 1 && pTableTextNodeInfoInner->isEndOfCell()) + if ( nDepth > 1 && pTableTextNodeInfoInner->isEndOfCell() ) { - InsUInt16(0x244b); - pO->Insert((BYTE)0x1, pO->Count()); - } + m_rWW8Export.InsUInt16( NS_sprm::LN_PCell ); + m_rWW8Export.pO->Insert( (BYTE)0x1, m_rWW8Export.pO->Count() ); + } } } -void SwWW8Writer::OutWW8TableInfoRow -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { sal_uInt32 nDepth = pTableTextNodeInfoInner->getDepth(); - - if (nDepth > 0) + + if ( nDepth > 0 ) { - /* Row */ - if (pTableTextNodeInfoInner->isEndOfLine()) + if ( pTableTextNodeInfoInner->isEndOfLine() ) { - InsUInt16(0x2416); - pO->Insert((BYTE)0x1, pO->Count()); - - if (nDepth == 1) + m_rWW8Export.InsUInt16( NS_sprm::LN_PFInTable ); + m_rWW8Export.pO->Insert( (BYTE)0x1, m_rWW8Export.pO->Count() ); + + if ( nDepth == 1 ) { - InsUInt16(0x2417); - pO->Insert((BYTE)0x1, pO->Count()); + m_rWW8Export.InsUInt16( NS_sprm::LN_PFTtp ); + m_rWW8Export.pO->Insert( (BYTE)0x1, m_rWW8Export.pO->Count() ); } - - InsUInt16(0x6649); - InsUInt32(nDepth); - - if (nDepth > 1) + + m_rWW8Export.InsUInt16( NS_sprm::LN_PTableDepth ); + m_rWW8Export.InsUInt32( nDepth ); + + if ( nDepth > 1 ) { - InsUInt16(0x244b); - pO->Insert((BYTE)0x1, pO->Count()); - InsUInt16(0x244c); - pO->Insert((BYTE)0x1, pO->Count()); - } - - OutWW8TableDefinition(pTableTextNodeInfoInner); - OutWW8TableHeight(pTableTextNodeInfoInner); - OutWW8TableBackgrounds(pTableTextNodeInfoInner); - OutWW8TableDefaultBorders(pTableTextNodeInfoInner); - OutWW8TableCanSplit(pTableTextNodeInfoInner); - OutWW8TableBidi(pTableTextNodeInfoInner); - OutWW8TableVerticalCell(pTableTextNodeInfoInner); - OutWW8TableOrientation(pTableTextNodeInfoInner); + m_rWW8Export.InsUInt16( NS_sprm::LN_PCell ); + m_rWW8Export.pO->Insert( (BYTE)0x1, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_PRow ); + m_rWW8Export.pO->Insert( (BYTE)0x1, m_rWW8Export.pO->Count() ); + } + + TableDefinition( pTableTextNodeInfoInner ); + TableHeight( pTableTextNodeInfoInner ); + TableBackgrounds( pTableTextNodeInfoInner ); + TableDefaultBorders( pTableTextNodeInfoInner ); + TableCanSplit( pTableTextNodeInfoInner ); + TableBidi( pTableTextNodeInfoInner ); + TableVerticalCell( pTableTextNodeInfoInner ); + TableOrientation( pTableTextNodeInfoInner ); } } } @@ -1862,14 +1916,14 @@ void SwWW8Writer::OutWW8TableInfoRow static sal_uInt16 lcl_TCFlags(const SwTableBox * pBox) { sal_uInt16 nFlags = 0; - + long nRowSpan = pBox->getRowSpan(); - + if (nRowSpan > 1) nFlags |= (3 << 5); else if (nRowSpan < 0) nFlags |= (1 << 5); - + const SwFrmFmt * pFmt = pBox->GetFrmFmt(); switch (pFmt->GetVertOrient().GetVertOrient()) { @@ -1880,37 +1934,35 @@ static sal_uInt16 lcl_TCFlags(const SwTableBox * pBox) nFlags |= (2 << 7); break; default: - break; + break; } - + return nFlags; } -void SwWW8Writer::OutWW8TableVerticalCell -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); const SwTableLine * pTabLine = pTabBox->GetUpper(); const SwTableBoxes & rTblBoxes = pTabLine->GetTabBoxes(); sal_uInt8 nBoxes = rTblBoxes.Count(); - for (sal_uInt8 n = 0; n < nBoxes; n++) + for ( sal_uInt8 n = 0; n < nBoxes; n++ ) { const SwTableBox * pTabBox1 = rTblBoxes[n]; const SwFrmFmt * pFrmFmt = pTabBox1->GetFrmFmt(); - if (FRMDIR_VERT_TOP_RIGHT == TrueFrameDirection(*pFrmFmt)) + if ( FRMDIR_VERT_TOP_RIGHT == m_rWW8Export.TrueFrameDirection( *pFrmFmt ) ) { - InsUInt16(0x7629); - pO->Insert(BYTE(n), pO->Count()); //start range - pO->Insert(BYTE(n + 1), pO->Count()); //end range - InsUInt16(5); //Equals vertical writing - } + m_rWW8Export.InsUInt16( NS_sprm::LN_TTextFlow ); + m_rWW8Export.pO->Insert( BYTE(n), m_rWW8Export.pO->Count() ); //start range + m_rWW8Export.pO->Insert( BYTE(n + 1), m_rWW8Export.pO->Count() ); //end range + m_rWW8Export.InsUInt16( 5 ); //Equals vertical writing + } } } -void SwWW8Writer::OutWW8TableCanSplit -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); const SwTableLine * pTabLine = pTabBox->GetUpper(); @@ -1924,37 +1976,35 @@ void SwWW8Writer::OutWW8TableCanSplit const SwFmtRowSplit& rSplittable = pLineFmt->GetRowSplit(); BYTE nCantSplit = (!rSplittable.GetValue()) ? 1 : 0; - if (bWrtWW8) + if ( m_rWW8Export.bWrtWW8 ) { - InsUInt16(0x3403); - pO->Insert(nCantSplit, pO->Count()); - InsUInt16(0x3466); // also write fCantSplit90 + m_rWW8Export.InsUInt16( NS_sprm::LN_TFCantSplit ); + m_rWW8Export.pO->Insert( nCantSplit, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_TFCantSplit90 ); // also write fCantSplit90 } else { - pO->Insert(185, pO->Count()); + m_rWW8Export.pO->Insert( 185, m_rWW8Export.pO->Count() ); } - pO->Insert(nCantSplit, pO->Count()); + m_rWW8Export.pO->Insert( nCantSplit, m_rWW8Export.pO->Count() ); } -void SwWW8Writer::OutWW8TableBidi -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { const SwTable * pTable = pTableTextNodeInfoInner->getTable(); const SwFrmFmt * pFrmFmt = pTable->GetFrmFmt(); - if (bWrtWW8) + if ( m_rWW8Export.bWrtWW8 ) { - if (TrueFrameDirection(*pFrmFmt) == FRMDIR_HORI_RIGHT_TOP) + if ( m_rWW8Export.TrueFrameDirection(*pFrmFmt) == FRMDIR_HORI_RIGHT_TOP ) { - InsUInt16(0x560B); - InsUInt16(1); + m_rWW8Export.InsUInt16( NS_sprm::LN_TFBiDi ); + m_rWW8Export.InsUInt16( 1 ); } } } -void SwWW8Writer::OutWW8TableHeight -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); const SwTableLine * pTabLine = pTabBox->GetUpper(); @@ -1984,27 +2034,26 @@ void SwWW8Writer::OutWW8TableHeight // Zeilenhoehe ausgeben sprmTDyaRowHeight long nHeight = 0; const SwFmtFrmSize& rLSz = pLineFmt->GetFrmSize(); - if( ATT_VAR_SIZE != rLSz.GetHeightSizeType() && rLSz.GetHeight() ) + if ( ATT_VAR_SIZE != rLSz.GetHeightSizeType() && rLSz.GetHeight() ) { - if (ATT_MIN_SIZE == rLSz.GetHeightSizeType()) + if ( ATT_MIN_SIZE == rLSz.GetHeightSizeType() ) nHeight = rLSz.GetHeight(); else nHeight = -rLSz.GetHeight(); } - if (nHeight) + if ( nHeight ) { - if( bWrtWW8 ) - InsUInt16( 0x9407 ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_TDyaRowHeight ); else - pO->Insert( 189, pO->Count() ); - InsUInt16( (USHORT)nHeight ); + m_rWW8Export.pO->Insert( 189, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( (USHORT)nHeight ); } } -void SwWW8Writer::OutWW8TableOrientation -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { const SwTable * pTable = pTableTextNodeInfoInner->getTable(); @@ -2029,11 +2078,11 @@ void SwWW8Writer::OutWW8TableOrientation { case text::HoriOrientation::CENTER: case text::HoriOrientation::RIGHT: - if( bWrtWW8 ) - InsUInt16(0x5400 ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_TJc ); else - pO->Insert(182, pO->Count()); - InsUInt16(text::HoriOrientation::RIGHT == eHOri ? 2 : 1); + m_rWW8Export.pO->Insert( 182, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( text::HoriOrientation::RIGHT == eHOri ? 2 : 1 ); break; default: break; @@ -2041,37 +2090,34 @@ void SwWW8Writer::OutWW8TableOrientation } } -void SwWW8Writer::OutWW8TableDefinition -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); const SwTableLine * pTabLine = pTabBox->GetUpper(); const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes(); - const SwNode * pTxtNd = pTableTextNodeInfoInner->getNode(); const SwTable * pTable = pTableTextNodeInfoInner->getTable(); - if( pTable->GetRowsToRepeat() > pTableTextNodeInfoInner->getRow()) + if ( pTable->GetRowsToRepeat() > pTableTextNodeInfoInner->getRow() ) { - if( bWrtWW8 ) - InsUInt16( 0x3404 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_TTableHeader ); else - pO->Insert(186, pO->Count()); - pO->Insert( 1, pO->Count() ); + m_rWW8Export.pO->Insert( 186, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( 1, m_rWW8Export.pO->Count() ); } // number of cell written sal_uInt32 nBoxes = rTabBoxes.Count(); - if (nBoxes > 32) + if ( nBoxes > 32 ) nBoxes = 32; // sprm header - InsUInt16(0xd608); + m_rWW8Export.InsUInt16( NS_sprm::LN_TDefTable ); sal_uInt16 nSprmSize = 2 + (nBoxes + 1) * 2 + nBoxes * 20; - InsUInt16(nSprmSize); // length + m_rWW8Export.InsUInt16( nSprmSize ); // length // number of boxes - pO->Insert(static_cast<BYTE>(nBoxes), pO->Count()); - + m_rWW8Export.pO->Insert( static_cast<BYTE>(nBoxes), m_rWW8Export.pO->Count() ); /* cellxs */ /* @@ -2100,13 +2146,13 @@ void SwWW8Writer::OutWW8TableDefinition ) { sal_Int16 eHOri = rHori.GetHoriOrient(); - switch (eHOri) + switch ( eHOri ) { case text::HoriOrientation::CENTER: case text::HoriOrientation::RIGHT: break; - default: - + + default: nTblOffset = rHori.GetPos(); const SvxLRSpaceItem& rLRSp = pFmt->GetLRSpace(); nTblOffset += rLRSp.GetLeft(); @@ -2114,6 +2160,97 @@ void SwWW8Writer::OutWW8TableDefinition } } + sal_uInt32 n = 0; + m_rWW8Export.InsUInt16( nTblOffset ); + + std::vector<SwTwips> gridCols = GetGridCols( pTableTextNodeInfoInner ); + for ( std::vector<SwTwips>::const_iterator it = gridCols.begin(), end = gridCols.end(); it != end; ++it ) + { + m_rWW8Export.InsUInt16( static_cast<USHORT>( *it ) + nTblOffset ); + } + + /* TCs */ + for ( n = 0; n < nBoxes; n++ ) + { +#ifdef DEBUG + sal_uInt16 npOCount = m_rWW8Export.pO->Count(); +#endif + + SwTableBox * pTabBox1 = rTabBoxes[n]; + const SwFrmFmt & rBoxFmt = *(pTabBox1->GetFrmFmt()); + if ( m_rWW8Export.bWrtWW8 ) + { + sal_uInt16 nFlags = lcl_TCFlags(pTabBox1); + m_rWW8Export.InsUInt16( nFlags ); + } + + static BYTE aNullBytes[] = { 0x0, 0x0 }; + + m_rWW8Export.pO->Insert( aNullBytes, 2, m_rWW8Export.pO->Count() ); // dummy + m_rWW8Export.Out_SwFmtTableBox( *m_rWW8Export.pO, rBoxFmt.GetBox() ); // 8/16 Byte + +#ifdef DEBUG + ::std::clog << "<tclength>" << m_rWW8Export.pO->Count() - npOCount << "</tclength>" + << ::std::endl; +#endif + } +} + +std::vector<SwTwips> AttributeOutputBase::GetGridCols( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) +{ + std::vector<SwTwips> gridCols; + + const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); + const SwTableLine * pTabLine = pTabBox->GetUpper(); + const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes(); + const SwTable *pTable = pTableTextNodeInfoInner->getTable( ); + + // number of cell written + sal_uInt32 nBoxes = rTabBoxes.Count(); + if ( nBoxes > 32 ) + nBoxes = 32; + + const SwFrmFmt *pFmt = pTable->GetFrmFmt(); + ASSERT(pFmt,"Impossible"); + if (!pFmt) + return gridCols; + + const SwFmtFrmSize &rSize = pFmt->GetFrmSize(); + unsigned long nTblSz = static_cast<unsigned long>(rSize.GetWidth()); + + sal_uInt32 nPageSize = 0; + bool bRelBoxSize = false; + + GetTablePageSize( pTableTextNodeInfoInner, nPageSize, bRelBoxSize ); + + SwTwips nSz = 0; + for ( sal_uInt32 n = 0; n < nBoxes; n++ ) + { + const SwFrmFmt* pBoxFmt = rTabBoxes[ n ]->GetFrmFmt(); + const SwFmtFrmSize& rLSz = pBoxFmt->GetFrmSize(); + nSz += rLSz.GetWidth(); + SwTwips nCalc = nSz; + if ( bRelBoxSize ) + nCalc = ( nCalc * nPageSize ) / nTblSz; + + gridCols.push_back( nCalc ); + } + + return gridCols; +} + +void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner, sal_uInt32& rPageSize, bool& rRelBoxSize ) +{ + sal_uInt32 nPageSize = 0; + + const SwNode *pTxtNd = pTableTextNodeInfoInner->getNode( ); + const SwTable *pTable = pTableTextNodeInfoInner->getTable( ); + + const SwFrmFmt *pFmt = pTable->GetFrmFmt(); + ASSERT(pFmt,"Impossible"); + if (!pFmt) + return; + const SwFmtFrmSize &rSize = pFmt->GetFrmSize(); int nWidthPercent = rSize.GetWidthPercent(); bool bManualAligned = pFmt->GetHoriOrient().GetHoriOrient() == text::HoriOrientation::NONE; @@ -2126,21 +2263,20 @@ void SwWW8Writer::OutWW8TableDefinition ASSERT(bRelBoxSize, "huge table width but not relative, suspicious"); bRelBoxSize = true; } - - unsigned long nPageSize = nTblSz; - if (bRelBoxSize) + + if ( bRelBoxSize ) { Point aPt; - SwRect aRect(pFmt->FindLayoutRect(false, &aPt)); - if (aRect.IsEmpty()) + SwRect aRect( pFmt->FindLayoutRect( false, &aPt ) ); + if ( aRect.IsEmpty() ) { // dann besorge mal die Seitenbreite ohne Raender !! const SwFrmFmt* pParentFmt = - mpParentFrame ? - &(mpParentFrame->GetFrmFmt()) : - const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetPageFmtOfNode(*pTxtNd, false); + GetExport().mpParentFrame ? + &(GetExport().mpParentFrame->GetFrmFmt()) : + const_cast<const SwDoc *>(GetExport().pDoc)->GetPageDesc(0).GetPageFmtOfNode(*pTxtNd, false); aRect = pParentFmt->FindLayoutRect(true); - if (0 == (nPageSize = aRect.Width())) + if ( 0 == ( nPageSize = aRect.Width() ) ) { const SvxLRSpaceItem& rLR = pParentFmt->GetLRSpace(); nPageSize = pParentFmt->GetFrmSize().GetWidth() - rLR.GetLeft() @@ -2150,7 +2286,7 @@ void SwWW8Writer::OutWW8TableDefinition else { nPageSize = aRect.Width(); - if(bManualAligned) + if ( bManualAligned ) { // #i37571# For manually aligned tables const SvxLRSpaceItem &rLR = pFmt->GetLRSpace(); @@ -2167,53 +2303,11 @@ void SwWW8Writer::OutWW8TableDefinition } } - SwTwips nSz = 0; - sal_uInt32 n = 0; - InsUInt16(nTblOffset); - - for (n = 0; n < nBoxes; n++) - { - const SwFrmFmt* pBoxFmt = rTabBoxes[ n ]->GetFrmFmt(); - const SwFmtFrmSize& rLSz = pBoxFmt->GetFrmSize(); - nSz += rLSz.GetWidth(); - SwTwips nCalc = nSz; - if (bRelBoxSize) - nCalc = (nCalc * nPageSize) / nTblSz; - - nCalc += nTblOffset; - - InsUInt16(static_cast<USHORT>(nCalc)); - } - - /* TCs */ - for (n = 0; n < nBoxes; n++) - { -#ifdef DEBUG - sal_uInt16 npOCount = pO->Count(); -#endif - - SwTableBox * pTabBox1 = rTabBoxes[n]; - const SwFrmFmt & rBoxFmt = *(pTabBox1->GetFrmFmt()); - if( bWrtWW8 ) - { - sal_uInt16 nFlags = lcl_TCFlags(pTabBox1); - InsUInt16( nFlags ); - } - - static BYTE aNullBytes[] = { 0x0, 0x0 }; - - pO->Insert( aNullBytes, 2, pO->Count() ); // dummy - Out_SwFmtTableBox( *pO, rBoxFmt.GetBox() ); // 8/16 Byte - -#ifdef DEBUG - ::std::clog << "<tclength>" << pO->Count() - npOCount << "</tclength>" - << ::std::endl; -#endif - } + rPageSize = nPageSize; + rRelBoxSize = bRelBoxSize; } -void SwWW8Writer::OutWW8TableDefaultBorders -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); const SwFrmFmt * pFrmFmt = pTabBox->GetFrmFmt(); @@ -2226,44 +2320,41 @@ void SwWW8Writer::OutWW8TableDefaultBorders BOX_LINE_BOTTOM, BOX_LINE_RIGHT }; - for( int i = 0; i < 4; ++i) - { - SwWW8Writer::InsUInt16(*pO, 0xD634); - pO->Insert( BYTE(6), pO->Count() ); - pO->Insert( BYTE(0), pO->Count() ); - pO->Insert( BYTE(1), pO->Count() ); - pO->Insert( BYTE(1 << i), pO->Count() ); - pO->Insert( BYTE(3), pO->Count() ); + for ( int i = 0; i < 4; ++i ) + { + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, 0xD634 ); + m_rWW8Export.pO->Insert( BYTE(6), m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( BYTE(0), m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( BYTE(1), m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( BYTE(1 << i), m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( BYTE(3), m_rWW8Export.pO->Count() ); - SwWW8Writer::InsUInt16(*pO, - pFrmFmt->GetBox().GetDistance(aBorders[i])); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, + pFrmFmt->GetBox().GetDistance( aBorders[i] ) ); } - } -void SwWW8Writer::OutWW8TableBackgrounds -(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner) +void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ) { const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox(); const SwTableLine * pTabLine = pTabBox->GetUpper(); const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes(); sal_uInt8 nBoxes = rTabBoxes.Count(); - if( bWrtWW8 ) - InsUInt16( 0xD609 ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_TDefTableShd ); else - pO->Insert( (BYTE)191, pO->Count() ); - pO->Insert( (BYTE)(nBoxes * 2), pO->Count() ); // Len + m_rWW8Export.pO->Insert( (BYTE)191, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( (BYTE)(nBoxes * 2), m_rWW8Export.pO->Count() ); // Len - for (sal_uInt8 n = 0; n < nBoxes; n++) + for ( sal_uInt8 n = 0; n < nBoxes; n++ ) { const SwTableBox * pBox1 = rTabBoxes[n]; const SwFrmFmt * pFrmFmt = pBox1->GetFrmFmt(); const SfxPoolItem * pI = NULL; Color aColor; - if (SFX_ITEM_ON == pFrmFmt->GetAttrSet().GetItemState(RES_BACKGROUND, - false, &pI)) + if ( SFX_ITEM_ON == pFrmFmt->GetAttrSet().GetItemState( RES_BACKGROUND, false, &pI ) ) { aColor = dynamic_cast<const SvxBrushItem *>(pI)->GetColor(); } @@ -2271,28 +2362,27 @@ void SwWW8Writer::OutWW8TableBackgrounds aColor = COL_AUTO; WW8_SHD aShd; - TransBrush(aColor, aShd); - InsUInt16(aShd.GetValue()); + m_rWW8Export.TransBrush( aColor, aShd ); + m_rWW8Export.InsUInt16( aShd.GetValue() ); } - if (bWrtWW8) + if ( m_rWW8Export.bWrtWW8 ) { sal_uInt8 nBoxes0 = rTabBoxes.Count(); if (nBoxes0 > 21) nBoxes0 = 21; - InsUInt16(0xd612); - pO->Insert(static_cast<BYTE>(nBoxes0 * 10), pO->Count()); + m_rWW8Export.InsUInt16( NS_sprm::LN_TCellShd ); + m_rWW8Export.pO->Insert( static_cast<BYTE>(nBoxes0 * 10), m_rWW8Export.pO->Count() ); - for (sal_uInt8 n = 0; n < nBoxes0; n++) + for ( sal_uInt8 n = 0; n < nBoxes0; n++ ) { const SwTableBox * pBox1 = rTabBoxes[n]; const SwFrmFmt * pFrmFmt = pBox1->GetFrmFmt(); const SfxPoolItem * pI = NULL; Color aColor; - if (SFX_ITEM_ON == pFrmFmt->GetAttrSet().GetItemState(RES_BACKGROUND, - false, &pI)) + if ( SFX_ITEM_ON == pFrmFmt->GetAttrSet().GetItemState( RES_BACKGROUND, false, &pI ) ) { aColor = dynamic_cast<const SvxBrushItem *>(pI)->GetColor(); } @@ -2300,99 +2390,100 @@ void SwWW8Writer::OutWW8TableBackgrounds aColor = COL_AUTO; WW8SHDLong aSHD; - aSHD.setCvFore(0xFF000000); + aSHD.setCvFore( 0xFF000000 ); sal_uInt32 nBgColor = aColor.GetColor(); - if (nBgColor == COL_AUTO) - aSHD.setCvBack(0xFF000000); + if ( nBgColor == COL_AUTO ) + aSHD.setCvBack( 0xFF000000 ); else - aSHD.setCvBack(wwUtility::RGBToBGR(nBgColor)); + aSHD.setCvBack( wwUtility::RGBToBGR( nBgColor ) ); - aSHD.Write(*this); + aSHD.Write( m_rWW8Export ); } } } -void SwWW8Writer::WriteText() +void WW8Export::SectionBreaksAndFrames( const SwTxtNode& rNode ) +{ + // output page/section breaks + OutputSectionBreaks( rNode.GetpSwAttrSet(), rNode ); + + // all textframes anchored as character for the winword 7- format + if ( !bWrtWW8 && !bIsInTable ) + OutWW6FlyFrmsInCntnt( rNode ); +} + +void MSWordExportBase::WriteText() { #ifdef DEBUG ::std::clog << "<WriteText>" << ::std::endl; - ::std::clog << dbg_out(pCurPam->GetDoc()->GetNodes()) << ::std::endl; +// ::std::clog << dbg_out(pCurPam->GetDoc()->GetNodes()) << ::std::endl; #endif while( pCurPam->GetPoint()->nNode < pCurPam->GetMark()->nNode || - (pCurPam->GetPoint()->nNode == pCurPam->GetMark()->nNode && - pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex()) ) + ( pCurPam->GetPoint()->nNode == pCurPam->GetMark()->nNode && + pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex() ) ) { SwNode * pNd = pCurPam->GetNode(); - if (pNd->IsTxtNode()) // blitzschnelle Methode - { - const SwTxtNode* pTxtNode = pNd->GetTxtNode(); - Out_SfxBreakItems(pTxtNode->GetpSwAttrSet(), *pTxtNode); - // all textframes anchored as character for the winword 7- format - if (!bWrtWW8 && !bIsInTable) - OutWW8FlyFrmsInCntnt(*pTxtNode); - } + if ( pNd->IsTxtNode() ) + SectionBreaksAndFrames( *pNd->GetTxtNode() ); - if( pNd->IsCntntNode() ) + // output the various types of nodes + if ( pNd->IsCntntNode() ) { SwCntntNode* pCNd = (SwCntntNode*)pNd; - const SwPageDesc* pTemp = - pCNd->GetSwAttrSet().GetPageDesc().GetPageDesc(); - if (pTemp) + const SwPageDesc* pTemp = pCNd->GetSwAttrSet().GetPageDesc().GetPageDesc(); + if ( pTemp ) pAktPageDesc = pTemp; pCurPam->GetPoint()->nContent.Assign( pCNd, 0 ); - Out( aWW8NodeFnTab, *pCNd, *this ); + OutputContentNode( *pCNd ); } - else if( pNd->IsTableNode() ) + else if ( pNd->IsTableNode() ) { - mpTableInfo->processSwTable(&(dynamic_cast<SwTableNode *>(pNd)->GetTable())); + mpTableInfo->processSwTable( &pNd->GetTableNode()->GetTable() ); } - else if( pNd->IsSectionNode() && TXT_MAINTEXT == nTxtTyp ) - OutWW8_SwSectionNode( *this, *pNd->GetSectionNode() ); - else if( TXT_MAINTEXT == nTxtTyp && pNd->IsEndNode() && - pNd->StartOfSectionNode()->IsSectionNode() ) + else if ( pNd->IsSectionNode() && TXT_MAINTEXT == nTxtTyp ) + OutputSectionNode( *pNd->GetSectionNode() ); + else if ( TXT_MAINTEXT == nTxtTyp && pNd->IsEndNode() && + pNd->StartOfSectionNode()->IsSectionNode() ) { const SwSection& rSect = pNd->StartOfSectionNode()->GetSectionNode() ->GetSection(); - if( bStartTOX && TOX_CONTENT_SECTION == rSect.GetType() ) + if ( bStartTOX && TOX_CONTENT_SECTION == rSect.GetType() ) bStartTOX = false; SwNodeIndex aIdx( *pNd, 1 ); - if( aIdx.GetNode().IsEndNode() - && aIdx.GetNode().StartOfSectionNode()->IsSectionNode() ) + if ( aIdx.GetNode().IsEndNode() && aIdx.GetNode().StartOfSectionNode()->IsSectionNode() ) ; - else - if( aIdx.GetNode().IsSectionNode() ) + else if ( aIdx.GetNode().IsSectionNode() ) ; - else if (!bIsInTable) //No sections in table + else if ( !bIsInTable ) //No sections in table { ReplaceCr( (char)0xc ); // Indikator fuer Page/Section-Break const SwSectionFmt* pParentFmt = rSect.GetFmt()->GetParent(); - if( !pParentFmt ) + if ( !pParentFmt ) pParentFmt = (SwSectionFmt*)0xFFFFFFFF; ULONG nRstLnNum; - if( aIdx.GetNode().IsCntntNode() ) + if ( aIdx.GetNode().IsCntntNode() ) nRstLnNum = ((SwCntntNode&)aIdx.GetNode()).GetSwAttrSet(). GetLineNumber().GetStartValue(); else nRstLnNum = 0; - pSepx->AppendSep( Fc2Cp( Strm().Tell() ), - pAktPageDesc, pParentFmt, nRstLnNum ); + AppendSection( pAktPageDesc, pParentFmt, nRstLnNum ); } } - else if (pNd->IsEndNode()) + else if ( pNd->IsEndNode() ) { - OutWW8_SwEndNode(pNd); + OutputEndNode( *pNd->GetEndNode() ); } - if( pNd == &pNd->GetNodes().GetEndOfContent() ) + if ( pNd == &pNd->GetNodes().GetEndOfContent() ) break; SwNode * pCurrentNode = &pCurPam->GetPoint()->nNode.GetNode(); @@ -2404,7 +2495,7 @@ void SwWW8Writer::WriteText() pCurPam->GetPoint()->nNode++; ULONG nPos = pCurPam->GetPoint()->nNode.GetIndex(); - ::SetProgressState( nPos, pCurPam->GetDoc()->GetDocShell() ); // Wie weit ? + ::SetProgressState( nPos, pCurPam->GetDoc()->GetDocShell() ); } #ifdef DEBUG @@ -2412,7 +2503,7 @@ void SwWW8Writer::WriteText() #endif } -void SwWW8Writer::WriteMainText() +void WW8Export::WriteMainText() { #ifdef DEBUG ::std::clog << "<WriteMainText>" << ::std::endl; @@ -2444,7 +2535,7 @@ void SwWW8Writer::WriteMainText() #endif } -void SwWW8Writer::WriteFkpPlcUsw() +void WW8Export::WriteFkpPlcUsw() { if( !bWrtWW8 ) { @@ -2460,7 +2551,7 @@ void SwWW8Writer::WriteFkpPlcUsw() pChpPlc->WriteFkps(); // Fkp.Chpx pPapPlc->WriteFkps(); // Fkp.Papx - pStyles->OutStyleTab(); // Styles + pStyles->OutputStylesTable(); // Styles pFtn->WritePlc( *this ); // Footnote-Ref & Text Plc pEdn->WritePlc( *this ); // Endnote-Ref & Text Plc pAtn->WritePlc( *this ); // Annotation-Ref & Text Plc @@ -2470,7 +2561,7 @@ void SwWW8Writer::WriteFkpPlcUsw() pPapPlc->WritePlc(); // Plcx.Papx maFontHelper.WriteFontTable(pTableStrm, *pFib); // FFNs if( pRedlAuthors ) - pRedlAuthors->Write( *this ); // sttbfRMark (RedlineAuthors) + pRedlAuthors->Write( GetWriter() ); // sttbfRMark (RedlineAuthors) pFldMain->Write( *this ); // Fields ( Main Text ) pFldHdFt->Write( *this ); // Fields ( Header/Footer ) pFldFtn->Write( *this ); // Fields ( FootNotes ) @@ -2492,7 +2583,7 @@ void SwWW8Writer::WriteFkpPlcUsw() pSepx->WriteSepx( Strm() ); // Sepx // Ausagbe in Table-Stream - pStyles->OutStyleTab(); // fuer WW8 StyleTab + pStyles->OutputStylesTable(); // fuer WW8 StyleTab pFtn->WritePlc( *this ); // Footnote-Ref & Text Plc pEdn->WritePlc( *this ); // Endnote-Ref & Text Plc pTxtBxs->WritePlc( *this ); // Textbox Text Plc @@ -2506,7 +2597,7 @@ void SwWW8Writer::WriteFkpPlcUsw() pPapPlc->WritePlc(); // Plcx.Papx if( pRedlAuthors ) - pRedlAuthors->Write( *this ); // sttbfRMark (RedlineAuthors) + pRedlAuthors->Write( GetWriter() ); // sttbfRMark (RedlineAuthors) pFldMain->Write( *this ); // Fields ( Main Text ) pFldHdFt->Write( *this ); // Fields ( Header/Footer ) pFldFtn->Write( *this ); // Fields ( FootNotes ) @@ -2537,7 +2628,7 @@ void SwWW8Writer::WriteFkpPlcUsw() #10570# Similiarly having msvbasic storage seems to also trigger creating this stream */ - GetStorage().OpenSotStorage(CREATE_CONST_ASC(SL::aObjectPool), + GetWriter().GetStorage().OpenSotStorage(CREATE_CONST_ASC(SL::aObjectPool), STREAM_READWRITE | STREAM_SHARE_DENYALL); } @@ -2552,9 +2643,7 @@ void SwWW8Writer::WriteFkpPlcUsw() pBkmks->Write( *this ); // Bookmarks - sttbfBkmk/ // plcfBkmkf/plcfBkmkl - OutListTab(); // listformats - LSTF - OutOverrideListTab(); // - "" - - LFO - OutListNamesTab(); // - "" - - ListNames + WriteNumbering(); RestoreMacroCmds(); @@ -2573,7 +2662,7 @@ void SwWW8Writer::WriteFkpPlcUsw() pFib->Write( Strm() ); // FIB } -void SwWW8Writer::StoreDoc1() +void WW8Export::StoreDoc1() { bool bNeedsFinalPara = false; // Start of Text ( Mangel ueber ) @@ -2610,7 +2699,7 @@ void SwWW8Writer::StoreDoc1() WriteFkpPlcUsw(); // FKP, PLC, ..... } -void SwWW8Writer::AddLinkTarget(const String& rURL) +void MSWordExportBase::AddLinkTarget(const String& rURL) { if( !rURL.Len() || rURL.GetChar(0) != INET_MARK_TOKEN ) return; @@ -2646,12 +2735,7 @@ void SwWW8Writer::AddLinkTarget(const String& rURL) } } -void SwWW8Writer::AddBookmark(String sBkmkName) -{ - pBkmks->Append(Fc2Cp(Strm().Tell()), BookmarkToWord(sBkmkName)); -} - -void SwWW8Writer::CollectOutlineBookmarks(const SwDoc &rDoc) +void MSWordExportBase::CollectOutlineBookmarks(const SwDoc &rDoc) { const SwFmtINetFmt* pINetFmt; const SwTxtINetFmt* pTxtAttr; @@ -2696,7 +2780,7 @@ void SwWW8Writer::CollectOutlineBookmarks(const SwDoc &rDoc) namespace { -#define WW_BLOCKSIZE 0x200 + const ULONG WW_BLOCKSIZE = 0x200; void EncryptRC4(svx::MSCodec_Std97& rCtx, SvStream &rIn, SvStream &rOut) { @@ -2716,7 +2800,7 @@ namespace } } -ULONG SwWW8Writer::StoreDoc() +void MSWordExportBase::ExportDocument( bool bWriteAll ) { nCharFmtStart = ANZ_DEFAULT_STYLES; nFmtCollStart = nCharFmtStart + pDoc->GetCharFmts()->Count() - 1; @@ -2741,64 +2825,91 @@ ULONG SwWW8Writer::StoreDoc() pOutFmtNode = 0; pEscher = 0; pRedlAuthors = 0; - if( aTOXArr.Count() ) + if ( aTOXArr.Count() ) aTOXArr.Remove( 0, aTOXArr.Count() ); - if( !pOLEExp ) + if ( !pOLEExp ) { UINT32 nSvxMSDffOLEConvFlags = 0; const SvtFilterOptions* pOpt = SvtFilterOptions::Get(); - if( pOpt->IsMath2MathType() ) + if ( pOpt->IsMath2MathType() ) nSvxMSDffOLEConvFlags |= OLE_STARMATH_2_MATHTYPE; - if( pOpt->IsWriter2WinWord() ) + if ( pOpt->IsWriter2WinWord() ) nSvxMSDffOLEConvFlags |= OLE_STARWRITER_2_WINWORD; - if( pOpt->IsCalc2Excel() ) + if ( pOpt->IsCalc2Excel() ) nSvxMSDffOLEConvFlags |= OLE_STARCALC_2_EXCEL; - if( pOpt->IsImpress2PowerPoint() ) + if ( pOpt->IsImpress2PowerPoint() ) nSvxMSDffOLEConvFlags |= OLE_STARIMPRESS_2_POWERPOINT; pOLEExp = new SvxMSExportOLEObjects( nSvxMSDffOLEConvFlags ); } - if( !pOleMap) + if ( !pOleMap) pOleMap = new WW8OleMaps; - if( !pOCXExp ) - pOCXExp = new SwMSConvertControls(pDoc->GetDocShell(),pCurPam); - - PrepareStorage(); + if ( !pOCXExp ) + pOCXExp = new SwMSConvertControls( pDoc->GetDocShell(), pCurPam ); // --> OD 2007-10-08 #i81405# // Collect anchored objects before changing the redline mode. - if (bWrtWW8) - maFrames = GetAllFrames(*pDoc, bWriteAll ? 0 : pOrigPam); - else - maFrames = GetNonDrawingFrames(*pDoc, bWriteAll ? 0 : pOrigPam); + maFrames = GetFrames( *pDoc, bWriteAll? NULL : pOrigPam ); // <-- - USHORT nRedlineMode = pDoc->GetRedlineMode(); - if (pDoc->GetRedlineTbl().Count()) + mnRedlineMode = pDoc->GetRedlineMode(); + if ( pDoc->GetRedlineTbl().Count() ) { - pDoc->SetRedlineMode((RedlineMode_t)(nRedlineMode | nsRedlineMode_t::REDLINE_SHOW_DELETE | - nsRedlineMode_t::REDLINE_SHOW_INSERT)); + pDoc->SetRedlineMode( (RedlineMode_t)(mnRedlineMode | nsRedlineMode_t::REDLINE_SHOW_DELETE | + nsRedlineMode_t::REDLINE_SHOW_INSERT) ); } - maFontHelper.InitFontTable(bWrtWW8, *pDoc); + maFontHelper.InitFontTable( HackIsWW8OrHigher(), *pDoc ); GatherChapterFields(); + CollectOutlineBookmarks(*pDoc); + + // make unique OrdNums (Z-Order) for all drawing-/fly Objects + if ( pDoc->GetDrawModel() ) + pDoc->GetDrawModel()->GetPage( 0 )->RecalcObjOrdNums(); + + ExportDocument_Impl(); + + if ( mnRedlineMode != pDoc->GetRedlineMode() ) + pDoc->SetRedlineMode( (RedlineMode_t)(mnRedlineMode) ); +} + +String SwWW8Writer::GetPassword() +{ + String sUniPassword; + if ( mpMedium ) + { + SfxItemSet* pSet = mpMedium->GetItemSet(); + + const SfxPoolItem* pPasswordItem = NULL; + if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_PASSWORD, sal_True, &pPasswordItem ) ) + if( pPasswordItem != NULL ) + sUniPassword = ( (const SfxStringItem*)pPasswordItem )->GetValue(); + } + + return sUniPassword; +} + +void WW8Export::ExportDocument_Impl() +{ + PrepareStorage(); + pFib = new WW8Fib( bWrtWW8 ? 8 : 6 ); - SvStream* pOldStrm = pStrm; // JP 19.05.99: wozu das ??? - SvStorageStreamRef xWwStrm( pStg->OpenSotStream( aMainStg ) ); + SvStream* pOldStrm = &(Strm()); // JP 19.05.99: wozu das ??? + SvStorageStreamRef xWwStrm( GetWriter().GetStorage().OpenSotStream( aMainStg ) ); SvStorageStreamRef xTableStrm( xWwStrm ), xDataStrm( xWwStrm ); xWwStrm->SetBufferSize( 32768 ); if( bWrtWW8 ) { pFib->fWhichTblStm = 1; - xTableStrm = pStg->OpenSotStream(CREATE_CONST_ASC(SL::a1Table), + xTableStrm = GetWriter().GetStorage().OpenSotStream(CREATE_CONST_ASC(SL::a1Table), STREAM_STD_WRITE ); - xDataStrm = pStg->OpenSotStream(CREATE_CONST_ASC(SL::aData), + xDataStrm = GetWriter().GetStorage().OpenSotStream(CREATE_CONST_ASC(SL::aData), STREAM_STD_WRITE ); xDataStrm->SetBufferSize( 32768 ); // fuer Grafiken @@ -2808,22 +2919,13 @@ ULONG SwWW8Writer::StoreDoc() xDataStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); } - pStrm = &xWwStrm; + GetWriter().SetStrm( *xWwStrm ); pTableStrm = &xTableStrm; pDataStrm = &xDataStrm; - pStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); - - String sUniPassword; - if ( mpMedium ) - { - SfxItemSet* pSet = mpMedium->GetItemSet(); + Strm().SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN ); - const SfxPoolItem* pPasswordItem = NULL; - if ( pSet && SFX_ITEM_SET == pSet->GetItemState( SID_PASSWORD, sal_True, &pPasswordItem ) ) - if( pPasswordItem != NULL ) - sUniPassword = ( (const SfxStringItem*)pPasswordItem )->GetValue(); - } + String sUniPassword( GetWriter().GetPassword() ); utl::TempFile aTempMain; aTempMain.EnableKillingFile(); @@ -2831,71 +2933,29 @@ ULONG SwWW8Writer::StoreDoc() aTempTable.EnableKillingFile(); utl::TempFile aTempData; aTempData.EnableKillingFile(); - + bool bEncrypt = false; xub_StrLen nLen = sUniPassword.Len(); if ( nLen > 0 && nLen <= 15) // Password has been set { bEncrypt =true; - - pStrm = aTempMain.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); + + GetWriter().SetStrm( *aTempMain.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ) ); pTableStrm = aTempTable.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); pDataStrm = aTempData.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ); - + sal_uInt8 aRC4EncryptionHeader[ 52 ] = {0}; pTableStrm->Write( aRC4EncryptionHeader, 52 ); } - const SwSectionFmt *pFmt=0; // Default: "Standard" - pAktPageDesc = &const_cast<const SwDoc *>(pDoc)->GetPageDesc( 0 ); - pSepx = new WW8_WrPlcSepx; // Sepx - { - const SfxPoolItem* pI; - const SwNode* pNd = pCurPam->GetCntntNode(); - const SfxItemSet* pSet = pNd ? &((SwCntntNode*)pNd)->GetSwAttrSet() - : 0; - - ULONG nRstLnNum = pSet ? ((SwFmtLineNumber&)pSet->Get( - RES_LINENUMBER )).GetStartValue() - : 0; + pSepx = new WW8_WrPlcSepx( *this ); // Sections/headers/footers - const SwTableNode* pTblNd = pCurPam->GetNode()->FindTableNode(); - const SwSectionNode* pSectNd; - if( pTblNd ) - { - pSet = &pTblNd->GetTable().GetFrmFmt()->GetAttrSet(); - pNd = pTblNd; - } - else if( 0 != ( pSectNd = pNd->FindSectionNode() ) ) - { - if( TOX_HEADER_SECTION == pSectNd->GetSection().GetType() && - pSectNd->StartOfSectionNode()->IsSectionNode() ) - pSectNd = pSectNd->StartOfSectionNode()->GetSectionNode(); - - if( TOX_CONTENT_SECTION == pSectNd->GetSection().GetType() ) - { - pNd = pSectNd; - pCurPam->GetPoint()->nNode = *pNd; - } - - if (CONTENT_SECTION == pSectNd->GetSection().GetType()) - pFmt = pSectNd->GetSection().GetFmt(); - } - - // Hole evtl. Pagedesc des 1. Nodes - if( pSet && SFX_ITEM_ON == pSet->GetItemState(RES_PAGEDESC, true, &pI) - && ((SwFmtPageDesc*)pI)->GetPageDesc() ) - pSepx->AppendSep( 0, *(SwFmtPageDesc*)pI, *pNd, pFmt, nRstLnNum ); - else - pSepx->AppendSep( 0, pAktPageDesc, pFmt, nRstLnNum ); - } - - pFtn = new WW8_WrPlcFtnEdn( TXT_FTN ); // Ftn - pEdn = new WW8_WrPlcFtnEdn( TXT_EDN ); // Edn + pFtn = new WW8_WrPlcFtnEdn( TXT_FTN ); // Footnotes + pEdn = new WW8_WrPlcFtnEdn( TXT_EDN ); // Endnotes pAtn = new WW8_WrPlcPostIt; // PostIts pTxtBxs = new WW8_WrPlcTxtBoxes( TXT_TXTBOX ); pHFTxtBxs = new WW8_WrPlcTxtBoxes( TXT_HFTXTBOX ); @@ -2904,12 +2964,12 @@ ULONG SwWW8Writer::StoreDoc() pHFSdrObjs = new HdFtPlcDrawObj; // Draw-/Fly-Objects for header/footer pBkmks = new WW8_WrtBookmarks; // Bookmarks - CreateBookmarkTbl(); + GetWriter().CreateBookmarkTbl(); pPapPlc = new WW8_WrPlcPn( *this, PAP, pFib->fcMin ); pChpPlc = new WW8_WrPlcPn( *this, CHP, pFib->fcMin ); pO = new WW8Bytes( 128, 128 ); - pStyles = new WW8WrtStyle( *this ); + pStyles = new MSWordStyles( *this ); pFldMain = new WW8_WrPlcFld( 2, TXT_MAINTEXT ); pFldHdFt = new WW8_WrPlcFld( 2, TXT_HDFT ); pFldFtn = new WW8_WrPlcFld( 2, TXT_FTN ); @@ -2925,12 +2985,10 @@ ULONG SwWW8Writer::StoreDoc() pDop = new WW8Dop; - pDop->fRevMarking = 0 != (nsRedlineMode_t::REDLINE_ON & nRedlineMode); - pDop->fRMView = 0 != ( nsRedlineMode_t::REDLINE_SHOW_DELETE & nRedlineMode ); + pDop->fRevMarking = 0 != ( nsRedlineMode_t::REDLINE_ON & mnRedlineMode ); + pDop->fRMView = 0 != ( nsRedlineMode_t::REDLINE_SHOW_DELETE & mnRedlineMode ); pDop->fRMPrint = pDop->fRMView; - CollectOutlineBookmarks(*pDoc); - // set AutoHyphenation flag if found in default para style const SfxPoolItem* pItem; SwTxtFmtColl* pStdTxtFmtColl = @@ -2941,10 +2999,6 @@ ULONG SwWW8Writer::StoreDoc() pDop->fAutoHyphen = ((const SvxHyphenZoneItem*)pItem)->IsHyphen(); } - // make unique OrdNums (Z-Order) for all drawing-/fly Objects - if (pDoc->GetDrawModel()) - pDoc->GetDrawModel()->GetPage( 0 )->RecalcObjOrdNums(); - StoreDoc1(); if ( bEncrypt ) @@ -2957,7 +3011,7 @@ ULONG SwWW8Writer::StoreDoc() sal_uInt8 aDocId[ 16 ] = {0}; rtl_random_getBytes( aRandomPool, aDocId, 16 ); - + rtl_random_destroyPool( aRandomPool ); sal_Unicode aPassword[16] = {0}; @@ -2966,7 +3020,7 @@ ULONG SwWW8Writer::StoreDoc() svx::MSCodec_Std97 aCtx; aCtx.InitKey(aPassword, aDocId); - + SvStream *pStrmTemp, *pTableStrmTemp, *pDataStrmTemp; pStrmTemp = &xWwStrm; pTableStrmTemp = &xTableStrm; @@ -2991,21 +3045,18 @@ ULONG SwWW8Writer::StoreDoc() pTableStrmTemp->Write( pSaltData, 16 ); pTableStrmTemp->Write( pSaltDigest, 16 ); - EncryptRC4(aCtx, *pStrm, *pStrmTemp); + EncryptRC4(aCtx, GetWriter().Strm(), *pStrmTemp); // Write Unencrypted Fib 68 bytes to the start of the workdocument stream pFib->fEncrypted = 1; // fEncrypted indicates the document is encrypted. pFib->fObfuscated = 0; // Must be 0 for RC4. pFib->nHash = 0x34; // encrypt header bytes count of table stream. pFib->nKey = 0; // lkey2 must be 0 for RC4. - + pStrmTemp->Seek( 0 ); pFib->WriteHeader( *pStrmTemp ); } - if (nRedlineMode != pDoc->GetRedlineMode()) - pDoc->SetRedlineMode((RedlineMode_t)(nRedlineMode)); - if (pUsedNumTbl) // all used NumRules { // clear the part of the list array that was copied from the document @@ -3042,7 +3093,7 @@ ULONG SwWW8Writer::StoreDoc() delete pPiece; delete pDop; delete pFib; - pStrm = pOldStrm; + GetWriter().SetStrm( *pOldStrm ); xWwStrm->SetBufferSize( 0 ); @@ -3054,15 +3105,13 @@ ULONG SwWW8Writer::StoreDoc() { xDataStrm.Clear(); pDataStrm = 0; - pStg->Remove(CREATE_CONST_ASC(SL::aData)); + GetWriter().GetStorage().Remove(CREATE_CONST_ASC(SL::aData)); } } - - return 0; } -void SwWW8Writer::PrepareStorage() +void WW8Export::PrepareStorage() { ULONG nLen; const BYTE* pData; @@ -3123,8 +3172,8 @@ void SwWW8Writer::PrepareStorage() SvGlobalName aGName( nId1, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 ); - pStg->SetClass( aGName, 0, String::CreateFromAscii( pName )); - SvStorageStreamRef xStor( pStg->OpenSotStream(sCompObj) ); + GetWriter().GetStorage().SetClass( aGName, 0, String::CreateFromAscii( pName )); + SvStorageStreamRef xStor( GetWriter().GetStorage().OpenSotStream(sCompObj) ); xStor->Write( pData, nLen ); SwDocShell* pDocShell = pDoc->GetDocShell (); @@ -3145,10 +3194,10 @@ void SwWW8Writer::PrepareStorage() pDocShell->GetPreviewMetaFile (sal_False); uno::Sequence<sal_uInt8> metaFile( sfx2::convertMetaFile(pMetaFile.get())); - sfx2::SaveOlePropertySet(xDocProps, pStg, &metaFile); + sfx2::SaveOlePropertySet(xDocProps, &GetWriter().GetStorage(), &metaFile); } else - sfx2::SaveOlePropertySet( xDocProps, pStg ); + sfx2::SaveOlePropertySet( xDocProps, &GetWriter().GetStorage() ); } } } @@ -3172,11 +3221,16 @@ ULONG SwWW8Writer::WriteStorage() pCurPam->GetPoint()->nNode = *pTNd; } - ULONG nRet = StoreDoc(); + // Do the actual export + { + WW8Export aExport( this, pDoc, pCurPam, pOrigPam, m_bWrtWW8 ); + m_pExport = &aExport; + aExport.ExportDocument( bWriteAll ); + m_pExport = NULL; + } ::EndProgress( pDoc->GetDocShell() ); - bWrtWW8 = false; // sicherheitshalber: Default fuer's naechste Mal - return nRet; + return 0; } ULONG SwWW8Writer::WriteMedium( SfxMedium& ) @@ -3185,7 +3239,7 @@ ULONG SwWW8Writer::WriteMedium( SfxMedium& ) } ULONG SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed, - const String* pFileName ) + const String* pFileName ) { mpMedium = &rMed; ULONG nRet = StgWriter::Write( rPaM, rMed, pFileName ); @@ -3193,43 +3247,69 @@ ULONG SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed, return nRet; } -ULONG SwWW8Writer::Write( SwPaM& rPaM, const uno::Reference < embed::XStorage >& xStorage, const String* pFileName, SfxMedium* pMedium ) +MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam ) + : aMainStg(sMainStream), pISet(0), pUsedNumTbl(0), mpTopNodeOfHdFtPage(0), + pBmpPal(0), pKeyMap(0), pOLEExp(0), pOCXExp(0), pOleMap(0), + mpTableInfo(new ww8::WW8TableInfo()), nUniqueList(0), + mnHdFtIndex(0), pAktPageDesc(0), pPapPlc(0), pChpPlc(0), pChpIter(0), + pStyles( NULL ), + bHasHdr(false), bHasFtr(false), + pDoc( pDocument ), + pCurPam( pCurrentPam ), + pOrigPam( pOriginalPam ) +{ +} + +MSWordExportBase::~MSWordExportBase() +{ + delete pBmpPal; + if (pKeyMap) + delete[] (NfKeywordTable*)pKeyMap; + delete pOLEExp; + delete pOCXExp; + delete pOleMap; +} + +WW8Export::WW8Export( SwWW8Writer *pWriter, + SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, + bool bIsWW8 ) + : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ), + pO( NULL ), + mpTableAt( NULL ), + mnTableStdAtLen( 0 ), + pSepx( NULL ), + bWrtWW8( bIsWW8 ), + m_pWriter( pWriter ), + m_pAttrOutput( new WW8AttributeOutput( *this ) ) +{ +} + +WW8Export::~WW8Export() { - // this method was added to let the windows compiler be happy, otherwise it shows warning - return StgWriter::Write( rPaM, xStorage, pFileName, pMedium ); + delete m_pAttrOutput, m_pAttrOutput = NULL; } -ULONG SwWW8Writer::Write( SwPaM& rPaM, SotStorage& rStorage, const String* pFileName ) +AttributeOutputBase& WW8Export::AttrOutput() const { - // this method was added to let the windows compiler be happy, otherwise it shows warning - return StgWriter::Write( rPaM, rStorage, pFileName ); + return *m_pAttrOutput; } -ULONG SwWW8Writer::Write( SwPaM& rPaM, SvStream& rStream, const String* pFileName ) +MSWordSections& WW8Export::Sections() const { - // this method was added to let the solaris compiler be happy, otherwise it shows warning - return StgWriter::Write( rPaM, rStream, pFileName ); + return *pSepx; } SwWW8Writer::SwWW8Writer(const String& rFltName, const String& rBaseURL) - : aMainStg(sMainStream), pISet(0), pUsedNumTbl(0), mpTopNodeOfHdFtPage(0), - pBmpPal(0), pKeyMap(0), pOLEExp(0), pOCXExp(0), pOleMap(0), - mpTableInfo(new ww8::WW8TableInfo()), nUniqueList(0), - mnHdFtIndex(0), mpMedium(0), pAktPageDesc(0), pPapPlc(0), pChpPlc(0), pChpIter(0), pO(0), - bHasHdr(false), bHasFtr(false) + : StgWriter(), + m_bWrtWW8( rFltName.EqualsAscii( FILTER_WW8 ) ), + m_pExport( NULL ), + mpMedium( 0 ) { SetBaseURL( rBaseURL ); - bWrtWW8 = rFltName.EqualsAscii(FILTER_WW8); } SwWW8Writer::~SwWW8Writer() { - delete pBmpPal; - if (pKeyMap) - delete[] (NfKeywordTable*)pKeyMap; - delete pOLEExp; - delete pOCXExp; - delete pOleMap; } extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL ExportDOC( const String& rFltName, const String& rBaseURL, WriterRef& xRet ) @@ -3237,7 +3317,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL ExportDOC( const String& rFltName, xRet = new SwWW8Writer( rFltName, rBaseURL ); } -bool WW8_WrPlcFtnEdn::WriteTxt( SwWW8Writer& rWrt ) +bool WW8_WrPlcFtnEdn::WriteTxt( WW8Export& rWrt ) { bool bRet = false; if (TXT_FTN == nTyp) @@ -3256,7 +3336,7 @@ bool WW8_WrPlcFtnEdn::WriteTxt( SwWW8Writer& rWrt ) return bRet; } -void WW8_WrPlcFtnEdn::WritePlc( SwWW8Writer& rWrt ) const +void WW8_WrPlcFtnEdn::WritePlc( WW8Export& rWrt ) const { if( TXT_FTN == nTyp ) { @@ -3273,7 +3353,7 @@ void WW8_WrPlcFtnEdn::WritePlc( SwWW8Writer& rWrt ) const } -bool WW8_WrPlcPostIt::WriteTxt(SwWW8Writer& rWrt) +bool WW8_WrPlcPostIt::WriteTxt( WW8Export& rWrt ) { bool bRet = WriteGenericTxt( rWrt, TXT_ATN, rWrt.pFib->ccpAtn ); rWrt.pFldAtn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ), @@ -3282,14 +3362,14 @@ bool WW8_WrPlcPostIt::WriteTxt(SwWW8Writer& rWrt) return bRet; } -void WW8_WrPlcPostIt::WritePlc( SwWW8Writer& rWrt ) const +void WW8_WrPlcPostIt::WritePlc( WW8Export& rWrt ) const { WriteGenericPlc( rWrt, TXT_ATN, rWrt.pFib->fcPlcfandTxt, rWrt.pFib->lcbPlcfandTxt, rWrt.pFib->fcPlcfandRef, rWrt.pFib->lcbPlcfandRef ); } -void WW8_WrPlcTxtBoxes::WritePlc( SwWW8Writer& rWrt ) const +void WW8_WrPlcTxtBoxes::WritePlc( WW8Export& rWrt ) const { if( TXT_TXTBOX == nTyp ) { @@ -3305,7 +3385,7 @@ void WW8_WrPlcTxtBoxes::WritePlc( SwWW8Writer& rWrt ) const } } -void SwWW8Writer::RestoreMacroCmds() +void WW8Export::RestoreMacroCmds() { pFib->fcCmds = pTableStrm->Tell(); @@ -3339,23 +3419,25 @@ void SwWW8Writer::RestoreMacroCmds() pFib->lcbCmds = pTableStrm->Tell() - pFib->fcCmds; } -void WW8SHDLong::Write(SwWW8Writer & rWriter) +void WW8SHDLong::Write( WW8Export& rExport ) { - rWriter.InsUInt32(m_cvFore); - rWriter.InsUInt32(m_cvBack); - rWriter.InsUInt16(m_ipat); + rExport.InsUInt32( m_cvFore ); + rExport.InsUInt32( m_cvBack ); + rExport.InsUInt16( m_ipat ); } -void SwWW8Writer::WriteFormData(const ::sw::mark::IFieldmark& rFieldmark) +void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) { - ASSERT(bWrtWW8, "No 95 export yet"); - if (!bWrtWW8) return; + ASSERT( bWrtWW8, "No 95 export yet" ); + if ( !bWrtWW8 ) + return; const ::sw::mark::IFieldmark* pFieldmark = &rFieldmark; - const ::sw::mark::ICheckboxFieldmark* pAsCheckbox = dynamic_cast< const ::sw::mark::ICheckboxFieldmark* >(pFieldmark); + const ::sw::mark::ICheckboxFieldmark* pAsCheckbox = dynamic_cast< const ::sw::mark::ICheckboxFieldmark* >( pFieldmark ); - int type=0; // TextFieldmark - if(pAsCheckbox) type=1; + int type = 0; // TextFieldmark + if ( pAsCheckbox ) + type = 1; const ::rtl::OUString ffname = rFieldmark.GetFieldname(); @@ -3374,7 +3456,7 @@ void SwWW8Writer::WriteFormData(const ::sw::mark::IFieldmark& rFieldmark) BYTE* pDataAdr = aArr1 + 2; Set_UInt32(pDataAdr, nDataStt); - pChpPlc->AppendFkpEntry(Strm().Tell(), sizeof(aArr1), aArr1); + pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aArr1 ), aArr1 ); sal_uInt8 aFldHeader[] = { @@ -3383,10 +3465,10 @@ void SwWW8Writer::WriteFormData(const ::sw::mark::IFieldmark& rFieldmark) }; aFldHeader[4] |= (type & 0x03); - int ffres=0; // rFieldmark.GetFFRes(); - if(pAsCheckbox && pAsCheckbox->IsChecked()) - ffres=1; - aFldHeader[4] |= ((ffres<<2) & 0x7C); + int ffres = 0; // rFieldmark.GetFFRes(); + if ( pAsCheckbox && pAsCheckbox->IsChecked() ) + ffres = 1; + aFldHeader[4] |= ( (ffres<<2) & 0x7C ); const ::rtl::OUString ffdeftext; const ::rtl::OUString ffformat; @@ -3405,42 +3487,39 @@ void SwWW8Writer::WriteFormData(const ::sw::mark::IFieldmark& rFieldmark) 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // | /16 0,0,0,0, // / /4 }; - int slen=sizeof(aFldData) - +sizeof(aFldHeader) - +2*ffname.getLength()+4 - +2*ffdeftext.getLength()+4 - +2*ffformat.getLength()+4 - +2*ffhelptext.getLength()+4 - +2*ffstattext.getLength()+4 - +2*ffentrymcr.getLength()+4 - +2*ffexitmcr.getLength()+4; + int slen = sizeof( aFldData ) + + sizeof( aFldHeader ) + + 2*ffname.getLength() + 4 + + 2*ffdeftext.getLength() + 4 + + 2*ffformat.getLength() + 4 + + 2*ffhelptext.getLength() + 4 + + 2*ffstattext.getLength() + 4 + + 2*ffentrymcr.getLength() + 4 + + 2*ffexitmcr.getLength() + 4; #ifdef OSL_BIGENDIAN - slen=SWAPLONG(slen); + slen = SWAPLONG( slen ); #endif // OSL_BIGENDIAN - *((sal_uInt32 *)aFldData)=slen; - int len=sizeof(aFldData); - OSL_ENSURE(len==0x44, - "SwWW8Writer::WriteFormData(..)" - " - wrong aFldData length"); - pDataStrm->Write(aFldData, len); - - len=sizeof(aFldHeader); - OSL_ENSURE(len==8, - "SwWW8Writer::WriteFormData(..)" - " - wrong aFldHeader length"); - pDataStrm->Write(aFldHeader, len); - - WriteString_xstz(*pDataStrm, ffname, true); // Form field name - - if (type==0) - WriteString_xstz(*pDataStrm, ffdeftext, true); + *( (sal_uInt32 *)aFldData ) = slen; + int len = sizeof( aFldData ); + OSL_ENSURE( len == 0x44, "SwWW8Writer::WriteFormData(..) - wrong aFldData length" ); + pDataStrm->Write( aFldData, len ); + + len = sizeof( aFldHeader ); + OSL_ENSURE( len == 8, "SwWW8Writer::WriteFormData(..) - wrong aFldHeader length" ); + pDataStrm->Write( aFldHeader, len ); + + SwWW8Writer::WriteString_xstz( *pDataStrm, ffname, true ); // Form field name + + if ( type == 0 ) + SwWW8Writer::WriteString_xstz( *pDataStrm, ffdeftext, true ); else - pDataStrm->WriteNumber((sal_uInt16)0); - WriteString_xstz(*pDataStrm, String(ffformat), true); - WriteString_xstz(*pDataStrm, String(ffhelptext), true); - WriteString_xstz(*pDataStrm, String(ffstattext), true); - WriteString_xstz(*pDataStrm, String(ffentrymcr), true); - WriteString_xstz(*pDataStrm, String(ffexitmcr), true); + pDataStrm->WriteNumber( (sal_uInt16)0 ); + + SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffformat ), true ); + SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffhelptext ), true ); + SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffstattext ), true ); + SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffentrymcr ), true ); + SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffexitmcr ), true ); // if (type==2) { // // 0xFF, 0xFF // // sal_uInt32 number of strings @@ -3448,30 +3527,30 @@ void SwWW8Writer::WriteFormData(const ::sw::mark::IFieldmark& rFieldmark) // } } -void SwWW8Writer::OutWW8_TableNodeInfoInner(ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner) +void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ) { SVBT16 nStyle; - ShortToSVBT16(nStyleBeforeFly, nStyle); + ShortToSVBT16( m_rWW8Export.nStyleBeforeFly, nStyle ); #ifdef DEBUG ::std::clog << "<OutWW8_TableNodeInfoInner>" << pNodeInfoInner->toString(); #endif - pO->Remove( 0, pO->Count() ); // leeren + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren if (pNodeInfoInner->isEndOfCell()) { #ifdef DEBUG ::std::clog << "<endOfCell/>" << ::std::endl; #endif - WriteCR(pNodeInfoInner); + m_rWW8Export.WriteCR(pNodeInfoInner); - pO->Insert( (BYTE*)&nStyle, 2, pO->Count() ); // Style # - OutWW8TableInfoCell(pNodeInfoInner); - pPapPlc->AppendFkpEntry( Strm().Tell(), pO->Count(), - pO->GetData() ); + m_rWW8Export.pO->Insert( (BYTE*)&nStyle, 2, m_rWW8Export.pO->Count() ); // Style # + TableInfoCell(pNodeInfoInner); + m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), + m_rWW8Export.pO->GetData() ); - pO->Remove( 0, pO->Count() ); // leeren + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren } if (pNodeInfoInner->isEndOfLine()) @@ -3479,28 +3558,27 @@ void SwWW8Writer::OutWW8_TableNodeInfoInner(ww8::WW8TableNodeInfoInner::Pointer_ #ifdef DEBUG ::std::clog << "<endOfLine/>" << ::std::endl; #endif - WriteRowEnd(pNodeInfoInner->getDepth()); + TableRowEnd(pNodeInfoInner->getDepth()); - pO->Insert( (BYTE*)&nStyle, 2, pO->Count() ); // Style # - OutWW8TableInfoRow(pNodeInfoInner); - pPapPlc->AppendFkpEntry( Strm().Tell(), pO->Count(), - pO->GetData() ); + m_rWW8Export.pO->Insert( (BYTE*)&nStyle, 2, m_rWW8Export.pO->Count() ); // Style # + TableInfoRow(pNodeInfoInner); + m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), + m_rWW8Export.pO->GetData() ); - pO->Remove( 0, pO->Count() ); // leeren + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // leeren } #ifdef DEBUG ::std::clog << "</OutWW8_TableNodeInfoInner>" << ::std::endl; #endif } -void SwWW8Writer::OutWW8_SwEndNode(SwNode * pNode) +void MSWordExportBase::OutputEndNode( const SwEndNode &rNode ) { #ifdef DEBUG - ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(pNode) << ::std::endl; + ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl; #endif - ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = - mpTableInfo->getTableNodeInfo(pNode); + ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = mpTableInfo->getTableNodeInfo( &rNode ); if (pNodeInfo) { @@ -3516,7 +3594,7 @@ void SwWW8Writer::OutWW8_SwEndNode(SwNode * pNode) while (aIt != aEnd) { ww8::WW8TableNodeInfoInner::Pointer_t pInner = aIt->second; - OutWW8_TableNodeInfoInner(pInner); + AttrOutput().TableNodeInfoInner(pInner); aIt++; } } @@ -3524,9 +3602,6 @@ void SwWW8Writer::OutWW8_SwEndNode(SwNode * pNode) #ifdef DEBUG ::std::clog << "</OutWW8_SwEndNode>" << ::std::endl; #endif - } - - /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index fa44b97e17..a96a2e5e17 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -39,24 +39,14 @@ #include <svtools/svstdarr.hxx> #endif -#ifndef __SGI_STL_MAP #include <map> -#endif -#ifndef __SGI_STL_VECTOR #include <vector> -#endif -#ifndef SHELLIO_HXX #include <shellio.hxx> -#endif -#ifndef WRT_FN_HXX #include <wrt_fn.hxx> -#endif #include <svx/msocximex.hxx> -#ifndef WW8STRUC_HXX #include "ww8struc.hxx" -#endif #include "ww8scan.hxx" #include "fields.hxx" #include "types.hxx" @@ -65,10 +55,14 @@ #include <expfld.hxx> // einige Forward Deklarationen +class SwAttrIter; +class AttributeOutputBase; +class DocxAttributeOutput; class BitmapPalette; class SwEscherEx; class DateTime; class Font; +class MSWordExportBase; class SdrObject; class SfxItemSet; class SvStream; @@ -103,9 +97,11 @@ class SwTxtFmtColl; class SwTxtNode; class SwWW8WrGrf; class SwWW8Writer; -class WW8WrtStyle; +class MSWordStyles; +class WW8AttributeOutput; class WW8Bytes; -class WW8_AttrIter; +class WW8Export; +class MSWordAttrIter; class WW8_WrFkp; class WW8_WrPlc0; class WW8_WrPlc1; @@ -114,7 +110,7 @@ class WW8_WrMagicTable; class WW8_WrPlcFtnEdn; class WW8_WrPlcPn; class WW8_WrPlcPostIt; -class WW8_WrPlcSepx; +class MSWordSections; class WW8_WrPlcTxtBoxes; class WW8_WrPct; // Verwaltung class WW8_WrPcPtrs; @@ -139,12 +135,12 @@ class SvxBrushItem; typedef BYTE FieldFlags; namespace nsFieldFlags // for InsertField- Method { - const FieldFlags WRITEFIELD_START = 0x01; - const FieldFlags WRITEFIELD_CMD_START = 0x02; - const FieldFlags WRITEFIELD_CMD_END = 0x04; - const FieldFlags WRITEFIELD_END = 0x10; - const FieldFlags WRITEFIELD_CLOSE = 0x20; - const FieldFlags WRITEFIELD_ALL = 0xFF; + const FieldFlags WRITEFIELD_START = 0x01; + const FieldFlags WRITEFIELD_CMD_START = 0x02; + const FieldFlags WRITEFIELD_CMD_END = 0x04; + const FieldFlags WRITEFIELD_END = 0x10; + const FieldFlags WRITEFIELD_CLOSE = 0x20; + const FieldFlags WRITEFIELD_ALL = 0xFF; } enum TxtTypes //enums for TextTypes @@ -153,9 +149,6 @@ enum TxtTypes //enums for TextTypes TXT_EDN = 4, TXT_ATN = 5, TXT_TXTBOX = 6, TXT_HFTXTBOX= 7 }; -extern SwNodeFnTab aWW8NodeFnTab; -extern SwAttrFnTab aWW8AttrFnTab; - SV_DECL_VARARR( WW8Bytes, BYTE, 128, 128 ) struct WW8_SepInfo @@ -173,45 +166,78 @@ struct WW8_SepInfo {} WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFmt* pFmt, - ULONG nLnRestart ) - : pPageDesc(pPD), pSectionFmt(pFmt), pPDNd(0), pNumNd(0), - nLnNumRestartNo(nLnRestart), nPgRestartNo(0) + ULONG nLnRestart, USHORT nPgRestart = 0, const SwNode* pNd = NULL ) + : pPageDesc( pPD ), pSectionFmt( pFmt ), pPDNd( pNd ), pNumNd( 0 ), + nLnNumRestartNo( nLnRestart ), nPgRestartNo( nPgRestart ) {} + bool IsProtected() const; }; -SV_DECL_VARARR( WW8_WrSepInfoPtrs, WW8_SepInfo, 4, 4 ) +SV_DECL_VARARR( WW8_WrSepInfoPtrs, WW8_SepInfo, 4, 4 ) -class WW8_WrPlcSepx // Plc fuer PageDescs -> Sepx ( Section Extensions ) +/// Class to collect and output the sections/headers/footers. +// Plc fuer PageDescs -> Sepx ( Section Extensions ) +class MSWordSections { -private: +protected: bool mbDocumentIsProtected; WW8_WrSepInfoPtrs aSects; // PTRARR von SwPageDesc und SwSectionFmt - SvULongs aCps; // PTRARR von CPs - WW8_PdAttrDesc* pAttrs; - WW8_WrPlc0* pTxtPos; // Pos der einzelnen Header / Footer - void CheckForFacinPg( SwWW8Writer& rWrt ) const; - void WriteOlst( SwWW8Writer& rWrt, USHORT i ); - void WriteFtnEndTxt( SwWW8Writer& rWrt, ULONG nCpStt ); - void OutHeader( SwWW8Writer& rWrt, const SwFmt& rFmt, - ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag ); - void OutFooter( SwWW8Writer& rWrt, const SwFmt& rFmt, - ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag ); + void CheckForFacinPg( WW8Export& rWrt ) const; + void WriteOlst( WW8Export& rWrt, const WW8_SepInfo& rSectionInfo ); + void NeedsDocumentProtected(const WW8_SepInfo &rInfo); + + //No copy, no assign + MSWordSections( const MSWordSections& ); + MSWordSections& operator=( const MSWordSections& ); +public: + MSWordSections( MSWordExportBase& rExport ); + ~MSWordSections(); + + void AppendSep( const SwPageDesc* pPd, + const SwSectionFmt* pSectionFmt = 0, + ULONG nLnNumRestartNo = 0 ); + void AppendSep( const SwFmtPageDesc& rPd, + const SwNode& rNd, + const SwSectionFmt* pSectionFmt, + ULONG nLnNumRestartNo ); + void SetNum( const SwTxtNode* pNumNd ); + + /// Number of columns based on the most recent WW8_SepInfo. + sal_uInt16 CurrentNumberOfColumns( const SwDoc &rDoc ) const; + + /// Number of columns of the provided WW8_SepInfo. + sal_uInt16 NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo ) const; + + bool DocumentIsProtected() const { return mbDocumentIsProtected; } + + /// The most recent WW8_SepInfo. + const WW8_SepInfo* CurrentSectionInfo(); + static void SetHeaderFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt, BYTE nFlag ); static void SetFooterFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt, BYTE nFlag ); + + /// Should we output borders? static int HasBorderItem( const SwFmt& rFmt ); +}; - void NeedsDocumentProtected(const WW8_SepInfo &rInfo); +class WW8_WrPlcSepx : public MSWordSections +{ + SvULongs aCps; // PTRARR von CPs + WW8_PdAttrDesc* pAttrs; + WW8_WrPlc0* pTxtPos; // Pos der einzelnen Header / Footer + + // No copy, no assign + WW8_WrPlcSepx( const WW8_WrPlcSepx& ); + WW8_WrPlcSepx& operator=( const WW8_WrPlcSepx& ); - //No copy, no assign - WW8_WrPlcSepx(const WW8_WrPlcSepx&); - WW8_WrPlcSepx& operator=(const WW8_WrPlcSepx&); public: - WW8_WrPlcSepx(); + WW8_WrPlcSepx( MSWordExportBase& rExport ); ~WW8_WrPlcSepx(); + void AppendSep( WW8_CP nStartCp, const SwPageDesc* pPd, const SwSectionFmt* pSectionFmt = 0, @@ -221,13 +247,17 @@ public: const SwSectionFmt* pSectionFmt, ULONG nLnNumRestartNo ); void Finish( WW8_CP nEndCp ) { aCps.Insert( nEndCp, aCps.Count() ); } - void SetNum( const SwTxtNode* pNumNd ); - bool WriteKFTxt( SwWW8Writer& rWrt ); + + bool WriteKFTxt( WW8Export& rWrt ); void WriteSepx( SvStream& rStrm ) const; - void WritePlcSed( SwWW8Writer& rWrt ) const; - void WritePlcHdd( SwWW8Writer& rWrt ) const; - sal_uInt16 CurrentNoColumns(const SwDoc &rDoc) const; - bool DocumentIsProtected() const { return mbDocumentIsProtected; } + void WritePlcSed( WW8Export& rWrt ) const; + void WritePlcHdd( WW8Export& rWrt ) const; + +private: + void WriteFtnEndTxt( WW8Export& rWrt, ULONG nCpStt ); +public: + void OutHeaderFooter(WW8Export& rWrt, bool bHeader, + const SwFmt& rFmt, ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag, BYTE nBreakCode); }; //-------------------------------------------------------------------------- @@ -242,12 +272,13 @@ public: WW8_WrPct(WW8_FC nStartFc, bool bSaveUniCode); ~WW8_WrPct(); void AppendPc(WW8_FC nStartFc, bool bIsUnicode); - void WritePc(SwWW8Writer& rWrt); + void WritePc( WW8Export& rWrt ); void SetParaBreak(); bool IsUnicode() const { return bIsUni; } WW8_CP Fc2Cp( ULONG nFc ) const; }; +/// Collects and outputs fonts. class wwFont { //In some future land the stream could be converted to a nice stream interface @@ -258,29 +289,41 @@ private: String msAltNm; bool mbAlt; bool mbWrtWW8; + FontPitch mePitch; + FontFamily meFamily; + rtl_TextEncoding meChrSet; public: - wwFont(const String &rFamilyName, FontPitch ePitch, FontFamily eFamily, - rtl_TextEncoding eChrSet, bool bWrtWW8); - bool Write(SvStream *pTableStram) const; + wwFont( const String &rFamilyName, FontPitch ePitch, FontFamily eFamily, + rtl_TextEncoding eChrSet, bool bWrtWW8 ); + bool Write( SvStream *pTableStram ) const; +#ifdef DOCX + void WriteDocx( const DocxAttributeOutput* rAttrOutput ) const; +#endif + rtl::OUString GetFamilyName() const { return rtl::OUString( msFamilyNm ); } friend bool operator < (const wwFont &r1, const wwFont &r2); }; class wwFontHelper { private: - /* - * Keep track of fonts that need to be exported. - */ + /// Keep track of fonts that need to be exported. ::std::map<wwFont, USHORT> maFonts; bool mbWrtWW8; + + /// Convert from fast insertion map to linear vector in the order that we want to write. + ::std::vector< const wwFont* > AsVector() const; + public: wwFontHelper() : mbWrtWW8(false) {} - //rDoc used only to get the initial standard font(s) in use. + /// rDoc used only to get the initial standard font(s) in use. void InitFontTable(bool bWrtWW8, const SwDoc& rDoc); USHORT GetId(const Font& rFont); USHORT GetId(const SvxFontItem& rFont); USHORT GetId(const wwFont& rFont); - void WriteFontTable(SvStream *pTableStream, WW8Fib& pFib ); + void WriteFontTable( SvStream *pTableStream, WW8Fib& pFib ); +#ifdef DOCX + void WriteFontTable( const DocxAttributeOutput& rAttrOutput ); +#endif }; class DrawObj @@ -320,9 +363,9 @@ protected: virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const = 0; public: PlcDrawObj() {} - void WritePlc(SwWW8Writer& rWrt) const; - bool Append(SwWW8Writer&, WW8_CP nCp, const sw::Frame& rFmt, - const Point& rNdTopLeft); + void WritePlc( WW8Export& rWrt ) const; + bool Append( WW8Export&, WW8_CP nCp, const sw::Frame& rFmt, + const Point& rNdTopLeft ); int size() { return maDrawObjs.size(); }; DrawObjVector &GetObjArr() { return maDrawObjs; } virtual ~PlcDrawObj(); @@ -370,13 +413,42 @@ class WW8_WrtRedlineAuthor : public sw::util::WrtRedlineAuthor virtual void Write(Writer &rWrt); }; -// der WW8-Writer -class SwWW8Writer: public StgWriter +/** Structure that is used to save some of the WW8Export/DocxExport data. + + It is used to be able to recurse inside of the WW8Export/DocxExport (eg. + for the needs of the tables) - you need to tall WriteText() from there with + new values of PaM etc. + + It must contain all the stuff that might be saved either in WW8Export or in + DocxExport, because it makes no sense to do it abstract, and specialize it + for each of the cases. If you implement other *Export, just add the needed + members here, and store them in the appropriate SaveData() method. + */ +struct MSWordSaveData { -friend bool WW8_WrPlcSepx::WriteKFTxt( SwWW8Writer& rWrt ); // pO -friend class WW8_WrPlcSepx; -friend Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ); + Point* pOldFlyOffset; + RndStdIds eOldAnchorType; + WW8Bytes* pOOld; ///< WW8Export only + WW8Bytes* mpTableAtOld; ///< WW8Export only: Additional buffer for the output of the tables + sal_uInt16 mnTableStdAtLenOld; ///< WW8Export only: Standard length of mpTableAt + SwPaM* pOldPam, *pOldEnd; + const sw::Frame* pOldFlyFmt; + const SwPageDesc* pOldPageDesc; + BYTE bOldWriteAll : 1; ///< WW8Export only + BYTE bOldOutTable : 1; + BYTE bOldIsInTable: 1; + BYTE bOldFlyFrmAttrs : 1; + BYTE bOldStartTOX : 1; + BYTE bOldInWriteTOX : 1; + // bOutPageDesc muss nicht gesichert werden, da es nur nicht waehrend der + // Ausgabe von Spezial-Texten veraendert wird. +}; + +/// Base class for WW8Export and DocxExport +class MSWordExportBase +{ +public: wwFontHelper maFontHelper; std::vector<ULONG> maChapterFieldLocs; typedef std::vector<ULONG>::const_iterator mycCFIter; @@ -385,9 +457,9 @@ friend Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ); const SfxItemSet* pISet; // fuer Doppel-Attribute WW8_WrPct* pPiece; // Pointer auf Piece-Table SwNumRuleTbl* pUsedNumTbl; // alle used NumRules - const SwTxtNode *mpTopNodeOfHdFtPage; //top node of host page when in hd/ft - std::map<USHORT, USHORT> aRuleDuplicates; //map to Duplicated numrules - std::stack<xub_StrLen> maCurrentCharPropStarts; + const SwTxtNode *mpTopNodeOfHdFtPage; ///< Top node of host page when in hd/ft + std::map< USHORT, USHORT > aRuleDuplicates; //map to Duplicated numrules + std::stack< xub_StrLen > m_aCurrentCharPropStarts; ///< To remember the position in a run. WW8_WrtBookmarks* pBkmks; WW8_WrtRedlineAuthor* pRedlAuthors; BitmapPalette* pBmpPal; @@ -399,68 +471,23 @@ friend Writer& OutWW8_SwTxtNode( Writer& rWrt, SwCntntNode& rNode ); USHORT nCharFmtStart; USHORT nFmtCollStart; - USHORT nStyleBeforeFly; // Style-Nummer des Nodes, - // in/an dem ein Fly verankert ist - USHORT nLastFmtId; // Style of last TxtNode in normal range - USHORT nUniqueList; // current number for creating unique list names + USHORT nStyleBeforeFly; ///< Style-Nummer des Nodes, + ///< in/an dem ein Fly verankert ist + USHORT nLastFmtId; ///< Style of last TxtNode in normal range + USHORT nUniqueList; ///< current number for creating unique list names unsigned int mnHdFtIndex; - SfxMedium* mpMedium; - - virtual ULONG WriteStorage(); - virtual ULONG WriteMedium( SfxMedium& ); - - void PrepareStorage(); - void WriteFkpPlcUsw(); - void WriteMainText(); - void StoreDoc1(); - ULONG StoreDoc(); - void Out_Olst( const SwNumRule& rRule ); - void Out_WwNumLvl( BYTE nWwLevel ); - void Out_SwNumLvl( BYTE nSwLevel ); - void Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt, - BYTE nSwLevel ); - void BuildAnlvBulletBase( WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen, - const SwNumFmt& rFmt ); - void SubstituteBullet(String& rNumStr, rtl_TextEncoding& rChrSet, - String& rFontName) const; - - static void BuildAnlvBase( WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen, - const SwNumRule& rRul, const SwNumFmt& rFmt, BYTE nSwLevel ); + USHORT mnRedlineMode; ///< Remember the original redline mode - void Out_BorderLine(WW8Bytes& rO, const SvxBorderLine* pLine, - USHORT nDist, USHORT nSprmNo, bool bShadow); - - void OutListTab(); - void OutOverrideListTab(); - void OutListNamesTab(); - - void RestoreMacroCmds(); - - void InitFontTable(); - - bool MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt); - void DoComboBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet); - void DoCheckBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet); - void GatherChapterFields(); - bool FmtHdFtContainsChapterField(const SwFrmFmt &rFmt) const; - bool CntntContainsChapterField(const SwFmtCntnt &rCntnt) const; - void OutWW8_SwEndNode( SwNode * pNode ); public: - /* implicit bookmark vector containing pairs of node indexes and bookmark names */ SwImplBookmarks maImplicitBookmarks; sw::Frames maFrames; // The floating frames in this document const SwPageDesc *pAktPageDesc; - WW8Fib* pFib; - WW8Dop* pDop; WW8_WrPlcPn* pPapPlc; WW8_WrPlcPn* pChpPlc; - WW8_AttrIter* pChpIter; - WW8WrtStyle* pStyles; - WW8_WrPlcSepx* pSepx; - WW8_WrPlcFtnEdn* pFtn; - WW8_WrPlcFtnEdn* pEdn; + MSWordAttrIter* pChpIter; + MSWordStyles* pStyles; WW8_WrPlcPostIt* pAtn; WW8_WrPlcTxtBoxes *pTxtBxs, *pHFTxtBxs; @@ -490,10 +517,6 @@ public: MainTxtPlcDrawObj *pSdrObjs; // Draw-/Fly-Objects HdFtPlcDrawObj *pHFSdrObjs; // Draw-/Fly-Objects in header or footer - WW8Bytes* pO; - - SvStream *pTableStrm, *pDataStrm; // Streams fuer WW97 Export - SwEscherEx* pEscher; // escher export class // --> OD 2007-04-19 #i43447# - removed // SwTwips nFlyWidth, nFlyHeight; // Fuer Anpassung Graphic @@ -505,14 +528,13 @@ public: BYTE bBreakBefore : 1; // Breaks werden 2mal ausgegeben BYTE bOutKF : 1; // Kopf/Fusstexte werden ausgegeben BYTE bOutFlyFrmAttrs : 1; // Rahmen-Attr von Flys werden ausgegeben - BYTE bOutPageDescs : 1; // PageDescs werden ausgegeben ( am Doc-Ende ) + BYTE bOutPageDescs : 1; ///< PageDescs (section properties) are being written BYTE bOutFirstPage : 1; // write Attrset of FirstPageDesc BYTE bOutTable : 1; // Tabelle wird ausgegeben // ( wird zB bei Flys in Tabelle zurueckgesetzt ) BYTE bIsInTable : 1; // wird sind innerhalb der Ausgabe einer Tabelle // ( wird erst nach der Tabelle zurueckgesetzt ) BYTE bOutGrf : 1; // Grafik wird ausgegeben - BYTE bWrtWW8 : 1; // Schreibe WW95 oder WW97 FileFormat BYTE bInWriteEscher : 1; // in write textboxes BYTE bStartTOX : 1; // true: a TOX is startet BYTE bInWriteTOX : 1; // true: all content are in a TOX @@ -521,91 +543,455 @@ public: BYTE bHasHdr : 1; BYTE bHasFtr : 1; + SwDoc *pDoc; + SwPaM *pCurPam, *pOrigPam; + + /// Stack to remember the nesting (see MSWordSaveData for more) + ::std::stack< MSWordSaveData > maSaveData; + +public: + /// The main function to export the document. + void ExportDocument( bool bWriteAll ); + + /// Iterate through the nodes and call the appropriate OutputNode() on them. + void WriteText(); + + /// Set the pCurPam appropriately and call WriteText(). + /// + /// Used to export paragraphs in footnotes/endnotes/etc. + void WriteSpecialText( ULONG nStart, ULONG nEnd, BYTE nTTyp ); + + /// Export the pool items to attributes (through an attribute output class). + void ExportPoolItemsToCHP( sw::PoolItems &rItems, USHORT nScript ); + + /// Return the numeric id of the numbering rule + USHORT GetId( const SwNumRule& rNumRule ); + + /// Return the numeric id of the style. + USHORT GetId( const SwTxtFmtColl& rColl ) const; + + /// Return the numeric id of the style. + USHORT GetId( const SwCharFmt& rFmt ) const; + + USHORT GetId( const SwTOXType& rTOXType ); + + const SfxPoolItem& GetItem( USHORT nWhich ) const; + + /// Find the reference. + bool HasRefToObject( USHORT nTyp, const String* pName, USHORT nSeqNo ); + + /// Find the bookmark name. + String GetBookmarkName( USHORT nTyp, const String* pName, USHORT nSeqNo ); + + /// Add a bookmark converted to a Word name. + void AppendWordBookmark( const String& rName ); + + /// Use OutputItem() on an item set according to the parameters. + void OutputItemSet( const SfxItemSet& rSet, bool bPapFmt, bool bChpFmt, USHORT nScript ); + + short GetDefaultFrameDirection( ) const; + + /// Right to left? + short TrueFrameDirection( const SwFrmFmt& rFlyFmt ) const; + + /// Right to left? + short GetCurrentPageDirection() const; + + /// In case of numbering restart. + + /// List is set to restart at a particular value so for export make a + /// completely new list based on this one and export that instead, + /// which duplicates words behaviour in this respect. + USHORT DuplicateNumRule( const SwNumRule *pRule, BYTE nLevel, USHORT nVal ); + + /// Access to the attribute output class. + virtual AttributeOutputBase& AttrOutput() const = 0; + + /// Access to the sections/headers/footres. + virtual MSWordSections& Sections() const = 0; + + /// Hack, unfortunately necessary at some places for now. + /// FIXME remove it when possible. + virtual bool HackIsWW8OrHigher() const = 0; + + /// Guess the script (asian/western). + /// + /// Sadly word does not have two different sizes for asian font size and + /// western font size, it has two different fonts, but not sizes, so we + /// have to use our guess as to the script used and disable the export of + /// one type. The same occurs for font weight and posture (bold and + /// italic). + /// + /// In addition WW7- has only one character language identifier while WW8+ + /// has two + virtual bool CollapseScriptsforWordOk( USHORT nScript, USHORT nWhich ) = 0; + + virtual void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen ) = 0; + + virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false ) = 0; + + // FIXME probably a hack... + virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ) = 0; + + // FIXME definitely a hack, must not be here - it can't do anything + // sensible for docx + virtual void WriteChar( sal_Unicode c ) = 0; + + /// Output attributes. + void OutputFormat( const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, bool bFlyFmt = false ); + + /// Getter for pISet. + const SfxItemSet* GetCurItemSet() const { return pISet; } + + /// Setter for pISet. + void SetCurItemSet( const SfxItemSet* pS ) { pISet = pS; } + + /// Remember some of the memebers so that we can recurse in WriteText(). + virtual void SaveData( ULONG nStt, ULONG nEnd ); + + /// Restore what was saved in SaveData(). + virtual void RestoreData(); + + /// The return value indicates, if a follow page desc is written. + bool OutputFollowPageDesc( const SfxItemSet* pSet, + const SwTxtNode* pNd ); + + /// Write header/footer text. + void WriteHeaderFooterText( const SwFmt& rFmt, bool bHeader); + + /// Format of the section. + const SwSectionFmt* GetSectionFormat( const SwNode& rNd ) const; + + /// Line number of the section start. + ULONG GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd ) const; + + /// Start new section. + void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd ); + /// Write section properties. + /// + /// pA is ignored for docx. + void SectionProperties( const WW8_SepInfo& rSectionInfo, WW8_PdAttrDesc* pA = NULL ); + + /// Output the numbering table. + virtual void WriteNumbering() = 0; + + /// Write static data of SwNumRule - LSTF + void NumberingDefinitions(); + + /// Write all Levels for all SwNumRules - LVLF + void AbstractNumberingDefinitions(); + + // Convert the bullet according to the font. + void SubstituteBullet( String& rNumStr, rtl_TextEncoding& rChrSet, + String& rFontName ) const; + + /// No-op for the newer WW versions. + virtual void OutputOlst( const SwNumRule& /*rRule*/ ) {} + + /// Setup the pA's info. + virtual void SetupSectionPositions( WW8_PdAttrDesc* /*pA*/ ) {} + + /// Top node of host page when in header/footer. + void SetHdFtPageRoot( const SwTxtNode *pNd ) { mpTopNodeOfHdFtPage = pNd; } + + /// Top node of host page when in header/footer. + const SwTxtNode *GetHdFtPageRoot() const { return mpTopNodeOfHdFtPage; } + + /// Output the actual headers and footers. + virtual void WriteHeadersFooters( BYTE nHeadFootFlags, + const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, + BYTE nBreakCode) = 0; + + /// Write the field + virtual void OutputField( const SwField* pFld, ww::eField eFldType, + const String& rFldCmd, BYTE nMode = nsFieldFlags::WRITEFIELD_ALL ) = 0; + + /// Write the data of the form field + virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) = 0; + + virtual void DoComboBox(const rtl::OUString &rName, + const rtl::OUString &rHelp, + const rtl::OUString &ToolTip, + const rtl::OUString &rSelected, + com::sun::star::uno::Sequence<rtl::OUString> &rListItems) = 0; + + virtual void DoFormText(const SwInputField * pFld) = 0; + + static bool NoPageBreakSection( const SfxItemSet *pSet ); + + // Compute the number format for WW dates + bool GetNumberFmt(const SwField& rFld, String& rStr); + + virtual ULONG ReplaceCr( BYTE nChar ) = 0; + + const SfxPoolItem* HasItem( USHORT nWhich ) const; + + +protected: + /// Format-dependant part of the actual export. + virtual void ExportDocument_Impl() = 0; + + /// Get the next position in the text node to output + virtual xub_StrLen GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos ); + + /// Update the information for GetNextPos(). + virtual void UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd ); + + /// Output SwTxtNode + void OutputTextNode( const SwTxtNode& ); + + /// Output SwTableNode + void OutputTableNode( const SwTableNode& ); + + /// Setup the chapter fields (maChapterFieldLocs). + void GatherChapterFields(); + + void AddLinkTarget( const String& rURL ); + void CollectOutlineBookmarks( const SwDoc &rDoc ); + + bool SetAktPageDescFromNode(const SwNode &rNd); + bool CntntContainsChapterField(const SwFmtCntnt &rCntnt) const; + bool FmtHdFtContainsChapterField(const SwFrmFmt &rFmt) const; + + virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ) = 0; + + virtual void PrepareNewPageDesc( const SfxItemSet* pSet, + const SwNode& rNd, + const SwFmtPageDesc* pNewPgDescFmt = 0, + const SwPageDesc* pNewPgDesc = 0 ) = 0; + + /// Return value indicates if an inherited outline numbering is suppressed. + virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt) = 0; + +protected: + /// Output SwEndNode + virtual void OutputEndNode( const SwEndNode& ); + + /// Output SwGrfNode + virtual void OutputGrfNode( const SwGrfNode& ) = 0; + + /// Output SwOLENode + virtual void OutputOLENode( const SwOLENode& ) = 0; + + /// Output SwSectionNode + virtual void OutputSectionNode( const SwSectionNode& ); + + virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum ) = 0; + + /// Call the right (virtual) function according to the type of the item. + /// + /// One of OutputTextNode(), OutputGrfNode(), or OutputOLENode() + void OutputContentNode( const SwCntntNode& ); + +public: + MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam ); + virtual ~MSWordExportBase(); + + // TODO move as much as possible here from WW8Export! ;-) + + static void CorrectTabStopInSet( SfxItemSet& rSet, USHORT nAbsLeft ); + +private: + /// No copying. + MSWordExportBase( const MSWordExportBase& ); + /// No copying. + MSWordExportBase& operator=( const MSWordExportBase& ); +}; + +/// The writer class that gets called for the WW8 filter. +class SwWW8Writer: public StgWriter +{ +// friends to get access to m_pExport +// FIXME avoid that, this is probably not what we want +// (if yes, remove the friends, and provide here a GetExport() method) +friend void WW8_WrtRedlineAuthor::Write(Writer &rWrt); + + bool m_bWrtWW8; + WW8Export *m_pExport; + SfxMedium *mpMedium; + +public: + SwWW8Writer( const String& rFltName, const String& rBaseURL ); + virtual ~SwWW8Writer(); + + virtual ULONG WriteStorage(); + virtual ULONG WriteMedium( SfxMedium& ); + + // TODO most probably we want to be able to get these in + // MSExportFilterBase + using Writer::getIDocumentSettingAccess; + +public: +#if 1 + /// Prefer ww::bytes to WW8Bytes, migrate away from the other ones. + static void InsUInt16(ww::bytes &rO, sal_uInt16 n); + static void InsUInt32(ww::bytes &rO, sal_uInt32 n); + static void InsAsString16(ww::bytes &rO, const String& rStr); + static void InsAsString8(ww::bytes & O, const String& rStr, + rtl_TextEncoding eCodeSet); +#endif + + static void InsUInt16( WW8Bytes& rO, UINT16 ); + static void InsUInt32( WW8Bytes& rO, UINT32 ); + static void InsAsString16( WW8Bytes& rO, const String& ); + static void InsAsString8( WW8Bytes& rO, const String& rStr, + rtl_TextEncoding eCodeSet ); + + static ULONG FillUntil( SvStream& rStrm, ULONG nEndPos = 0 ); + static void FillCount( SvStream& rStrm, ULONG nCount ); + + static void WriteShort( SvStream& rStrm, INT16 nVal ) { rStrm << nVal; } + static void WriteShort( SvStream& rStrm, ULONG nPos, INT16 nVal ); + + static void WriteLong( SvStream& rStrm, INT32 nVal ) { rStrm << nVal; } + static void WriteLong( SvStream& rStrm, ULONG nPos, INT32 nVal ); + + static void WriteString16(SvStream& rStrm, const String& rStr, + bool bAddZero); + static void WriteString8(SvStream& rStrm, const String& rStr, + bool bAddZero, rtl_TextEncoding eCodeSet); + + static void WriteString_xstz(SvStream& rStrm, const String& rStr, bool bAddZero); + + String GetPassword(); + + using StgWriter::Write; virtual ULONG Write( SwPaM&, SfxMedium&, const String* = 0 ); - virtual ULONG Write( SwPaM&, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const String* = 0, SfxMedium* = 0 ); - virtual ULONG Write( SwPaM&, SotStorage&, const String* = 0 ); - virtual ULONG Write( SwPaM&, SvStream&, const String* = 0 ); +private: + /// No copying. + SwWW8Writer(const SwWW8Writer&); + /// No copying. + SwWW8Writer& operator=(const SwWW8Writer&); +}; + +/// Exporter of the binary Word file formats. +class WW8Export : public MSWordExportBase +{ +public: + WW8Bytes* pO; ///< Buffer + WW8Bytes* mpTableAt; ///< Additional buffer for the output of the tables + sal_uInt16 mnTableStdAtLen; ///< Standard length of mpTableAt + + SvStream *pTableStrm, *pDataStrm; ///< Streams for WW97 Export + + WW8Fib* pFib; ///< File Information Block + WW8Dop* pDop; ///< DOcument Properties + WW8_WrPlcFtnEdn *pFtn; ///< Footnotes - structure to remember them, and output + WW8_WrPlcFtnEdn *pEdn; ///< Endnotes - structure to remember them, and output + WW8_WrPlcSepx* pSepx; ///< Sections/headers/footers + + BYTE bWrtWW8 : 1; ///< Write WW95 (false) or WW97 (true) file format + +protected: + SwWW8Writer *m_pWriter; ///< Pointer to the writer + WW8AttributeOutput *m_pAttrOutput; ///< Converting attributes to stream data + +public: + /// Access to the attribute output class. + virtual AttributeOutputBase& AttrOutput() const; + + /// Access to the sections/headers/footres. + virtual MSWordSections& Sections() const; + + /// False for WW6, true for WW8. + virtual bool HackIsWW8OrHigher() const { return bWrtWW8; } + +private: + /// Format-dependant part of the actual export. + virtual void ExportDocument_Impl(); + + void PrepareStorage(); + void WriteFkpPlcUsw(); + void WriteMainText(); + void StoreDoc1(); + void Out_WwNumLvl( BYTE nWwLevel ); + void BuildAnlvBulletBase( WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen, + const SwNumFmt& rFmt ); + static void BuildAnlvBase( WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen, + const SwNumRule& rRul, const SwNumFmt& rFmt, BYTE nSwLevel ); + + void Out_BorderLine(WW8Bytes& rO, const SvxBorderLine* pLine, + USHORT nDist, sal_uInt16 nSprmNo, bool bShadow); + + /// Output the numbering table. + virtual void WriteNumbering(); + + void OutOverrideListTab(); + void OutListNamesTab(); + + void RestoreMacroCmds(); + + void InitFontTable(); + + void DoComboBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet); + void DoCheckBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet); + +public: + virtual void OutputOlst( const SwNumRule& rRule ); + + /// Setup the pA's info. + virtual void SetupSectionPositions( WW8_PdAttrDesc* pA ); + + void Out_SwNumLvl( BYTE nSwLevel ); + void Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt, + BYTE nSwLevel ); + + bool MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt); SvxMSExportOLEObjects& GetOLEExp() { return *pOLEExp; } SwMSConvertControls& GetOCXExp() { return *pOCXExp; } WW8OleMaps& GetOLEMap() { return *pOleMap; } void ExportDopTypography(WW8DopTypography &rTypo); - const SfxPoolItem* HasItem( USHORT nWhich ) const; - const SfxPoolItem& GetItem( USHORT nWhich ) const; - - USHORT GetId( const SwTxtFmtColl& rColl ) const; - USHORT GetId( const SwCharFmt& rFmt ) const; - USHORT GetId( const SwNumRule& rNumRule ) const; - USHORT GetId( const SwTOXType& rTOXType ); + using MSWordExportBase::GetId; USHORT GetId( const SvxFontItem& rFont) { return maFontHelper.GetId(rFont); } - void OutRedline( const SwRedlineData& rRedline ); USHORT AddRedlineAuthor( USHORT nId ); - void StartTOX( const SwSection& rSect ); - void EndTOX( const SwSection& rSect ); - - void WriteSpecialText( ULONG nStart, ULONG nEnd, BYTE nTTyp ); - void WriteKFTxt1( const SwFmtCntnt& rCntnt ); void WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pO = 0 ); void WritePostItBegin( WW8Bytes* pO = 0 ); - short TrueFrameDirection(const SwFrmFmt &rFlyFmt) const; - short GetCurrentPageDirection() const; const SvxBrushItem* GetCurrentPageBgBrush() const; SvxBrushItem TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const; - void OutWW8FlyFrmsInCntnt( const SwTxtNode& rNd ); - void OutWW8FlyFrm(const sw::Frame& rFmt, const Point& rNdTopLeft); - void OutFlyFrm(const sw::Frame& rFmt); + + /// Output all textframes anchored as character for the winword 7- format. + void OutWW6FlyFrmsInCntnt( const SwTxtNode& rNd ); + void AppendFlyInFlys(const sw::Frame& rFrmFmt, const Point& rNdTopLeft); void WriteOutliner(const OutlinerParaObject& rOutliner, BYTE nTyp); void WriteSdrTextObj(const SdrObject& rObj, BYTE nTyp); - void OutWW8TableInfoCell(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo); - void OutWW8TableInfoRow(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo); - void OutWW8TableDefinition(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo); - void OutWW8TableDefaultBorders(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo); - void OutWW8TableBackgrounds(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo); - void OutWW8TableHeight(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo); - void OutWW8TableCanSplit(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo); - void OutWW8TableBidi(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo); - void OutWW8TableVerticalCell(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo); - void OutWW8TableNodeInfo(ww8::WW8TableNodeInfo::Pointer_t pNodeInfo); - void OutWW8_TableNodeInfoInner(ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner); - void OutWW8TableOrientation(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner); UINT32 GetSdrOrdNum( const SwFrmFmt& rFmt ) const; void CreateEscher(); void WriteEscher(); bool Out_SwNum(const SwTxtNode* pNd); - void Out_SwFmt(const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, - bool bFlyFmt = false); - bool GetNumberFmt(const SwField& rFld, String& rStr); - void OutField(const SwField* pFld, ww::eField eFldType, - const String& rFldCmd, BYTE nMode = nsFieldFlags::WRITEFIELD_ALL); + + /// Write the field + virtual void OutputField( const SwField* pFld, ww::eField eFldType, + const String& rFldCmd, BYTE nMode = nsFieldFlags::WRITEFIELD_ALL ); + void StartCommentOutput( const String& rName ); void EndCommentOutput( const String& rName ); void OutGrf(const sw::Frame &rFrame); bool TestOleNeedsGraphic(const SwAttrSet& rSet, SvStorageRef xOleStg, SvStorageRef xObjStg, String &rStorageName, SwOLENode *pOLENd); - void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, - xub_StrLen nLen ); - void AppendBookmark( const String& rName, USHORT nOffset = 0 ); - String GetBookmarkName( USHORT nTyp, const String* pNm, USHORT nSeqNo ); + + virtual void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen ); + virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false ); void MoveFieldMarks(ULONG nFrom, ULONG nTo); - bool HasRefToObject(USHORT nTyp, const String* pNm, USHORT nSeqNo); void WriteAsStringTable(const ::std::vector<String>&, INT32& rfcSttbf, INT32& rlcbSttbf, USHORT nExtraLen = 0); - void WriteText(); - void WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()); + + virtual ULONG ReplaceCr( BYTE nChar ); + + virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ); void WriteChar( sal_Unicode c ); - void WriteRowEnd(sal_uInt32 nDepth = 1); #if 0 USHORT StartTableFromFrmFmt(WW8Bytes &rAt, const SwFrmFmt *pFmt, SwTwips &rPageSize); @@ -614,8 +1000,6 @@ public: void OutSwString(const String&, xub_StrLen nStt, xub_StrLen nLen, bool bUnicode, rtl_TextEncoding eChrSet); - ULONG ReplaceCr( BYTE nChar ); - WW8_CP Fc2Cp( ULONG nFc ) const { return pPiece->Fc2Cp( nFc ); } // einige z.T. static halb-interne Funktions-Deklarationen @@ -625,24 +1009,14 @@ public: inline bool IsUnicode() const { return pPiece->IsUnicode(); } - const SfxItemSet* GetCurItemSet() const { return pISet; } - void SetCurItemSet( const SfxItemSet* pS ) { pISet = pS; } + virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ); - void ExportPoolItemsToCHP(sw::PoolItems &rItems, USHORT nScript); - void Out_SfxItemSet(const SfxItemSet& rSet, bool bPapFmt, bool bChpFmt, - USHORT nScript); - void Out_SfxBreakItems(const SfxItemSet *pSet, const SwNode& rNd); - bool SetAktPageDescFromNode(const SwNode &rNd); - // --> OD 2007-05-29 #i76300# - // return value indicates, if a follow page desc is written. - bool Out_FollowPageDesc( const SfxItemSet* pSet, - const SwTxtNode* pNd ); - // helper method for <Out_SfxBreakItems(..)> and <Out_FollowPageDesc(..)> - void PrepareNewPageDesc( const SfxItemSet* pSet, - const SwNode& rNd, - const SwFmtPageDesc* pNewPgDescFmt = 0, - const SwPageDesc* pNewPgDesc = 0 ); - // <-- + /// Helper method for OutputSectionBreaks() and OutputFollowPageDesc(). + // OD 2007-05-29 #i76300# + virtual void PrepareNewPageDesc( const SfxItemSet* pSet, + const SwNode& rNd, + const SwFmtPageDesc* pNewPgDescFmt = 0, + const SwPageDesc* pNewPgDesc = 0 ); void Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow); void Out_SwFmtTableBox( WW8Bytes& rO, const SvxBoxItem& rBox ); @@ -651,56 +1025,31 @@ public: WW8_BRC TranslateBorderLine(const SvxBorderLine& pLine, USHORT nDist, bool bShadow); - void ExportOutlineNumbering(BYTE nLvl, const SwNumFmt &rNFmt, - const SwFmt &rFmt); // --> OD 2007-06-04 #i77805# // new return value indicates, if an inherited outline numbering is suppressed - bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt); + virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt); // <-- unsigned int GetHdFtIndex() const { return mnHdFtIndex; } void SetHdFtIndex(unsigned int nHdFtIndex) { mnHdFtIndex = nHdFtIndex; } + void IncrementHdFtIndex() { ++mnHdFtIndex; } static long GetDTTM( const DateTime& rDT ); + /// Convert the SVX numbering type to id static BYTE GetNumId( USHORT eNumType ); - static void CorrTabStopInSet( SfxItemSet& rSet, USHORT nAbsLeft ); - - static ULONG FillUntil( SvStream& rStrm, ULONG nEndPos = 0 ); - static void FillCount( SvStream& rStrm, ULONG nCount ); - static void WriteShort( SvStream& rStrm, INT16 nVal ) { rStrm << nVal; } - static void WriteShort( SvStream& rStrm, ULONG nPos, INT16 nVal ); + /// Guess the script (asian/western). + virtual bool CollapseScriptsforWordOk( USHORT nScript, USHORT nWhich ); - static void WriteLong( SvStream& rStrm, INT32 nVal ) { rStrm << nVal; } - static void WriteLong( SvStream& rStrm, ULONG nPos, INT32 nVal ); - - static void WriteString16(SvStream& rStrm, const String& rStr, - bool bAddZero); - static void WriteString8(SvStream& rStrm, const String& rStr, - bool bAddZero, rtl_TextEncoding eCodeSet); - - static void WriteString_xstz(SvStream& rStrm, const String& rStr, bool bAddZero); -#if 1 - //Prefer ww::bytes to WW8Bytes, migrate away from the other ones. - static void InsUInt16(ww::bytes &rO, sal_uInt16 n); - static void InsUInt32(ww::bytes &rO, sal_uInt32 n); - static void InsAsString16(ww::bytes &rO, const String& rStr); - static void InsAsString8(ww::bytes & O, const String& rStr, - rtl_TextEncoding eCodeSet); -#endif - - static void InsUInt16( WW8Bytes& rO, UINT16 ); - static void InsUInt32( WW8Bytes& rO, UINT32 ); - static void InsAsString16( WW8Bytes& rO, const String& ); - static void InsAsString8( WW8Bytes& rO, const String& rStr, - rtl_TextEncoding eCodeSet ); - bool CollapseScriptsforWordOk(USHORT nScript, USHORT nWhich); USHORT DupNumRuleWithLvlStart(const SwNumRule *pRule,BYTE nLvl,USHORT nVal); SwTwips CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const; + + /// Nasty swap for bidi if neccessary bool MiserableRTLFrmFmtHack(SwTwips &rLeft, SwTwips &rRight, const sw::Frame &rFrmFmt); + void InsUInt16( UINT16 n ) { SwWW8Writer::InsUInt16( *pO, n ); } void InsUInt32( UINT32 n ) { SwWW8Writer::InsUInt32( *pO, n ); } void InsAsString16( const String& rStr ) @@ -709,41 +1058,56 @@ public: { SwWW8Writer::InsAsString8( *pO, rStr, eCodeSet ); } void WriteStringAsPara( const String& rTxt, USHORT nStyleId = 0 ); - // nach aussen interessant - - SwWW8Writer( const String& rFltName, const String& rBaseURL ); - virtual ~SwWW8Writer(); + /// Setup the exporter. + WW8Export( SwWW8Writer *pWriter, + SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, + bool bIsWW8 ); + virtual ~WW8Export(); - // fuer WW8SaveData - SwPaM* GetEndPaM() { return pOrigPam; } - void SetEndPaM( SwPaM* pPam ) { pOrigPam = pPam; } - - void DoComboBox(const rtl::OUString &rName, + virtual void DoComboBox(const rtl::OUString &rName, const rtl::OUString &rHelp, const rtl::OUString &ToolTip, const rtl::OUString &rSelected, com::sun::star::uno::Sequence<rtl::OUString> &rListItems); - void DoFormText(const SwInputField * pFld); + virtual void DoFormText(const SwInputField * pFld); - static bool NoPageBreakSection(const SfxItemSet *pSet); - void push_charpropstart(xub_StrLen nPos); - void pop_charpropstart(); - xub_StrLen top_charpropstart() const; void GetCurrentItems(WW8Bytes &rItems) const; - void SetHdFtPageRoot(const SwTxtNode *pNd) { mpTopNodeOfHdFtPage = pNd; } - const SwTxtNode *GetHdFtPageRoot() const { return mpTopNodeOfHdFtPage; } - void AddLinkTarget(const String& rURL); - void CollectOutlineBookmarks(const SwDoc &rDoc); - void AddBookmark(String sBkmkName); + /// Write the data of the form field + virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ); - void WriteFormData(const ::sw::mark::IFieldmark& rFieldmark); + /// Fields. WW8_WrPlcFld* CurrentFieldPlc() const; + + SwWW8Writer& GetWriter() const { return *m_pWriter; } + SvStream& Strm() const { return m_pWriter->Strm(); } + + /// Remember some of the memebers so that we can recurse in WriteText(). + virtual void SaveData( ULONG nStt, ULONG nEnd ); + + /// Restore what was saved in SaveData(). + virtual void RestoreData(); + + /// Output the actual headers and footers. + virtual void WriteHeadersFooters( BYTE nHeadFootFlags, + const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, + BYTE nBreakCode); + +protected: + /// Output SwGrfNode + virtual void OutputGrfNode( const SwGrfNode& ); + + /// Output SwOLENode + virtual void OutputOLENode( const SwOLENode& ); + + virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum ); + private: - //No copying - SwWW8Writer(const SwWW8Writer&); - SwWW8Writer& operator=(const SwWW8Writer&); + /// No copying. + WW8Export(const WW8Export&); + /// No copying. + WW8Export& operator=(const WW8Export&); }; class WW8_WrPlcSubDoc // Doppel-Plc fuer Foot-/Endnotes und Postits @@ -760,8 +1124,8 @@ protected: WW8_WrPlcSubDoc(); virtual ~WW8_WrPlcSubDoc(); - bool WriteGenericTxt(SwWW8Writer& rWrt, BYTE nTTyp, WW8_CP& rCount); - void WriteGenericPlc( SwWW8Writer& rWrt, BYTE nTTyp, WW8_FC& rTxtStt, + bool WriteGenericTxt( WW8Export& rWrt, BYTE nTTyp, WW8_CP& rCount ); + void WriteGenericPlc( WW8Export& rWrt, BYTE nTTyp, WW8_FC& rTxtStt, sal_Int32& rTxtCnt, WW8_FC& rRefStt, sal_Int32& rRefCnt ) const; virtual const SvULongs* GetShapeIdArr() const; @@ -779,8 +1143,8 @@ private: public: WW8_WrPlcFtnEdn( BYTE nTTyp ) : nTyp( nTTyp ) {} - bool WriteTxt(SwWW8Writer& rWrt); - void WritePlc( SwWW8Writer& rWrt ) const; + bool WriteTxt( WW8Export& rWrt ); + void WritePlc( WW8Export& rWrt ) const; void Append( WW8_CP nCp, const SwFmtFtn& rFtn ); }; @@ -795,8 +1159,8 @@ public: WW8_WrPlcPostIt() {} void Append( WW8_CP nCp, const SwPostItField& rPostIt ); - bool WriteTxt(SwWW8Writer& rWrt); - void WritePlc( SwWW8Writer& rWrt ) const; + bool WriteTxt( WW8Export& rWrt ); + void WritePlc( WW8Export& rWrt ) const; }; class WW8_WrPlcTxtBoxes : public WW8_WrPlcSubDoc // Doppel-Plc fuer Textboxen @@ -812,8 +1176,8 @@ private: public: WW8_WrPlcTxtBoxes( BYTE nTTyp ) : nTyp( nTTyp ) {} - bool WriteTxt(SwWW8Writer& rWrt); - void WritePlc( SwWW8Writer& rWrt ) const; + bool WriteTxt( WW8Export& rWrt ); + void WritePlc( WW8Export& rWrt ) const; void Append( const SdrObject& rObj, UINT32 nShapeId ); USHORT Count() const { return aCntnt.Count(); } USHORT GetPos( const VoidPtr& p ) const { return aCntnt.GetPos( p ); } @@ -825,7 +1189,7 @@ SV_DECL_PTRARR( WW8_WrFkpPtrs, WW8_FkpPtr, 4, 4 ) class WW8_WrPlcPn // Plc fuer Page Numbers { private: - SwWW8Writer& rWrt; + WW8Export& rWrt; WW8_WrFkpPtrs aFkps; // PTRARR USHORT nFkpStartPage; ePLCFT ePlc; @@ -836,7 +1200,7 @@ private: WW8_WrPlcPn(const WW8_WrPlcPn&); WW8_WrPlcPn& operator=(const WW8_WrPlcPn&); public: - WW8_WrPlcPn( SwWW8Writer& rWrt, ePLCFT ePl, WW8_FC nStartFc ); + WW8_WrPlcPn( WW8Export& rWrt, ePLCFT ePl, WW8_FC nStartFc ); ~WW8_WrPlcPn(); void AppendFkpEntry(WW8_FC nEndFc,short nVarLen = 0,const BYTE* pSprms = 0); void WriteFkps(); @@ -881,7 +1245,7 @@ public: WW8_WrPlcFld( USHORT nStructSz, BYTE nTTyp ) : WW8_WrPlc1( nStructSz ), nTxtTyp( nTTyp ), nResults(0) {} - bool Write( SwWW8Writer& rWrt ); + bool Write( WW8Export& rWrt ); void ResultAdded() { ++nResults; } USHORT ResultCount() const { return nResults; } }; @@ -895,7 +1259,7 @@ private: public: WW8_WrMagicTable() : WW8_WrPlc1( 4 ) {Append(0,0);} void Append( WW8_CP nCp, ULONG nData ); - bool Write(SwWW8Writer& rWrt); + bool Write( WW8Export& rWrt ); }; class GraphicDetails @@ -924,7 +1288,9 @@ public: class SwWW8WrGrf { private: - SwWW8Writer& rWrt; // SwWW8Writer fuer Zugriff auf die Vars + /// for access to the variables + WW8Export& rWrt; + std::vector<GraphicDetails> maDetails; typedef std::vector<GraphicDetails>::iterator myiter; USHORT mnIdx; // Index in File-Positionen @@ -940,102 +1306,76 @@ private: SwWW8WrGrf(const SwWW8WrGrf&); SwWW8WrGrf& operator=(const SwWW8WrGrf&); public: - SwWW8WrGrf(SwWW8Writer& rW) : rWrt(rW), mnIdx(0) {} + SwWW8WrGrf( WW8Export& rW ) : rWrt( rW ), mnIdx( 0 ) {} void Insert(const sw::Frame &rFly); void Write(); ULONG GetFPos() { return (mnIdx < maDetails.size()) ? maDetails[mnIdx++].mnPos : 0; } }; -// The class WW8_AttrIter is a helper class to build the Fkp.chpx. This -// class may be overloaded for output the SwTxtAttrs and the -// EditEngineTxtAttrs. -class WW8_AttrIter +/** The class MSWordAttrIter is a helper class to build the Fkp.chpx. + This class may be overloaded for output the SwTxtAttrs and the + EditEngineTxtAttrs. +*/ +class MSWordAttrIter { private: - WW8_AttrIter* pOld; + MSWordAttrIter* pOld; //No copying - WW8_AttrIter(const WW8_AttrIter&); - WW8_AttrIter& operator=(const WW8_AttrIter&); + MSWordAttrIter(const MSWordAttrIter&); + MSWordAttrIter& operator=(const MSWordAttrIter&); protected: - SwWW8Writer& rWrt; + MSWordExportBase& m_rExport; public: - WW8_AttrIter( SwWW8Writer& rWrt ); - virtual ~WW8_AttrIter(); + MSWordAttrIter( MSWordExportBase& rExport ); + virtual ~MSWordAttrIter(); virtual const SfxPoolItem* HasTextItem( USHORT nWhich ) const = 0; virtual const SfxPoolItem& GetItem( USHORT nWhich ) const = 0; - void StartURL(const String &rUrl, const String &rTarget); - void EndURL(); }; -class WW8WrtStyle +/// Class to collect and output the styles table. +class MSWordStyles { - SwWW8Writer& rWrt; + MSWordExportBase& m_rExport; SwFmt** pFmtA; - USHORT nPOPosStdLen1, nPOPosStdLen2; USHORT nUsedSlots; - void BuildStyleTab(); - void BuildUpx(const SwFmt* pFmt, bool bPap, USHORT nPos, - bool bInsDefCharSiz); - USHORT Build_GetWWSlot( const SwFmt& rFmt ); - USHORT GetWWId( const SwFmt& rFmt ) const; - void Set1StyleDefaults(const SwFmt& rFmt, bool bPap); - void Out1Style( SwFmt* pFmt, USHORT nPos ); + /// Create the style table, called from the constructor. + void BuildStylesTable(); - void WriteStyle( SvStream& rStrm ); - void SkipOdd(); - void BuildStd(const String& rName, bool bPapFmt, short nWwBase, - short nWwNext, USHORT nWwId); - //No copying - WW8WrtStyle(const WW8WrtStyle&); - WW8WrtStyle& operator=(const WW8WrtStyle&); -public: - WW8WrtStyle( SwWW8Writer& rWr ); - ~WW8WrtStyle(); + /// Get slot number during building the style table. + USHORT BuildGetSlot( const SwFmt& rFmt ); - void OutStyleTab(); - USHORT Sty_GetWWSlot( const SwFmt& rFmt ) const; - SwFmt* GetSwFmt(){return (*pFmtA);} -}; + /// Return information about one style. + void GetStyleData( SwFmt* pFmt, bool& bFmtColl, USHORT& nBase, USHORT& nNext ); -class WW8SaveData -{ -private: - //No copying - WW8SaveData(const WW8SaveData&); - WW8SaveData& operator=(const WW8SaveData &); -public: - SwWW8Writer& rWrt; - Point* pOldFlyOffset; - RndStdIds eOldAnchorType; - WW8Bytes* pOOld; - SwPaM* pOldPam, *pOldEnd; - const sw::Frame* pOldFlyFmt; - const SwPageDesc* pOldPageDesc; + /// Outputs attributes of one style. + void WriteProperties( const SwFmt* pFmt, bool bPap, USHORT nPos, bool bInsDefCharSiz ); - BYTE bOldWriteAll : 1; - BYTE bOldOutTable : 1; - BYTE bOldIsInTable: 1; - BYTE bOldFlyFrmAttrs : 1; - BYTE bOldStartTOX : 1; - BYTE bOldInWriteTOX : 1; - // bOutPageDesc muss nicht gesichert werden, da es nur nicht waehrend der - // Ausgabe von Spezial-Texten veraendert wird. + USHORT GetWWId( const SwFmt& rFmt ) const; - WW8SaveData( SwWW8Writer&, ULONG nStt, ULONG nEnd ); - ~WW8SaveData(); -}; + void SetStyleDefaults( const SwFmt& rFmt, bool bPap ); + + /// Outputs one style - called (in a loop) from OutputStylesTable(). + void OutputStyle( SwFmt* pFmt, USHORT nPos ); + + // No copying + MSWordStyles( const MSWordStyles& ); + MSWordStyles& operator=( const MSWordStyles& ); -// einige halb-interne Funktions-Deklarationen fuer die Node-Tabelle +public: + MSWordStyles( MSWordExportBase& rExport ); + ~MSWordStyles(); + + /// Output the styles table. + void OutputStylesTable(); -Writer& OutWW8_SwGrfNode( Writer& rWrt, SwCntntNode& rNode ); -Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode ); -Writer& OutWW8_SwSectionNode(Writer& rWrt, SwSectionNode& rSectionNode ); + /// Get id of the style (rFmt). + USHORT GetSlot( const SwFmt& rFmt ) const; -Writer& OutWW8_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt ); -Writer& OutWW8_SwFmtVertOrient( Writer& rWrt, const SfxPoolItem& rHt ); + SwFmt* GetSwFmt() { return (*pFmtA); } +}; sal_Int16 GetWordFirstLineOffset(const SwNumFmt &rFmt); //A bit of a bag on the side for now @@ -1052,12 +1392,20 @@ public: WW8SHDLong() : m_cvFore(0), m_cvBack(0), m_ipat(0) {} virtual ~WW8SHDLong() {} - void Write(SwWW8Writer & rWriter); + void Write(WW8Export & rExport); void setCvFore(sal_uInt32 cvFore) { m_cvFore = cvFore; } void setCvBack(sal_uInt32 cvBack) { m_cvBack = cvBack; } void setIPat(sal_uInt16 ipat) { m_ipat = ipat; } }; +/// For the output of sections. +struct WW8_PdAttrDesc +{ + BYTE* pData; + USHORT nLen; + WW8_FC nSepxFcPos; +}; + #endif // _WRTWW8_HXX /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx index 92fb7551cb..ed3d1b3b7e 100644 --- a/sw/source/filter/ww8/wrtww8gr.cxx +++ b/sw/source/filter/ww8/wrtww8gr.cxx @@ -42,13 +42,8 @@ #include <svtools/embedhlp.hxx> -#ifndef _VIRDEV_HXX //autogen #include <vcl/virdev.hxx> -#endif -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif - #include <hintids.hxx> #include <svx/boxitem.hxx> @@ -70,6 +65,8 @@ #include <fmtfsize.hxx> #include <fmtornt.hxx> +#include <writerfilter/doctok/sprmids.hxx> + #include <doc.hxx> #include "writerhelper.hxx" #include "writerwordglue.hxx" @@ -98,20 +95,20 @@ using namespace nsFieldFlags; // in der Graf-Klasse der GrfNode-Ptr gemerkt ( fuers spaetere Ausgeben der // Grafiken und Patchen der PicLocFc-Attribute ) -Writer& OutWW8_SwGrfNode( Writer& rWrt, SwCntntNode& /*rNode*/ ) +void WW8Export::OutputGrfNode( const SwGrfNode& /*rNode*/ ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - ASSERT(rWW8Wrt.mpParentFrame, "frame not set!"); - if (rWW8Wrt.mpParentFrame) +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "WW8Export::OutputGrfNode( const SwGrfNode& )\n" ); +#endif + ASSERT( mpParentFrame, "frame not set!" ); + if ( mpParentFrame ) { - rWW8Wrt.OutGrf(*rWW8Wrt.mpParentFrame); - rWW8Wrt.pFib->fHasPic = 1; + OutGrf( *mpParentFrame ); + pFib->fHasPic = 1; } - - return rWrt; } -bool SwWW8Writer::TestOleNeedsGraphic(const SwAttrSet& rSet, +bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, SvStorageRef xOleStg, SvStorageRef xObjStg, String &rStorageName, SwOLENode *pOLENd) { @@ -220,9 +217,11 @@ bool SwWW8Writer::TestOleNeedsGraphic(const SwAttrSet& rSet, #endif } -Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode ) +void WW8Export::OutputOLENode( const SwOLENode& rOLENode ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "WW8Export::OutputOLENode( const SwOLENode& rOLENode )\n" ); +#endif BYTE *pSpecOLE; BYTE *pDataAdr; short nSize; @@ -237,7 +236,7 @@ Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode ) 118, 1 // sprmCFObj }; - if( rWW8Wrt.bWrtWW8 ) + if ( bWrtWW8 ) { pSpecOLE = aSpecOLE_WW8; nSize = sizeof( aSpecOLE_WW8 ); @@ -248,15 +247,14 @@ Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode ) nSize = sizeof( aSpecOLE_WW6 ); } pDataAdr = pSpecOLE + 2; //WW6 sprm is 1 but has 1 byte len as well. - SwOLENode *pOLENd = rNode.GetOLENode(); - SvStorageRef xObjStg = rWW8Wrt.GetStorage().OpenSotStorage( + SvStorageRef xObjStg = GetWriter().GetStorage().OpenSotStorage( CREATE_CONST_ASC(SL::aObjectPool), STREAM_READWRITE | STREAM_SHARE_DENYALL ); if( xObjStg.Is() ) { - uno::Reference < embed::XEmbeddedObject > xObj(pOLENd->GetOLEObj().GetOleRef()); + uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef()); if( xObj.is() ) { embed::XEmbeddedObject *pObj = xObj.get(); @@ -265,7 +263,7 @@ Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode ) WW8OleMap *pMap = new WW8OleMap(nPictureId); bool bDuplicate = false; - WW8OleMaps &rOleMap = rWW8Wrt.GetOLEMap(); + WW8OleMaps &rOleMap = GetOLEMap(); USHORT nPos; if ( rOleMap.Seek_Entry(pMap, &nPos) ) { @@ -287,9 +285,9 @@ Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode ) */ if (!bDuplicate) { - sal_Int64 nAspect = pOLENd->GetAspect(); + sal_Int64 nAspect = rOLENode.GetAspect(); svt::EmbeddedObjectRef aObjRef( xObj, nAspect ); - rWW8Wrt.GetOLEExp().ExportOLEObject( aObjRef, *xOleStg ); + GetOLEExp().ExportOLEObject( aObjRef, *xOleStg ); if ( nAspect == embed::Aspects::MSOLE_ICON ) { ::rtl::OUString aObjInfo( RTL_CONSTASCII_USTRINGPARAM( "\3ObjInfo" ) ); @@ -312,10 +310,10 @@ Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode ) sServer += xOleStg->GetUserName(); sServer += ' '; - rWW8Wrt.OutField(0, ww::eEMBED, sServer, WRITEFIELD_START | + OutputField(0, ww::eEMBED, sServer, WRITEFIELD_START | WRITEFIELD_CMD_START | WRITEFIELD_CMD_END); - rWW8Wrt.pChpPlc->AppendFkpEntry( rWrt.Strm().Tell(), + pChpPlc->AppendFkpEntry( Strm().Tell(), nSize, pSpecOLE ); bool bEndCR = true; @@ -330,22 +328,22 @@ Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode ) */ bool bGraphicNeeded = false; - if (rWW8Wrt.mpParentFrame) + if (mpParentFrame) { bGraphicNeeded = true; - if (rWW8Wrt.mpParentFrame->IsInline()) + if (mpParentFrame->IsInline()) { const SwAttrSet& rSet = - rWW8Wrt.mpParentFrame->GetFrmFmt().GetAttrSet(); + mpParentFrame->GetFrmFmt().GetAttrSet(); bEndCR = false; - bGraphicNeeded = rWW8Wrt.TestOleNeedsGraphic(rSet, - xOleStg, xObjStg, sStorageName, pOLENd); + bGraphicNeeded = TestOleNeedsGraphic(rSet, + xOleStg, xObjStg, sStorageName, const_cast<SwOLENode*>(&rOLENode)); } } if (!bGraphicNeeded) - rWW8Wrt.WriteChar(0x1); + WriteChar(0x1); else { /* @@ -355,26 +353,25 @@ Writer& OutWW8_SwOleNode( Writer& rWrt, SwCntntNode& rNode ) has no place to find the dimensions of the ole object, and will not be able to draw it */ - rWW8Wrt.OutGrf(*rWW8Wrt.mpParentFrame); + OutGrf(*mpParentFrame); } - rWW8Wrt.OutField(0, ww::eEMBED, aEmptyStr, + OutputField(0, ww::eEMBED, aEmptyStr, WRITEFIELD_END | WRITEFIELD_CLOSE); if (bEndCR) //No newline in inline case - rWW8Wrt.WriteCR(); + WriteCR(); } } } - return rWrt; } -void SwWW8Writer::OutGrf(const sw::Frame &rFrame) +void WW8Export::OutGrf(const sw::Frame &rFrame) { // GrfNode fuer spaeteres rausschreiben der Grafik merken pGrf->Insert(rFrame); - pChpPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() ); + pChpPlc->AppendFkpEntry( Strm().Tell(), pO->Count(), pO->GetData() ); pO->Remove( 0, pO->Count() ); // leeren // --> OD 2007-06-06 #i29408# @@ -395,7 +392,7 @@ void SwWW8Writer::OutGrf(const sw::Frame &rFrame) } sStr.APPEND_CONST_ASC("\" \\d"); - OutField( 0, ww::eINCLUDEPICTURE, sStr, + OutputField( 0, ww::eINCLUDEPICTURE, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START | WRITEFIELD_CMD_END ); } // <-- @@ -431,7 +428,7 @@ void SwWW8Writer::OutGrf(const sw::Frame &rFrame) nHeight-=nFontHeight/20; if (bWrtWW8) - Set_UInt16( pArr, 0x4845 ); + Set_UInt16( pArr, NS_sprm::LN_CHpsPos ); else Set_UInt8( pArr, 101 ); Set_UInt16( pArr, -((INT16)nHeight)); @@ -448,7 +445,7 @@ void SwWW8Writer::OutGrf(const sw::Frame &rFrame) // sprmCPicLocation if( bWrtWW8 ) - Set_UInt16( pArr, 0x6a03 ); + Set_UInt16( pArr, NS_sprm::LN_CPicLocation ); else { Set_UInt8( pArr, 68 ); @@ -461,7 +458,7 @@ void SwWW8Writer::OutGrf(const sw::Frame &rFrame) static BYTE nAttrMagicIdx = 0; --pArr; Set_UInt8( pArr, nAttrMagicIdx++ ); - pChpPlc->AppendFkpEntry( pStrm->Tell(), static_cast< short >(pArr - aArr), aArr ); + pChpPlc->AppendFkpEntry( Strm().Tell(), static_cast< short >(pArr - aArr), aArr ); // --> OD 2007-04-23 #i75464# // Check, if graphic isn't exported as-character anchored. @@ -479,17 +476,17 @@ void SwWW8Writer::OutGrf(const sw::Frame &rFrame) bool bOldGrf = bOutGrf; bOutGrf = true; - Out_SwFmt(rFrame.GetFrmFmt(), false, false, true); // Fly-Attrs + OutputFormat( rFrame.GetFrmFmt(), false, false, true ); // Fly-Attrs bOutGrf = bOldGrf; - pPapPlc->AppendFkpEntry( pStrm->Tell(), pO->Count(), pO->GetData() ); + pPapPlc->AppendFkpEntry( Strm().Tell(), pO->Count(), pO->GetData() ); pO->Remove( 0, pO->Count() ); // leeren } // --> OD 2007-06-06 #i29408# // linked, as-character anchored graphics have to be exported as fields. else if ( pGrfNd && pGrfNd->IsLinkedFile() ) { - OutField( 0, ww::eINCLUDEPICTURE, String(), WRITEFIELD_CLOSE ); + OutputField( 0, ww::eINCLUDEPICTURE, String(), WRITEFIELD_CLOSE ); } // <-- } diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index fff1b6bb41..e379e44a65 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -33,23 +33,19 @@ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ /* - * Dieses File enthaelt alle Ausgabe-Funktionen des WW8-Writers; - * fuer alle Nodes, Attribute, Formate und Chars. + * This file contains methods for the WW8 output + * (nodes, attributes, formats und chars). */ - #include <hintids.hxx> -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <vcl/salbtype.hxx> #include <svtools/zformat.hxx> #include <svtools/itemiter.hxx> +#include <svtools/whiter.hxx> #include <svx/fontitem.hxx> -#ifndef _SVX_TSTPITEM_HXX //autogen #include <svx/tstpitem.hxx> -#endif #include <svx/adjitem.hxx> #include <svx/spltitem.hxx> #include <svx/widwitem.hxx> @@ -104,16 +100,15 @@ #include <txtfld.hxx> #include <txtftn.hxx> #include <poolfmt.hxx> -#include <doc.hxx> // Doc fuer Fussnoten +#include <doc.hxx> // Doc for footnotes #include <pam.hxx> #include <paratr.hxx> -#include <fldbas.hxx> // fuer SwField ... -#include <docufld.hxx> // fuer SwField ... +#include <fldbas.hxx> // for SwField +#include <docufld.hxx> // for SwField #include <expfld.hxx> -#include <pagedesc.hxx> // fuer SwPageDesc... -#include <flddat.hxx> // fuer Datum-Felder -#include <ndtxt.hxx> // fuer Numrules -#include <fmthbsh.hxx> +#include <pagedesc.hxx> // for SwPageDesc +#include <flddat.hxx> // for Date fields +#include <ndtxt.hxx> // for Numrules #include <swrect.hxx> #include <reffld.hxx> #include <ftninfo.hxx> @@ -124,15 +119,15 @@ #include <tox.hxx> #include <fmtftntx.hxx> #include <breakit.hxx> -#ifndef _COM_SUN_STAR_I18N_SCRIPTTYPE_HDL_ #include <com/sun/star/i18n/ScriptType.hdl> -#endif #include <unotools/localedatawrapper.hxx> #include <tgrditem.hxx> #include <flddropdown.hxx> #include <chpfld.hxx> #include <fmthdft.hxx> +#include <writerfilter/doctok/sprmids.hxx> + #if OSL_DEBUG_LEVEL > 1 # include <fmtcntnt.hxx> #endif @@ -140,6 +135,7 @@ #include "writerwordglue.hxx" #include "wrtww8.hxx" #include "ww8par.hxx" +#include "ww8attributeoutput.hxx" #include "fields.hxx" #include <vcl/outdev.hxx> #include <i18npool/mslangid.hxx> @@ -148,7 +144,6 @@ using namespace ::com::sun::star; using namespace nsFieldFlags; using namespace nsSwDocInfoSubType; - /* * um nicht immer wieder nach einem Update festzustellen, das irgendwelche * Hint-Ids dazugekommen sind, wird hier definiert, die Groesse der Tabelle @@ -175,30 +170,17 @@ using namespace nsSwDocInfoSubType; using namespace sw::util; using namespace sw::types; -//------------------------------------------------------------ -// Forward-Declarationen -//------------------------------------------------------------ -static Writer& OutWW8_SwFmtBreak( Writer& rWrt, const SfxPoolItem& rHt ); -static Writer& OutWW8_SwNumRuleItem( Writer& rWrt, const SfxPoolItem& rHt ); -/* -Sadly word does not have two different sizes for asian font size and western -font size, it has two different fonts, but not sizes, so we have to use our -guess as to the script used and disable the export of one type. The same -occurs for font weight and posture (bold and italic) - -In addition WW7- has only one character language identifier while WW8+ has two -*/ -bool SwWW8Writer::CollapseScriptsforWordOk(USHORT nScript, USHORT nWhich) +bool WW8Export::CollapseScriptsforWordOk( USHORT nScript, USHORT nWhich ) { bool bRet = true; - if (nScript == i18n::ScriptType::ASIAN) + if ( nScript == i18n::ScriptType::ASIAN ) { //for asian in ww8, there is only one fontsize //and one fontstyle (posture/weight) for ww6 //there is the additional problem that there //is only one font setting for all three scripts - switch (nWhich) + switch ( nWhich ) { case RES_CHRATR_FONTSIZE: case RES_CHRATR_POSTURE: @@ -217,14 +199,14 @@ bool SwWW8Writer::CollapseScriptsforWordOk(USHORT nScript, USHORT nWhich) break; } } - else if (nScript == i18n::ScriptType::COMPLEX) + else if ( nScript == i18n::ScriptType::COMPLEX ) { //Complex is ok in ww8, but for ww6 there is only //one font, one fontsize, one fontsize (weight/posture) //and only one language - if (bWrtWW8 == 0) + if ( bWrtWW8 == 0 ) { - switch (nWhich) + switch ( nWhich ) { case RES_CHRATR_CJK_FONT: case RES_CHRATR_CJK_FONTSIZE: @@ -249,7 +231,7 @@ bool SwWW8Writer::CollapseScriptsforWordOk(USHORT nScript, USHORT nWhich) //and one fontstyle (posture/weight) for ww6 //there is the additional problem that there //is only one font setting for all three scripts - switch (nWhich) + switch ( nWhich ) { case RES_CHRATR_CJK_FONTSIZE: case RES_CHRATR_CJK_POSTURE: @@ -262,7 +244,7 @@ bool SwWW8Writer::CollapseScriptsforWordOk(USHORT nScript, USHORT nWhich) case RES_CHRATR_CTL_LANGUAGE: case RES_CHRATR_CTL_POSTURE: case RES_CHRATR_CTL_WEIGHT: - if (bWrtWW8 == 0) + if ( bWrtWW8 == 0 ) bRet = false; default: break; @@ -275,19 +257,16 @@ bool SwWW8Writer::CollapseScriptsforWordOk(USHORT nScript, USHORT nWhich) // Hilfsroutinen fuer Styles //------------------------------------------------------------ -void SwWW8Writer::ExportPoolItemsToCHP(sw::PoolItems &rItems, USHORT nScript) +void MSWordExportBase::ExportPoolItemsToCHP( sw::PoolItems &rItems, USHORT nScript ) { sw::cPoolItemIter aEnd = rItems.end(); - for (sw::cPoolItemIter aI = rItems.begin(); aI != aEnd; ++aI) + for ( sw::cPoolItemIter aI = rItems.begin(); aI != aEnd; ++aI ) { const SfxPoolItem *pItem = aI->second; USHORT nWhich = pItem->Which(); - if (!isCHRATR(nWhich) && !isTXTATR(nWhich)) - continue; - if (FnAttrOut pOut = aWW8AttrFnTab[nWhich - RES_CHRATR_BEGIN]) + if ( ( isCHRATR( nWhich ) || isTXTATR( nWhich ) ) && CollapseScriptsforWordOk( nScript, nWhich ) ) { - if (SwWW8Writer::CollapseScriptsforWordOk(nScript, nWhich)) - (*pOut)(*this, *pItem); + AttrOutput().OutputItem( *pItem ); } } } @@ -297,71 +276,62 @@ void SwWW8Writer::ExportPoolItemsToCHP(sw::PoolItems &rItems, USHORT nScript) * - gebe die Attribute aus; ohne Parents! */ -void SwWW8Writer::Out_SfxItemSet(const SfxItemSet& rSet, bool bPapFmt, - bool bChpFmt, USHORT nScript) +void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFmt, bool bChpFmt, USHORT nScript ) { - if (rSet.Count()) + if ( rSet.Count() ) { const SfxPoolItem* pItem; - FnAttrOut pOut; - pISet = &rSet; // fuer Doppel-Attribute - //If frame dir is set, but not adjust, then force adjust as well - if (bPapFmt && SFX_ITEM_SET == rSet.GetItemState(RES_FRAMEDIR, false)) + // If frame dir is set, but not adjust, then force adjust as well + if ( bPapFmt && SFX_ITEM_SET == rSet.GetItemState( RES_FRAMEDIR, false ) ) { - //No explicit adjust set ? - if (SFX_ITEM_SET != rSet.GetItemState(RES_PARATR_ADJUST, false)) + // No explicit adjust set ? + if ( SFX_ITEM_SET != rSet.GetItemState( RES_PARATR_ADJUST, false ) ) { - if (0 != (pItem = rSet.GetItem(RES_PARATR_ADJUST))) + if ( 0 != ( pItem = rSet.GetItem( RES_PARATR_ADJUST ) ) ) { // then set the adjust used by the parent format - pOut = aWW8AttrFnTab[ static_cast< USHORT >(RES_PARATR_ADJUST) - RES_CHRATR_BEGIN]; - (*pOut)( *this, *pItem ); + AttrOutput().OutputItem( *pItem ); } } } - if (bPapFmt && SFX_ITEM_SET == rSet.GetItemState(RES_PARATR_NUMRULE, - false, &pItem)) + if ( bPapFmt && SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, false, &pItem ) ) { - pOut = aWW8AttrFnTab[ static_cast< USHORT >(RES_PARATR_NUMRULE) - RES_CHRATR_BEGIN ]; - (*pOut)( *this, *pItem ); + AttrOutput().OutputItem( *pItem ); + // switch off the numerbering? - if( !((SwNumRuleItem*)pItem)->GetValue().Len() && SFX_ITEM_SET - != rSet.GetItemState( RES_LR_SPACE, false) && SFX_ITEM_SET - == rSet.GetItemState( RES_LR_SPACE, true, &pItem ) ) + if ( !( (SwNumRuleItem*)pItem )->GetValue().Len() && + SFX_ITEM_SET != rSet.GetItemState( RES_LR_SPACE, false) && + SFX_ITEM_SET == rSet.GetItemState( RES_LR_SPACE, true, &pItem ) ) { // the set the LR-Space of the parentformat! - pOut = aWW8AttrFnTab[ static_cast< USHORT >(RES_LR_SPACE) - RES_CHRATR_BEGIN ]; - (*pOut)( *this, *pItem ); + AttrOutput().OutputItem( *pItem ); } } sw::PoolItems aItems; - GetPoolItems(rSet, aItems); - if (bChpFmt) + GetPoolItems( rSet, aItems ); + if ( bChpFmt ) ExportPoolItemsToCHP(aItems, nScript); - if (bPapFmt) + if ( bPapFmt ) { sw::cPoolItemIter aEnd = aItems.end(); - for (sw::cPoolItemIter aI = aItems.begin(); aI != aEnd; ++aI) + for ( sw::cPoolItemIter aI = aItems.begin(); aI != aEnd; ++aI ) { pItem = aI->second; USHORT nWhich = pItem->Which(); - if (nWhich < RES_PARATR_BEGIN || nWhich >= RES_FRMATR_END || nWhich == RES_PARATR_NUMRULE) - continue; - pOut = aWW8AttrFnTab[nWhich - RES_CHRATR_BEGIN]; - if( 0 != pOut ) - (*pOut)(*this, *pItem); + if ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END && nWhich != RES_PARATR_NUMRULE) + AttrOutput().OutputItem( *pItem ); } } pISet = 0; // fuer Doppel-Attribute } } -void SwWW8Writer::GatherChapterFields() +void MSWordExportBase::GatherChapterFields() { //If the header/footer contains a chapter field SwClientIter aIter(*pDoc->GetSysFldType(RES_CHAPTERFLD)); @@ -378,20 +348,20 @@ void SwWW8Writer::GatherChapterFields() } } -bool SwWW8Writer::CntntContainsChapterField(const SwFmtCntnt &rCntnt) const +bool MSWordExportBase::CntntContainsChapterField(const SwFmtCntnt &rCntnt) const { bool bRet = false; - if (const SwNodeIndex* pSttIdx = rCntnt.GetCntntIdx()) + if ( const SwNodeIndex* pSttIdx = rCntnt.GetCntntIdx() ) { - SwNodeIndex aIdx(*pSttIdx, 1); - SwNodeIndex aEnd(*pSttIdx->GetNode().EndOfSectionNode()); + SwNodeIndex aIdx( *pSttIdx, 1 ); + SwNodeIndex aEnd( *pSttIdx->GetNode().EndOfSectionNode() ); ULONG nStart = aIdx.GetIndex(); ULONG nEnd = aEnd.GetIndex(); //If the header/footer contains a chapter field mycCFIter aIEnd = maChapterFieldLocs.end(); - for (mycCFIter aI = maChapterFieldLocs.begin(); aI != aIEnd; ++aI) + for ( mycCFIter aI = maChapterFieldLocs.begin(); aI != aIEnd; ++aI ) { - if ((nStart <= *aI) && (*aI <= nEnd)) + if ( ( nStart <= *aI ) && ( *aI <= nEnd ) ) { bRet = true; break; @@ -401,22 +371,25 @@ bool SwWW8Writer::CntntContainsChapterField(const SwFmtCntnt &rCntnt) const return bRet; } -bool SwWW8Writer::FmtHdFtContainsChapterField(const SwFrmFmt &rFmt) const +bool MSWordExportBase::FmtHdFtContainsChapterField(const SwFrmFmt &rFmt) const { - if (maChapterFieldLocs.empty()) + if ( maChapterFieldLocs.empty() ) return false; - bool bRet = false; const SwFrmFmt *pFmt = 0; - if (0 != (pFmt = rFmt.GetHeader().GetHeaderFmt())) - bRet = CntntContainsChapterField(pFmt->GetCntnt()); - if (!bRet && 0 != (pFmt = rFmt.GetFooter().GetFooterFmt())) - bRet = CntntContainsChapterField(pFmt->GetCntnt()); - return bRet; + pFmt = rFmt.GetHeader().GetHeaderFmt(); + if ( pFmt && CntntContainsChapterField( pFmt->GetCntnt() ) ) + return true; + + pFmt = rFmt.GetFooter().GetFooterFmt(); + if ( pFmt && CntntContainsChapterField( pFmt->GetCntnt() ) ) + return true; + + return false; } -bool SwWW8Writer::SetAktPageDescFromNode(const SwNode &rNd) +bool MSWordExportBase::SetAktPageDescFromNode(const SwNode &rNd) { bool bNewPageDesc = false; const SwPageDesc* pCurrent = SwPageDesc::GetPageDescOfNode(rNd); @@ -453,13 +426,9 @@ bool SwWW8Writer::SetAktPageDescFromNode(const SwNode &rNd) // Es duerfen nur Funktionen gerufen werden, die nicht in den // Ausgabebereich pO schreiben, da dieser nur einmal fuer CHP und PAP existiert // und damit im falschen landen wuerden. -void SwWW8Writer::Out_SfxBreakItems(const SfxItemSet *pSet, const SwNode& rNd) +void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd ) { - bool bAllowOutputPageDesc = false; - if (!bStyDef && !bOutKF && !bInWriteEscher && !bOutPageDescs) - bAllowOutputPageDesc = true; - - if (!bAllowOutputPageDesc) + if ( bStyDef || bOutKF || bInWriteEscher || bOutPageDescs ) return; bBreakBefore = true; @@ -474,17 +443,17 @@ void SwWW8Writer::Out_SfxBreakItems(const SfxItemSet *pSet, const SwNode& rNd) //section. bool bBreakSet = false; - if (pSet && pSet->Count()) + if ( pSet && pSet->Count() ) { - if (SFX_ITEM_SET == pSet->GetItemState(RES_PAGEDESC, false, &pItem) - && ((SwFmtPageDesc*)pItem)->GetRegisteredIn()) + if ( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) + && ( (SwFmtPageDesc*)pItem )->GetRegisteredIn() ) { bBreakSet = true; bNewPageDesc = true; pPgDesc = (const SwFmtPageDesc*)pItem; pAktPageDesc = pPgDesc->GetPageDesc(); } - else if (SFX_ITEM_SET == pSet->GetItemState(RES_BREAK, false, &pItem)) + else if ( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, false, &pItem ) ) { // --> FME 2007-05-30 #146867# Word does not like hard break attributes in some table cells bool bRemoveHardBreakInsideTable = false; @@ -521,7 +490,7 @@ void SwWW8Writer::Out_SfxBreakItems(const SfxItemSet *pSet, const SwNode& rNd) done when it happens when we get a new pagedesc because we overflow from the first page style. */ - if (pAktPageDesc) + if ( pAktPageDesc ) { // --> OD 2007-05-30 #i76301# // assure that there is a page break before set at the node. @@ -529,12 +498,12 @@ void SwWW8Writer::Out_SfxBreakItems(const SfxItemSet *pSet, const SwNode& rNd) if ( pBreak && pBreak->GetBreak() == SVX_BREAK_PAGE_BEFORE ) { - bNewPageDesc = SetAktPageDescFromNode(rNd); + bNewPageDesc = SetAktPageDescFromNode( rNd ); } // <-- } - if (!bNewPageDesc) - OutWW8_SwFmtBreak( *this, *pItem ); + if ( !bNewPageDesc ) + AttrOutput().OutputItem( *pItem ); } } } @@ -547,72 +516,41 @@ void SwWW8Writer::Out_SfxBreakItems(const SfxItemSet *pSet, const SwNode& rNd) that moves onto a new page because of layout, but that would be insane. */ bool bHackInBreak = false; - if (!bBreakSet) + if ( !bBreakSet ) { - if (const SwCntntNode *pNd = rNd.GetCntntNode()) + if ( const SwCntntNode *pNd = rNd.GetCntntNode() ) { const SvxFmtBreakItem &rBreak = - ItemGet<SvxFmtBreakItem>(*pNd, RES_BREAK); - if (rBreak.GetBreak() == SVX_BREAK_PAGE_BEFORE) + ItemGet<SvxFmtBreakItem>( *pNd, RES_BREAK ); + if ( rBreak.GetBreak() == SVX_BREAK_PAGE_BEFORE ) bHackInBreak = true; else { // Even a pagedesc item is set, the break item can be set 'NONE', // but a pagedesc item is an implicit page break before... const SwFmtPageDesc &rPageDesc = ItemGet<SwFmtPageDesc>( *pNd, RES_PAGEDESC ); - if( rPageDesc.GetRegisteredIn() ) + if ( rPageDesc.GetRegisteredIn() ) bHackInBreak = true; } } } - if (bHackInBreak) + if ( bHackInBreak ) { - ASSERT(pAktPageDesc, "should not be possible"); - if (pAktPageDesc) - bNewPageDesc = SetAktPageDescFromNode(rNd); + ASSERT( pAktPageDesc, "should not be possible" ); + if ( pAktPageDesc ) + bNewPageDesc = SetAktPageDescFromNode( rNd ); } - if (bNewPageDesc && pAktPageDesc) + if ( bNewPageDesc && pAktPageDesc ) { - // --> OD 2007-05-29 #i76300# - // code moved code to method <SwWW8Writer::PrepareNewPageDesc(..)> -// // Die PageDescs werden beim Auftreten von PageDesc-Attributen nur in -// // WW8Writer::pSepx mit der entsprechenden Position eingetragen. Das -// // Aufbauen und die Ausgabe der am PageDesc haengenden Attribute und -// // Kopf/Fusszeilen passiert nach dem Haupttext und seinen Attributen. - -// ULONG nFcPos = ReplaceCr(0x0c); // Page/Section-Break - -// const SwSectionFmt *pFmt = 0; -// const SwSectionNode* pSect = rNd.FindSectionNode(); -// if (pSect && CONTENT_SECTION == pSect->GetSection().GetType()) -// pFmt = pSect->GetSection().GetFmt(); - -// // tatsaechlich wird hier NOCH NICHTS ausgegeben, sondern -// // nur die Merk-Arrays aCps, aSects entsprechend ergaenzt -// if (nFcPos) -// { -// const SwFmtLineNumber *pNItem = 0; -// if (pSet) -// pNItem = &(ItemGet<SwFmtLineNumber>(*pSet,RES_LINENUMBER)); -// else if (const SwCntntNode *pNd = rNd.GetCntntNode()) -// pNItem = &(ItemGet<SwFmtLineNumber>(*pNd,RES_LINENUMBER)); -// ULONG nLnNm = pNItem ? pNItem->GetStartValue() : 0; - -// if (pPgDesc) -// pSepx->AppendSep(Fc2Cp(nFcPos), *pPgDesc, rNd, pFmt, nLnNm); -// else -// pSepx->AppendSep(Fc2Cp(nFcPos), pAktPageDesc, rNd, pFmt, nLnNm); -// } PrepareNewPageDesc( pSet, rNd, pPgDesc, pAktPageDesc ); } bBreakBefore = false; } // --> OD 2007-05-29 #i76300# -bool SwWW8Writer::Out_FollowPageDesc( const SfxItemSet* pSet, - const SwTxtNode* pNd ) +bool MSWordExportBase::OutputFollowPageDesc( const SfxItemSet* pSet, const SwTxtNode* pNd ) { bool bRet = false; @@ -627,8 +565,35 @@ bool SwWW8Writer::Out_FollowPageDesc( const SfxItemSet* pSet, return bRet; } -// initial version by extracting corresponding code from method <SwWW8Writer::Out_SfxBreakItems(..)> -void SwWW8Writer::PrepareNewPageDesc( const SfxItemSet*pSet, +const SwSectionFmt* MSWordExportBase::GetSectionFormat( const SwNode& rNd ) const +{ + const SwSectionFmt* pFmt = NULL; + const SwSectionNode* pSect = rNd.FindSectionNode(); + if ( pSect && + CONTENT_SECTION == pSect->GetSection().GetType() ) + { + pFmt = pSect->GetSection().GetFmt(); + } + + return pFmt; +} + +ULONG MSWordExportBase::GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd ) const +{ + const SwFmtLineNumber* pNItem = 0; + if ( pSet ) + { + pNItem = &( ItemGet<SwFmtLineNumber>( *pSet, RES_LINENUMBER ) ); + } + else if ( const SwCntntNode *pNd = rNd.GetCntntNode() ) + { + pNItem = &( ItemGet<SwFmtLineNumber>( *pNd, RES_LINENUMBER ) ); + } + + return pNItem? pNItem->GetStartValue() : 0; +} + +void WW8Export::PrepareNewPageDesc( const SfxItemSet*pSet, const SwNode& rNd, const SwFmtPageDesc* pNewPgDescFmt, const SwPageDesc* pNewPgDesc ) @@ -638,63 +603,45 @@ void SwWW8Writer::PrepareNewPageDesc( const SfxItemSet*pSet, // Aufbauen und die Ausgabe der am PageDesc haengenden Attribute und // Kopf/Fusszeilen passiert nach dem Haupttext und seinen Attributen. - ULONG nFcPos = ReplaceCr(0x0c); // Page/Section-Break - - const SwSectionFmt* pFmt = 0; - const SwSectionNode* pSect = rNd.FindSectionNode(); - if ( pSect && - CONTENT_SECTION == pSect->GetSection().GetType() ) - { - pFmt = pSect->GetSection().GetFmt(); - } + ULONG nFcPos = ReplaceCr( msword::PageBreak ); // Page/Section-Break // tatsaechlich wird hier NOCH NICHTS ausgegeben, sondern // nur die Merk-Arrays aCps, aSects entsprechend ergaenzt - if ( nFcPos ) - { - const SwFmtLineNumber* pNItem = 0; - if ( pSet ) - { - pNItem = &(ItemGet<SwFmtLineNumber>(*pSet,RES_LINENUMBER)); - } - else if (const SwCntntNode *pNd = rNd.GetCntntNode()) - { - pNItem = &(ItemGet<SwFmtLineNumber>(*pNd,RES_LINENUMBER)); - } - const ULONG nLnNm = pNItem ? pNItem->GetStartValue() : 0; + if ( !nFcPos ) + return; - if ( pNewPgDescFmt ) - { - pSepx->AppendSep(Fc2Cp(nFcPos), *pNewPgDescFmt, rNd, pFmt, nLnNm); - } - else if ( pNewPgDesc ) - { - pSepx->AppendSep(Fc2Cp(nFcPos), pNewPgDesc, rNd, pFmt, nLnNm); - } - else - { - ASSERT( false, "<SwWW8Writer::PrepareNewPageDesc(..)> - misusage: neither page desc format nor page desc provided." ); - } + const SwSectionFmt* pFmt = GetSectionFormat( rNd ); + const ULONG nLnNm = GetSectionLineNo( pSet, rNd ); + + ASSERT( pNewPgDescFmt || pNewPgDesc, "Neither page desc format nor page desc provided." ); + + if ( pNewPgDescFmt ) + { + pSepx->AppendSep( Fc2Cp( nFcPos ), *pNewPgDescFmt, rNd, pFmt, nLnNm ); + } + else if ( pNewPgDesc ) + { + pSepx->AppendSep( Fc2Cp( nFcPos ), pNewPgDesc, rNd, pFmt, nLnNm ); } } -// <-- - -void SwWW8Writer::CorrTabStopInSet(SfxItemSet& rSet, USHORT nAbsLeft) +void MSWordExportBase::CorrectTabStopInSet( SfxItemSet& rSet, USHORT nAbsLeft ) { const SvxTabStopItem *pItem = - sw::util::HasItem<SvxTabStopItem>(rSet, RES_PARATR_TABSTOP); + sw::util::HasItem<SvxTabStopItem>( rSet, RES_PARATR_TABSTOP ); - if (pItem) + if ( pItem ) { // dann muss das fuer die Ausgabe korrigiert werden SvxTabStopItem aTStop(*pItem); - for(USHORT nCnt = 0; nCnt < aTStop.Count(); ++nCnt) + for ( USHORT nCnt = 0; nCnt < aTStop.Count(); ++nCnt ) { SvxTabStop& rTab = (SvxTabStop&)aTStop[ nCnt ]; - if( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() && + if ( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() && rTab.GetTabPos() >= nAbsLeft ) + { rTab.GetTabPos() -= nAbsLeft; + } else { aTStop.Remove( nCnt ); @@ -705,7 +652,7 @@ void SwWW8Writer::CorrTabStopInSet(SfxItemSet& rSet, USHORT nAbsLeft) } } -BYTE SwWW8Writer::GetNumId( USHORT eNumType ) +BYTE WW8Export::GetNumId( USHORT eNumType ) { BYTE nRet = 0; switch( eNumType ) @@ -726,26 +673,25 @@ BYTE SwWW8Writer::GetNumId( USHORT eNumType ) return nRet; } -void SwWW8Writer::ExportOutlineNumbering(BYTE nLvl, const SwNumFmt &rNFmt, - const SwFmt &rFmt) +void WW8AttributeOutput::OutlineNumbering( BYTE nLvl, const SwNumFmt &rNFmt, const SwFmt &rFmt ) { - if (nLvl >= WW8ListManager::nMaxLevel) + if ( nLvl >= WW8ListManager::nMaxLevel ) nLvl = WW8ListManager::nMaxLevel-1; - if( bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) { // write sprmPOutLvl sprmPIlvl and sprmPIlfo - SwWW8Writer::InsUInt16( *pO, 0x2640 ); - pO->Insert( nLvl, pO->Count() ); - SwWW8Writer::InsUInt16( *pO, 0x260a ); - pO->Insert( nLvl, pO->Count() ); - SwWW8Writer::InsUInt16( *pO, 0x460b ); - SwWW8Writer::InsUInt16( *pO, 1 + GetId( - *pDoc->GetOutlineNumRule() ) ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_POutLvl ); + m_rWW8Export.pO->Insert( nLvl, m_rWW8Export.pO->Count() ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlvl ); + m_rWW8Export.pO->Insert( nLvl, m_rWW8Export.pO->Count() ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlfo ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, + 1 + m_rWW8Export.GetId( *m_rWW8Export.pDoc->GetOutlineNumRule() ) ); } else { - Out_SwNumLvl( nLvl ); + m_rWW8Export.Out_SwNumLvl( nLvl ); // --> OD 2008-06-03 #i86652# // if (rNFmt.GetAbsLSpace()) if ( rNFmt.GetPositionAndSpaceMode() == @@ -753,22 +699,25 @@ void SwWW8Writer::ExportOutlineNumbering(BYTE nLvl, const SwNumFmt &rNFmt, rNFmt.GetAbsLSpace() ) // <-- { - SwNumFmt aNumFmt(rNFmt); + SwNumFmt aNumFmt( rNFmt ); const SvxLRSpaceItem& rLR = - ItemGet<SvxLRSpaceItem>(rFmt, RES_LR_SPACE); - aNumFmt.SetAbsLSpace(writer_cast<short>( - aNumFmt.GetAbsLSpace() + rLR.GetLeft())); - Out_NumRuleAnld( *pDoc->GetOutlineNumRule(), - aNumFmt, nLvl ); + ItemGet<SvxLRSpaceItem>( rFmt, RES_LR_SPACE ); + + aNumFmt.SetAbsLSpace( writer_cast<short>( + aNumFmt.GetAbsLSpace() + rLR.GetLeft() ) ); + m_rWW8Export.Out_NumRuleAnld( + *m_rWW8Export.pDoc->GetOutlineNumRule(), + aNumFmt, nLvl ); } else - Out_NumRuleAnld( *pDoc->GetOutlineNumRule(), - rNFmt, nLvl ); + m_rWW8Export.Out_NumRuleAnld( + *m_rWW8Export.pDoc->GetOutlineNumRule(), + rNFmt, nLvl ); } } // --> OD 2007-06-04 #i77805# -bool SwWW8Writer::DisallowInheritingOutlineNumbering(const SwFmt &rFmt) +bool WW8Export::DisallowInheritingOutlineNumbering(const SwFmt &rFmt) { bool bRet( false ); @@ -780,16 +729,13 @@ bool SwWW8Writer::DisallowInheritingOutlineNumbering(const SwFmt &rFmt) { if (const SwFmt *pParent = rFmt.DerivedFrom()) { - //BYTE nLvl = ((const SwTxtFmtColl*)pParent)->GetOutlineLevel(); //#outline level,removed by zhaojianwei - //if (MAXLEVEL > nLvl) - //{ //<-end, ->add by zhaojianwei if (((const SwTxtFmtColl*)pParent)->IsAssignedToListLevelOfOutlineStyle()) - { //<-end,zhaojianwei + { if (bWrtWW8) { - SwWW8Writer::InsUInt16(*pO, 0x2640); + SwWW8Writer::InsUInt16(*pO, NS_sprm::LN_POutLvl); pO->Insert(BYTE(9), pO->Count()); - SwWW8Writer::InsUInt16(*pO, 0x460b); + SwWW8Writer::InsUInt16(*pO, NS_sprm::LN_PIlfo); SwWW8Writer::InsUInt16(*pO, 0); bRet = true; @@ -803,8 +749,7 @@ bool SwWW8Writer::DisallowInheritingOutlineNumbering(const SwFmt &rFmt) } // <-- -void SwWW8Writer::Out_SwFmt(const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, - bool bFlyFmt) +void MSWordExportBase::OutputFormat( const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, bool bFlyFmt ) { bool bCallOutSet = true; const SwModify* pOldMod = pOutFmtNode; @@ -816,18 +761,15 @@ void SwWW8Writer::Out_SwFmt(const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, case RES_TXTFMTCOLL: if( bPapFmt ) { - //BYTE nLvl = ((const SwTxtFmtColl&)rFmt).GetOutlineLevel(); //#outline level,removed by zhaojianwei - //if (MAXLEVEL > nLvl) - //{ //<-end, ->add by zhaojianwei if (((const SwTxtFmtColl&)rFmt).IsAssignedToListLevelOfOutlineStyle()) { - int nLvl = ((const SwTxtFmtColl&)rFmt).GetAssignedOutlineStyleLevel(); //<-end,zhaojianwei + int nLvl = ((const SwTxtFmtColl&)rFmt).GetAssignedOutlineStyleLevel(); //if outline numbered // if Write StyleDefinition then write the OutlineRule - const SwNumFmt& rNFmt = pDoc->GetOutlineNumRule()->Get(static_cast<USHORT>(nLvl)); - if (bStyDef) - ExportOutlineNumbering(static_cast<BYTE>(nLvl), rNFmt, rFmt); + const SwNumFmt& rNFmt = pDoc->GetOutlineNumRule()->Get( static_cast<USHORT>( nLvl ) ); + if ( bStyDef ) + AttrOutput().OutlineNumbering( static_cast< BYTE >( nLvl ), rNFmt, rFmt ); // --> OD 2008-06-03 #i86652# // if (rNFmt.GetAbsLSpace()) @@ -844,8 +786,8 @@ void SwWW8Writer::Out_SwFmt(const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, aLR.SetTxtFirstLineOfst( GetWordFirstLineOffset(rNFmt)); aSet.Put( aLR ); - SwWW8Writer::CorrTabStopInSet( aSet, rNFmt.GetAbsLSpace() ); - Out_SfxItemSet( aSet, bPapFmt, bChpFmt, + CorrectTabStopInSet( aSet, rNFmt.GetAbsLSpace() ); + OutputItemSet( aSet, bPapFmt, bChpFmt, i18n::ScriptType::LATIN); bCallOutSet = false; } @@ -863,7 +805,7 @@ void SwWW8Writer::Out_SwFmt(const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, SvxLRSpaceItem aLR( ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE)); aSet.Put( aLR ); - Out_SfxItemSet( aSet, bPapFmt, bChpFmt, + OutputItemSet( aSet, bPapFmt, bChpFmt, com::sun::star::i18n::ScriptType::LATIN); bCallOutSet = false; } @@ -903,7 +845,7 @@ void SwWW8Writer::Out_SwFmt(const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, bOutFlyFrmAttrs = true; //script doesn't matter if not exporting chp - Out_SfxItemSet(aSet, true, false, + OutputItemSet(aSet, true, false, i18n::ScriptType::LATIN); bOutFlyFrmAttrs = false; @@ -917,55 +859,64 @@ void SwWW8Writer::Out_SwFmt(const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, } if( bCallOutSet ) - Out_SfxItemSet( rFmt.GetAttrSet(), bPapFmt, bChpFmt, + OutputItemSet( rFmt.GetAttrSet(), bPapFmt, bChpFmt, i18n::ScriptType::LATIN); pOutFmtNode = pOldMod; } -bool SwWW8Writer::HasRefToObject(USHORT nTyp, const String* pNm, USHORT nSeqNo) +bool MSWordExportBase::HasRefToObject( USHORT nTyp, const String* pName, USHORT nSeqNo ) { - bool bFnd = false; const SwTxtNode* pNd; - SwClientIter aIter( *pDoc->GetSysFldType( RES_GETREFFLD )); - for( SwFmtFld* pFld = (SwFmtFld*)aIter.First( TYPE( SwFmtFld )); - pFld && !bFnd; pFld = (SwFmtFld*)aIter.Next() ) - if( pFld->GetTxtFld() && nTyp == pFld->GetFld()->GetSubType() && - 0 != ( pNd = pFld->GetTxtFld()->GetpTxtNode() ) && - pNd->GetNodes().IsDocNodes() ) + SwClientIter aIter( *pDoc->GetSysFldType( RES_GETREFFLD ) ); + for ( SwFmtFld* pFld = static_cast< SwFmtFld* >( aIter.First( TYPE( SwFmtFld ) ) ); + pFld; + pFld = static_cast< SwFmtFld* >( aIter.Next() ) ) + { + if ( pFld->GetTxtFld() && nTyp == pFld->GetFld()->GetSubType() && + 0 != ( pNd = pFld->GetTxtFld()->GetpTxtNode() ) && + pNd->GetNodes().IsDocNodes() ) { - const SwGetRefField& rRFld = *(SwGetRefField*)pFld->GetFld(); - switch( nTyp ) + const SwGetRefField& rRFld = *static_cast< SwGetRefField* >( pFld->GetFld() ); + switch ( nTyp ) { - case REF_BOOKMARK: - case REF_SETREFATTR: - bFnd = (*pNm == rRFld.GetSetRefName()) ? true : false; - break; - case REF_FOOTNOTE: - case REF_ENDNOTE: - bFnd = (nSeqNo == rRFld.GetSeqNo()) ? true : false; - break; - case REF_SEQUENCEFLD: break; // ??? - case REF_OUTLINE: break; // ??? + case REF_BOOKMARK: + case REF_SETREFATTR: + if ( pName && *pName == rRFld.GetSetRefName() ) + return true; + break; + case REF_FOOTNOTE: + case REF_ENDNOTE: + if ( nSeqNo == rRFld.GetSeqNo() ) + return true; + break; + case REF_SEQUENCEFLD: + break; // ??? + case REF_OUTLINE: + break; // ??? } } + } - return bFnd; + return false; } -String SwWW8Writer::GetBookmarkName( USHORT nTyp, const String* pNm, - USHORT nSeqNo ) +String MSWordExportBase::GetBookmarkName( USHORT nTyp, const String* pName, USHORT nSeqNo ) { String sRet; - switch( nTyp ) + switch ( nTyp ) { case REF_SETREFATTR: - sRet.APPEND_CONST_ASC( "Ref_" ); - sRet += *pNm; + if ( pName ) + { + sRet.APPEND_CONST_ASC( "Ref_" ); + sRet += *pName; + } break; case REF_SEQUENCEFLD: break; // ??? case REF_BOOKMARK: - sRet = *pNm; + if ( pName ) + sRet = *pName; break; case REF_OUTLINE: break; // ??? @@ -986,238 +937,307 @@ String SwWW8Writer::GetBookmarkName( USHORT nTyp, const String* pNm, //----------------------------------------------------------------------- /* */ /* File CHRATR.HXX: */ +void WW8AttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ) +{ + if ( m_rWW8Export.bWrtWW8 && bIsRTL ) + { + m_rWW8Export.InsUInt16( NS_sprm::LN_CFBiDi ); + m_rWW8Export.pO->Insert( (BYTE)1, m_rWW8Export.pO->Count() ); + } + + // #i46087# patch from james_clark; complex texts needs the undocumented SPRM CComplexScript with param 0x81. + if ( m_rWW8Export.bWrtWW8 && nScript == i18n::ScriptType::COMPLEX && !bIsRTL ) + { + m_rWW8Export.InsUInt16( NS_sprm::LN_CComplexScript ); + m_rWW8Export.pO->Insert( (BYTE)0x81, m_rWW8Export.pO->Count() ); + m_rWW8Export.pDop->bUseThaiLineBreakingRules = true; + } +} + +void WW8AttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ) +{ + m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), m_rWW8Export.pO->GetData() ); + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // delete + + if ( pTextNodeInfoInner.get() != NULL ) + { + if ( pTextNodeInfoInner->isEndOfLine() ) + { + TableRowEnd( pTextNodeInfoInner->getDepth() ); + + SVBT16 nSty; + ShortToSVBT16( m_rWW8Export.nStyleBeforeFly, nSty ); + m_rWW8Export.pO->Insert( (BYTE*)&nSty, 2, m_rWW8Export.pO->Count() ); // Style # + TableInfoRow( pTextNodeInfoInner ); + m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->Count(), + m_rWW8Export.pO->GetData() ); + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // delete + } + } +} + +void WW8AttributeOutput::StartRunProperties() +{ + WW8_WrPlcFld* pCurrentFields = m_rWW8Export.CurrentFieldPlc(); + m_nFieldResults = pCurrentFields ? pCurrentFields->ResultCount() : 0; +} -static Writer& OutWW8_SwBoldUSW(Writer& rWrt, BYTE nId, bool bVal) +void WW8AttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16(8 == nId ? 0x2a53 : 0x0835 + nId); + Redline( pRedlineData ); + + WW8_WrPlcFld* pCurrentFields = m_rWW8Export.CurrentFieldPlc(); + USHORT nNewFieldResults = pCurrentFields ? pCurrentFields->ResultCount() : 0; + + bool bExportedFieldResult = ( m_nFieldResults != nNewFieldResults ); + + // If we have exported a field result, then we will have been forced to + // split up the text into a 0x13, 0x14, <result> 0x15 sequence with the + // properties forced out at the end of the result, so the 0x15 itself + // should remain clean of all other attributes to avoid #iXXXXX# + if ( !bExportedFieldResult ) + { + m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), + m_rWW8Export.pO->Count(), m_rWW8Export.pO->GetData() ); + } + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // delete +} + +void WW8AttributeOutput::RunText( const String& rText, rtl_TextEncoding eCharSet ) +{ + RawText( rText, m_rWW8Export.bWrtWW8, eCharSet ); +} + +void WW8AttributeOutput::RawText( const String& rText, bool bForceUnicode, rtl_TextEncoding eCharSet ) +{ + m_rWW8Export.OutSwString( rText, 0, rText.Len(), bForceUnicode, eCharSet ); +} + +void WW8AttributeOutput::OutputFKP() +{ + if ( m_rWW8Export.pO->Count() ) + { + m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), + m_rWW8Export.pO->Count(), m_rWW8Export.pO->GetData() ); + m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); // delete + } +} + +void WW8AttributeOutput::ParagraphStyle( USHORT nStyle ) +{ + ASSERT( !m_rWW8Export.pO->Count(), " pO ist am ZeilenEnde nicht leer" ); + + SVBT16 nSty; + ShortToSVBT16( nStyle, nSty ); + m_rWW8Export.pO->Insert( (BYTE*)&nSty, 2, m_rWW8Export.pO->Count() ); // Style # +} + +void WW8AttributeOutput::OutputWW8Attribute( BYTE nId, bool bVal ) +{ + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( 8 == nId ? NS_sprm::LN_CFDStrike : NS_sprm::LN_CFBold + nId ); else if (8 == nId ) - return rWrt; // das Attribut gibt es im WW6 nicht + return; // no such attribute in WW6 else - rWrtWW8.pO->Insert( 85 + nId, rWrtWW8.pO->Count() ); - rWrtWW8.pO->Insert( bVal ? 1 : 0, rWrtWW8.pO->Count() ); - return rWrt; + m_rWW8Export.pO->Insert( 85 + nId, m_rWW8Export.pO->Count() ); + + m_rWW8Export.pO->Insert( bVal ? 1 : 0, m_rWW8Export.pO->Count() ); } -static Writer& OutWW8_SwBoldBiDiUSW(Writer& rWrt, BYTE nId, bool bVal) +void WW8AttributeOutput::OutputWW8AttributeCTL( BYTE nId, bool bVal ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - ASSERT(nId <= 1, "out of range"); - if (!rWrtWW8.bWrtWW8 || nId > 1) - return rWrt; + ASSERT( nId <= 1, "out of range" ); + if ( !m_rWW8Export.bWrtWW8 || nId > 1 ) + return; - rWrtWW8.InsUInt16(0x085C + nId); - rWrtWW8.pO->Insert(bVal ? 1 : 0, rWrtWW8.pO->Count()); - return rWrt; + m_rWW8Export.InsUInt16( NS_sprm::LN_CFBoldBi + nId ); + m_rWW8Export.pO->Insert( bVal ? 1 : 0, m_rWW8Export.pO->Count() ); } -static Writer& OutWW8_SwFont( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharFont( const SvxFontItem& rFont ) { - const SvxFontItem& rAttr = (const SvxFontItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - USHORT nFontID= rWrtWW8.GetId(rAttr); + USHORT nFontID = m_rWW8Export.GetId( rFont ); - if( rWrtWW8.bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) { - rWrtWW8.InsUInt16( 0x4a4f ); - rWrtWW8.InsUInt16( nFontID ); - rWrtWW8.InsUInt16( 0x4a51 ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc0 ); + m_rWW8Export.InsUInt16( nFontID ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc2 ); } else - rWrtWW8.pO->Insert( 93, rWrtWW8.pO->Count() ); - rWrtWW8.InsUInt16( nFontID ); - return rWrt; + m_rWW8Export.pO->Insert( 93, m_rWW8Export.pO->Count() ); + + m_rWW8Export.InsUInt16( nFontID ); } -static Writer& OutWW8_SwCTLFont(Writer& rWrt, const SfxPoolItem& rHt) +void WW8AttributeOutput::CharFontCTL( const SvxFontItem& rFont ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if (rWrtWW8.bWrtWW8) + if ( m_rWW8Export.bWrtWW8 ) { - rWrtWW8.InsUInt16(0x4A5E); - rWrtWW8.InsUInt16(rWrtWW8.GetId((const SvxFontItem&)rHt)); + m_rWW8Export.InsUInt16( NS_sprm::LN_CFtcBi ); + m_rWW8Export.InsUInt16( m_rWW8Export.GetId( rFont ) ); } - return rWrt; } -static Writer& OutWW8_SwCJKFont( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharFontCJK( const SvxFontItem& rFont ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) { - rWrtWW8.InsUInt16( 0x4a50 ); - rWrtWW8.InsUInt16(rWrtWW8.GetId((const SvxFontItem&)rHt)); + m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc1 ); + m_rWW8Export.InsUInt16( m_rWW8Export.GetId( rFont ) ); } - return rWrt; } -static Writer& OutWW8_SwBiDiWeight( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight ) { //Can only export in 8+, in 7- export as normal varient and expect that //upperlevel code has blocked exporting clobbering attributes - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if (rWrtWW8.bWrtWW8) + if (m_rWW8Export.bWrtWW8) { - OutWW8_SwBoldBiDiUSW(rWrt, 0, - WEIGHT_BOLD == ((const SvxWeightItem&)rHt).GetWeight()); + OutputWW8AttributeCTL( 0, WEIGHT_BOLD == rWeight.GetWeight()); } else { - OutWW8_SwBoldUSW(rWrt, 0, - WEIGHT_BOLD == ((const SvxWeightItem&)rHt).GetWeight()); + OutputWW8Attribute( 0, WEIGHT_BOLD == rWeight.GetWeight()); } - return rWrt; } -static Writer& OutWW8_SwBiDiPosture( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture ) { - //Can only export in 8+, in 7- export as normal varient and expect that - //upperlevel code has blocked exporting clobbering attributes - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if (rWrtWW8.bWrtWW8) + // Can only export in 8+, in 7- export as normal varient and expect that + // upperlevel code has blocked exporting clobbering attributes + if (m_rWW8Export.bWrtWW8) { - OutWW8_SwBoldBiDiUSW( rWrt, 1, - ITALIC_NONE != ((const SvxPostureItem&)rHt).GetPosture() ); + OutputWW8AttributeCTL( 1, ITALIC_NONE != rPosture.GetPosture() ); } else { - OutWW8_SwBoldUSW( rWrt, 1, - ITALIC_NONE != ((const SvxPostureItem&)rHt).GetPosture() ); + OutputWW8Attribute( 1, ITALIC_NONE != rPosture.GetPosture() ); } - return rWrt; } -static Writer& OutWW8_SwPosture( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharPosture( const SvxPostureItem& rPosture ) { - return OutWW8_SwBoldUSW( rWrt, 1, - ITALIC_NONE != ((const SvxPostureItem&)rHt).GetPosture() ); + OutputWW8Attribute( 1, ITALIC_NONE != rPosture.GetPosture() ); } -static Writer& OutWW8_SwWeight( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharWeight( const SvxWeightItem& rWeight ) { - return OutWW8_SwBoldUSW( rWrt, 0, - WEIGHT_BOLD == ((const SvxWeightItem&)rHt).GetWeight() ); + OutputWW8Attribute( 0, WEIGHT_BOLD == rWeight.GetWeight() ); } -// Shadowed und Contour gibts in WW-UI nicht. JP: ?? -static Writer& OutWW8_SwContour( Writer& rWrt, const SfxPoolItem& rHt ) +// Shadowed und Contour are not in WW-UI. JP: ?? +void WW8AttributeOutput::CharContour( const SvxContourItem& rContour ) { - return OutWW8_SwBoldUSW(rWrt, 3, - ((const SvxContourItem&)rHt).GetValue() ? true : false); + OutputWW8Attribute( 3, rContour.GetValue() ? true : false); } -static Writer& OutWW8_SwShadow( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharShadow( const SvxShadowedItem& rShadow ) { - return OutWW8_SwBoldUSW(rWrt, 4, - ((const SvxShadowedItem&)rHt).GetValue() ? true : false); + OutputWW8Attribute( 4, rShadow.GetValue() ? true : false); } -static Writer& OutWW8_SwKerning( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharKerning( const SvxKerningItem& rKerning ) { - const SvxKerningItem& rAttr = (const SvxKerningItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x8840 ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_CDxaSpace ); else - rWrtWW8.pO->Insert( 96, rWrtWW8.pO->Count() ); - rWrtWW8.InsUInt16( rAttr.GetValue() ); - return rWrt; + m_rWW8Export.pO->Insert( 96, m_rWW8Export.pO->Count() ); + + m_rWW8Export.InsUInt16( rKerning.GetValue() ); } -static Writer& OutWW8_SvxAutoKern( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharAutoKern( const SvxAutoKernItem& rAutoKern ) { - const SvxAutoKernItem& rAttr = (const SvxAutoKernItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x484B ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_CHpsKern ); else - rWrtWW8.pO->Insert( 107, rWrtWW8.pO->Count() ); - rWrtWW8.InsUInt16( rAttr.GetValue() ? 1 : 0 ); - return rWrt; + m_rWW8Export.pO->Insert( 107, m_rWW8Export.pO->Count() ); + + m_rWW8Export.InsUInt16( rAutoKern.GetValue() ? 1 : 0 ); } -static Writer& OutWW8_SwAnimatedText( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink ) { - const SvxBlinkItem& rAttr = (const SvxBlinkItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) { - rWrtWW8.InsUInt16( 0x2859 ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CSfxText ); // At the moment the only animated text effect we support is blinking - rWrtWW8.InsUInt16( rAttr.GetValue() ? 2 : 0 ); + m_rWW8Export.InsUInt16( rBlink.GetValue() ? 2 : 0 ); } - return rWrt; } - -static Writer& OutWW8_SwCrossedOut( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossed ) { - FontStrikeout eSt = ((const SvxCrossedOutItem&)rHt).GetStrikeout(); - if( STRIKEOUT_DOUBLE == eSt ) - return OutWW8_SwBoldUSW(rWrt, 8, true); - if( STRIKEOUT_NONE != eSt ) - return OutWW8_SwBoldUSW(rWrt, 2, true); + FontStrikeout eSt = rCrossed.GetStrikeout(); + if ( STRIKEOUT_DOUBLE == eSt ) + { + OutputWW8Attribute( 8, true ); + return; + } + if ( STRIKEOUT_NONE != eSt ) + { + OutputWW8Attribute( 2, true ); + return; + } - // dann auch beide ausschalten! - OutWW8_SwBoldUSW(rWrt, 8, false); - return OutWW8_SwBoldUSW(rWrt, 2, false); + // otherwise both off + OutputWW8Attribute( 8, false ); + OutputWW8Attribute( 2, false ); } -static Writer& OutWW8_SwCaseMap( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap ) { - USHORT eSt = ((const SvxCaseMapItem&)rHt).GetValue(); - switch (eSt) + USHORT eSt = rCaseMap.GetValue(); + switch ( eSt ) { case SVX_CASEMAP_KAPITAELCHEN: - return OutWW8_SwBoldUSW(rWrt, 5, true); + OutputWW8Attribute( 5, true ); + return; case SVX_CASEMAP_VERSALIEN: - return OutWW8_SwBoldUSW(rWrt, 6, true); + OutputWW8Attribute( 6, true ); + return; case SVX_CASEMAP_TITEL: - //NO such feature in word + // no such feature in word break; default: - // dann auch beide ausschalten! - OutWW8_SwBoldUSW(rWrt, 5, false); - return OutWW8_SwBoldUSW(rWrt, 6, false); + // otherwise both off + OutputWW8Attribute( 5, false ); + OutputWW8Attribute( 6, false ); + return; } - return rWrt; } -static Writer& OutWW8_SvxCharHidden(Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden ) { - OutWW8_SwBoldUSW(rWrt, 7, (item_cast<SvxCharHiddenItem>(rHt)).GetValue()); - return rWrt; + OutputWW8Attribute( 7, rHidden.GetValue() ); } -static Writer& OutWW8_SwUnderline( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline ) { - const SvxUnderlineItem& rAttr = (const SvxUnderlineItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x2A3E ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_CKul ); else - rWrtWW8.pO->Insert( 94, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( 94, m_rWW8Export.pO->Count() ); - const SfxPoolItem* pItem = ((SwWW8Writer&)rWrt).HasItem( - RES_CHRATR_WORDLINEMODE ); + const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_CHRATR_WORDLINEMODE ); bool bWord = false; if (pItem) bWord = ((const SvxWordLineModeItem*)pItem)->GetValue() ? true : false; - // WW95 - parameters: 0 = none, 1 = single, 2 = by Word, - // 3 = double, 4 = dotted, 5 = hidden - // WW97 - additional parameters: - // 6 = thick, 7 = dash, 8 = dot(not used) - // 9 = dotdash 10 = dotdotdash, 11 = wave + // WW95 - parameters: 0 = none, 1 = single, 2 = by Word, + // 3 = double, 4 = dotted, 5 = hidden + // WW97 - additional parameters: + // 6 = thick, 7 = dash, 8 = dot(not used) + // 9 = dotdash 10 = dotdotdash, 11 = wave BYTE b = 0; - switch (rAttr.GetLineStyle()) + switch ( rUnderline.GetLineStyle() ) { case UNDERLINE_SINGLE: b = ( bWord ) ? 2 : 1; break; case UNDERLINE_BOLD: - b = rWrtWW8.bWrtWW8 ? 6 : 1; + b = m_rWW8Export.bWrtWW8 ? 6 : 1; break; case UNDERLINE_DOUBLE: b = 3; @@ -1226,286 +1246,265 @@ static Writer& OutWW8_SwUnderline( Writer& rWrt, const SfxPoolItem& rHt ) b = 4; break; case UNDERLINE_DASH: - b = rWrtWW8.bWrtWW8 ? 7 : 4; + b = m_rWW8Export.bWrtWW8 ? 7 : 4; break; case UNDERLINE_DASHDOT: - b = rWrtWW8.bWrtWW8 ? 9 : 4; + b = m_rWW8Export.bWrtWW8 ? 9 : 4; break; case UNDERLINE_DASHDOTDOT: - b = rWrtWW8.bWrtWW8 ? 10 : 4; + b = m_rWW8Export.bWrtWW8 ? 10 : 4; break; case UNDERLINE_WAVE: - b = rWrtWW8.bWrtWW8 ? 11 : 3; + b = m_rWW8Export.bWrtWW8 ? 11 : 3; break; // ------------ new in WW2000 ------------------------------------- case UNDERLINE_BOLDDOTTED: - b = rWrtWW8.bWrtWW8 ? 20 : 4; + b = m_rWW8Export.bWrtWW8 ? 20 : 4; break; case UNDERLINE_BOLDDASH: - b = rWrtWW8.bWrtWW8 ? 23 : 4; + b = m_rWW8Export.bWrtWW8 ? 23 : 4; break; case UNDERLINE_LONGDASH: - b = rWrtWW8.bWrtWW8 ? 39 : 4; + b = m_rWW8Export.bWrtWW8 ? 39 : 4; break; case UNDERLINE_BOLDLONGDASH: - b = rWrtWW8.bWrtWW8 ? 55 : 4; + b = m_rWW8Export.bWrtWW8 ? 55 : 4; break; case UNDERLINE_BOLDDASHDOT: - b = rWrtWW8.bWrtWW8 ? 25 : 4; + b = m_rWW8Export.bWrtWW8 ? 25 : 4; break; case UNDERLINE_BOLDDASHDOTDOT: - b = rWrtWW8.bWrtWW8 ? 26 : 4; + b = m_rWW8Export.bWrtWW8 ? 26 : 4; break; case UNDERLINE_BOLDWAVE: - b = rWrtWW8.bWrtWW8 ? 27 : 3; + b = m_rWW8Export.bWrtWW8 ? 27 : 3; break; case UNDERLINE_DOUBLEWAVE: - b = rWrtWW8.bWrtWW8 ? 43 : 3; + b = m_rWW8Export.bWrtWW8 ? 43 : 3; break; case UNDERLINE_NONE: b = 0; break; default: - ASSERT(rAttr.GetLineStyle() == UNDERLINE_NONE, "Unhandled underline type"); + ASSERT( rUnderline.GetLineStyle() == UNDERLINE_NONE, "Unhandled underline type" ); break; } - rWrtWW8.pO->Insert(b, rWrtWW8.pO->Count()); - return rWrt; + m_rWW8Export.pO->Insert( b, m_rWW8Export.pO->Count() ); } -static Writer& OutWW8_SwLanguage( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage ) { USHORT nId = 0; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if (rWrtWW8.bWrtWW8) + if ( m_rWW8Export.bWrtWW8 ) { - switch (rHt.Which()) + switch ( rLanguage.Which() ) { case RES_CHRATR_LANGUAGE: - nId = 0x486D; + nId = NS_sprm::LN_CRgLid0; break; case RES_CHRATR_CJK_LANGUAGE: - nId = 0x486E; + nId = NS_sprm::LN_CRgLid1; break; case RES_CHRATR_CTL_LANGUAGE: - nId = 0x485F; + nId = NS_sprm::LN_CLidBi; break; } } else nId = 97; - if (nId) + if ( nId ) { - if (rWrtWW8.bWrtWW8) // use sprmCRgLid0 rather than sprmCLid - rWrtWW8.InsUInt16(nId); + if ( m_rWW8Export.bWrtWW8 ) // use sprmCRgLid0 rather than sprmCLid + m_rWW8Export.InsUInt16( nId ); else - rWrtWW8.pO->Insert((BYTE)nId, rWrtWW8.pO->Count()); - rWrtWW8.InsUInt16(((const SvxLanguageItem&)rHt).GetLanguage()); + m_rWW8Export.pO->Insert( (BYTE)nId, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( rLanguage.GetLanguage() ); - //unknown as to exactly why, but this seems to shadow the other - //paramater in word 2000 and without it spellchecking doesn't work - if (nId == 0x486D) + // unknown as to exactly why, but this seems to shadow the other + // paramater in word 2000 and without it spellchecking doesn't work + if ( nId == NS_sprm::LN_CRgLid0 ) { - rWrtWW8.InsUInt16(0x4873); - rWrtWW8.InsUInt16(((const SvxLanguageItem&)rHt).GetLanguage()); + m_rWW8Export.InsUInt16( 0x4873 ); + m_rWW8Export.InsUInt16( rLanguage.GetLanguage() ); } - else if (nId == 0x485F) + else if ( nId == NS_sprm::LN_CLidBi ) { - rWrtWW8.InsUInt16(0x4874); - rWrtWW8.InsUInt16(((const SvxLanguageItem&)rHt).GetLanguage()); + m_rWW8Export.InsUInt16( 0x4874 ); + m_rWW8Export.InsUInt16( rLanguage.GetLanguage() ); } } - return rWrt; } -static Writer& OutWW8_SwEscapement( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement ) { - const SvxEscapementItem& rAttr = (const SvxEscapementItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - BYTE b = 0xFF; - short nEsc = rAttr.GetEsc(), nProp = rAttr.GetProp(); - if( !nEsc ) + short nEsc = rEscapement.GetEsc(), nProp = rEscapement.GetProp(); + if ( !nEsc ) { b = 0; nEsc = 0; nProp = 100; } - else if( DFLT_ESC_PROP == nProp ) + else if ( DFLT_ESC_PROP == nProp ) { - if( DFLT_ESC_SUB == nEsc || DFLT_ESC_AUTO_SUB == nEsc ) + if ( DFLT_ESC_SUB == nEsc || DFLT_ESC_AUTO_SUB == nEsc ) b = 2; - else if( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc ) + else if ( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc ) b = 1; } - if( 0xFF != b ) + if ( 0xFF != b ) { - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x2A48 ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_CIss ); else - rWrtWW8.pO->Insert( 104, rWrtWW8.pO->Count() ); - rWrtWW8.pO->Insert( b, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( 104, m_rWW8Export.pO->Count() ); + + m_rWW8Export.pO->Insert( b, m_rWW8Export.pO->Count() ); } - if( 0 == b || 0xFF == b ) + if ( 0 == b || 0xFF == b ) { - long nHeight = ((SvxFontHeightItem&)rWrtWW8.GetItem( + long nHeight = ((SvxFontHeightItem&)m_rWW8Export.GetItem( RES_CHRATR_FONTSIZE )).GetHeight(); - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x4845 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_CHpsPos ); else - rWrtWW8.pO->Insert( 101, rWrtWW8.pO->Count() ); - rWrtWW8.InsUInt16( (short)(( nHeight * nEsc + 500 ) / 1000 )); + m_rWW8Export.pO->Insert( 101, m_rWW8Export.pO->Count() ); + + m_rWW8Export.InsUInt16( (short)(( nHeight * nEsc + 500 ) / 1000 )); if( 100 != nProp || !b ) { - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x4A43 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_CHps ); else - rWrtWW8.pO->Insert( 99, rWrtWW8.pO->Count() ); - rWrtWW8.InsUInt16( - msword_cast<sal_uInt16>((nHeight * nProp + 500 ) / 1000)); + m_rWW8Export.pO->Insert( 99, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( + msword_cast<sal_uInt16>((nHeight * nProp + 500 ) / 1000)); } } - return rWrt; } -static Writer& OutWW8_SwSize( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharFontSize( const SvxFontHeightItem& rHeight ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; USHORT nId = 0; - if (rWrtWW8.bWrtWW8) + if ( m_rWW8Export.bWrtWW8 ) { - switch (rHt.Which()) + switch ( rHeight.Which() ) { case RES_CHRATR_FONTSIZE: case RES_CHRATR_CJK_FONTSIZE: - nId = 0x4A43; + nId = NS_sprm::LN_CHps; break; case RES_CHRATR_CTL_FONTSIZE: - nId = 0x4A61; + nId = NS_sprm::LN_CHpsBi; break; } } else nId = 99; - if( nId ) + if ( nId ) { - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( nId ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( nId ); else - rWrtWW8.pO->Insert( (BYTE)nId, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( (BYTE)nId, m_rWW8Export.pO->Count() ); - const SvxFontHeightItem& rAttr = (const SvxFontHeightItem&)rHt; - rWrtWW8.InsUInt16( (UINT16)(( rAttr.GetHeight() + 5 ) / 10 ) ); + m_rWW8Export.InsUInt16( (UINT16)(( rHeight.GetHeight() + 5 ) / 10 ) ); } - return rWrt; } -static Writer& OutWW8_ScaleWidth( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) { - rWrtWW8.InsUInt16( 0x4852 ); - rWrtWW8.InsUInt16( ((SvxCharScaleWidthItem&)rHt).GetValue() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CCharScale ); + m_rWW8Export.InsUInt16( rScaleWidth.GetValue() ); } - return rWrt; } -static Writer& OutWW8_Relief( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharRelief( const SvxCharReliefItem& rRelief ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) { - const SvxCharReliefItem& rAttr = (const SvxCharReliefItem&)rHt; USHORT nId; - switch ( rAttr.GetValue() ) + switch ( rRelief.GetValue() ) { - case RELIEF_EMBOSSED: nId = 0x858; break; - case RELIEF_ENGRAVED: nId = 0x854; break; - default: nId = 0; break; + case RELIEF_EMBOSSED: nId = NS_sprm::LN_CFEmboss; break; + case RELIEF_ENGRAVED: nId = NS_sprm::LN_CFImprint; break; + default: nId = 0; break; } if( nId ) { - rWrtWW8.InsUInt16( nId ); - rWrtWW8.pO->Insert( (BYTE)0x81, rWrtWW8.pO->Count() ); + m_rWW8Export.InsUInt16( nId ); + m_rWW8Export.pO->Insert( (BYTE)0x81, m_rWW8Export.pO->Count() ); } else { // switch both flags off - rWrtWW8.InsUInt16( 0x858 ); - rWrtWW8.pO->Insert( (BYTE)0x0, rWrtWW8.pO->Count() ); - rWrtWW8.InsUInt16( 0x854 ); - rWrtWW8.pO->Insert( (BYTE)0x0, rWrtWW8.pO->Count() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CFEmboss ); + m_rWW8Export.pO->Insert( (BYTE)0x0, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CFImprint ); + m_rWW8Export.pO->Insert( (BYTE)0x0, m_rWW8Export.pO->Count() ); } } - return rWrt; } - -static Writer& OutWW8_CharRotate( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharRotate( const SvxCharRotateItem& rRotate ) { // #i28331# - check that a Value is set - if((static_cast<const SvxCharRotateItem&>(rHt)).GetValue()) + if ( !rRotate.GetValue() ) + return; + + if ( m_rWW8Export.bWrtWW8 && !m_rWW8Export.bIsInTable ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 && !rWrtWW8.bIsInTable ) - { - // #i36867 In word the text in a table is rotated via the TC or 0x7629 - // This means you can only rotate all or none of the text adding 0xCA78 - // here corrupts the table, hence !rWrtWW8.bIsInTable - const SvxCharRotateItem& rAttr = (const SvxCharRotateItem&)rHt; - - rWrtWW8.InsUInt16( 0xCA78 ); - rWrtWW8.pO->Insert( (BYTE)0x06, rWrtWW8.pO->Count() ); //len 6 - rWrtWW8.pO->Insert( (BYTE)0x01, rWrtWW8.pO->Count() ); - - rWrtWW8.InsUInt16( rAttr.IsFitToLine() ? 1 : 0 ); - static const BYTE aZeroArr[ 3 ] = { 0, 0, 0 }; - rWrtWW8.pO->Insert( aZeroArr, 3, rWrtWW8.pO->Count() ); - } + // #i36867 In word the text in a table is rotated via the TC or NS_sprm::LN_TTextFlow + // This means you can only rotate all or none of the text adding NS_sprm::LN_CEastAsianLayout + // here corrupts the table, hence !m_rWW8Export.bIsInTable + + m_rWW8Export.InsUInt16( NS_sprm::LN_CEastAsianLayout ); + m_rWW8Export.pO->Insert( (BYTE)0x06, m_rWW8Export.pO->Count() ); //len 6 + m_rWW8Export.pO->Insert( (BYTE)0x01, m_rWW8Export.pO->Count() ); + + m_rWW8Export.InsUInt16( rRotate.IsFitToLine() ? 1 : 0 ); + static const BYTE aZeroArr[ 3 ] = { 0, 0, 0 }; + m_rWW8Export.pO->Insert( aZeroArr, 3, m_rWW8Export.pO->Count() ); } - return rWrt; } - -static Writer& OutWW8_EmphasisMark( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) + if ( m_rWW8Export.bWrtWW8 ) { BYTE nVal; - switch ( ((const SvxEmphasisMarkItem&)rHt).GetValue() ) + switch ( rEmphasisMark.GetValue() ) { - case EMPHASISMARK_NONE: nVal = 0; break; - case EMPHASISMARK_SIDE_DOTS: nVal = 2; break; - case EMPHASISMARK_CIRCLE_ABOVE: nVal = 3; break; - case EMPHASISMARK_DOTS_BELOW: nVal = 4; break; -// case 1: - default: nVal = 1; break; + case EMPHASISMARK_NONE: nVal = 0; break; + case EMPHASISMARK_SIDE_DOTS: nVal = 2; break; + case EMPHASISMARK_CIRCLE_ABOVE: nVal = 3; break; + case EMPHASISMARK_DOTS_BELOW: nVal = 4; break; + // case 1: + default: nVal = 1; break; } - rWrtWW8.InsUInt16( 0x2A34 ); - rWrtWW8.pO->Insert( nVal, rWrtWW8.pO->Count() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CKcd ); + m_rWW8Export.pO->Insert( nVal, m_rWW8Export.pO->Count() ); } - return rWrt; } - // TransCol uebersetzt SW-Farben in WW. Heraus kommt die bei WW fuer // Text- und Hintergrundfarbe benutzte Codierung. // Gibt es keine direkte Entsprechung, dann wird versucht, eine moeglichst // aehnliche WW-Farbe zu finden. // return: 5-Bit-Wert ( 0..16 ) -BYTE SwWW8Writer::TransCol( const Color& rCol ) +BYTE WW8Export::TransCol( const Color& rCol ) { BYTE nCol = 0; // ->Auto switch( rCol.GetColor() ) @@ -1554,7 +1553,7 @@ BYTE SwWW8Writer::TransCol( const Color& rCol ) // Return: Echte Brush ( nicht transparent ) // auch bei Transparent wird z.B. fuer Tabellen eine transparente Brush // geliefert -bool SwWW8Writer::TransBrush(const Color& rCol, WW8_SHD& rShd) +bool WW8Export::TransBrush(const Color& rCol, WW8_SHD& rShd) { if( rCol.GetTransparency() ) rShd = WW8_SHD(); // alles Nullen : transparent @@ -1574,77 +1573,66 @@ sal_uInt32 SuitableBGColor(sal_uInt32 nIn) return wwUtility::RGBToBGR(nIn); } -static Writer& OutWW8_SwColor( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharColor( const SvxColorItem& rColor ) { - const SvxColorItem& rAttr = (const SvxColorItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if (rWrtWW8.bWrtWW8) - rWrtWW8.InsUInt16(0x2A42); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_CIco ); else - rWrtWW8.pO->Insert(98, rWrtWW8.pO->Count()); + m_rWW8Export.pO->Insert( 98, m_rWW8Export.pO->Count() ); - BYTE nColour = rWrtWW8.TransCol(rAttr.GetValue()); - rWrtWW8.pO->Insert(nColour, rWrtWW8.pO->Count()); + BYTE nColor = m_rWW8Export.TransCol( rColor.GetValue() ); + m_rWW8Export.pO->Insert( nColor, m_rWW8Export.pO->Count() ); - if (rWrtWW8.bWrtWW8 && nColour) + if ( m_rWW8Export.bWrtWW8 && nColor ) { - rWrtWW8.InsUInt16(0x6870); - rWrtWW8.InsUInt32(wwUtility::RGBToBGR(rAttr.GetValue().GetColor())); + m_rWW8Export.InsUInt16( 0x6870 ); + m_rWW8Export.InsUInt32( wwUtility::RGBToBGR( rColor.GetValue().GetColor() ) ); } - return rWrt; } -static Writer& OutWW8_SwFmtCharBackground( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharBackground( const SvxBrushItem& rBrush ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - - if( rWW8Wrt.bWrtWW8 ) // nur WW8 kann ZeichenHintergrund + if( m_rWW8Export.bWrtWW8 ) // nur WW8 kann ZeichenHintergrund { - const SvxBrushItem& rBack = (const SvxBrushItem&)rHt; WW8_SHD aSHD; - rWW8Wrt.TransBrush(rBack.GetColor(), aSHD); + m_rWW8Export.TransBrush( rBrush.GetColor(), aSHD ); // sprmCShd - rWW8Wrt.InsUInt16( 0x4866 ); - rWW8Wrt.InsUInt16( aSHD.GetValue() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CShd ); + m_rWW8Export.InsUInt16( aSHD.GetValue() ); //Quite a few unknowns, some might be transparency or something //of that nature... - rWW8Wrt.InsUInt16(0xCA71); - rWW8Wrt.pO->Insert(10, rWW8Wrt.pO->Count()); - rWW8Wrt.InsUInt32(0xFF000000); - rWW8Wrt.InsUInt32(SuitableBGColor(rBack.GetColor().GetColor())); - rWW8Wrt.InsUInt16(0x0000); + m_rWW8Export.InsUInt16( 0xCA71 ); + m_rWW8Export.pO->Insert( 10, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt32( 0xFF000000 ); + m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor().GetColor() ) ); + m_rWW8Export.InsUInt16( 0x0000); } - return rWrt; } -static Writer& OutSwFmtINetFmt( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::TextINetFormat( const SwFmtINetFmt& rINet ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - const SwFmtINetFmt& rINet = (SwFmtINetFmt&)rHt; - - if( rINet.GetValue().Len() ) + if ( rINet.GetValue().Len() ) { USHORT nId; const String& rStr = rINet.GetINetFmt(); - if( rStr.Len() ) + if ( rStr.Len() ) nId = rINet.GetINetFmtId(); else nId = RES_POOLCHR_INET_NORMAL; const SwCharFmt* pFmt = IsPoolUserFmt( nId ) - ? rWrt.pDoc->FindCharFmtByName( rStr ) - : rWrt.pDoc->GetCharFmtFromPool( nId ); + ? m_rWW8Export.pDoc->FindCharFmtByName( rStr ) + : m_rWW8Export.pDoc->GetCharFmtFromPool( nId ); - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x4A30 ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_CIstd ); else - rWrtWW8.pO->Insert( 80, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( 80, m_rWW8Export.pO->Count() ); - rWrtWW8.InsUInt16( rWrtWW8.GetId( *pFmt ) ); + m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *pFmt ) ); } - return rWrt; } // --> OD 2005-06-08 #i43956# - add optional parameter <pLinkStr> @@ -1652,7 +1640,7 @@ static Writer& OutSwFmtINetFmt( Writer& rWrt, const SfxPoolItem& rHt ) // - it contains the name of the link target, which is a bookmark. // --> OD 2008-08-14 #158418# - add optional parameter <bIncludeEmptyPicLocation> // It is needed to write an empty picture location for page number field separators -static void InsertSpecialChar( SwWW8Writer& rWrt, BYTE c, +static void InsertSpecialChar( WW8Export& rWrt, BYTE c, String* pLinkStr = 0L, bool bIncludeEmptyPicLocation = false ) { @@ -1672,7 +1660,7 @@ static void InsertSpecialChar( SwWW8Writer& rWrt, BYTE c, if ( bIncludeEmptyPicLocation && ( c == 0x13 || c == 0x14 || c == 0x15 ) ) { - SwWW8Writer::InsUInt16( aItems, 0x6a03 ); + SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CPicLocation ); SwWW8Writer::InsUInt32( aItems, 0x00000000 ); } // <-- @@ -1714,11 +1702,11 @@ static void InsertSpecialChar( SwWW8Writer& rWrt, BYTE c, rStrm.Seek( nCurrPos ); // write attributes of hyperlink character 0x01 - SwWW8Writer::InsUInt16( aItems, 0x0802 ); //sprmCFFldVanish + SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFFldVanish ); aItems.Insert( (BYTE)0x81, aItems.Count() ); - SwWW8Writer::InsUInt16( aItems, 0x6a03 ); + SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CPicLocation ); SwWW8Writer::InsUInt32( aItems, nLinkPosInDataStrm ); - SwWW8Writer::InsUInt16( aItems, 0x0806 ); + SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFData ); aItems.Insert( (BYTE)0x01, aItems.Count() ); } @@ -1729,7 +1717,7 @@ static void InsertSpecialChar( SwWW8Writer& rWrt, BYTE c, // fSpec-Attribute true if( rWrt.bWrtWW8 ) { - SwWW8Writer::InsUInt16( aItems, 0x855 ); //sprmCFSpec + SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFSpec ); aItems.Insert( 1, aItems.Count() ); } else @@ -1752,7 +1740,7 @@ String lcl_GetExpandedField(const SwField &rFld) return sRet; } -WW8_WrPlcFld* SwWW8Writer::CurrentFieldPlc() const +WW8_WrPlcFld* WW8Export::CurrentFieldPlc() const { WW8_WrPlcFld* pFldP = NULL; switch (nTxtTyp) @@ -1784,8 +1772,8 @@ WW8_WrPlcFld* SwWW8Writer::CurrentFieldPlc() const return pFldP; } -void SwWW8Writer::OutField(const SwField* pFld, ww::eField eFldType, - const String& rFldCmd, BYTE nMode) +void WW8Export::OutputField( const SwField* pFld, ww::eField eFldType, + const String& rFldCmd, BYTE nMode ) { bool bUnicode = IsUnicode(); WW8_WrPlcFld* pFldP = CurrentFieldPlc(); @@ -1891,16 +1879,16 @@ void SwWW8Writer::OutField(const SwField* pFld, ww::eField eFldType, BYTE aArr[12]; BYTE *pArr = aArr; - if( bWrtWW8 ) + if ( bWrtWW8 ) { - Set_UInt16(pArr, 0x6a03); //sprmCPicLocation - Set_UInt32(pArr, 0x0); + Set_UInt16( pArr, NS_sprm::LN_CPicLocation ); + Set_UInt32( pArr, 0x0 ); - Set_UInt16( pArr, 0x855 );//sprmCFSpec + Set_UInt16( pArr, NS_sprm::LN_CFSpec ); Set_UInt8( pArr, 1 ); - Set_UInt16( pArr, 0x875 );//sprmCFNoProof - Set_UInt8(pArr, 1); + Set_UInt16( pArr, NS_sprm::LN_CFNoProof ); + Set_UInt8( pArr, 1 ); } else { @@ -1910,7 +1898,7 @@ void SwWW8Writer::OutField(const SwField* pFld, ww::eField eFldType, Set_UInt8( pArr, 117 ); //sprmCFSpec Set_UInt8( pArr, 1 ); } - pChpPlc->AppendFkpEntry( pStrm->Tell(), static_cast< short >(pArr - aArr), aArr ); + pChpPlc->AppendFkpEntry( Strm().Tell(), static_cast< short >(pArr - aArr), aArr ); } } } @@ -1938,25 +1926,25 @@ void SwWW8Writer::OutField(const SwField* pFld, ww::eField eFldType, } } -void SwWW8Writer::StartCommentOutput(const String& rName) +void WW8Export::StartCommentOutput(const String& rName) { String sStr(FieldString(ww::eQUOTE)); sStr.APPEND_CONST_ASC("["); sStr += rName; sStr.APPEND_CONST_ASC("] "); - OutField(0, ww::eQUOTE, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START); + OutputField(0, ww::eQUOTE, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START); } -void SwWW8Writer::EndCommentOutput(const String& rName) +void WW8Export::EndCommentOutput(const String& rName) { String sStr(CREATE_CONST_ASC(" [")); sStr += rName; sStr.APPEND_CONST_ASC("] "); - OutField(0, ww::eQUOTE, sStr, WRITEFIELD_CMD_END | WRITEFIELD_END | + OutputField(0, ww::eQUOTE, sStr, WRITEFIELD_CMD_END | WRITEFIELD_END | WRITEFIELD_CLOSE); } -USHORT SwWW8Writer::GetId( const SwTOXType& rTOXType ) +USHORT MSWordExportBase::GetId( const SwTOXType& rTOXType ) { void* p = (void*)&rTOXType; USHORT nRet = aTOXArr.GetPos( p ); @@ -2052,9 +2040,9 @@ bool lcl_IsHyperlinked(const SwForm& rForm, USHORT nTOXLvl) return bRes; } -void SwWW8Writer::StartTOX( const SwSection& rSect ) +void AttributeOutputBase::StartTOX( const SwSection& rSect ) { - if (const SwTOXBase* pTOX = rSect.GetTOXBase()) + if ( const SwTOXBase* pTOX = rSect.GetTOXBase() ) { static const sal_Char sEntryEnd[] = "\" "; @@ -2136,10 +2124,9 @@ void SwWW8Writer::StartTOX( const SwSection& rSect ) if( TOX_USER == pTOX->GetType() ) { sStr += '\"'; - sStr += (sal_Char)('A' + GetId( *pTOX->GetTOXType())); + sStr += (sal_Char)( 'A' + GetExport( ).GetId( *pTOX->GetTOXType() ) ); sStr.AppendAscii( sEntryEnd ); } - } if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() ) { @@ -2151,7 +2138,7 @@ void SwWW8Writer::StartTOX( const SwSection& rSect ) // // (ignoring headline styles 1-9) // //BYTE nLvl = 0, nMinLvl = 0; //#outline level, removed by zhaojianwei // int nLvl = 0, nMinLvl = 0; //<-end,add by zhaojianwei -// const SwTxtFmtColls& rColls = *pDoc->GetTxtFmtColls(); +// const SwTxtFmtColls& rColls = *GetExport().pDoc->GetTxtFmtColls(); // const SwTxtFmtColl* pColl; // for( n = rColls.Count(); n; ) // { @@ -2215,7 +2202,86 @@ void SwWW8Writer::StartTOX( const SwSection& rSect ) // } // } // } + } + + + if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() ) + { + // Take the TOC value of the max level to evaluate to as + // the starting point for the \o flag, but reduce it to the + // value of the highest outline level filled by a *standard* + // Heading 1 - 9 style because \o "Builds a table of + // contents from paragraphs formatted with built-in heading + // styles". And afterward fill in any outline styles left + // uncovered by that range to the \t flag + // + // i.e. for + // Heading 1 + // Heading 2 + // custom-style + // Heading 4 + // output + // \o 1-2 \tcustom-style,3,Heading 3,4 + + // Search over all the outline styles used and figure out + // what is the minimum outline level (if any) filled by a + // non-standard style for that level, i.e. ignore headline + // styles 1-9 and find the lowest valid outline level + BYTE nPosOfLowestNonStandardLvl = MAXLEVEL; + const SwTxtFmtColls& rColls = *GetExport().pDoc->GetTxtFmtColls(); + for( n = rColls.Count(); n; ) + { + const SwTxtFmtColl* pColl = rColls[ --n ]; + USHORT nPoolId = pColl->GetPoolFmtId(); + if ( + //Is a Non-Standard Outline Style + (RES_POOLCOLL_HEADLINE1 > nPoolId || RES_POOLCOLL_HEADLINE9 < nPoolId) && + //Has a valid outline level + (pColl->IsAssignedToListLevelOfOutlineStyle()) && + // Is less than the lowest known non-standard level + (pColl->GetAssignedOutlineStyleLevel() < nPosOfLowestNonStandardLvl) + ) + { + nPosOfLowestNonStandardLvl = ::sal::static_int_cast<BYTE>(pColl->GetAssignedOutlineStyleLevel()); + } + } + + BYTE nMaxMSAutoEvaluate = nPosOfLowestNonStandardLvl < nTOXLvl ? nPosOfLowestNonStandardLvl : (BYTE)nTOXLvl; + + //output \o 1-X where X is the highest normal outline style to be included in the toc + if ( nMaxMSAutoEvaluate ) + { + if (nMaxMSAutoEvaluate > WW8ListManager::nMaxLevel) + nMaxMSAutoEvaluate = WW8ListManager::nMaxLevel; + + sStr.APPEND_CONST_ASC( "\\o \"1-" ); + sStr += String::CreateFromInt32( nMaxMSAutoEvaluate ); + sStr.AppendAscii(sEntryEnd); + } + + //collect up any other styles in the writer TOC which will + //not already appear in the MS TOC and place then into the + //\t option + if( nMaxMSAutoEvaluate < nTOXLvl ) + { + // collect this templates into the \t otion + for( n = rColls.Count(); n;) + { + const SwTxtFmtColl* pColl = rColls[ --n ]; + if (!pColl->IsAssignedToListLevelOfOutlineStyle()) + continue; + BYTE nTestLvl = ::sal::static_int_cast<BYTE>(pColl->GetAssignedOutlineStyleLevel()); + if (nTestLvl < nTOXLvl && nTestLvl >= nMaxMSAutoEvaluate) + { + if( sTOption.Len() ) + sTOption += ','; + (( sTOption += pColl->GetName() ) += ',' ) + += String::CreateFromInt32( nTestLvl + 1 ); + } + } + } + } if( nsSwTOXElement::TOX_TEMPLATE & pTOX->GetCreateType() ) // --> OD 2009-02-27 #i99641# @@ -2227,16 +2293,20 @@ void SwWW8Writer::StartTOX( const SwSection& rSect ) if( rStyles.Len() ) { xub_StrLen nPos = 0; - String sLvl( ';' ); + String sLvl( ',' ); sLvl += String::CreateFromInt32( n + 1 ); do { String sStyle( rStyles.GetToken( 0, TOX_STYLE_DELIMITER, nPos )); if( sStyle.Len() ) { - if( sTOption.Len() ) - sTOption += ';'; - ( sTOption += sStyle ) += sLvl; + SwTxtFmtColl* pColl = GetExport().pDoc->FindTxtFmtCollByName(sStyle); + if (!pColl->IsAssignedToListLevelOfOutlineStyle() || pColl->GetAssignedOutlineStyleLevel() < nTOXLvl) + { + if( sTOption.Len() ) + sTOption += ','; + ( sTOption += sStyle ) += sLvl; + } } } while( STRING_NOTFOUND != nPos ); } @@ -2303,30 +2373,32 @@ void SwWW8Writer::StartTOX( const SwSection& rSect ) sStr.APPEND_CONST_ASC("\\h"); } break; + } } if( sStr.Len() ) { - bInWriteTOX = true; - OutField(0, eCode, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START | - WRITEFIELD_CMD_END); + GetExport( ).bInWriteTOX = true; + GetExport( ).OutputField( 0, eCode, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START | + WRITEFIELD_CMD_END ); } } - bStartTOX = false; + + GetExport( ).bStartTOX = false; } -void SwWW8Writer::EndTOX( const SwSection& rSect ) +void AttributeOutputBase::EndTOX( const SwSection& rSect ) { const SwTOXBase* pTOX = rSect.GetTOXBase(); - if( pTOX ) + if ( pTOX ) { ww::eField eCode = TOX_INDEX == pTOX->GetType() ? ww::eINDEX : ww::eTOC; - OutField(0, eCode, aEmptyStr, WRITEFIELD_CLOSE); + GetExport( ).OutputField( 0, eCode, aEmptyStr, WRITEFIELD_CLOSE ); } - bInWriteTOX = false; + GetExport( ).bInWriteTOX = false; } -bool SwWW8Writer::GetNumberFmt(const SwField& rFld, String& rStr) +bool MSWordExportBase::GetNumberFmt(const SwField& rFld, String& rStr) { // Returns a date or time format string by using the US NfKeywordTable bool bHasFmt = false; @@ -2361,7 +2433,7 @@ bool SwWW8Writer::GetNumberFmt(const SwField& rFld, String& rStr) return bHasFmt; } -void WW8_GetNumberPara( String& rStr, const SwField& rFld ) +void AttributeOutputBase::GetNumberPara( String& rStr, const SwField& rFld ) { switch(rFld.GetFormat()) { @@ -2391,14 +2463,14 @@ void WW8_GetNumberPara( String& rStr, const SwField& rFld ) } } -void SwWW8Writer::WritePostItBegin( WW8Bytes* pOut ) +void WW8Export::WritePostItBegin( WW8Bytes* pOut ) { BYTE aArr[ 3 ]; BYTE* pArr = aArr; // sprmCFSpec true if( bWrtWW8 ) - Set_UInt16( pArr, 0x855 ); //sprmCFSpec + Set_UInt16( pArr, NS_sprm::LN_CFSpec ); else Set_UInt8( pArr, 117 ); //sprmCFSpec Set_UInt8( pArr, 1 ); @@ -2420,46 +2492,128 @@ String FieldString(ww::eField eIndex) return sRet; } -void OutWW8_RefField(SwWW8Writer& rWW8Wrt, const SwField &rFld, - const String &rRef) +void WW8AttributeOutput::HiddenField( const SwField& rFld ) { - String sStr(FieldString(ww::eREF)); - sStr.APPEND_CONST_ASC("\""); - sStr += rRef; - sStr.APPEND_CONST_ASC( "\" " ); - rWW8Wrt.OutField(&rFld, ww::eREF, sStr, WRITEFIELD_START | + String sExpand(rFld.GetPar2()); + + //replace LF 0x0A with VT 0x0B + sExpand.SearchAndReplaceAll(0x0A, 0x0B); + m_rWW8Export.pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell()); + if (m_rWW8Export.IsUnicode()) + { + SwWW8Writer::WriteString16(m_rWW8Export.Strm(), sExpand, false); + static BYTE aArr[] = + { + 0x3C, 0x08, 0x1 + }; + m_rWW8Export.pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell(), sizeof(aArr), aArr); + } + else + { + SwWW8Writer::WriteString8(m_rWW8Export.Strm(), sExpand, false, + RTL_TEXTENCODING_MS_1252); + static BYTE aArr[] = + { + 92, 0x1 + }; + m_rWW8Export.pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell(), sizeof(aArr), aArr); + } +} + +void WW8AttributeOutput::SetField( const SwField& rFld, ww::eField eType, const String& rCmd ) +{ + const SwSetExpField* pSet=(const SwSetExpField*)(&rFld); + const String &rVar = pSet->GetPar2(); + + ULONG nFrom = m_rWW8Export.Fc2Cp(m_rWW8Export.Strm().Tell()); + + GetExport().OutputField(&rFld, eType, rCmd, WRITEFIELD_START | WRITEFIELD_CMD_START | WRITEFIELD_CMD_END); - String sVar = lcl_GetExpandedField(rFld); - if (sVar.Len()) + + /* + Is there a bookmark at the start position of this field, if so + move it to the 0x14 of the result of the field. This is what word + does. MoveFieldMarks moves any bookmarks at this position to + the beginning of the field result, and marks the bookmark as a + fieldbookmark which is to be ended before the field end mark + instead of after it like a normal bookmark. + */ + m_rWW8Export.MoveFieldMarks(nFrom,m_rWW8Export.Fc2Cp(m_rWW8Export.Strm().Tell())); + + if (rVar.Len()) { - if (rWW8Wrt.IsUnicode()) - SwWW8Writer::WriteString16(rWW8Wrt.Strm(), sVar, false); + if (m_rWW8Export.IsUnicode()) + SwWW8Writer::WriteString16(m_rWW8Export.Strm(), rVar, false); else { - SwWW8Writer::WriteString8(rWW8Wrt.Strm(), sVar, false, + SwWW8Writer::WriteString8(m_rWW8Export.Strm(), rVar, false, RTL_TEXTENCODING_MS_1252); } } - rWW8Wrt.OutField(&rFld, ww::eREF, sStr, WRITEFIELD_CLOSE); + GetExport().OutputField(&rFld, eType, rCmd, WRITEFIELD_CLOSE); +} + +void WW8AttributeOutput::PostitField( const SwField* pFld ) +{ + const SwPostItField& rPFld = *(SwPostItField*)pFld; + m_rWW8Export.pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), rPFld ); + m_rWW8Export.WritePostItBegin( m_rWW8Export.pO ); +} + +bool WW8AttributeOutput::DropdownField( const SwField* pFld ) +{ + bool bExpand = true; + if ( m_rWW8Export.bWrtWW8 ) + { + const SwDropDownField& rFld2 = *(SwDropDownField*)pFld; + uno::Sequence<rtl::OUString> aItems = + rFld2.GetItemSequence(); + GetExport().DoComboBox(rFld2.GetName(), + rFld2.GetHelp(), + rFld2.GetToolTip(), + rFld2.GetSelectedItem(), aItems); + bExpand = false; + } + return bExpand; } -void WriteExpand(SwWW8Writer& rWW8Wrt, const SwField &rFld) +void WW8AttributeOutput::RefField( const SwField &rFld, const String &rRef) { - String sExpand(lcl_GetExpandedField(rFld)); - if (rWW8Wrt.IsUnicode()) - SwWW8Writer::WriteString16(rWW8Wrt.Strm(), sExpand, false); + String sStr( FieldString( ww::eREF ) ); + sStr.APPEND_CONST_ASC( "\"" ); + sStr += rRef; + sStr.APPEND_CONST_ASC( "\" " ); + m_rWW8Export.OutputField( &rFld, ww::eREF, sStr, WRITEFIELD_START | + WRITEFIELD_CMD_START | WRITEFIELD_CMD_END ); + String sVar = lcl_GetExpandedField( rFld ); + if ( sVar.Len() ) + { + if ( m_rWW8Export.IsUnicode() ) + SwWW8Writer::WriteString16( m_rWW8Export.Strm(), sVar, false ); + else + { + SwWW8Writer::WriteString8( m_rWW8Export.Strm(), sVar, false, + RTL_TEXTENCODING_MS_1252 ); + } + } + m_rWW8Export.OutputField( &rFld, ww::eREF, sStr, WRITEFIELD_CLOSE ); +} + +void WW8AttributeOutput::WriteExpand( const SwField* pFld ) +{ + String sExpand( lcl_GetExpandedField( *pFld ) ); + if ( m_rWW8Export.IsUnicode() ) + SwWW8Writer::WriteString16( m_rWW8Export.Strm(), sExpand, false ); else { - SwWW8Writer::WriteString8(rWW8Wrt.Strm(), sExpand, false, - RTL_TEXTENCODING_MS_1252); + SwWW8Writer::WriteString8( m_rWW8Export.Strm(), sExpand, false, + RTL_TEXTENCODING_MS_1252 ); } } -static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) +void AttributeOutputBase::TextField( const SwFmtFld& rField ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - const SwFmtFld& rFld = (SwFmtFld&)rHt; - const SwField* pFld = rFld.GetFld(); + const SwField* pFld = rField.GetFld(); String sStr; // fuer optionale Parameter bool bWriteExpand = false; USHORT nSubType = pFld->GetSubType(); @@ -2470,7 +2624,7 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) if (nSubType == nsSwGetSetExpType::GSE_STRING) { const SwGetExpField *pGet=(const SwGetExpField*)(pFld); - OutWW8_RefField(rWW8Wrt, *pGet, pGet->GetFormula()); + RefField( *pGet, pGet->GetFormula() ); } else bWriteExpand = true; @@ -2483,8 +2637,8 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) sStr += pFld->GetTyp()->GetName(); sStr.APPEND_CONST_ASC( "\" " ); - ::WW8_GetNumberPara( sStr, *pFld ); - rWW8Wrt.OutField(pFld, ww::eSEQ, sStr); + GetNumberPara( sStr, *pFld ); + GetExport().OutputField(pFld, ww::eSEQ, sStr); } else if (nSubType & nsSwGetSetExpType::GSE_STRING) { @@ -2514,69 +2668,44 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) bShowAsWell = (nSubType & nsSwExtendedSubType::SUB_INVISIBLE) ? false : true; } - ULONG nFrom = rWW8Wrt.Fc2Cp(rWrt.Strm().Tell()); - - rWW8Wrt.OutField(pFld, eFieldNo, sStr, WRITEFIELD_START | - WRITEFIELD_CMD_START | WRITEFIELD_CMD_END); - - /* - Is there a bookmark at the start position of this field, if so - move it to the 0x14 of the result of the field. This is what word - does. MoveFieldMarks moves any bookmarks at this position to - the beginning of the field result, and marks the bookmark as a - fieldbookmark which is to be ended before the field end mark - instead of after it like a normal bookmark. - */ - rWW8Wrt.MoveFieldMarks(nFrom,rWW8Wrt.Fc2Cp(rWrt.Strm().Tell())); - - if (rVar.Len()) - { - if (rWW8Wrt.IsUnicode()) - SwWW8Writer::WriteString16(rWrt.Strm(), rVar, false); - else - { - SwWW8Writer::WriteString8(rWrt.Strm(), rVar, false, - RTL_TEXTENCODING_MS_1252); - } - } - rWW8Wrt.OutField(pFld, eFieldNo, sStr, WRITEFIELD_CLOSE); + SetField( *pFld, eFieldNo, sStr ); if (bShowAsWell) - OutWW8_RefField(rWW8Wrt, *pSet, pSet->GetPar1()); + RefField( *pSet, pSet->GetPar1() ); } else bWriteExpand = true; break; case RES_PAGENUMBERFLD: sStr = FieldString(ww::ePAGE); - ::WW8_GetNumberPara(sStr, *pFld); - rWW8Wrt.OutField(pFld, ww::ePAGE, sStr); + GetNumberPara(sStr, *pFld); + GetExport().OutputField(pFld, ww::ePAGE, sStr); break; case RES_FILENAMEFLD: sStr = FieldString(ww::eFILENAME); if (pFld->GetFormat() == FF_PATHNAME) sStr.APPEND_CONST_ASC("\\p "); - rWW8Wrt.OutField(pFld, ww::eFILENAME, sStr); + GetExport().OutputField(pFld, ww::eFILENAME, sStr); break; case RES_DBNAMEFLD: { sStr = FieldString(ww::eDATABASE); - SwDBData aData = rWrt.pDoc->GetDBData(); + SwDBData aData = GetExport().pDoc->GetDBData(); sStr += String(aData.sDataSource); sStr += DB_DELIM; sStr += String(aData.sCommand); - rWW8Wrt.OutField(pFld, ww::eDATABASE, sStr); + GetExport().OutputField(pFld, ww::eDATABASE, sStr); } break; case RES_AUTHORFLD: { ww::eField eFld = (AF_SHORTCUT & nSubType ? ww::eUSERINITIALS : ww::eUSERNAME); - rWW8Wrt.OutField(pFld, eFld, FieldString(eFld)); + GetExport().OutputField(pFld, eFld, FieldString(eFld)); } break; case RES_TEMPLNAMEFLD: - rWW8Wrt.OutField(pFld, ww::eTEMPLATE, FieldString(ww::eTEMPLATE)); + GetExport().OutputField(pFld, ww::eTEMPLATE, FieldString(ww::eTEMPLATE)); break; case RES_DOCINFOFLD: // Last printed, last edited,... if( DI_SUB_FIXED & nSubType ) @@ -2604,25 +2733,25 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) case DI_CREATE: if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK)) eFld = ww::eAUTHOR; - else if (rWW8Wrt.GetNumberFmt(*pFld, sStr)) + else if (GetExport().GetNumberFmt(*pFld, sStr)) eFld = ww::eCREATEDATE; break; case DI_CHANGE: if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK)) eFld = ww::eLASTSAVEDBY; - else if (rWW8Wrt.GetNumberFmt(*pFld, sStr)) + else if (GetExport().GetNumberFmt(*pFld, sStr)) eFld = ww::eSAVEDATE; break; case DI_PRINT: if (DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK) && - rWW8Wrt.GetNumberFmt(*pFld, sStr)) + GetExport().GetNumberFmt(*pFld, sStr)) eFld = ww::ePRINTDATE; break; case DI_EDIT: if( DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK ) && - rWW8Wrt.GetNumberFmt( *pFld, sStr )) + GetExport().GetNumberFmt( *pFld, sStr )) eFld = ww::eSAVEDATE; break; case DI_CUSTOM: @@ -2653,20 +2782,20 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) if (eFld != ww::eNONE) { sStr.Insert(FieldString(eFld), 0); - rWW8Wrt.OutField(pFld, eFld, sStr); + GetExport().OutputField(pFld, eFld, sStr); } else bWriteExpand = true; } break; case RES_DATETIMEFLD: - if (FIXEDFLD & nSubType || !rWW8Wrt.GetNumberFmt(*pFld, sStr)) + if (FIXEDFLD & nSubType || !GetExport().GetNumberFmt(*pFld, sStr)) bWriteExpand = true; else { ww::eField eFld = (DATEFLD & nSubType) ? ww::eDATE : ww::eTIME; sStr.Insert(FieldString(eFld), 0); - rWW8Wrt.OutField(pFld, eFld, sStr); + GetExport().OutputField(pFld, eFld, sStr); } break; case RES_DOCSTATFLD: @@ -2689,8 +2818,8 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) if (eFld != ww::eNONE) { sStr = FieldString(eFld); - ::WW8_GetNumberPara(sStr, *pFld); - rWW8Wrt.OutField(pFld, eFld, sStr); + GetNumberPara(sStr, *pFld); + GetExport().OutputField(pFld, eFld, sStr); } else bWriteExpand = true; @@ -2719,7 +2848,7 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) if (eFld != ww::eNONE) { sStr = FieldString(eFld); - rWW8Wrt.OutField(pFld, eFld, sStr); + GetExport().OutputField(pFld, eFld, sStr); } else bWriteExpand = true; @@ -2727,11 +2856,9 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) break; case RES_POSTITFLD: //Sadly only possible for word in main document text - if (rWW8Wrt.nTxtTyp == TXT_MAINTEXT) + if (GetExport().nTxtTyp == TXT_MAINTEXT) { - const SwPostItField& rPFld = *(SwPostItField*)pFld; - rWW8Wrt.pAtn->Append( rWW8Wrt.Fc2Cp( rWrt.Strm().Tell() ), rPFld ); - rWW8Wrt.WritePostItBegin( rWW8Wrt.pO ); + PostitField( pFld ); } break; case RES_INPUTFLD: @@ -2740,16 +2867,16 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) dynamic_cast<const SwInputField *>(pFld); if (pInputField->isFormField()) - rWW8Wrt.DoFormText(pInputField); + GetExport().DoFormText(pInputField); else { sStr = FieldString(ww::eFILLIN); - sStr.ASSIGN_CONST_ASC("\""); + sStr.APPEND_CONST_ASC("\""); sStr += pFld->GetPar2(); sStr += '\"'; - rWW8Wrt.OutField(pFld, ww::eFILLIN, sStr); + GetExport().OutputField(pFld, ww::eFILLIN, sStr); } } break; @@ -2772,7 +2899,7 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) break; } sStr = FieldString(eFld); - sStr += rWW8Wrt.GetBookmarkName(nSubType, + sStr += GetExport().GetBookmarkName(nSubType, &rRFld.GetSetRefName(), 0); break; case REF_FOOTNOTE: @@ -2792,7 +2919,7 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) break; } sStr = FieldString(eFld); - sStr += rWW8Wrt.GetBookmarkName(nSubType, 0, + sStr += GetExport().GetBookmarkName(nSubType, 0, rRFld.GetSeqNo()); break; } @@ -2811,7 +2938,7 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) break; } sStr.APPEND_CONST_ASC(" \\h "); // insert hyperlink - rWW8Wrt.OutField(pFld, eFld, sStr); + GetExport().OutputField(pFld, eFld, sStr); } else bWriteExpand = true; @@ -2833,12 +2960,12 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) font size of that script as our default. */ USHORT nScript; - if( pBreakIt->xBreak.is() ) - nScript = pBreakIt->xBreak->getScriptType( pFld->GetPar1(), 0); + if( pBreakIt->GetBreakIter().is() ) + nScript = pBreakIt->GetBreakIter()->getScriptType( pFld->GetPar1(), 0); else nScript = i18n::ScriptType::ASIAN; - long nHeight = ((SvxFontHeightItem&)(((SwWW8Writer&)rWrt).GetItem( + long nHeight = ((SvxFontHeightItem&)(GetExport().GetItem( GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript)))).GetHeight();; nHeight = (nHeight + 10) / 20; //Font Size in points; @@ -2861,31 +2988,20 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) sStr.Append('('); sStr += String(pFld->GetPar1(),nAbove,pFld->GetPar1().Len()-nAbove); sStr.APPEND_CONST_ASC("))"); - rWW8Wrt.OutField(pFld, ww::eEQ, sStr); + GetExport().OutputField(pFld, ww::eEQ, sStr); } break; case RES_DROPDOWN: - if (rWW8Wrt.bWrtWW8) - { - const SwDropDownField& rFld2 = *(SwDropDownField*)pFld; - uno::Sequence<rtl::OUString> aItems = - rFld2.GetItemSequence(); - rWW8Wrt.DoComboBox(rFld2.GetName(), - rFld2.GetHelp(), - rFld2.GetToolTip(), - rFld2.GetSelectedItem(), aItems); - } - else - bWriteExpand = true; + bWriteExpand = DropdownField( pFld ); break; case RES_CHAPTERFLD: bWriteExpand = true; - if (rWW8Wrt.bOutKF && rFld.GetTxtFld()) + if (GetExport().bOutKF && rField.GetTxtFld()) { - const SwTxtNode *pTxtNd = rWW8Wrt.GetHdFtPageRoot(); + const SwTxtNode *pTxtNd = GetExport().GetHdFtPageRoot(); if (!pTxtNd) { - if (const SwNode *pNd = rWW8Wrt.pCurPam->GetNode()) + if (const SwNode *pNd = GetExport().pCurPam->GetNode()) pTxtNd = pNd->GetTxtNode(); } @@ -2893,7 +3009,7 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) { SwChapterField aCopy(*(const SwChapterField*)pFld); aCopy.ChangeExpansion(*pTxtNd, false); - WriteExpand(rWW8Wrt, aCopy); + WriteExpand( &aCopy ); bWriteExpand = false; } } @@ -2903,28 +3019,7 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) String sExpand(pFld->GetPar2()); if (sExpand.Len()) { - //replace LF 0x0A with VT 0x0B - sExpand.SearchAndReplaceAll(0x0A, 0x0B); - rWW8Wrt.pChpPlc->AppendFkpEntry(rWW8Wrt.Strm().Tell()); - if (rWW8Wrt.IsUnicode()) - { - SwWW8Writer::WriteString16(rWW8Wrt.Strm(), sExpand, false); - static BYTE aArr[] = - { - 0x3C, 0x08, 0x1 - }; - rWW8Wrt.pChpPlc->AppendFkpEntry(rWW8Wrt.Strm().Tell(), sizeof(aArr), aArr); - } - else - { - SwWW8Writer::WriteString8(rWW8Wrt.Strm(), sExpand, false, - RTL_TEXTENCODING_MS_1252); - static BYTE aArr[] = - { - 92, 0x1 - }; - rWW8Wrt.pChpPlc->AppendFkpEntry(rWW8Wrt.Strm().Tell(), sizeof(aArr), aArr); - } + HiddenField( *pFld ); } } break; @@ -2934,27 +3029,23 @@ static Writer& OutWW8_SwField( Writer& rWrt, const SfxPoolItem& rHt ) } if (bWriteExpand) - WriteExpand(rWW8Wrt, *pFld); - - return rWrt; + WriteExpand( pFld ); } -static Writer& OutWW8_SwFlyCntnt( Writer& rWrt, const SfxPoolItem& rHt ) +void AttributeOutputBase::TextFlyContent( const SwFmtFlyCnt& rFlyContent ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if (rWrtWW8.pOutFmtNode && rWrtWW8.pOutFmtNode->ISA(SwCntntNode)) + if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwCntntNode ) ) { - SwTxtNode* pTxtNd = (SwTxtNode*)rWrtWW8.pOutFmtNode; + SwTxtNode* pTxtNd = (SwTxtNode*)GetExport().pOutFmtNode; Point aLayPos; - aLayPos = pTxtNd->FindLayoutRect(false, &aLayPos).Pos(); + aLayPos = pTxtNd->FindLayoutRect( false, &aLayPos ).Pos(); - SwPosition aPos(*pTxtNd); - sw::Frame aFrm(*((const SwFmtFlyCnt&)rHt).GetFrmFmt(), aPos); + SwPosition aPos( *pTxtNd ); + sw::Frame aFrm( *rFlyContent.GetFrmFmt(), aPos ); - rWrtWW8.OutWW8FlyFrm(aFrm, aLayPos); + OutputFlyFrame_Impl( aFrm, aLayPos ); } - return rWrt; } // TOXMarks fehlen noch @@ -2965,74 +3056,62 @@ static Writer& OutWW8_SwFlyCntnt( Writer& rWrt, const SfxPoolItem& rHt ) // --- // ACK. Dieser Vorschlag passt exakt zu unserer Implementierung des Import, // daher setze ich das gleich mal um. (KHZ, 07/15/2000) -static Writer& OutWW8_SvxHyphenZone( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone ) { -// sprmPFNoAutoHyph - const SvxHyphenZoneItem& rAttr = (const SvxHyphenZoneItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x242A ); + // sprmPFNoAutoHyph + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PFNoAutoHyph ); else - rWrtWW8.pO->Insert( 44, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( 44, m_rWW8Export.pO->Count() ); - rWrtWW8.pO->Insert( rAttr.IsHyphen() ? 0 : 1, rWrtWW8.pO->Count() ); - return rWrt; + m_rWW8Export.pO->Insert( rHyphenZone.IsHyphen() ? 0 : 1, m_rWW8Export.pO->Count() ); } -static Writer& OutWW8_SfxBoolItem( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace ) { USHORT nId = 0; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - switch ( rHt.Which() ) + if ( m_rWW8Export.bWrtWW8 ) + switch ( rScriptSpace.Which() ) { - case RES_PARATR_SCRIPTSPACE: nId = 0x2437; break; - case RES_PARATR_HANGINGPUNCTUATION: nId = 0x2435; break; - case RES_PARATR_FORBIDDEN_RULES: nId = 0x2433; break; + case RES_PARATR_SCRIPTSPACE: nId = NS_sprm::LN_PFAutoSpaceDE; break; + case RES_PARATR_HANGINGPUNCTUATION: nId = NS_sprm::LN_PFOverflowPunct; break; + case RES_PARATR_FORBIDDEN_RULES: nId = NS_sprm::LN_PFKinsoku; break; } - if( nId ) + if ( nId ) { - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( nId ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( nId ); else - rWrtWW8.pO->Insert( (BYTE)nId, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( (BYTE)nId, m_rWW8Export.pO->Count() ); - rWrtWW8.pO->Insert( ((SfxBoolItem&)rHt).GetValue() ? 1 : 0, - rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( rScriptSpace.GetValue() ? 1 : 0, + m_rWW8Export.pO->Count() ); } - return rWrt; } -static Writer& OutWW8_SvxParaGridItem(Writer& rWrt, const SfxPoolItem& rHt) +void WW8AttributeOutput::ParaSnapToGrid( const SvxParaGridItem& rGrid ) { -// sprmPFUsePgsuSettings - - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - //97+ only - if (!rWrtWW8.bWrtWW8) - return rWrt; + // sprmPFUsePgsuSettings + // 97+ only + if ( !m_rWW8Export.bWrtWW8 ) + return; - rWrtWW8.InsUInt16(0x2447); - const SvxParaGridItem& rAttr = (const SvxParaGridItem&)rHt; - rWrtWW8.pO->Insert( rAttr.GetValue(), rWrtWW8.pO->Count() ); - return rWrt; + m_rWW8Export.InsUInt16( NS_sprm::LN_PFUsePgsuSettings ); + m_rWW8Export.pO->Insert( rGrid.GetValue(), m_rWW8Export.pO->Count() ); } -static Writer& OutWW8_SvxParaVertAlignItem(Writer& rWrt, const SfxPoolItem& rHt) +void WW8AttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign ) { -// sprmPWAlignFont - - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - //97+ only - if( !rWrtWW8.bWrtWW8 ) - return rWrt; + // sprmPWAlignFont + // 97+ only + if( !m_rWW8Export.bWrtWW8 ) + return; - rWrtWW8.InsUInt16( 0x4439 ); - const SvxParaVertAlignItem & rAttr = (const SvxParaVertAlignItem&)rHt; + m_rWW8Export.InsUInt16( NS_sprm::LN_PWAlignFont ); - INT16 nVal = rAttr.GetValue(); - switch (nVal) + INT16 nVal = rAlign.GetValue(); + switch ( nVal ) { case SvxParaVertAlignItem::BASELINE: nVal = 2; @@ -3051,25 +3130,19 @@ static Writer& OutWW8_SvxParaVertAlignItem(Writer& rWrt, const SfxPoolItem& rHt) break; default: nVal = 4; - ASSERT(!(&rWrt), "Unknown vert alignment"); + ASSERT( false, "Unknown vert alignment" ); break; } - rWrtWW8.InsUInt16( nVal ); - return rWrt; + m_rWW8Export.InsUInt16( nVal ); } // NoHyphen: ich habe keine Entsprechung in der SW-UI und WW-UI gefunden -static Writer& OutWW8_SwHardBlank( Writer& rWrt, const SfxPoolItem& rHt ) -{ - ((SwWW8Writer&)rWrt).WriteChar( ((SwFmtHardBlank&)rHt).GetChar() ); - return rWrt; -} // RefMark, NoLineBreakHere fehlen noch -void SwWW8Writer::WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pOutArr ) +void WW8Export::WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pOutArr ) { WW8Bytes aAttrArr; bool bAutoNum = !rFtn.GetNumStr().Len(); // Auto-Nummer @@ -3107,7 +3180,7 @@ void SwWW8Writer::WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pOutArr ) ? pInfo->GetAnchorCharFmt( *pDoc ) : pInfo->GetCharFmt( *pDoc ); if( bWrtWW8 ) - SwWW8Writer::InsUInt16( aAttrArr, 0x4a30 ); + SwWW8Writer::InsUInt16( aAttrArr, NS_sprm::LN_CIstd ); else aAttrArr.Insert( 80, aAttrArr.Count() ); SwWW8Writer::InsUInt16( aAttrArr, GetId( *pCFmt ) ); @@ -3151,7 +3224,7 @@ void SwWW8Writer::WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pOutArr ) pTxtFtn->GetTxtNode().GetAttr( aSet, *pTxtFtn->GetStart(), (*pTxtFtn->GetStart()) + 1 ); - ::OutWW8_SwFont( *this, aSet.Get( RES_CHRATR_FONT )); + m_pAttrOutput->OutputItem( aSet.Get( RES_CHRATR_FONT ) ); pO = pOld; } pChpPlc->AppendFkpEntry( Strm().Tell(), aOutArr.Count(), @@ -3180,84 +3253,81 @@ static bool lcl_IsAtTxtEnd(const SwFmtFtn& rFtn) } -static Writer& OutWW8_SwFtn( Writer& rWrt, const SfxPoolItem& rHt ) +void AttributeOutputBase::TextFootnote( const SwFmtFtn& rFtn ) { - const SwFmtFtn& rFtn = (const SwFmtFtn&)rHt; - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - USHORT nTyp; - WW8_WrPlcFtnEdn* pFtnEnd; - if( rFtn.IsEndNote() ) + if ( rFtn.IsEndNote() ) { - pFtnEnd = rWW8Wrt.pEdn; nTyp = REF_ENDNOTE; - if( rWW8Wrt.bEndAtTxtEnd ) - rWW8Wrt.bEndAtTxtEnd = lcl_IsAtTxtEnd( rFtn ); + if ( GetExport().bEndAtTxtEnd ) + GetExport().bEndAtTxtEnd = lcl_IsAtTxtEnd( rFtn ); } else { - pFtnEnd = rWW8Wrt.pFtn; nTyp = REF_FOOTNOTE; - if( rWW8Wrt.bFtnAtTxtEnd ) - rWW8Wrt.bFtnAtTxtEnd = lcl_IsAtTxtEnd( rFtn ); + if ( GetExport().bFtnAtTxtEnd ) + GetExport().bFtnAtTxtEnd = lcl_IsAtTxtEnd( rFtn ); } // if any reference to this footnote/endnote then insert an internal // Bookmark. String sBkmkNm; - if( rWW8Wrt.HasRefToObject( nTyp, 0, rFtn.GetTxtFtn()->GetSeqRefNo() )) + if ( GetExport().HasRefToObject( nTyp, 0, rFtn.GetTxtFtn()->GetSeqRefNo() )) { - sBkmkNm = rWW8Wrt.GetBookmarkName( nTyp, 0, + sBkmkNm = GetExport().GetBookmarkName( nTyp, 0, rFtn.GetTxtFtn()->GetSeqRefNo() ); - rWW8Wrt.AppendBookmark( sBkmkNm ); + GetExport().AppendBookmark( sBkmkNm ); } + TextFootnote_Impl( rFtn ); - pFtnEnd->Append( rWW8Wrt.Fc2Cp( rWrt.Strm().Tell() ), rFtn ); - rWW8Wrt.WriteFtnBegin( rFtn, rWW8Wrt.pO ); + if ( sBkmkNm.Len() ) + GetExport().AppendBookmark( sBkmkNm ); // FIXME: Why is it added twice? Shouldn't this one go to WW8AttributeOuput::TextFootnote_Impl()? +} - if( sBkmkNm.Len() ) - rWW8Wrt.AppendBookmark( sBkmkNm ); +void WW8AttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFtn ) +{ + WW8_WrPlcFtnEdn* pFtnEnd; + if ( rFtn.IsEndNote() ) + pFtnEnd = m_rWW8Export.pEdn; + else + pFtnEnd = m_rWW8Export.pFtn; - return rWrt; + pFtnEnd->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), rFtn ); + m_rWW8Export.WriteFtnBegin( rFtn, m_rWW8Export.pO ); } -static Writer& OutWW8_SwTxtCharFmt( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt ) { - const SwFmtCharFmt& rAttr = (const SwFmtCharFmt&)rHt; - if( rAttr.GetCharFmt() ) + if( rCharFmt.GetCharFmt() ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x4A30 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_CIstd ); else - rWrtWW8.pO->Insert( 80, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( 80, m_rWW8Export.pO->Count() ); - rWrtWW8.InsUInt16( rWrtWW8.GetId( *rAttr.GetCharFmt() ) ); + m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *rCharFmt.GetCharFmt() ) ); } - return rWrt; } /* See ww8par6.cxx Read_DoubleLine for some more info */ -static Writer& OutWW8_SvxTwoLinesItem( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines ) { // #i28331# - check that bOn is set - if((static_cast<const SvxTwoLinesItem&>(rHt)).GetValue()) + if ( rTwoLines.GetValue() ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; //97+ only - if( !rWrtWW8.bWrtWW8 ) - return rWrt; + if( !m_rWW8Export.bWrtWW8 ) + return; - const SvxTwoLinesItem& rAttr = (const SvxTwoLinesItem&)rHt; - rWrtWW8.InsUInt16( 0xCA78 ); - rWrtWW8.pO->Insert( (BYTE)0x06, rWrtWW8.pO->Count() ); //len 6 - rWrtWW8.pO->Insert( (BYTE)0x02, rWrtWW8.pO->Count() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_CEastAsianLayout ); + m_rWW8Export.pO->Insert( (BYTE)0x06, m_rWW8Export.pO->Count() ); //len 6 + m_rWW8Export.pO->Insert( (BYTE)0x02, m_rWW8Export.pO->Count() ); - sal_Unicode cStart = rAttr.GetStartBracket(); - sal_Unicode cEnd = rAttr.GetStartBracket(); + sal_Unicode cStart = rTwoLines.GetStartBracket(); + sal_Unicode cEnd = rTwoLines.GetStartBracket(); /* As per usual we have problems. We can have seperate left and right brackets @@ -3284,43 +3354,39 @@ static Writer& OutWW8_SvxTwoLinesItem( Writer& rWrt, const SfxPoolItem& rHt ) nType = 2; else nType = 1; - rWrtWW8.InsUInt16( nType ); + m_rWW8Export.InsUInt16( nType ); static const BYTE aZeroArr[ 3 ] = { 0, 0, 0 }; - rWrtWW8.pO->Insert( aZeroArr, 3, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( aZeroArr, 3, m_rWW8Export.pO->Count() ); } - return rWrt; } -static Writer& OutWW8_SwNumRuleItem( Writer& rWrt, const SfxPoolItem& rHt ) +void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - const SwNumRuleItem& rNumRule = (const SwNumRuleItem&)rHt; - const SwTxtNode* pTxtNd = 0; USHORT nNumId; BYTE nLvl = 0; - if( rNumRule.GetValue().Len() ) + if ( rNumRule.GetValue().Len() ) { - const SwNumRule* pRule = rWrt.pDoc->FindNumRulePtr( + const SwNumRule* pRule = GetExport().pDoc->FindNumRulePtr( rNumRule.GetValue() ); - if( pRule && USHRT_MAX != ( nNumId = rWW8Wrt.GetId( *pRule )) ) + if ( pRule && USHRT_MAX != ( nNumId = GetExport().GetId( *pRule ) ) ) { ++nNumId; - if( rWW8Wrt.pOutFmtNode ) + if ( GetExport().pOutFmtNode ) { - if( rWW8Wrt.pOutFmtNode->ISA( SwCntntNode )) + if ( GetExport().pOutFmtNode->ISA( SwCntntNode ) ) { - pTxtNd = (SwTxtNode*)rWW8Wrt.pOutFmtNode; + pTxtNd = (SwTxtNode*)GetExport().pOutFmtNode; if( pTxtNd->IsCountedInList()) { nLvl = static_cast< BYTE >(pTxtNd->GetActualListLevel()); - if (pTxtNd->IsListRestart()) + if ( pTxtNd->IsListRestart() ) { - USHORT nStartWith = static_cast< USHORT >(pTxtNd->GetActualListStartValue()); - nNumId = rWW8Wrt.DupNumRuleWithLvlStart(pRule,nLvl,nStartWith); - if (USHRT_MAX != nNumId) + USHORT nStartWith = static_cast< USHORT >( pTxtNd->GetActualListStartValue() ); + nNumId = GetExport().DuplicateNumRule( pRule, nLvl, nStartWith ); + if ( USHRT_MAX != nNumId ) ++nNumId; } } @@ -3333,13 +3399,11 @@ static Writer& OutWW8_SwNumRuleItem( Writer& rWrt, const SfxPoolItem& rHt ) nNumId = 0; } } - else if( rWW8Wrt.pOutFmtNode->ISA( SwTxtFmtColl )) + else if ( GetExport().pOutFmtNode->ISA( SwTxtFmtColl ) ) { - const SwTxtFmtColl* pC = (SwTxtFmtColl*)rWW8Wrt.pOutFmtNode; - //if( pC && MAXLEVEL > pC->GetOutlineLevel() ) //#outline level,removed by zhaojianwei - // nLvl = pC->GetOutlineLevel(); //<-end, ->add by zhaojianwei - if( pC && pC->IsAssignedToListLevelOfOutlineStyle() ) - nLvl = static_cast<BYTE>(pC->GetAssignedOutlineStyleLevel()); //<-end,zhaojianwei + const SwTxtFmtColl* pC = (SwTxtFmtColl*)GetExport().pOutFmtNode; + if ( pC && pC->IsAssignedToListLevelOfOutlineStyle() ) + nLvl = static_cast< BYTE >( pC->GetAssignedOutlineStyleLevel() ); //<-end,zhaojianwei } } } @@ -3349,94 +3413,95 @@ static Writer& OutWW8_SwNumRuleItem( Writer& rWrt, const SfxPoolItem& rHt ) else nNumId = 0; - if (USHRT_MAX != nNumId) + if ( USHRT_MAX != nNumId ) { - if (nLvl >= WW8ListManager::nMaxLevel) - nLvl = WW8ListManager::nMaxLevel-1; - if( rWW8Wrt.bWrtWW8 ) - { - // write sprmPIlvl and sprmPIlfo - SwWW8Writer::InsUInt16( *rWW8Wrt.pO, 0x260a ); - rWW8Wrt.pO->Insert( nLvl, rWW8Wrt.pO->Count() ); - SwWW8Writer::InsUInt16( *rWW8Wrt.pO, 0x460b ); - SwWW8Writer::InsUInt16( *rWW8Wrt.pO, nNumId ); - } - else if( pTxtNd && rWW8Wrt.Out_SwNum( pTxtNd ) ) // NumRules - rWW8Wrt.pSepx->SetNum( pTxtNd ); + if ( nLvl >= WW8ListManager::nMaxLevel ) + nLvl = WW8ListManager::nMaxLevel - 1; + + ParaNumRule_Impl( pTxtNd, nLvl, nNumId ); + } +} + +void WW8AttributeOutput::ParaNumRule_Impl( const SwTxtNode* pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId ) +{ + if ( m_rWW8Export.bWrtWW8 ) + { + // write sprmPIlvl and sprmPIlfo + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlvl ); + m_rWW8Export.pO->Insert( ::sal::static_int_cast<BYTE>(nLvl), m_rWW8Export.pO->Count() ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlfo ); + SwWW8Writer::InsUInt16( *m_rWW8Export.pO, ::sal::static_int_cast<UINT16>(nNumId) ); } - return rWrt; + else if ( pTxtNd && m_rWW8Export.Out_SwNum( pTxtNd ) ) // NumRules + m_rWW8Export.pSepx->SetNum( pTxtNd ); } /* File FRMATR.HXX */ -static Writer& OutWW8_SwFrmSize( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - const SwFmtFrmSize& rSz = (const SwFmtFrmSize&)rHt; - - if( rWW8Wrt.bOutFlyFrmAttrs ) // Flys + if( m_rWW8Export.bOutFlyFrmAttrs ) // Flys { - if( rWW8Wrt.bOutGrf ) - return rWrt; // Fly um Grafik -> Auto-Groesse + if( m_rWW8Export.bOutGrf ) + return; // Fly um Grafik -> Auto-Groesse //???? was ist bei Prozentangaben ??? - if( rSz.GetWidth() && rSz.GetWidthSizeType() == ATT_FIX_SIZE) + if ( rSize.GetWidth() && rSize.GetWidthSizeType() == ATT_FIX_SIZE) { //"sprmPDxaWidth" - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x841A ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaWidth ); else - rWW8Wrt.pO->Insert( 28, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( (USHORT)rSz.GetWidth() ); + m_rWW8Export.pO->Insert( 28, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( (USHORT)rSize.GetWidth() ); } - if( rSz.GetHeight() ) + if ( rSize.GetHeight() ) { // sprmPWHeightAbs - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x442B ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PWHeightAbs ); else - rWW8Wrt.pO->Insert( 45, rWW8Wrt.pO->Count() ); + m_rWW8Export.pO->Insert( 45, m_rWW8Export.pO->Count() ); USHORT nH = 0; - switch( rSz.GetHeightSizeType() ) + switch ( rSize.GetHeightSizeType() ) { - case ATT_VAR_SIZE: break; - case ATT_FIX_SIZE: nH = (USHORT)rSz.GetHeight() & 0x7fff; break; - default: nH = (USHORT)rSz.GetHeight() | 0x8000; break; + case ATT_VAR_SIZE: break; + case ATT_FIX_SIZE: nH = (USHORT)rSize.GetHeight() & 0x7fff; break; + default: nH = (USHORT)rSize.GetHeight() | 0x8000; break; } - rWW8Wrt.InsUInt16( nH ); + m_rWW8Export.InsUInt16( nH ); } } - else if( rWW8Wrt.bOutPageDescs ) // PageDesc : Breite + Hoehe + else if( m_rWW8Export.bOutPageDescs ) // PageDesc : Breite + Hoehe { - if( rWW8Wrt.pAktPageDesc->GetLandscape() ) + if( m_rWW8Export.pAktPageDesc->GetLandscape() ) { /*sprmSBOrientation*/ - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x301d ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SBOrientation ); else - rWW8Wrt.pO->Insert( 162, rWW8Wrt.pO->Count() ); - rWW8Wrt.pO->Insert( 2, rWW8Wrt.pO->Count() ); + m_rWW8Export.pO->Insert( 162, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( 2, m_rWW8Export.pO->Count() ); } /*sprmSXaPage*/ - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0xB01F ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SXaPage ); else - rWW8Wrt.pO->Insert( 164, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( - msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSz.GetWidth()))); + m_rWW8Export.pO->Insert( 164, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( + msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSize.GetWidth()))); /*sprmSYaPage*/ - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0xB020 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SYaPage ); else - rWW8Wrt.pO->Insert( 165, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( - msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSz.GetHeight()))); + m_rWW8Export.pO->Insert( 165, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( + msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSize.GetHeight()))); } - return rWrt; } // FillOrder fehlt noch @@ -3446,7 +3511,7 @@ static Writer& OutWW8_SwFrmSize( Writer& rWrt, const SfxPoolItem& rHt ) // direkt nach Schreiben des CR gerufen werden. // Rueckgabe: FilePos des ersetzten CRs + 1 oder 0 fuer nicht ersetzt -ULONG SwWW8Writer::ReplaceCr( BYTE nChar ) +ULONG WW8Export::ReplaceCr( BYTE nChar ) { // Bug #49917# ASSERT( nChar, "gegen 0 ersetzt bringt WW97/95 zum Absturz" ); @@ -3527,12 +3592,12 @@ ULONG SwWW8Writer::ReplaceCr( BYTE nChar ) return nRetPos; } -void SwWW8Writer::WriteRowEnd(sal_uInt32 nDepth) +void WW8AttributeOutput::TableRowEnd(sal_uInt32 nDepth) { - if (nDepth == 1) - WriteChar( (BYTE)0x07 ); - else if (nDepth > 1) - WriteChar( (BYTE)0x0d ); + if ( nDepth == 1 ) + m_rWW8Export.WriteChar( (BYTE)0x07 ); + else if ( nDepth > 1 ) + m_rWW8Export.WriteChar( (BYTE)0x0d ); //Technically in a word document this is a different value for a row ends //that are not row ends directly after a cell with a graphic. But it @@ -3540,55 +3605,50 @@ void SwWW8Writer::WriteRowEnd(sal_uInt32 nDepth) //pMagicTable->Append(Fc2Cp(Strm().Tell()),0x1B6); } -static Writer& OutWW8_SwFmtPageDesc(Writer& rWrt, const SfxPoolItem& rHt) +void AttributeOutputBase::FormatPageDescription( const SwFmtPageDesc& rPageDesc ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - if (rWW8Wrt.bStyDef && rWW8Wrt.pOutFmtNode && rWW8Wrt.pOutFmtNode->ISA(SwTxtFmtColl)) + if ( GetExport().bStyDef && GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwTxtFmtColl ) ) { - const SwFmtPageDesc &rPgDesc = (const SwFmtPageDesc&)rHt; - const SwTxtFmtColl* pC = (SwTxtFmtColl*)rWW8Wrt.pOutFmtNode; - if ((SFX_ITEM_SET != pC->GetItemState(RES_BREAK, false)) && rPgDesc.GetRegisteredIn()) - OutWW8_SwFmtBreak(rWrt, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK)); + const SwTxtFmtColl* pC = (SwTxtFmtColl*)GetExport().pOutFmtNode; + if ( (SFX_ITEM_SET != pC->GetItemState( RES_BREAK, false ) ) && rPageDesc.GetRegisteredIn() ) + FormatBreak( SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ) ); } - return rWrt; +} + +void WW8AttributeOutput::PageBreakBefore( bool bBreak ) +{ + // sprmPPageBreakBefore/sprmPFPageBreakBefore + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PFPageBreakBefore ); + else + m_rWW8Export.pO->Insert( 9, m_rWW8Export.pO->Count() ); + + m_rWW8Export.pO->Insert( bBreak ? 1 : 0, m_rWW8Export.pO->Count() ); } // Breaks schreiben nichts in das Ausgabe-Feld rWrt.pO, // sondern nur in den Text-Stream ( Bedingung dafuer, dass sie von Out_Break... // gerufen werden duerfen ) -static Writer& OutWW8_SwFmtBreak( Writer& rWrt, const SfxPoolItem& rHt ) +void AttributeOutputBase::FormatBreak( const SvxFmtBreakItem& rBreak ) { -/*UMSTELLEN*/ - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - const SvxFmtBreakItem &rBreak = (const SvxFmtBreakItem&)rHt; - - if( rWW8Wrt.bStyDef ) + if ( GetExport().bStyDef ) { - switch( rBreak.GetBreak() ) + switch ( rBreak.GetBreak() ) { -//JP 21.06.99: column breaks does never change to pagebreaks -// case SVX_BREAK_COLUMN_BEFORE: -// case SVX_BREAK_COLUMN_BOTH: - case SVX_BREAK_NONE: - case SVX_BREAK_PAGE_BEFORE: - case SVX_BREAK_PAGE_BOTH: - // sprmPPageBreakBefore/sprmPFPageBreakBefore - if (rWW8Wrt.bWrtWW8) - rWW8Wrt.InsUInt16(0x2407); - else - rWW8Wrt.pO->Insert(9, rWW8Wrt.pO->Count()); - rWW8Wrt.pO->Insert(rBreak.GetValue() ? 1 : 0, - rWW8Wrt.pO->Count()); - break; - default: - break; + // JP 21.06.99: column breaks never change to pagebreaks + // case SVX_BREAK_COLUMN_BEFORE: + // case SVX_BREAK_COLUMN_BOTH: + case SVX_BREAK_NONE: + case SVX_BREAK_PAGE_BEFORE: + case SVX_BREAK_PAGE_BOTH: + PageBreakBefore( rBreak.GetValue() ); + break; + default: + break; } } - else if (!rWW8Wrt.mpParentFrame) + else if ( !GetExport().mpParentFrame ) { - static const BYTE cColBreak = 0xe; - static const BYTE cPageBreak = 0xc; - BYTE nC = 0; bool bBefore = false; // --> OD 2007-05-29 #i76300# @@ -3596,95 +3656,83 @@ static Writer& OutWW8_SwFmtBreak( Writer& rWrt, const SfxPoolItem& rHt ) bool bCheckForFollowPageDesc = false; // <-- - switch( rBreak.GetBreak() ) + switch ( rBreak.GetBreak() ) { - case SVX_BREAK_NONE: // Ausgeschaltet - if( !rWW8Wrt.bBreakBefore ) - { - // sprmPPageBreakBefore/sprmPFPageBreakBefore - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x2407 ); - else - rWW8Wrt.pO->Insert( 9, rWW8Wrt.pO->Count() ); - rWW8Wrt.pO->Insert( (BYTE)0, rWW8Wrt.pO->Count() ); - } - return rWrt; + case SVX_BREAK_NONE: // Ausgeschaltet + if ( !GetExport().bBreakBefore ) + PageBreakBefore( false ); + return; - case SVX_BREAK_COLUMN_BEFORE: // ColumnBreak - bBefore = true; + case SVX_BREAK_COLUMN_BEFORE: // ColumnBreak + bBefore = true; // no break; - case SVX_BREAK_COLUMN_AFTER: - case SVX_BREAK_COLUMN_BOTH: - ASSERT (rWW8Wrt.pSepx, "how come this is 0"); - if (rWW8Wrt.pSepx && - rWW8Wrt.pSepx->CurrentNoColumns(*rWW8Wrt.pDoc) > 1) - { - nC = cColBreak; - } - break; + case SVX_BREAK_COLUMN_AFTER: + case SVX_BREAK_COLUMN_BOTH: + if ( GetExport().Sections().CurrentNumberOfColumns( *GetExport().pDoc ) > 1 ) + { + nC = msword::ColumnBreak; + } + break; - case SVX_BREAK_PAGE_BEFORE: // PageBreak - // From now on(fix for #i77900#) we prefer to save a page break as - // paragraph attribute, this has to be done after the export of the - // paragraph ( => !rWW8Wrt.bBreakBefore ) - if( !rWW8Wrt.bBreakBefore ) - { - // sprmPPageBreakBefore/sprmPFPageBreakBefore - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x2407 ); - else - rWW8Wrt.pO->Insert( 9, rWW8Wrt.pO->Count() ); - rWW8Wrt.pO->Insert( (BYTE)1, rWW8Wrt.pO->Count() ); - } - break; - case SVX_BREAK_PAGE_AFTER: - case SVX_BREAK_PAGE_BOTH: - nC = cPageBreak; - // --> OD 2007-05-29 #i76300# - // check for follow page description, if current writing attributes - // of a paragraph. - if ( dynamic_cast<const SwTxtNode*>(rWW8Wrt.pOutFmtNode) && - rWW8Wrt.GetCurItemSet() ) - { - bCheckForFollowPageDesc = true; - } - // <-- - break; - default: - break; + case SVX_BREAK_PAGE_BEFORE: // PageBreak + // From now on(fix for #i77900#) we prefer to save a page break as + // paragraph attribute, this has to be done after the export of the + // paragraph ( => !GetExport().bBreakBefore ) + if ( !GetExport().bBreakBefore ) + PageBreakBefore( true ); + break; + + case SVX_BREAK_PAGE_AFTER: + case SVX_BREAK_PAGE_BOTH: + nC = msword::PageBreak; + // --> OD 2007-05-29 #i76300# + // check for follow page description, if current writing attributes + // of a paragraph. + if ( dynamic_cast< const SwTxtNode* >( GetExport().pOutFmtNode ) && + GetExport().GetCurItemSet() ) + { + bCheckForFollowPageDesc = true; + } + // <-- + break; + + default: + break; } - if ( (bBefore == rWW8Wrt.bBreakBefore ) && nC ) // #49917# + if ( ( bBefore == GetExport().bBreakBefore ) && nC ) // #49917# { // --> OD 2007-05-29 #i76300# - bool bFollowPageDescWritten( false ); + bool bFollowPageDescWritten = false; if ( bCheckForFollowPageDesc && !bBefore ) { bFollowPageDescWritten = - rWW8Wrt.Out_FollowPageDesc( rWW8Wrt.GetCurItemSet(), - dynamic_cast<const SwTxtNode*>(rWW8Wrt.pOutFmtNode) ); + GetExport().OutputFollowPageDesc( GetExport().GetCurItemSet(), + dynamic_cast<const SwTxtNode*>( GetExport().pOutFmtNode ) ); } if ( !bFollowPageDescWritten ) { - rWW8Wrt.ReplaceCr( nC ); + SectionBreak( nC ); } // <-- } } - return rWrt; } -static Writer& OutWW8_SwTextGrid( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::SectionBreak( BYTE nC, const WW8_SepInfo* /*pSectionInfo*/ ) +{ + m_rWW8Export.ReplaceCr( nC ); +} + +void WW8AttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if (rWrtWW8.bOutPageDescs && rWrtWW8.bWrtWW8) + if ( m_rWW8Export.bOutPageDescs && m_rWW8Export.bWrtWW8 ) { - const SwTextGridItem& rItem = (const SwTextGridItem&)rHt; - UINT16 nGridType=0; - switch (rItem.GetGridType()) + UINT16 nGridType = 0; + switch ( rGrid.GetGridType() ) { default: - ASSERT(!(&rWrt), "Unknown grid type"); + ASSERT(false, "Unknown grid type"); case GRID_NONE: nGridType = 0; break; @@ -3692,103 +3740,95 @@ static Writer& OutWW8_SwTextGrid( Writer& rWrt, const SfxPoolItem& rHt ) nGridType = 2; break; case GRID_LINES_CHARS: - { - if(rItem.IsSnapToChars()) - { - nGridType = 3; - } - else - { - nGridType = 1; - } - } + if ( rGrid.IsSnapToChars() ) + nGridType = 3; + else + nGridType = 1; break; } - rWrtWW8.InsUInt16(0x5032); - rWrtWW8.InsUInt16(nGridType); - - UINT16 nHeight = rItem.GetBaseHeight() + rItem.GetRubyHeight(); - rWrtWW8.InsUInt16(0x9031); - rWrtWW8.InsUInt16(nHeight); - sal_uInt32 nPageCharSize = ItemGet<SvxFontHeightItem>(*(rWrtWW8.pStyles->GetSwFmt()), - RES_CHRATR_CJK_FONTSIZE).GetHeight(); - - INT32 nCharWidth = rItem.GetBaseWidth() - nPageCharSize; - INT32 nFraction = 0; - nFraction = nCharWidth%20; - if( nCharWidth < 0 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SClm ); + m_rWW8Export.InsUInt16( nGridType ); + + UINT16 nHeight = rGrid.GetBaseHeight() + rGrid.GetRubyHeight(); + m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaLinePitch ); + m_rWW8Export.InsUInt16( nHeight ); + + MSWordStyles * pStyles = m_rWW8Export.pStyles; + SwFmt * pSwFmt = pStyles->GetSwFmt(); + + sal_uInt32 nPageCharSize = 0; + + if (pSwFmt != NULL) + { + nPageCharSize = ItemGet<SvxFontHeightItem> + (*pSwFmt, RES_CHRATR_CJK_FONTSIZE).GetHeight(); + } + + INT32 nCharWidth = rGrid.GetBaseWidth() - nPageCharSize; + INT32 nFraction = 0; + nFraction = nCharWidth % 20; + if ( nCharWidth < 0 ) nFraction = 20 + nFraction; - nFraction = ((nFraction)*0xFFF)/20; - nFraction = (nFraction & 0x00000FFF); + nFraction = ( nFraction * 0xFFF ) / 20; + nFraction = ( nFraction & 0x00000FFF ); - INT32 nMain = 0; - nMain = nCharWidth/20; - if( nCharWidth < 0 ) + INT32 nMain = 0; + nMain = nCharWidth / 20; + if ( nCharWidth < 0 ) nMain -= 1; - nMain = nMain * 0x1000; - nMain = (nMain & 0xFFFFF000); + nMain = nMain * 0x1000; + nMain = ( nMain & 0xFFFFF000 ); - UINT32 nCharSpace = nFraction + nMain; - rWrtWW8.InsUInt16(0x7030); - rWrtWW8.InsUInt32(nCharSpace); + UINT32 nCharSpace = nFraction + nMain; + m_rWW8Export.InsUInt16( NS_sprm::LN_SDxtCharSpace ); + m_rWW8Export.InsUInt32( nCharSpace ); } - return rWrt; } -static Writer& OutWW8_SvxPaperBin( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatPaperBin( const SvxPaperBinItem& rPaperBin ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - const SvxPaperBinItem& rItem = (const SvxPaperBinItem&)rHt; - - if( rWrtWW8.bOutPageDescs ) + if ( m_rWW8Export.bOutPageDescs ) { USHORT nVal; - switch( rItem.GetValue() ) + switch ( rPaperBin.GetValue() ) { - case 0: nVal = 15; break; // Automatically select - case 1: nVal = 1; break; // Upper paper tray - case 2: nVal = 4; break; // Manual paper feed - default: nVal = 0; break; + case 0: nVal = 15; break; // Automatically select + case 1: nVal = 1; break; // Upper paper tray + case 2: nVal = 4; break; // Manual paper feed + default: nVal = 0; break; } - if( nVal ) + if ( nVal ) { - // sprmSDmBinFirst 0x5007 word - // sprmSDmBinOther 0x5008 word - BYTE nOff = rWrtWW8.bOutFirstPage ? 0 : 1; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x5007 + nOff ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( m_rWW8Export.bOutFirstPage? NS_sprm::LN_SDmBinFirst: NS_sprm::LN_SDmBinOther ); else - rWrtWW8.pO->Insert( 140 + nOff, rWrtWW8.pO->Count() ); - rWrtWW8.InsUInt16( nVal ); + m_rWW8Export.pO->Insert( m_rWW8Export.bOutFirstPage? 140: 141, m_rWW8Export.pO->Count() ); + + m_rWW8Export.InsUInt16( nVal ); } } - return rWrt; } -static Writer& OutWW8_SwFmtLRSpace( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - const SvxLRSpaceItem & rLR = (const SvxLRSpaceItem&) rHt; - - // Flys fehlen noch ( siehe RTF ) - if( rWW8Wrt.bOutFlyFrmAttrs ) // Flys + if ( m_rWW8Export.bOutFlyFrmAttrs ) // Flys { // sprmPDxaFromText10 - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x4622 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaFromText10 ); else - rWW8Wrt.pO->Insert( 49, rWW8Wrt.pO->Count() ); + m_rWW8Export.pO->Insert( 49, m_rWW8Export.pO->Count() ); // Mittelwert nehmen, da WW nur 1 Wert kennt - rWW8Wrt.InsUInt16( (USHORT) ( ( rLR.GetLeft() + rLR.GetRight() ) / 2 ) ); + m_rWW8Export.InsUInt16( (USHORT) ( ( rLR.GetLeft() + rLR.GetRight() ) / 2 ) ); } - else if( rWW8Wrt.bOutPageDescs ) // PageDescs + else if ( m_rWW8Export.bOutPageDescs ) // PageDescs { USHORT nLDist, nRDist; - const SfxPoolItem* pItem = ((SwWW8Writer&)rWrt).HasItem( RES_BOX ); - if( pItem ) + const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_BOX ); + if ( pItem ) { nRDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_LEFT ); nLDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_RIGHT ); @@ -3799,249 +3839,235 @@ static Writer& OutWW8_SwFmtLRSpace( Writer& rWrt, const SfxPoolItem& rHt ) nRDist = nRDist + (USHORT)rLR.GetRight(); // sprmSDxaLeft - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0xB021 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaLeft ); else - rWW8Wrt.pO->Insert( 166, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( nLDist ); + m_rWW8Export.pO->Insert( 166, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( nLDist ); + // sprmSDxaRight - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0xB022 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaRight ); else - rWW8Wrt.pO->Insert( 167, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( nRDist ); + m_rWW8Export.pO->Insert( 167, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( nRDist ); } else { // normale Absaetze // sprmPDxaLeft - if( rWW8Wrt.bWrtWW8 ) + if( m_rWW8Export.bWrtWW8 ) { - rWW8Wrt.InsUInt16( 0x845E ); //asian version ? - rWW8Wrt.InsUInt16( (USHORT)rLR.GetTxtLeft() ); - + m_rWW8Export.InsUInt16( 0x845E ); //asian version ? + m_rWW8Export.InsUInt16( (USHORT)rLR.GetTxtLeft() ); } else { - rWW8Wrt.pO->Insert( 17, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( (USHORT)rLR.GetTxtLeft() ); + m_rWW8Export.pO->Insert( 17, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( (USHORT)rLR.GetTxtLeft() ); } + // sprmPDxaRight - if( rWW8Wrt.bWrtWW8 ) + if( m_rWW8Export.bWrtWW8 ) { - rWW8Wrt.InsUInt16( 0x845D ); //asian version ? - rWW8Wrt.InsUInt16( (USHORT)rLR.GetRight() ); + m_rWW8Export.InsUInt16( 0x845D ); //asian version ? + m_rWW8Export.InsUInt16( (USHORT)rLR.GetRight() ); } else { - rWW8Wrt.pO->Insert( 16, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( (USHORT)rLR.GetRight() ); + m_rWW8Export.pO->Insert( 16, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( (USHORT)rLR.GetRight() ); } + // sprmPDxaLeft1 - if( rWW8Wrt.bWrtWW8 ) + if( m_rWW8Export.bWrtWW8 ) { - rWW8Wrt.InsUInt16( 0x8460 ); //asian version ? - rWW8Wrt.InsUInt16( rLR.GetTxtFirstLineOfst() ); + m_rWW8Export.InsUInt16( 0x8460 ); //asian version ? + m_rWW8Export.InsUInt16( rLR.GetTxtFirstLineOfst() ); } else { - rWW8Wrt.pO->Insert( 19, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( rLR.GetTxtFirstLineOfst() ); + m_rWW8Export.pO->Insert( 19, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( rLR.GetTxtFirstLineOfst() ); } } - return rWrt; } -static Writer& OutWW8_SwFmtULSpace( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - const SvxULSpaceItem & rUL = (const SvxULSpaceItem&) rHt; - // Flys fehlen noch ( siehe RTF ) - if( rWW8Wrt.bOutFlyFrmAttrs ) // Flys + if ( m_rWW8Export.bOutFlyFrmAttrs ) // Flys { // sprmPDyaFromText - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x842E ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaFromText ); else - rWW8Wrt.pO->Insert( 48, rWW8Wrt.pO->Count() ); + m_rWW8Export.pO->Insert( 48, m_rWW8Export.pO->Count() ); // Mittelwert nehmen, da WW nur 1 Wert kennt - rWW8Wrt.InsUInt16( (USHORT) ( ( rUL.GetUpper() + rUL.GetLower() ) / 2 ) ); + m_rWW8Export.InsUInt16( (USHORT) ( ( rUL.GetUpper() + rUL.GetLower() ) / 2 ) ); } - else if( rWW8Wrt.bOutPageDescs ) // Page-UL + else if ( m_rWW8Export.bOutPageDescs ) // Page-UL { - ASSERT(rWW8Wrt.GetCurItemSet(), "Impossible"); - if (!rWW8Wrt.GetCurItemSet()) - return rWrt; + ASSERT( m_rWW8Export.GetCurItemSet(), "Impossible" ); + if ( !m_rWW8Export.GetCurItemSet() ) + return; - HdFtDistanceGlue aDistances(*rWW8Wrt.GetCurItemSet()); + HdFtDistanceGlue aDistances( *m_rWW8Export.GetCurItemSet() ); - if (aDistances.HasHeader()) + if ( aDistances.HasHeader() ) { //sprmSDyaHdrTop - if (rWW8Wrt.bWrtWW8) - rWW8Wrt.InsUInt16(0xB017); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaHdrTop ); else - rWW8Wrt.pO->Insert(156, rWW8Wrt.pO->Count()); - rWW8Wrt.InsUInt16(aDistances.dyaHdrTop); + m_rWW8Export.pO->Insert( 156, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( aDistances.dyaHdrTop ); } // sprmSDyaTop - if (rWW8Wrt.bWrtWW8) - rWW8Wrt.InsUInt16(0x9023); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaTop ); else - rWW8Wrt.pO->Insert(168, rWW8Wrt.pO->Count()); - rWW8Wrt.InsUInt16(aDistances.dyaTop); + m_rWW8Export.pO->Insert( 168, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( aDistances.dyaTop ); - if (aDistances.HasFooter()) + if ( aDistances.HasFooter() ) { //sprmSDyaHdrBottom - if (rWW8Wrt.bWrtWW8) - rWW8Wrt.InsUInt16(0xB018); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaHdrBottom ); else - rWW8Wrt.pO->Insert(157, rWW8Wrt.pO->Count()); - rWW8Wrt.InsUInt16(aDistances.dyaHdrBottom); + m_rWW8Export.pO->Insert( 157, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( aDistances.dyaHdrBottom ); } //sprmSDyaBottom - if (rWW8Wrt.bWrtWW8) - rWW8Wrt.InsUInt16(0x9024); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaBottom ); else - rWW8Wrt.pO->Insert(169, rWW8Wrt.pO->Count()); - rWW8Wrt.InsUInt16(aDistances.dyaBottom); + m_rWW8Export.pO->Insert( 169, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( aDistances.dyaBottom ); } else { // sprmPDyaBefore - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0xA413 ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaBefore ); else - rWW8Wrt.pO->Insert( 21, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( rUL.GetUpper() ); + m_rWW8Export.pO->Insert( 21, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( rUL.GetUpper() ); // sprmPDyaAfter - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0xA414 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaAfter ); else - rWW8Wrt.pO->Insert( 22, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( rUL.GetLower() ); + m_rWW8Export.pO->Insert( 22, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( rUL.GetLower() ); } - return rWrt; } // Print, Opaque, Protect fehlen noch -static Writer& OutWW8_SwFmtSurround( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatSurround( const SwFmtSurround& rSurround ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - if( rWW8Wrt.bOutFlyFrmAttrs ) + if ( m_rWW8Export.bOutFlyFrmAttrs ) { - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x2423 ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PWr ); else - rWW8Wrt.pO->Insert( 37, rWW8Wrt.pO->Count() ); + m_rWW8Export.pO->Insert( 37, m_rWW8Export.pO->Count() ); - rWW8Wrt.pO->Insert( (SURROUND_NONE != - ((const SwFmtSurround&) rHt).GetSurround() ) - ? 2 : 1, rWW8Wrt.pO->Count() ); + m_rWW8Export.pO->Insert( + ( SURROUND_NONE != rSurround.GetSurround() ) ? 2 : 1, + m_rWW8Export.pO->Count() ); } - return rWrt; } -Writer& OutWW8_SwFmtVertOrient( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - //!!!! Ankertyp und entsprechende Umrechnung fehlt noch - if( rWW8Wrt.bOutFlyFrmAttrs ) + if ( m_rWW8Export.bOutFlyFrmAttrs ) { - const SwFmtVertOrient& rFlyVert = (const SwFmtVertOrient&) rHt; - short nPos; switch( rFlyVert.GetVertOrient() ) { - case text::VertOrientation::NONE: - nPos = (short)rFlyVert.GetPos(); - break; - case text::VertOrientation::CENTER: - case text::VertOrientation::LINE_CENTER: - nPos = -8; - break; - case text::VertOrientation::BOTTOM: - case text::VertOrientation::LINE_BOTTOM: - nPos = -12; - break; - case text::VertOrientation::TOP: - case text::VertOrientation::LINE_TOP: - default: - nPos = -4; - break; + case text::VertOrientation::NONE: + nPos = (short)rFlyVert.GetPos(); + break; + case text::VertOrientation::CENTER: + case text::VertOrientation::LINE_CENTER: + nPos = -8; + break; + case text::VertOrientation::BOTTOM: + case text::VertOrientation::LINE_BOTTOM: + nPos = -12; + break; + case text::VertOrientation::TOP: + case text::VertOrientation::LINE_TOP: + default: + nPos = -4; + break; } // sprmPDyaAbs - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x8419 ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaAbs ); else - rWW8Wrt.pO->Insert( 27, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( nPos ); + m_rWW8Export.pO->Insert( 27, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( nPos ); } - return rWrt; } -Writer& OutWW8_SwFmtHoriOrient( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - if (!rWW8Wrt.mpParentFrame) + if ( !m_rWW8Export.mpParentFrame ) { - ASSERT(rWW8Wrt.mpParentFrame, "HoriOrient without mpParentFrame !!"); - return rWrt; + ASSERT( m_rWW8Export.mpParentFrame, "HoriOrient without mpParentFrame !!" ); + return; } //!!!! Ankertyp und entsprechende Umrechnung fehlt noch - if( rWW8Wrt.bOutFlyFrmAttrs ) + if ( m_rWW8Export.bOutFlyFrmAttrs ) { - const SwFmtHoriOrient& rFlyHori = (const SwFmtHoriOrient&) rHt; - short nPos; switch( rFlyHori.GetHoriOrient() ) { - case text::HoriOrientation::NONE: { - nPos = (short)rFlyHori.GetPos(); - if( !nPos ) - nPos = 1; // WW: 0 ist reserviert - } - break; - - case text::HoriOrientation::LEFT: nPos = rFlyHori.IsPosToggle() ? -12 : 0; - break; - case text::HoriOrientation::RIGHT: nPos = rFlyHori.IsPosToggle() ? -16 : -8; - break; - case text::HoriOrientation::CENTER: - case text::HoriOrientation::FULL: // FULL nur fuer Tabellen - default: nPos = -4; break; + case text::HoriOrientation::NONE: + nPos = (short)rFlyHori.GetPos(); + if( !nPos ) + nPos = 1; // WW: 0 ist reserviert + break; + case text::HoriOrientation::LEFT: + nPos = rFlyHori.IsPosToggle() ? -12 : 0; + break; + case text::HoriOrientation::RIGHT: + nPos = rFlyHori.IsPosToggle() ? -16 : -8; + break; + case text::HoriOrientation::CENTER: + case text::HoriOrientation::FULL: // FULL nur fuer Tabellen + default: + nPos = -4; + break; } // sprmPDxaAbs - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x8418 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaAbs ); else - rWW8Wrt.pO->Insert( 26, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( nPos ); + m_rWW8Export.pO->Insert( 26, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( nPos ); } - return rWrt; } -static Writer& OutWW8_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - ASSERT(rWW8Wrt.mpParentFrame, "Anchor without mpParentFrame !!"); + ASSERT( m_rWW8Export.mpParentFrame, "Anchor without mpParentFrame !!" ); - if( rWW8Wrt.bOutFlyFrmAttrs ) + if ( m_rWW8Export.bOutFlyFrmAttrs ) { - const SwFmtAnchor& rAnchor = (const SwFmtAnchor&) rHt; BYTE nP = 0; - switch( rAnchor.GetAnchorId() ) + switch ( rAnchor.GetAnchorId() ) { case FLY_PAGE: // Vert: Page | Horz: Page @@ -4060,48 +4086,43 @@ static Writer& OutWW8_SwFmtAnchor( Writer& rWrt, const SfxPoolItem& rHt ) } // sprmPPc - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x261B ); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PPc ); else - rWW8Wrt.pO->Insert( 29, rWW8Wrt.pO->Count() ); - rWW8Wrt.pO->Insert( nP, rWW8Wrt.pO->Count() ); + m_rWW8Export.pO->Insert( 29, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( nP, m_rWW8Export.pO->Count() ); } - return rWrt; } -static Writer& OutWW8_SwFmtBackground( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - - if( !rWW8Wrt.bOutPageDescs ) // WW kann keinen Hintergrund - { // in Section - const SvxBrushItem& rBack = (const SvxBrushItem&)rHt; + // WW cannot have background in a section + if ( !m_rWW8Export.bOutPageDescs ) + { WW8_SHD aSHD; - rWW8Wrt.TransBrush(rBack.GetColor(), aSHD); + m_rWW8Export.TransBrush( rBrush.GetColor(), aSHD ); // sprmPShd - if (rWW8Wrt.bWrtWW8) - rWW8Wrt.InsUInt16(0x442D); + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PShd ); else - rWW8Wrt.pO->Insert(47, rWW8Wrt.pO->Count()); - rWW8Wrt.InsUInt16( aSHD.GetValue() ); + m_rWW8Export.pO->Insert(47, m_rWW8Export.pO->Count()); + m_rWW8Export.InsUInt16( aSHD.GetValue() ); - //Quite a few unknowns, some might be transparency or something - //of that nature... - if (rWW8Wrt.bWrtWW8) + // Quite a few unknowns, some might be transparency or something + // of that nature... + if ( m_rWW8Export.bWrtWW8 ) { - rWW8Wrt.InsUInt16(0xC64D); - rWW8Wrt.pO->Insert(10, rWW8Wrt.pO->Count()); - rWW8Wrt.InsUInt32(0xFF000000); - rWW8Wrt.InsUInt32(SuitableBGColor( - rBack.GetColor().GetColor())); - rWW8Wrt.InsUInt16(0x0000); + m_rWW8Export.InsUInt16( 0xC64D ); + m_rWW8Export.pO->Insert( 10, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt32( 0xFF000000 ); + m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor().GetColor() ) ); + m_rWW8Export.InsUInt16( 0x0000 ); } } - return rWrt; } -WW8_BRC SwWW8Writer::TranslateBorderLine(const SvxBorderLine& rLine, +WW8_BRC WW8Export::TranslateBorderLine(const SvxBorderLine& rLine, USHORT nDist, bool bShadow) { // M.M. This function writes out border lines to the word format similar to @@ -4184,12 +4205,14 @@ WW8_BRC SwWW8Writer::TranslateBorderLine(const SvxBorderLine& rLine, // auch fuer die Tabellen-Umrandungen zu benutzen. // Wenn nSprmNo == 0, dann wird der Opcode nicht ausgegeben. // bShadow darf bei Tabellenzellen *nicht* gesetzt sein ! -void SwWW8Writer::Out_BorderLine(WW8Bytes& rO, const SvxBorderLine* pLine, - USHORT nDist, USHORT nOffset, bool bShadow) +void WW8Export::Out_BorderLine(WW8Bytes& rO, const SvxBorderLine* pLine, + USHORT nDist, sal_uInt16 nSprmNo, bool bShadow) { - ASSERT( (nOffset <= 3) || USHRT_MAX == nOffset || - ((0x702b - 0x6424) <= nOffset && nOffset <= (0x702e - 0x6424)), - "SprmOffset ausserhalb des Bereichs" ); + ASSERT( ( nSprmNo == 0 ) || + ( nSprmNo >= 38 && nSprmNo <= 41 ) || + ( nSprmNo >= NS_sprm::LN_PBrcTop && nSprmNo <= NS_sprm::LN_PBrcRight ) || + ( nSprmNo >= NS_sprm::LN_SBrcTop && nSprmNo <= NS_sprm::LN_SBrcRight ), + "Sprm for border out is of range" ); WW8_BRC aBrc; @@ -4198,68 +4221,70 @@ void SwWW8Writer::Out_BorderLine(WW8Bytes& rO, const SvxBorderLine* pLine, if( bWrtWW8 ) { -// WW97-SprmIds -// 0x6424, sprmPBrcTop pap.brcTop;BRC;long; !!!! -// 0x6425, sprmPBrcLeft -// 0x6426, sprmPBrcBottom -// 0x6427, sprmPBrcRight - if( USHRT_MAX != nOffset ) // mit OpCode-Ausgabe ? - SwWW8Writer::InsUInt16( rO, 0x6424 + nOffset ); + // WW97-SprmIds + if ( nSprmNo != 0 ) + SwWW8Writer::InsUInt16( rO, nSprmNo ); rO.Insert( aBrc.aBits1, 2, rO.Count() ); rO.Insert( aBrc.aBits2, 2, rO.Count() ); } else { -// WW95-SprmIds -// 38, sprmPBrcTop - pap.brcTop BRC short !!! -// 39, sprmPBrcLeft -// 40, sprmPBrcBottom -// 41, sprmPBrcRight - if( USHRT_MAX != nOffset ) // mit OpCode-Ausgabe ? - rO.Insert( (BYTE)( 38 + nOffset ), rO.Count() ); + // WW95-SprmIds + if ( nSprmNo != 0 ) + rO.Insert( (BYTE)( nSprmNo ), rO.Count() ); rO.Insert( aBrc.aBits1, 2, rO.Count() ); } } -// OutWW8_SwFmtBox1() ist fuer alle Boxen ausser in Tabellen. +// FormatBox1() ist fuer alle Boxen ausser in Tabellen. // es wird pO des WW8Writers genommen -void SwWW8Writer::Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow) +void WW8Export::Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow) { - USHORT nOffset = 0; - if( bOutPageDescs ) - { - if( !bWrtWW8 ) - return ; // WW95 kennt keine Seitenumrandung - -// WW97-SprmIds -// 0x702b, sprmSBrcTop pap.brcTop;BRC;long; !!!! -// 0x702c, sprmSBrcLeft -// 0x702d, sprmSBrcBottom -// 0x702e, sprmSBrcRight - nOffset = (0x702b - 0x6424); - } + if ( bOutPageDescs && !bWrtWW8 ) + return; // no page ouline in WW6 static const USHORT aBorders[] = { BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT }; + static const sal_uInt16 aPBrc[] = + { + NS_sprm::LN_PBrcTop, NS_sprm::LN_PBrcLeft, NS_sprm::LN_PBrcBottom, NS_sprm::LN_PBrcRight + }; + static const sal_uInt16 aSBrc[] = + { + NS_sprm::LN_SBrcTop, NS_sprm::LN_SBrcLeft, NS_sprm::LN_SBrcBottom, NS_sprm::LN_SBrcRight + }; + static const sal_uInt16 aWW6PBrc[] = + { + 38, 39, 40, 41 + }; + const USHORT* pBrd = aBorders; for( USHORT i = 0; i < 4; ++i, ++pBrd ) { const SvxBorderLine* pLn = rBox.GetLine( *pBrd ); - Out_BorderLine( *pO, pLn, rBox.GetDistance( *pBrd ), nOffset+i, - bShadow ); + + sal_uInt16 nSprmNo = 0; + if ( !bWrtWW8 ) + nSprmNo = aWW6PBrc[i]; + else if ( bOutPageDescs ) + nSprmNo = aSBrc[i]; + else + nSprmNo = aPBrc[i]; + + Out_BorderLine( *pO, pLn, rBox.GetDistance( *pBrd ), nSprmNo, bShadow ); } } -// OutWW8_SwFmtBox2() ist fuer TC-Strukturen in Tabellen. Der Sprm-Opcode +// FormatBox2() ist fuer TC-Strukturen in Tabellen. Der Sprm-Opcode // wird nicht geschrieben, da es in der TC-Structur ohne Opcode gepackt ist. // dxpSpace wird immer 0, da WW das in Tabellen so verlangt // ( Tabellenumrandungen fransen sonst aus ) // Ein WW8Bytes-Ptr wird als Ausgabe-Parameter uebergeben -void SwWW8Writer::Out_SwFmtTableBox( WW8Bytes& rO, const SvxBoxItem& rBox ) +void WW8Export::Out_SwFmtTableBox( WW8Bytes& rO, const SvxBoxItem& rBox ) { // moeglich und vielleicht besser waere 0xffff static const USHORT aBorders[] = @@ -4270,32 +4295,30 @@ void SwWW8Writer::Out_SwFmtTableBox( WW8Bytes& rO, const SvxBoxItem& rBox ) for( int i = 0; i < 4; ++i, ++pBrd ) { const SvxBorderLine* pLn = rBox.GetLine( *pBrd ); - Out_BorderLine(rO, pLn, 0, USHRT_MAX, false); + Out_BorderLine(rO, pLn, 0, 0, false); } } -static Writer& OutWW8_SwFmtBox( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatBox( const SvxBoxItem& rBox ) { - // Fly um Grafik-> keine Umrandung hier, da - // der GrafikHeader bereits die Umrandung hat - SwWW8Writer& rWW8Wrt = ((SwWW8Writer&)rWrt); - if( !rWW8Wrt.bOutGrf ) + // Fly um Grafik-> keine Umrandung hier, da + // der GrafikHeader bereits die Umrandung hat + if ( !m_rWW8Export.bOutGrf ) { bool bShadow = false; - const SfxPoolItem* pItem = ((SwWW8Writer&)rWrt).HasItem( RES_SHADOW ); - if( pItem ) + const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_SHADOW ); + if ( pItem ) { const SvxShadowItem* p = (const SvxShadowItem*)pItem; bShadow = ( p->GetLocation() != SVX_SHADOW_NONE ) && ( p->GetWidth() != 0 ); } - rWW8Wrt.Out_SwFmtBox( (SvxBoxItem&)rHt, bShadow ); + m_rWW8Export.Out_SwFmtBox( rBox, bShadow ); } - return rWrt; } -SwTwips SwWW8Writer::CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const +SwTwips WW8Export::CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const { const SwFrmFmt* pFmt = pAktPageDesc ? &pAktPageDesc->GetMaster() : &const_cast<const SwDoc *>(pDoc)->GetPageDesc(0).GetMaster(); @@ -4307,28 +4330,109 @@ SwTwips SwWW8Writer::CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const return nPageSize; } -static Writer& OutWW8_SwFmtCol( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatColumns_Impl( USHORT nCols, const SwFmtCol & rCol, bool bEven, SwTwips nPageSize ) +{ + // CColumns + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SCcolumns ); + else + m_rWW8Export.pO->Insert( 144, m_rWW8Export.pO->Count( ) ); + m_rWW8Export.InsUInt16( nCols - 1 ); + + // DxaColumns + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaColumns ); + else + m_rWW8Export.pO->Insert( 145, m_rWW8Export.pO->Count( ) ); + m_rWW8Export.InsUInt16( rCol.GetGutterWidth( true ) ); + + // LBetween + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SLBetween ); + else + m_rWW8Export.pO->Insert( 158, m_rWW8Export.pO->Count( ) ); + m_rWW8Export.pO->Insert( COLADJ_NONE == rCol.GetLineAdj( )? 0 : 1, + m_rWW8Export.pO->Count( ) ); + + const SwColumns & rColumns = rCol.GetColumns( ); + + // FEvenlySpaced + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SFEvenlySpaced ); + else + m_rWW8Export.pO->Insert( 138, m_rWW8Export.pO->Count( ) ); + m_rWW8Export.pO->Insert( bEven ? 1 : 0, m_rWW8Export.pO->Count( ) ); + +#if 0 + // FIXME what's the use of this code + if ( bEven ) + { + USHORT nSpace = rColumns[0]->GetRight() + rColumns[1]->GetLeft(); + for ( n = 2; n < nCols; n++ ) + { + short nDiff = nSpace - ( rColumns[n - 1]->GetRight() + + rColumns[n]->GetLeft() ); + if (nDiff > 10 || nDiff < -10) + { + // Toleranz: 10 tw + bEven = false; + break; + } + } + } +#endif + + if ( !bEven ) + { + for ( USHORT n = 0; n < nCols; ++n ) + { + //sprmSDxaColWidth + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaColWidth ); + else + m_rWW8Export.pO->Insert( 136, m_rWW8Export.pO->Count( ) ); + m_rWW8Export.pO->Insert( ( BYTE ) n, m_rWW8Export.pO->Count( ) ); + m_rWW8Export.InsUInt16( rCol. + CalcPrtColWidth( n, + ( USHORT ) nPageSize ) ); + + if ( n + 1 != nCols ) + { + //sprmSDxaColSpacing + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaColSpacing ); + else + m_rWW8Export.pO->Insert( 137, + m_rWW8Export.pO->Count( ) ); + m_rWW8Export.pO->Insert( ( BYTE ) n, + m_rWW8Export.pO->Count( ) ); + m_rWW8Export.InsUInt16( rColumns[n]->GetRight( ) + + rColumns[n + 1]->GetLeft( ) ); + } + } + } +} + +void AttributeOutputBase::FormatColumns( const SwFmtCol& rCol ) { - const SwFmtCol& rCol = (const SwFmtCol&)rHt; const SwColumns& rColumns = rCol.GetColumns(); - SwWW8Writer& rWW8Wrt = ((SwWW8Writer&)rWrt); USHORT nCols = rColumns.Count(); - if (1 < nCols && !rWW8Wrt.bOutFlyFrmAttrs) + if ( 1 < nCols && !GetExport( ).bOutFlyFrmAttrs ) { // dann besorge mal die Seitenbreite ohne Raender !! - const SwFrmFmt* pFmt = rWW8Wrt.pAktPageDesc ? &rWW8Wrt.pAktPageDesc->GetMaster() : &const_cast<const SwDoc *>(rWW8Wrt.pDoc)->GetPageDesc(0).GetMaster(); + const SwFrmFmt* pFmt = GetExport( ).pAktPageDesc ? &GetExport( ).pAktPageDesc->GetMaster() : &const_cast<const SwDoc *>(GetExport( ).pDoc)->GetPageDesc(0).GetMaster(); const SvxFrameDirectionItem &frameDirection = pFmt->GetFrmDir(); SwTwips nPageSize; - if (frameDirection.GetValue() == FRMDIR_VERT_TOP_RIGHT || frameDirection.GetValue() == FRMDIR_VERT_TOP_LEFT) + if ( frameDirection.GetValue() == FRMDIR_VERT_TOP_RIGHT || frameDirection.GetValue() == FRMDIR_VERT_TOP_LEFT ) { const SvxULSpaceItem &rUL = pFmt->GetULSpace(); nPageSize = pFmt->GetFrmSize().GetHeight(); nPageSize -= rUL.GetUpper() + rUL.GetLower(); const SwFmtHeader *header = dynamic_cast<const SwFmtHeader *>(pFmt->GetAttrSet().GetItem(RES_HEADER)); - if (header) + if ( header ) { const SwFrmFmt *headerFmt = header->GetHeaderFmt(); if (headerFmt) @@ -4337,10 +4441,10 @@ static Writer& OutWW8_SwFmtCol( Writer& rWrt, const SfxPoolItem& rHt ) } } const SwFmtFooter *footer = dynamic_cast<const SwFmtFooter *>(pFmt->GetAttrSet().GetItem(RES_FOOTER)); - if (footer) + if ( footer ) { const SwFrmFmt *footerFmt = footer->GetFooterFmt(); - if (footerFmt) + if ( footerFmt ) { nPageSize -= footerFmt->GetFrmSize().GetHeight(); } @@ -4353,144 +4457,70 @@ static Writer& OutWW8_SwFmtCol( Writer& rWrt, const SfxPoolItem& rHt ) nPageSize -= rLR.GetLeft() + rLR.GetRight(); } - // CColumns - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x500b ); - else - rWW8Wrt.pO->Insert( 144, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( nCols - 1 ); - - // DxaColumns - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x900c ); - else - rWW8Wrt.pO->Insert( 145, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16(rCol.GetGutterWidth(true)); - - // LBetween - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x3019 ); - else - rWW8Wrt.pO->Insert( 158, rWW8Wrt.pO->Count() ); - rWW8Wrt.pO->Insert( COLADJ_NONE == rCol.GetLineAdj() ? 0 : 1, - rWW8Wrt.pO->Count() ); - // Nachsehen, ob alle Spalten gleich sind bool bEven = true; USHORT n; USHORT nColWidth = rCol.CalcPrtColWidth( 0, (USHORT)nPageSize ); - for (n = 1; n < nCols; n++) + for ( n = 1; n < nCols; n++ ) { short nDiff = nColWidth - rCol.CalcPrtColWidth( n, (USHORT)nPageSize ); - if( nDiff > 10 || nDiff < -10 ) // Toleranz: 10 tw + if ( nDiff > 10 || nDiff < -10 ) // Toleranz: 10 tw { bEven = false; break; } } - if (bEven) - { - USHORT nSpace = rColumns[0]->GetRight() + rColumns[1]->GetLeft(); - for( n = 2; n < nCols; n++ ) - { - short nDiff = nSpace - ( rColumns[n - 1]->GetRight() - + rColumns[n]->GetLeft() ); - if (nDiff > 10 || nDiff < -10) - { - // Toleranz: 10 tw - bEven = false; - break; - } - } - } - - // FEvenlySpaced - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0x3005 ); - else - rWW8Wrt.pO->Insert( 138, rWW8Wrt.pO->Count() ); - rWW8Wrt.pO->Insert( bEven ? 1 : 0, rWW8Wrt.pO->Count() ); - - if( !bEven ) - { - for (n = 0; n < nCols; ++n) - { - //sprmSDxaColWidth - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0xF203 ); - else - rWW8Wrt.pO->Insert( 136, rWW8Wrt.pO->Count() ); - rWW8Wrt.pO->Insert( (BYTE)n, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16(rCol.CalcPrtColWidth(n, (USHORT)nPageSize)); - - if( n+1 != nCols ) - { - //sprmSDxaColSpacing - if( rWW8Wrt.bWrtWW8 ) - rWW8Wrt.InsUInt16( 0xF204 ); - else - rWW8Wrt.pO->Insert( 137, rWW8Wrt.pO->Count() ); - rWW8Wrt.pO->Insert( (BYTE)n, rWW8Wrt.pO->Count() ); - rWW8Wrt.InsUInt16( rColumns[ n ]->GetRight() + - rColumns[ n + 1 ]->GetLeft() ); - } - } - } + + FormatColumns_Impl( nCols, rCol, bEven, nPageSize ); } - return rWrt; } -// "Absaetze zusammenhalten" -static Writer& OutWW8_SvxFmtKeep( Writer& rWrt, const SfxPoolItem& rHt ) +// "Paragraphs together" +void WW8AttributeOutput::FormatKeep( const SvxFmtKeepItem& rKeep ) { -// sprmFKeepFollow - const SvxFmtKeepItem& rAttr = (const SvxFmtKeepItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x2406 ); + // sprmFKeepFollow + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PFKeepFollow ); else - rWrtWW8.pO->Insert( 8, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( 8, m_rWW8Export.pO->Count() ); - rWrtWW8.pO->Insert( rAttr.GetValue() ? 1 : 0, rWrtWW8.pO->Count() ); - return rWrt; + m_rWW8Export.pO->Insert( rKeep.GetValue() ? 1 : 0, m_rWW8Export.pO->Count() ); } - // exclude a paragraph from Line Numbering -static Writer& OutWW8_SwFmtLineNumber( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatLineNumbering( const SwFmtLineNumber& rNumbering ) { -// sprmPFNoLineNumb - const SwFmtLineNumber& rAttr = (const SwFmtLineNumber&)rHt; - - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x240C ); + // sprmPFNoLineNumb + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PFNoLineNumb ); else - rWrtWW8.pO->Insert( 14, rWrtWW8.pO->Count() ); - - rWrtWW8.pO->Insert( rAttr.IsCount() ? 0 : 1, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( 14, m_rWW8Export.pO->Count() ); - return rWrt; + m_rWW8Export.pO->Insert( rNumbering.IsCount() ? 0 : 1, m_rWW8Export.pO->Count() ); } /* File PARATR.HXX */ -static Writer& OutWW8_SvxLineSpacing( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti ) { -// sprmPDyaLine - const SvxLineSpacingItem& rAttr = (const SvxLineSpacingItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x6412 ); + // sprmPDyaLine + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaLine ); else - rWrtWW8.pO->Insert( 20, rWrtWW8.pO->Count() ); + m_rWW8Export.pO->Insert( 20, m_rWW8Export.pO->Count() ); + m_rWW8Export.InsUInt16( nSpace ); + m_rWW8Export.InsUInt16( nMulti ); +} + +void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing ) +{ short nSpace = 240, nMulti = 0; - switch (rAttr.GetLineSpaceRule()) + switch ( rSpacing.GetLineSpaceRule() ) { default: break; @@ -4498,68 +4528,63 @@ static Writer& OutWW8_SvxLineSpacing( Writer& rWrt, const SfxPoolItem& rHt ) case SVX_LINE_SPACE_FIX: case SVX_LINE_SPACE_MIN: { - switch (rAttr.GetInterLineSpaceRule()) + switch ( rSpacing.GetInterLineSpaceRule() ) { case SVX_INTER_LINE_SPACE_FIX: // unser Durchschuss { // gibt es aber nicht in WW - also wie kommt man an // die MaxLineHeight heran? - nSpace = (short)rAttr.GetInterLineSpace(); + nSpace = (short)rSpacing.GetInterLineSpace(); sal_uInt16 nScript = i18n::ScriptType::LATIN; const SwAttrSet *pSet = 0; - if (rWrtWW8.pOutFmtNode && rWrtWW8.pOutFmtNode->ISA(SwFmt)) + if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwFmt ) ) { - const SwFmt *pFmt = (const SwFmt*)(rWrtWW8.pOutFmtNode); + const SwFmt *pFmt = (const SwFmt*)( GetExport().pOutFmtNode ); pSet = &pFmt->GetAttrSet(); } - else if (rWrtWW8.pOutFmtNode && - rWrtWW8.pOutFmtNode->ISA(SwTxtNode)) + else if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwTxtNode ) ) { - const SwTxtNode* pNd = - (const SwTxtNode*)rWrtWW8.pOutFmtNode; + const SwTxtNode* pNd = (const SwTxtNode*)GetExport().pOutFmtNode; pSet = &pNd->GetSwAttrSet(); - if (pBreakIt->xBreak.is()) + if ( pBreakIt->GetBreakIter().is() ) { - nScript = pBreakIt->xBreak-> + nScript = pBreakIt->GetBreakIter()-> getScriptType(pNd->GetTxt(), 0); } } - ASSERT(pSet, "No attrset for lineheight :-("); - if (pSet) + ASSERT( pSet, "No attrset for lineheight :-(" ); + if ( pSet ) { - nSpace = nSpace + (short)(AttrSetToLineHeight(*rWrtWW8.pDoc, - *pSet, *Application::GetDefaultDevice(), nScript)); + nSpace = nSpace + (short)( AttrSetToLineHeight( *GetExport().pDoc, + *pSet, *Application::GetDefaultDevice(), nScript ) ); } } break; case SVX_INTER_LINE_SPACE_PROP: - nSpace = (short)(( 240L * rAttr.GetPropLineSpace() ) / 100L ); + nSpace = (short)( ( 240L * rSpacing.GetPropLineSpace() ) / 100L ); nMulti = 1; break; default: // z.B. Minimum oder FIX? - if( SVX_LINE_SPACE_FIX == rAttr.GetLineSpaceRule() ) - nSpace = -(short)rAttr.GetLineHeight(); + if ( SVX_LINE_SPACE_FIX == rSpacing.GetLineSpaceRule() ) + nSpace = -(short)rSpacing.GetLineHeight(); else - nSpace = (short)rAttr.GetLineHeight(); + nSpace = (short)rSpacing.GetLineHeight(); break; } } break; } - rWrtWW8.InsUInt16(nSpace); - rWrtWW8.InsUInt16(nMulti); - return rWrt; + ParaLineSpacing_Impl( nSpace, nMulti ); } -static Writer& OutWW8_SvxAdjust(Writer& rWrt, const SfxPoolItem& rHt) +void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust ) { -// sprmPJc - const SvxAdjustItem& rAttr = (const SvxAdjustItem&)rHt; + // sprmPJc BYTE nAdj = 255; BYTE nAdjBiDi = 255; - switch(rAttr.GetAdjust()) + switch ( rAdjust.GetAdjust() ) { case SVX_ADJUST_LEFT: nAdj = 0; @@ -4577,101 +4602,99 @@ static Writer& OutWW8_SvxAdjust(Writer& rWrt, const SfxPoolItem& rHt) nAdj = nAdjBiDi = 1; break; default: - return rWrt; // not a supported Attribut + return; // not a supported Attribut } - if (255 != nAdj) // supported Attribut? + if ( 255 != nAdj ) // supported Attribut? { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if (rWrtWW8.bWrtWW8) + if ( m_rWW8Export.bWrtWW8 ) { - rWrtWW8.InsUInt16(0x2403); - rWrtWW8.pO->Insert(nAdj, rWrtWW8.pO->Count()); + m_rWW8Export.InsUInt16( NS_sprm::LN_PJc ); + m_rWW8Export.pO->Insert( nAdj, m_rWW8Export.pO->Count() ); /* Sadly for left to right paragraphs both these values are the same, for right to left paragraphs the bidi one is the reverse of the normal one. */ - rWrtWW8.InsUInt16(0x2461); //bidi version ? - bool bBiDiSwap=false; - if (rWrtWW8.pOutFmtNode) + m_rWW8Export.InsUInt16( NS_sprm::LN_PJcExtra ); //bidi version ? + bool bBiDiSwap = false; + if ( m_rWW8Export.pOutFmtNode ) { short nDirection = FRMDIR_HORI_LEFT_TOP; - if (rWrtWW8.pOutFmtNode->ISA(SwTxtNode)) + if ( m_rWW8Export.pOutFmtNode->ISA( SwTxtNode ) ) { - SwPosition aPos(*(const SwCntntNode*)rWrtWW8.pOutFmtNode); - nDirection = rWrtWW8.pDoc->GetTextDirection(aPos); + SwPosition aPos(*(const SwCntntNode*)m_rWW8Export.pOutFmtNode); + nDirection = m_rWW8Export.pDoc->GetTextDirection(aPos); } - else if (rWrtWW8.pOutFmtNode->ISA(SwTxtFmtColl)) + else if ( m_rWW8Export.pOutFmtNode->ISA( SwTxtFmtColl ) ) { const SwTxtFmtColl* pC = - (const SwTxtFmtColl*)rWrtWW8.pOutFmtNode; + (const SwTxtFmtColl*)m_rWW8Export.pOutFmtNode; const SvxFrameDirectionItem &rItem = ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR); nDirection = rItem.GetValue(); } - if ((nDirection == FRMDIR_HORI_RIGHT_TOP) - || (nDirection == FRMDIR_ENVIRONMENT && Application::GetSettings().GetLayoutRTL())) - bBiDiSwap=true; + if ( ( nDirection == FRMDIR_HORI_RIGHT_TOP ) || + ( nDirection == FRMDIR_ENVIRONMENT && Application::GetSettings().GetLayoutRTL() ) ) + { + bBiDiSwap = true; + } } - if (bBiDiSwap) - rWrtWW8.pO->Insert(nAdjBiDi, rWrtWW8.pO->Count()); + if ( bBiDiSwap ) + m_rWW8Export.pO->Insert( nAdjBiDi, m_rWW8Export.pO->Count() ); else - rWrtWW8.pO->Insert(nAdj, rWrtWW8.pO->Count()); + m_rWW8Export.pO->Insert( nAdj, m_rWW8Export.pO->Count() ); } else { - rWrtWW8.pO->Insert(5, rWrtWW8.pO->Count()); - rWrtWW8.pO->Insert(nAdj, rWrtWW8.pO->Count()); + m_rWW8Export.pO->Insert( 5, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( nAdj, m_rWW8Export.pO->Count() ); } } - return rWrt; } -static Writer& OutWW8_SvxFrameDirection( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection ) { - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if (!rWrtWW8.bWrtWW8) //8+ only - return rWrt; + if ( !m_rWW8Export.bWrtWW8 ) //8+ only + return; - const SvxFrameDirectionItem& rItem = (const SvxFrameDirectionItem&)rHt; UINT16 nTextFlow=0; bool bBiDi = false; - short nDir = rItem.GetValue(); + short nDir = rDirection.GetValue(); - if (nDir == FRMDIR_ENVIRONMENT) + if ( nDir == FRMDIR_ENVIRONMENT ) { - if (rWrtWW8.bOutPageDescs) - nDir = rWrtWW8.GetCurrentPageDirection(); - else if (rWrtWW8.pOutFmtNode) + if ( m_rWW8Export.bOutPageDescs ) + nDir = m_rWW8Export.GetCurrentPageDirection(); + else if ( m_rWW8Export.pOutFmtNode ) { - if (rWrtWW8.bOutFlyFrmAttrs) //frame + if ( m_rWW8Export.bOutFlyFrmAttrs ) //frame { - nDir = rWrtWW8.TrueFrameDirection( - *(const SwFrmFmt*)rWrtWW8.pOutFmtNode); + nDir = m_rWW8Export.TrueFrameDirection( + *(const SwFrmFmt*)m_rWW8Export.pOutFmtNode ); } - else if (rWrtWW8.pOutFmtNode->ISA(SwCntntNode)) //pagagraph + else if ( m_rWW8Export.pOutFmtNode->ISA( SwCntntNode ) ) //pagagraph { const SwCntntNode* pNd = - (const SwCntntNode*)rWrtWW8.pOutFmtNode; - SwPosition aPos(*pNd); - nDir = rWrt.pDoc->GetTextDirection(aPos); + (const SwCntntNode*)m_rWW8Export.pOutFmtNode; + SwPosition aPos( *pNd ); + nDir = m_rWW8Export.pDoc->GetTextDirection( aPos ); } - else if (rWrtWW8.pOutFmtNode->ISA(SwTxtFmtColl)) + else if ( m_rWW8Export.pOutFmtNode->ISA( SwTxtFmtColl ) ) nDir = FRMDIR_HORI_LEFT_TOP; //what else can we do :-( } - if (nDir == FRMDIR_ENVIRONMENT) + if ( nDir == FRMDIR_ENVIRONMENT ) nDir = FRMDIR_HORI_LEFT_TOP; //Set something } - switch (nDir) + switch ( nDir ) { default: //Can't get an unknown type here - ASSERT(!(&rWrt), "Unknown frame direction"); + ASSERT(false, "Unknown frame direction"); case FRMDIR_HORI_LEFT_TOP: nTextFlow = 0; break; @@ -4685,49 +4708,42 @@ static Writer& OutWW8_SvxFrameDirection( Writer& rWrt, const SfxPoolItem& rHt ) break; } - if (rWrtWW8.bOutPageDescs) + if ( m_rWW8Export.bOutPageDescs ) { - rWrtWW8.InsUInt16(0x5033); - rWrtWW8.InsUInt16(nTextFlow); - rWrtWW8.InsUInt16(0x3228); - rWrtWW8.pO->Insert(bBiDi, rWrtWW8.pO->Count() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_STextFlow ); + m_rWW8Export.InsUInt16( nTextFlow ); + m_rWW8Export.InsUInt16( NS_sprm::LN_SFBiDi ); + m_rWW8Export.pO->Insert( bBiDi, m_rWW8Export.pO->Count() ); } - else if (!rWrtWW8.bOutFlyFrmAttrs) //paragraph/style + else if ( !m_rWW8Export.bOutFlyFrmAttrs ) //paragraph/style { - rWrtWW8.InsUInt16(0x2441); - rWrtWW8.pO->Insert(bBiDi, rWrtWW8.pO->Count() ); + m_rWW8Export.InsUInt16( NS_sprm::LN_PFBiDi ); + m_rWW8Export.pO->Insert( bBiDi, m_rWW8Export.pO->Count() ); } - return rWrt; } -// "Absaetze trennen" -static Writer& OutWW8_SvxFmtSplit( Writer& rWrt, const SfxPoolItem& rHt ) +// "Separate paragraphs" +void WW8AttributeOutput::ParaSplit( const SvxFmtSplitItem& rSplit ) { -// sprmPFKeep - const SvxFmtSplitItem& rAttr = (const SvxFmtSplitItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x2405 ); + // sprmPFKeep + if ( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PFKeep ); else - rWrtWW8.pO->Insert( 7, rWrtWW8.pO->Count() ); - rWrtWW8.pO->Insert( rAttr.GetValue() ? 0 : 1, rWrtWW8.pO->Count() ); - return rWrt; + m_rWW8Export.pO->Insert( 7, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( rSplit.GetValue() ? 0 : 1, m_rWW8Export.pO->Count() ); } // Es wird nur das Item "SvxWidowItem" und nicht die Orphans uebersetzt, // da es fuer beides im WW nur ein Attribut "Absatzkontrolle" gibt und // im SW wahrscheinlich vom Anwender immer Beide oder keiner gesetzt werden. -static Writer& OutWW8_SvxWidows( Writer& rWrt, const SfxPoolItem& rHt ) +void WW8AttributeOutput::ParaWidows( const SvxWidowsItem& rWidows ) { // sprmPFWidowControl - const SvxWidowsItem& rAttr = (const SvxWidowsItem&)rHt; - SwWW8Writer& rWrtWW8 = (SwWW8Writer&)rWrt; - if( rWrtWW8.bWrtWW8 ) - rWrtWW8.InsUInt16( 0x2431 ); + if( m_rWW8Export.bWrtWW8 ) + m_rWW8Export.InsUInt16( NS_sprm::LN_PFWidowControl ); else - rWrtWW8.pO->Insert( 51, rWrtWW8.pO->Count() ); - rWrtWW8.pO->Insert( rAttr.GetValue() ? 1 : 0, rWrtWW8.pO->Count() ); - return rWrt; + m_rWW8Export.pO->Insert( 51, m_rWW8Export.pO->Count() ); + m_rWW8Export.pO->Insert( rWidows.GetValue() ? 1 : 0, m_rWW8Export.pO->Count() ); } @@ -4744,7 +4760,7 @@ public: void Add(const SvxTabStop &rTS, long nAdjustment); void Del(const SvxTabStop &rTS, long nAdjustment); - void PutAll(SwWW8Writer& rWW8Wrt); + void PutAll(WW8Export& rWW8Wrt); }; SwWW8WrTabu::SwWW8WrTabu(sal_uInt16 nDelMax, sal_uInt16 nAddMax) @@ -4822,8 +4838,8 @@ void SwWW8WrTabu::Del(const SvxTabStop &rTS, long nAdjustment) ++nDel; } -// PutAll( SwWW8Writer& rWW8Wrt ) schreibt das Attribut nach rWrt.pO -void SwWW8WrTabu::PutAll(SwWW8Writer& rWrt) +// PutAll( WW8Export& rWW8Wrt ) schreibt das Attribut nach rWrt.pO +void SwWW8WrTabu::PutAll(WW8Export& rWrt) { if (!nAdd && !nDel) //It its a no-op return; @@ -4839,7 +4855,7 @@ void SwWW8WrTabu::PutAll(SwWW8Writer& rWrt) nSiz = 255; if (rWrt.bWrtWW8) - rWrt.InsUInt16(0xC60D); + rWrt.InsUInt16(NS_sprm::LN_PChgTabsPapx); else rWrt.pO->Insert(15, rWrt.pO->Count()); // cch eintragen @@ -4854,8 +4870,8 @@ void SwWW8WrTabu::PutAll(SwWW8Writer& rWrt) } -static void OutWW8_SwTabStopAdd(Writer& rWrt, const SvxTabStopItem& rTStops, - long nLParaMgn) +static void ParaTabStopAdd( WW8Export& rWrt, const SvxTabStopItem& rTStops, + long nLParaMgn ) { SwWW8WrTabu aTab( 0, rTStops.Count()); @@ -4866,7 +4882,7 @@ static void OutWW8_SwTabStopAdd(Writer& rWrt, const SvxTabStopItem& rTStops, if (SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment()) aTab.Add(rTS, nLParaMgn); } - aTab.PutAll( (SwWW8Writer&)rWrt ); + aTab.PutAll( rWrt ); } bool lcl_IsEqual(long nOneLeft, const SvxTabStop &rOne, @@ -4880,8 +4896,8 @@ bool lcl_IsEqual(long nOneLeft, const SvxTabStop &rOne, ); } -static void OutWW8_SwTabStopDelAdd(Writer& rWrt, const SvxTabStopItem& rTStyle, - long nLStypeMgn, const SvxTabStopItem& rTNew, long nLParaMgn) +static void ParaTabStopDelAdd( WW8Export& rWrt, const SvxTabStopItem& rTStyle, + long nLStypeMgn, const SvxTabStopItem& rTNew, long nLParaMgn ) { SwWW8WrTabu aTab(rTStyle.Count(), rTNew.Count()); @@ -4952,54 +4968,50 @@ static void OutWW8_SwTabStopDelAdd(Writer& rWrt, const SvxTabStopItem& rTStyle, } } while( 1 ); - aTab.PutAll( (SwWW8Writer&)rWrt ); + aTab.PutAll( rWrt ); } -static Writer& OutWW8_SwTabStop(Writer& rWrt, const SfxPoolItem& rHt) +void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops ) { - SwWW8Writer& rWW8Wrt = (SwWW8Writer&)rWrt; - const SvxTabStopItem & rTStops = (const SvxTabStopItem&)rHt; - bool bTabsRelativeToIndex = rWW8Wrt.pCurPam->GetDoc()->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT); + bool bTabsRelativeToIndex = m_rWW8Export.pCurPam->GetDoc()->get( IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT ); long nCurrentLeft = 0; - if (bTabsRelativeToIndex) + if ( bTabsRelativeToIndex ) { - const SfxPoolItem* pLR = rWW8Wrt.HasItem( RES_LR_SPACE ); + const SfxPoolItem* pLR = m_rWW8Export.HasItem( RES_LR_SPACE ); - if (pLR != NULL) + if ( pLR != NULL ) nCurrentLeft = ((const SvxLRSpaceItem*)pLR)->GetTxtLeft(); } - // --> FLR 2009-03-17 #i100264# - if (rWW8Wrt.bStyDef - && rWW8Wrt.pCurrentStyle!=NULL - && rWW8Wrt.pCurrentStyle->DerivedFrom()!=NULL) - { - SvxTabStopItem aTabs(0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP); - const SwFmt *pParentStyle=rWW8Wrt.pCurrentStyle->DerivedFrom(); - const SvxTabStopItem* pParentTabs=HasItem<SvxTabStopItem>(pParentStyle->GetAttrSet(), RES_PARATR_TABSTOP); - if (pParentTabs) + if ( m_rWW8Export.bStyDef && + m_rWW8Export.pCurrentStyle != NULL && + m_rWW8Export.pCurrentStyle->DerivedFrom() != NULL ) + { + SvxTabStopItem aTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP ); + const SwFmt *pParentStyle = m_rWW8Export.pCurrentStyle->DerivedFrom(); + const SvxTabStopItem* pParentTabs = HasItem<SvxTabStopItem>( pParentStyle->GetAttrSet(), RES_PARATR_TABSTOP ); + if ( pParentTabs ) { - aTabs.Insert(pParentTabs); + aTabs.Insert( pParentTabs ); } - OutWW8_SwTabStopDelAdd(rWW8Wrt, aTabs, 0, rTStops, 0); - return rWrt; + ParaTabStopDelAdd( m_rWW8Export, aTabs, 0, rTabStops, 0 ); + return; } // <-- - // StyleDef -> "einfach" eintragen || keine Style-Attrs -> dito const SvxTabStopItem* pStyleTabs = 0; - if (!rWW8Wrt.bStyDef && rWW8Wrt.pStyAttr) + if ( !m_rWW8Export.bStyDef && m_rWW8Export.pStyAttr ) { pStyleTabs = - HasItem<SvxTabStopItem>(*rWW8Wrt.pStyAttr, RES_PARATR_TABSTOP); + HasItem<SvxTabStopItem>( *m_rWW8Export.pStyAttr, RES_PARATR_TABSTOP ); } - if (!pStyleTabs) - OutWW8_SwTabStopAdd(rWW8Wrt, rTStops, nCurrentLeft); + if ( !pStyleTabs ) + ParaTabStopAdd(m_rWW8Export, rTabStops, nCurrentLeft); else { long nStyleLeft = 0; @@ -5007,175 +5019,279 @@ static Writer& OutWW8_SwTabStop(Writer& rWrt, const SfxPoolItem& rHt) if (bTabsRelativeToIndex) { const SvxLRSpaceItem &rStyleLR = - ItemGet<SvxLRSpaceItem>(*rWW8Wrt.pStyAttr, RES_LR_SPACE); + ItemGet<SvxLRSpaceItem>(*m_rWW8Export.pStyAttr, RES_LR_SPACE); nStyleLeft = rStyleLR.GetTxtLeft(); } - OutWW8_SwTabStopDelAdd(rWW8Wrt, *pStyleTabs, nStyleLeft, rTStops, + ParaTabStopDelAdd(m_rWW8Export, *pStyleTabs, nStyleLeft, rTabStops, nCurrentLeft); } - return rWrt; } //----------------------------------------------------------------------- -/* - * lege hier die Tabellen fuer die WW-Funktions-Pointer auf - * die Ausgabe-Funktionen an. - * Es sind lokale Strukturen, die nur innerhalb - * bekannt sein muessen. - */ +void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt ) +{ + // FIXME maybe use 'item_cast', like 'item_cast<SvxCharHiddenItem>( rHt )'? + switch ( rHt.Which() ) + { + case RES_CHRATR_CASEMAP: + CharCaseMap( static_cast< const SvxCaseMapItem& >( rHt ) ); + break; + case RES_CHRATR_COLOR: + CharColor( static_cast< const SvxColorItem& >( rHt ) ); + break; + case RES_CHRATR_CONTOUR: + CharContour( static_cast< const SvxContourItem& >( rHt ) ); + break; + case RES_CHRATR_CROSSEDOUT: + CharCrossedOut( static_cast< const SvxCrossedOutItem& >( rHt ) ); + break; + case RES_CHRATR_ESCAPEMENT: + CharEscapement( static_cast< const SvxEscapementItem& >( rHt ) ); + break; + case RES_CHRATR_FONT: + CharFont( static_cast< const SvxFontItem& >( rHt ) ); + break; + case RES_CHRATR_FONTSIZE: + CharFontSize( static_cast< const SvxFontHeightItem& >( rHt ) ); + break; + case RES_CHRATR_KERNING: + CharKerning( static_cast< const SvxKerningItem& >( rHt ) ); + break; + case RES_CHRATR_LANGUAGE: + CharLanguage( static_cast< const SvxLanguageItem& >( rHt ) ); + break; + case RES_CHRATR_POSTURE: + CharPosture( static_cast< const SvxPostureItem& >( rHt ) ); + break; + case RES_CHRATR_SHADOWED: + CharShadow( static_cast< const SvxShadowedItem& >( rHt ) ); + break; + case RES_CHRATR_UNDERLINE: + CharUnderline( static_cast< const SvxUnderlineItem& >( rHt ) ); + break; + case RES_CHRATR_WEIGHT: + CharWeight( static_cast< const SvxWeightItem& >( rHt ) ); + break; + case RES_CHRATR_AUTOKERN: + CharAutoKern( static_cast< const SvxAutoKernItem& >( rHt ) ); + break; + case RES_CHRATR_BLINK: + CharAnimatedText( static_cast< const SvxBlinkItem& >( rHt ) ); + break; + case RES_CHRATR_BACKGROUND: + CharBackground( static_cast< const SvxBrushItem& >( rHt ) ); + break; -SwAttrFnTab aWW8AttrFnTab = { -/* RES_CHRATR_CASEMAP */ OutWW8_SwCaseMap, -/* RES_CHRATR_CHARSETCOLOR */ 0, -/* RES_CHRATR_COLOR */ OutWW8_SwColor, -/* RES_CHRATR_CONTOUR */ OutWW8_SwContour, -/* RES_CHRATR_CROSSEDOUT */ OutWW8_SwCrossedOut, -/* RES_CHRATR_ESCAPEMENT */ OutWW8_SwEscapement, -/* RES_CHRATR_FONT */ OutWW8_SwFont, -/* RES_CHRATR_FONTSIZE */ OutWW8_SwSize, -/* RES_CHRATR_KERNING */ OutWW8_SwKerning, -/* RES_CHRATR_LANGUAGE */ OutWW8_SwLanguage, -/* RES_CHRATR_POSTURE */ OutWW8_SwPosture, -/* RES_CHRATR_PROPORTIONALFONTSIZE*/0, -/* RES_CHRATR_SHADOWED */ OutWW8_SwShadow, -/* RES_CHRATR_UNDERLINE */ OutWW8_SwUnderline, -/* RES_CHRATR_WEIGHT */ OutWW8_SwWeight, -/* RES_CHRATR_WORDLINEMODE */ 0, // Wird bei Underline mitbehandelt -/* RES_CHRATR_AUTOKERN */ OutWW8_SvxAutoKern, -/* RES_CHRATR_BLINK */ OutWW8_SwAnimatedText, // neu: blinkender Text -/* RES_CHRATR_NOHYPHEN */ 0, // Neu: nicht trennen -/* RES_CHRATR_NOLINEBREAK */ 0, // Neu: nicht umbrechen -/* RES_CHRATR_BACKGROUND */ OutWW8_SwFmtCharBackground, -/* RES_CHRATR_CJK_FONT */ OutWW8_SwCJKFont, -/* RES_CHRATR_CJK_FONTSIZE */ OutWW8_SwSize, -/* RES_CHRATR_CJK_LANGUAGE */ OutWW8_SwLanguage, -/* RES_CHRATR_CJK_POSTURE */ OutWW8_SwPosture, -/* RES_CHRATR_CJK_WEIGHT */ OutWW8_SwWeight, -/* RES_CHRATR_CTL_FONT */ OutWW8_SwCTLFont, -/* RES_CHRATR_CTL_FONTSIZE */ OutWW8_SwSize, -/* RES_CHRATR_CTL_LANGUAGE */ OutWW8_SwLanguage, -/* RES_CHRATR_CTL_POSTURE */ OutWW8_SwBiDiPosture, -/* RES_CHRATR_CTL_WEIGHT */ OutWW8_SwBiDiWeight, -/* RES_CHRATR_WRITING_DIRECTION */ OutWW8_CharRotate, -/* RES_CHRATR_EMPHASIS_MARK*/ OutWW8_EmphasisMark, -/* RES_TXTATR_TWO_LINES */ OutWW8_SvxTwoLinesItem, -/* RES_CHRATR_DUMMY4 */ OutWW8_ScaleWidth, -/* RES_CHRATR_RELIEF*/ OutWW8_Relief, -/* RES_CHRATR_HIDDEN */ OutWW8_SvxCharHidden, -/* RES_CHRATR_OVERLINE */ 0, -/* RES_CHRATR_DUMMY1 */ 0, -/* RES_CHRATR_DUMMY2 */ 0, - -/* RES_TXTATR_DUMMY4 */ 0, -/* RES_TXTATR_INETFMT */ OutSwFmtINetFmt, -/* RES_TXTATR_REFMARK */ 0, // handled by SwAttrIter -/* RES_TXTATR_TOXMARK */ 0, // handled by SwAttrIter -/* RES_TXTATR_CHARFMT */ OutWW8_SwTxtCharFmt, -/* RES_TXTATR_DUMMY5*/ 0, -/* RES_TXTATR_CJK_RUBY */ 0, // handled by SwAttrIter -/* RES_TXTATR_UNKNOWN_CONTAINER */ 0, -/* RES_TXTATR_DUMMY6 */ 0, -/* RES_TXTATR_DUMMY7 */ 0, - -/* RES_TXTATR_FIELD */ OutWW8_SwField, -/* RES_TXTATR_FLYCNT */ OutWW8_SwFlyCntnt, -/* RES_TXTATR_FTN */ OutWW8_SwFtn, -/* RES_TXTATR_SOFTHYPH */ 0, // old attr. - coded now by character -/* RES_TXTATR_HARDBLANK */ OutWW8_SwHardBlank, -/* RES_TXTATR_DUMMY1 */ 0, // Dummy: -/* RES_TXTATR_DUMMY2 */ 0, // Dummy: - -/* RES_PARATR_LINESPACING */ OutWW8_SvxLineSpacing, -/* RES_PARATR_ADJUST */ OutWW8_SvxAdjust, -/* RES_PARATR_SPLIT */ OutWW8_SvxFmtSplit, -/* RES_PARATR_ORPHANS */ 0, // OutW4W_SwOrphans, // kann WW nicht unabhaengig von Widows -/* RES_PARATR_WIDOWS */ OutWW8_SvxWidows, -/* RES_PARATR_TABSTOP */ OutWW8_SwTabStop, -/* RES_PARATR_HYPHENZONE*/ OutWW8_SvxHyphenZone, -/* RES_PARATR_DROP */ 0, -/* RES_PARATR_REGISTER */ 0, // neu: Registerhaltigkeit -/* RES_PARATR_NUMRULE */ OutWW8_SwNumRuleItem, -/* RES_PARATR_SCRIPTSPACE */ OutWW8_SfxBoolItem, -/* RES_PARATR_HANGINGPUNCTUATION */ OutWW8_SfxBoolItem, -/* RES_PARATR_FORBIDDEN_RULES */ OutWW8_SfxBoolItem, -/* RES_PARATR_VERTALIGN */ OutWW8_SvxParaVertAlignItem, -/* RES_PARATR_SNAPTOGRID*/ OutWW8_SvxParaGridItem, -/* RES_PARATR_CONNECT_TO_BORDER */ 0, // new -/* RES_PARATR_OUTLINELEVEL */ 0, // new - outlinelevel - -/* RES_PARATR_LIST_ID */ 0, // new -/* RES_PARATR_LIST_LEVEL */ 0, // new -/* RES_PARATR_LIST_ISRESTART */ 0, // new -/* RES_PARATR_LIST_RESTARTVALUE */ 0, // new -/* RES_PARATR_LIST_ISCOUNTED */ 0, // new - -/* RES_FILL_ORDER */ 0, // OutW4W_SwFillOrder, -/* RES_FRM_SIZE */ OutWW8_SwFrmSize, -/* RES_PAPER_BIN */ OutWW8_SvxPaperBin, -/* RES_LR_SPACE */ OutWW8_SwFmtLRSpace, -/* RES_UL_SPACE */ OutWW8_SwFmtULSpace, -/* RES_PAGEDESC */ OutWW8_SwFmtPageDesc, -/* RES_BREAK */ OutWW8_SwFmtBreak, -/* RES_CNTNT */ 0, /* 0, // OutW4W_??? */ -/* RES_HEADER */ 0, // wird bei der PageDesc ausgabe beachtet -/* RES_FOOTER */ 0, // wird bei der PageDesc ausgabe beachtet -/* RES_PRINT */ 0, // OutW4W_SwFmtPrint, -/* RES_OPAQUE */ 0, // OutW4W_SwFmtOpaque, // kann WW nicht -/* RES_PROTECT */ 0, // OutW4W_SwFmtProtect, -/* RES_SURROUND */ OutWW8_SwFmtSurround, -/* RES_VERT_ORIENT */ OutWW8_SwFmtVertOrient, -/* RES_HORI_ORIENT */ OutWW8_SwFmtHoriOrient, -/* RES_ANCHOR */ OutWW8_SwFmtAnchor, -/* RES_BACKGROUND */ OutWW8_SwFmtBackground, -/* RES_BOX */ OutWW8_SwFmtBox, -/* RES_SHADOW */ 0, // Wird bei SwFmtBox mitbehandelt -/* RES_FRMMACRO */ 0, /* 0, // OutW4W_??? */ -/* RES_COL */ OutWW8_SwFmtCol, -/* RES_KEEP */ OutWW8_SvxFmtKeep, -/* RES_URL */ 0, // URL -/* RES_EDIT_IN_READONLY */ 0, -/* RES_LAYOUT_SPLIT */ 0, -/* RES_CHAIN */ 0, -/* RES_TEXTGRID*/ OutWW8_SwTextGrid, -/* RES_LINENUMBER */ OutWW8_SwFmtLineNumber, // Line Numbering -/* RES_FTN_AT_TXTEND*/ 0, // Dummy: -/* RES_END_AT_TXTEND*/ 0, // Dummy: -/* RES_COLUMNBALANCE*/ 0, // Dummy: -/* RES_FRAMEDIR*/ OutWW8_SvxFrameDirection, -/* RES_FRMATR_DUMMY8 */ 0, // Dummy: -/* RES_FRMATR_DUMMY9 */ 0, // Dummy: -/* RES_FOLLOW_TEXT_FLOW */ 0, -/* RES_WRAP_INFLUENCE_ON_OBJPOS */ 0, -/* RES_FRMATR_DUMMY2 */ 0, // Dummy: -/* RES_AUTO_STYLE */ 0, // Dummy: -/* RES_FRMATR_DUMMY4 */ 0, // Dummy: -/* RES_FRMATR_DUMMY5 */ 0, // Dummy: - -/* RES_GRFATR_MIRRORGRF */ 0, // OutW4W_SwMirrorGrf, -/* RES_GRFATR_CROPGRF */ 0, // OutW4W_SwCropGrf -/* RES_GRFATR_ROTATION */ 0, -/* RES_GRFATR_LUMINANCE */ 0, -/* RES_GRFATR_CONTRAST */ 0, -/* RES_GRFATR_CHANNELR */ 0, -/* RES_GRFATR_CHANNELG */ 0, -/* RES_GRFATR_CHANNELB */ 0, -/* RES_GRFATR_GAMMA */ 0, -/* RES_GRFATR_INVERT */ 0, -/* RES_GRFATR_TRANSPARENCY */ 0, -/* RES_GRFATR_DRWAMODE */ 0, -/* RES_GRFATR_DUMMY1 */ 0, -/* RES_GRFATR_DUMMY2 */ 0, -/* RES_GRFATR_DUMMY3 */ 0, -/* RES_GRFATR_DUMMY4 */ 0, -/* RES_GRFATR_DUMMY5 */ 0, - -/* RES_BOXATR_FORMAT */ 0, -/* RES_BOXATR_FORMULA */ 0, -/* RES_BOXATR_VALUE */ 0, - -/* RES_UNKNOWNATR_CONTAINER */ 0 -}; + case RES_CHRATR_CJK_FONT: + CharFontCJK( static_cast< const SvxFontItem& >( rHt ) ); + break; + case RES_CHRATR_CJK_FONTSIZE: + CharFontSizeCJK( static_cast< const SvxFontHeightItem& >( rHt ) ); + break; + case RES_CHRATR_CJK_LANGUAGE: + CharLanguageCJK( static_cast< const SvxLanguageItem& >( rHt ) ); + break; + case RES_CHRATR_CJK_POSTURE: + CharPostureCJK( static_cast< const SvxPostureItem& >( rHt ) ); + break; + case RES_CHRATR_CJK_WEIGHT: + CharWeightCJK( static_cast< const SvxWeightItem& >( rHt ) ); + break; + + case RES_CHRATR_CTL_FONT: + CharFontCTL( static_cast< const SvxFontItem& >( rHt ) ); + break; + case RES_CHRATR_CTL_FONTSIZE: + CharFontSizeCTL( static_cast< const SvxFontHeightItem& >( rHt ) ); + break; + case RES_CHRATR_CTL_LANGUAGE: + CharLanguageCTL( static_cast< const SvxLanguageItem& >( rHt ) ); + break; + case RES_CHRATR_CTL_POSTURE: + CharPostureCTL( static_cast< const SvxPostureItem& >( rHt ) ); + break; + case RES_CHRATR_CTL_WEIGHT: + CharWeightCTL( static_cast< const SvxWeightItem& >( rHt ) ); + break; + + case RES_CHRATR_ROTATE: + CharRotate( static_cast< const SvxCharRotateItem& >( rHt ) ); + break; + case RES_CHRATR_EMPHASIS_MARK: + CharEmphasisMark( static_cast< const SvxEmphasisMarkItem& >( rHt ) ); + break; + case RES_CHRATR_TWO_LINES: + CharTwoLines( static_cast< const SvxTwoLinesItem& >( rHt ) ); + break; + case RES_CHRATR_SCALEW: + CharScaleWidth( static_cast< const SvxCharScaleWidthItem& >( rHt ) ); + break; + case RES_CHRATR_RELIEF: + CharRelief( static_cast< const SvxCharReliefItem& >( rHt ) ); + break; + case RES_CHRATR_HIDDEN: + CharHidden( static_cast< const SvxCharHiddenItem& >( rHt ) ); + break; + + case RES_TXTATR_INETFMT: + TextINetFormat( static_cast< const SwFmtINetFmt& >( rHt ) ); + break; + case RES_TXTATR_CHARFMT: + TextCharFormat( static_cast< const SwFmtCharFmt& >( rHt ) ); + break; + case RES_TXTATR_FIELD: + TextField( static_cast< const SwFmtFld& >( rHt ) ); + break; + case RES_TXTATR_FLYCNT: + TextFlyContent( static_cast< const SwFmtFlyCnt& >( rHt ) ); + break; + case RES_TXTATR_FTN: + TextFootnote( static_cast< const SwFmtFtn& >( rHt ) ); + break; + + case RES_PARATR_LINESPACING: + ParaLineSpacing( static_cast< const SvxLineSpacingItem& >( rHt ) ); + break; + case RES_PARATR_ADJUST: + ParaAdjust( static_cast< const SvxAdjustItem& >( rHt ) ); + break; + case RES_PARATR_SPLIT: + ParaSplit( static_cast< const SvxFmtSplitItem& >( rHt ) ); + break; + case RES_PARATR_WIDOWS: + ParaWidows( static_cast< const SvxWidowsItem& >( rHt ) ); + break; + case RES_PARATR_TABSTOP: + ParaTabStop( static_cast< const SvxTabStopItem& >( rHt ) ); + break; + case RES_PARATR_HYPHENZONE: + ParaHyphenZone( static_cast< const SvxHyphenZoneItem& >( rHt ) ); + break; + case RES_PARATR_NUMRULE: + ParaNumRule( static_cast< const SwNumRuleItem& >( rHt ) ); + break; + case RES_PARATR_SCRIPTSPACE: + ParaScriptSpace( static_cast< const SfxBoolItem& >( rHt ) ); + break; + case RES_PARATR_HANGINGPUNCTUATION: + ParaHangingPunctuation( static_cast< const SfxBoolItem& >( rHt ) ); + break; + case RES_PARATR_FORBIDDEN_RULES: + ParaForbiddenRules( static_cast< const SfxBoolItem& >( rHt ) ); + break; + case RES_PARATR_VERTALIGN: + ParaVerticalAlign( static_cast< const SvxParaVertAlignItem& >( rHt ) ); + break; + case RES_PARATR_SNAPTOGRID: + ParaSnapToGrid( static_cast< const SvxParaGridItem& >( rHt ) ); + break; + + case RES_FRM_SIZE: + FormatFrameSize( static_cast< const SwFmtFrmSize& >( rHt ) ); + break; + case RES_PAPER_BIN: + FormatPaperBin( static_cast< const SvxPaperBinItem& >( rHt ) ); + break; + case RES_LR_SPACE: + FormatLRSpace( static_cast< const SvxLRSpaceItem& >( rHt ) ); + break; + case RES_UL_SPACE: + FormatULSpace( static_cast< const SvxULSpaceItem& >( rHt ) ); + break; + case RES_PAGEDESC: + FormatPageDescription( static_cast< const SwFmtPageDesc& >( rHt ) ); + break; + case RES_BREAK: + FormatBreak( static_cast< const SvxFmtBreakItem& >( rHt ) ); + break; + case RES_SURROUND: + FormatSurround( static_cast< const SwFmtSurround& >( rHt ) ); + break; + case RES_VERT_ORIENT: + FormatVertOrientation( static_cast< const SwFmtVertOrient& >( rHt ) ); + break; + case RES_HORI_ORIENT: + FormatHorizOrientation( static_cast< const SwFmtHoriOrient& >( rHt ) ); + break; + case RES_ANCHOR: + FormatAnchor( static_cast< const SwFmtAnchor& >( rHt ) ); + break; + case RES_BACKGROUND: + FormatBackground( static_cast< const SvxBrushItem& >( rHt ) ); + break; + case RES_BOX: + FormatBox( static_cast< const SvxBoxItem& >( rHt ) ); + break; + case RES_COL: + FormatColumns( static_cast< const SwFmtCol& >( rHt ) ); + break; + case RES_KEEP: + FormatKeep( static_cast< const SvxFmtKeepItem& >( rHt ) ); + break; + case RES_TEXTGRID: + FormatTextGrid( static_cast< const SwTextGridItem& >( rHt ) ); + break; + case RES_LINENUMBER: + FormatLineNumbering( static_cast< const SwFmtLineNumber& >( rHt ) ); + break; + case RES_FRAMEDIR: + FormatFrameDirection( static_cast< const SvxFrameDirectionItem& >( rHt ) ); + break; + + default: +#if OSL_DEBUG_LEVEL > 0 + fprintf( stderr, "Unhandled SfxPoolItem with id %d.\n", rHt.Which() ); +#endif + break; + } +} + +void AttributeOutputBase::OutputStyleItemSet( const SfxItemSet& rSet, BOOL bDeep, BOOL bTestForDefault ) +{ + // based on OutputItemSet() from wrt_fn.cxx + + const SfxItemPool& rPool = *rSet.GetPool(); + const SfxItemSet* pSet = &rSet; + if ( !pSet->Count() ) + { + if ( !bDeep ) + return; + + while ( 0 != ( pSet = pSet->GetParent() ) && !pSet->Count() ) + ; + + if ( !pSet ) + return; + } + + const SfxPoolItem* pItem; + if ( !bDeep || !pSet->GetParent() ) + { + ASSERT( rSet.Count(), "Wurde doch schon behandelt oder?" ); + SfxItemIter aIter( *pSet ); + pItem = aIter.GetCurItem(); + do { + OutputItem( *pItem ); + } while ( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) ); + } + else + { + SfxWhichIter aIter( *pSet ); + USHORT nWhich = aIter.FirstWhich(); + while ( nWhich ) + { + if ( SFX_ITEM_SET == pSet->GetItemState( nWhich, bDeep, &pItem ) && + ( !bTestForDefault || + *pItem != rPool.GetDefaultItem( nWhich ) || + ( pSet->GetParent() && *pItem != pSet->GetParent()->Get( nWhich ) ) ) ) + { + OutputItem( *pItem ); + } + nWhich = aIter.NextWhich(); + } + } +} /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx new file mode 100644 index 0000000000..608dfc17d2 --- /dev/null +++ b/sw/source/filter/ww8/ww8attributeoutput.hxx @@ -0,0 +1,456 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile$ + * $Revision$ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _WW8ATTRIBUTEOUTPUT_HXX_ +#define _WW8ATTRIBUTEOUTPUT_HXX_ + +#include "attributeoutputbase.hxx" +#include "wrtww8.hxx" + +class WW8AttributeOutput : public AttributeOutputBase +{ +public: + /// Export the state of RTL/CJK. + virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript ); + + /// Start of the paragraph. + virtual void StartParagraph( ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/ ) {} + + /// End of the paragraph. + virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ); + + /// Called before we start outputting the attributes. + virtual void StartParagraphProperties( const SwTxtNode& /*rNode*/ ) {} + + /// Called after we end outputting the attributes. + virtual void EndParagraphProperties() {} + + /// Empty paragraph. + virtual void EmptyParagraph(); + + /// Start of the text run. + /// + /// No-op for binary filters. + virtual void StartRun( const SwRedlineData* /*pRedlineData*/ ) {} + + /// End of the text run. + /// + /// No-op for binary filters. + virtual void EndRun() {} + + /// Before we start outputting the attributes. + virtual void StartRunProperties(); + + /// After we end outputting the attributes. + virtual void EndRunProperties( const SwRedlineData* pRedlineData ); + + /// Output text. + virtual void RunText( const String& rText, rtl_TextEncoding eCharSet ); + + /// Output text (without markup). + virtual void RawText( const String& rText, bool bForceUnicode, rtl_TextEncoding eCharSet ); + + /// Output ruby start. + virtual void StartRuby( const SwTxtNode& rNode, const SwFmtRuby& rRuby ); + + /// Output ruby end. + virtual void EndRuby(); + + /// Output URL start. + virtual bool StartURL( const String &rUrl, const String &rTarget ); + + /// Output URL end. + virtual bool EndURL(); + + virtual void FieldVanish( const String& rTxt, ww::eField eType ); + + /// Output redlining. + virtual void Redline( const SwRedlineData* pRedline ); + + virtual void FormatDrop( const SwTxtNode& rNode, const SwFmtDrop &rSwFmtDrop, USHORT nStyle, ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner ); + + /// Output FKP (Formatted disK Page) - necessary for binary formats only. + /// FIXME having it in AttributeOutputBase is probably a hack, it + /// should be in WW8AttributeOutput only... + virtual void OutputFKP(); + + /// Output style. + virtual void ParagraphStyle( USHORT nStyle ); + + virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ); + + virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ); + + virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ); + + virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ); + + virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ); + + virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ); + + virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ); + + virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ); + + virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfo ); + + virtual void TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t pNodeInfo ); + + virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner ); + + virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner ); + + virtual void TableRowEnd( sal_uInt32 nDepth = 1 ); + + /// Start of the styles table. + virtual void StartStyles(); + + /// End of the styles table. + virtual void EndStyles( USHORT nNumberOfStyles ); + + /// Write default style. + virtual void DefaultStyle( USHORT nStyle ); + + /// Start of a style in the styles table. + virtual void StartStyle( const String& rName, bool bPapFmt, + USHORT nBase, USHORT nNext, USHORT nWwIdi, USHORT nId ); + + /// End of a style in the styles table. + virtual void EndStyle(); + + /// Start of (paragraph or run) properties of a style. + virtual void StartStyleProperties( bool bParProp, USHORT nStyle ); + + /// End of (paragraph or run) properties of a style. + virtual void EndStyleProperties( bool bParProp ); + + /// Numbering rule and Id. + virtual void OutlineNumbering( BYTE nLvl, const SwNumFmt &rNFmt, const SwFmt &rFmt ); + + /// Page break + /// As a paragraph property - the paragraph should be on the next page. + virtual void PageBreakBefore( bool bBreak ); + + /// Write a section break + /// msword::ColumnBreak or msword::PageBreak + virtual void SectionBreak( BYTE nC, const WW8_SepInfo* pSectionInfo = NULL ); + + /// Start of the section properties. + virtual void StartSection(); + + /// End of the section properties. + /// + /// No-op for binary filters. + virtual void EndSection() {} + + /// Protection of forms. + virtual void SectionFormProtection( bool bProtected ); + + /// Numbering of the lines in the document. + virtual void SectionLineNumbering( ULONG nRestartNo, const SwLineNumberInfo& rLnNumInfo ); + + /// Has different headers/footers for the title page. + virtual void SectionTitlePage(); + + /// Description of the page borders. + virtual void SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* pFirstPageFmt ); + + /// Columns populated from right/numbers on the right side? + virtual void SectionBiDi( bool bBiDi ); + + /// The style of the page numbers. + /// + /// nPageRestartNumberr being 0 means no restart. + virtual void SectionPageNumbering( USHORT nNumType, USHORT nPageRestartNumber ); + + /// The type of breaking. + virtual void SectionType( BYTE nBreakCode ); + + /// Special header/footer flags, needed for old versions only. + virtual void SectionWW6HeaderFooterFlags( BYTE nHeadFootFlags ); + + /// Definition of a numbering instance. + virtual void NumberingDefinition( USHORT nId, const SwNumRule &rRule ); + + /// All the numbering level information. + virtual void NumberingLevel( BYTE nLevel, + USHORT nStart, + USHORT nNumberingType, + SvxAdjust eAdjust, + const BYTE *pNumLvlPos, + BYTE nFollow, + const wwFont *pFont, + const SfxItemSet *pOutSet, + sal_Int16 nIndentAt, + sal_Int16 nFirstLineIndex, + sal_Int16 nListTabPos, + const String &rNumberingString ); + +protected: + /// Output frames - the implementation. + void OutputFlyFrame_Impl( const sw::Frame& rFmt, const Point& rNdTopLeft ); + + /// Sfx item Sfx item RES_CHRATR_CASEMAP + virtual void CharCaseMap( const SvxCaseMapItem& ); + + /// Sfx item Sfx item RES_CHRATR_COLOR + virtual void CharColor( const SvxColorItem& ); + + /// Sfx item Sfx item RES_CHRATR_CONTOUR + virtual void CharContour( const SvxContourItem& ); + + /// Sfx item RES_CHRATR_CROSSEDOUT + virtual void CharCrossedOut( const SvxCrossedOutItem& rHt ); + + /// Sfx item RES_CHRATR_ESCAPEMENT + virtual void CharEscapement( const SvxEscapementItem& ); + + /// Sfx item RES_CHRATR_FONT + virtual void CharFont( const SvxFontItem& ); + + /// Sfx item RES_CHRATR_FONTSIZE + virtual void CharFontSize( const SvxFontHeightItem& ); + + /// Sfx item RES_CHRATR_KERNING + virtual void CharKerning( const SvxKerningItem& ); + + /// Sfx item RES_CHRATR_LANGUAGE + virtual void CharLanguage( const SvxLanguageItem& ); + + /// Sfx item RES_CHRATR_POSTURE + virtual void CharPosture( const SvxPostureItem& ); + + /// Sfx item RES_CHRATR_SHADOWED + virtual void CharShadow( const SvxShadowedItem& ); + + /// Sfx item RES_CHRATR_UNDERLINE + virtual void CharUnderline( const SvxUnderlineItem& ); + + /// Sfx item RES_CHRATR_WEIGHT + virtual void CharWeight( const SvxWeightItem& ); + + /// Sfx item RES_CHRATR_AUTOKERN + virtual void CharAutoKern( const SvxAutoKernItem& ); + + /// Sfx item RES_CHRATR_BLINK + virtual void CharAnimatedText( const SvxBlinkItem& ); + + /// Sfx item RES_CHRATR_BACKGROUND + virtual void CharBackground( const SvxBrushItem& ); + + /// Sfx item RES_CHRATR_CJK_FONT + virtual void CharFontCJK( const SvxFontItem& ); + + /// Sfx item RES_CHRATR_CJK_FONTSIZE + virtual void CharFontSizeCJK( const SvxFontHeightItem& rHt ) { CharFontSize( rHt ); } + + /// Sfx item RES_CHRATR_CJK_LANGUAGE + virtual void CharLanguageCJK( const SvxLanguageItem& rHt ) { CharLanguage( rHt ); } + + /// Sfx item RES_CHRATR_CJK_POSTURE + virtual void CharPostureCJK( const SvxPostureItem& rHt ) { CharPosture( rHt ); } + + /// Sfx item RES_CHRATR_CJK_WEIGHT + virtual void CharWeightCJK( const SvxWeightItem& rHt ) { CharWeight( rHt ); } + + /// Sfx item RES_CHRATR_CTL_FONT + virtual void CharFontCTL( const SvxFontItem& ); + + /// Sfx item RES_CHRATR_CTL_FONTSIZE + virtual void CharFontSizeCTL( const SvxFontHeightItem& rHt ) { CharFontSize( rHt ); } + + /// Sfx item RES_CHRATR_CTL_LANGUAGE + virtual void CharLanguageCTL( const SvxLanguageItem& rHt ) { CharLanguage( rHt ); } + + /// Sfx item RES_CHRATR_CTL_POSTURE + virtual void CharPostureCTL( const SvxPostureItem& ); + + /// Sfx item RES_CHRATR_CTL_WEIGHT + virtual void CharWeightCTL( const SvxWeightItem& ); + + /// Sfx item RES_CHRATR_ROTATE + virtual void CharRotate( const SvxCharRotateItem& ); + + /// Sfx item RES_CHRATR_EMPHASIS_MARK + virtual void CharEmphasisMark( const SvxEmphasisMarkItem& rHt ); + + /// Sfx item RES_CHRATR_TWO_LINES + virtual void CharTwoLines( const SvxTwoLinesItem& ); + + /// Sfx item RES_CHRATR_SCALEW + virtual void CharScaleWidth( const SvxCharScaleWidthItem& ); + + /// Sfx item RES_CHRATR_RELIEF + virtual void CharRelief( const SvxCharReliefItem& ); + + /// Sfx item RES_CHRATR_HIDDEN + virtual void CharHidden( const SvxCharHiddenItem& ); + + /// Sfx item RES_TXTATR_INETFMT + virtual void TextINetFormat( const SwFmtINetFmt& ); + + /// Sfx item RES_TXTATR_CHARFMT + virtual void TextCharFormat( const SwFmtCharFmt& ); + + /// Sfx item RES_TXTATR_FTN + virtual void TextFootnote_Impl( const SwFmtFtn& ); + + /// Sfx item RES_PARATR_LINESPACING + virtual void ParaLineSpacing_Impl( short nSpace, short nMulti ); + + /// Sfx item RES_PARATR_ADJUST + virtual void ParaAdjust( const SvxAdjustItem& rHt ); + + /// Sfx item RES_PARATR_SPLIT + virtual void ParaSplit( const SvxFmtSplitItem& ); + + /// Sfx item RES_PARATR_WIDOWS + virtual void ParaWidows( const SvxWidowsItem& rHt ); + + /// Sfx item RES_PARATR_TABSTOP + virtual void ParaTabStop( const SvxTabStopItem& rHt ); + + /// Sfx item RES_PARATR_HYPHENZONE + virtual void ParaHyphenZone( const SvxHyphenZoneItem& ); + + /// Sfx item RES_PARATR_NUMRULE + virtual void ParaNumRule_Impl( const SwTxtNode *pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId ); + + /// Sfx item RES_PARATR_SCRIPTSPACE + virtual void ParaScriptSpace( const SfxBoolItem& ); + + /// Sfx item RES_PARATR_VERTALIGN + virtual void ParaVerticalAlign( const SvxParaVertAlignItem& ); + + /// Sfx item RES_PARATR_SNAPTOGRID + virtual void ParaSnapToGrid( const SvxParaGridItem& ); + + /// Sfx item RES_FRM_SIZE + virtual void FormatFrameSize( const SwFmtFrmSize& ); + + /// Sfx item RES_PAPER_BIN + virtual void FormatPaperBin( const SvxPaperBinItem& ); + + /// Sfx item RES_LR_SPACE + virtual void FormatLRSpace( const SvxLRSpaceItem& ); + + /// Sfx item RES_UL_SPACE + virtual void FormatULSpace( const SvxULSpaceItem& rHt ); + + /// Sfx item RES_SURROUND + virtual void FormatSurround( const SwFmtSurround& ); + + /// Sfx item RES_VERT_ORIENT + virtual void FormatVertOrientation( const SwFmtVertOrient& ); + + /// Sfx item RES_HORI_ORIENT + virtual void FormatHorizOrientation( const SwFmtHoriOrient& ); + + /// Sfx item RES_ANCHOR + virtual void FormatAnchor( const SwFmtAnchor& ); + + /// Sfx item RES_BACKGROUND + virtual void FormatBackground( const SvxBrushItem& ); + + /// Sfx item RES_BOX + virtual void FormatBox( const SvxBoxItem& ); + + /// Sfx item RES_COL + virtual void FormatColumns_Impl( USHORT nCols, const SwFmtCol & rCol, bool bEven, SwTwips nPageSize ); + + /// Sfx item RES_KEEP + virtual void FormatKeep( const SvxFmtKeepItem& ); + + /// Sfx item RES_TEXTGRID + virtual void FormatTextGrid( const SwTextGridItem& ); + + /// Sfx item RES_LINENUMBER + virtual void FormatLineNumbering( const SwFmtLineNumber& ); + + /// Sfx item RES_FRAMEDIR + virtual void FormatFrameDirection( const SvxFrameDirectionItem& ); + + /// Write the expanded field + virtual void WriteExpand( const SwField* pFld ); + + virtual void RefField ( const SwField& rFld, const String& rRef ); + virtual void HiddenField( const SwField& rFld ); + virtual void SetField( const SwField& rFld, ww::eField eType, const String& rCmd ); + virtual void PostitField( const SwField* pFld ); + virtual bool DropdownField( const SwField* pFld ); + + virtual bool AnalyzeURL( const String& rURL, const String& rTarget, String* pLinkURL, String* pMark ); + + /// Reference to the export, where to get the data from + WW8Export &m_rWW8Export; + + /// For output of styles. + /// + /// We have to remember these positions between the StartStyle() and + /// EndStyle(). + USHORT nPOPosStdLen1, nPOPosStdLen2; + + /// For output of styles. + /// + /// We have to remember this position between StartStyleProperties() and + /// EndStyleProperties(). + USHORT m_nStyleStartSize, m_nStyleLenPos; + + /// For output of styles. + /// + /// Used between StartStyles() and EndStyles(). + ULONG m_nStyAnzPos; + + /// For output of run properties. + /// + /// We have to remember the number of field results, and do not export end + /// of the field results if we were forced to split text. + USHORT m_nFieldResults; + +public: + WW8AttributeOutput( WW8Export &rWW8Export ) : AttributeOutputBase(), m_rWW8Export( rWW8Export ) {} + virtual ~WW8AttributeOutput() {} + + /// Return the right export class. + virtual MSWordExportBase& GetExport() { return m_rWW8Export; } + +protected: + /// Output the bold etc. attributes + void OutputWW8Attribute( BYTE nId, bool bVal ); + + /// Output the bold etc. attributes, the Complex Text Layout version + void OutputWW8AttributeCTL( BYTE nId, bool bVal ); + +}; + +#endif // _WW8ATTRIBUTEOUTPUT_HXX_ + +/* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx index 1eb9ae96b6..fe7fb79e01 100644 --- a/sw/source/filter/ww8/ww8glsy.cxx +++ b/sw/source/filter/ww8/ww8glsy.cxx @@ -187,7 +187,7 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks &rBlocks, -1 ); pCNd = aIdx.GetNode().GetCntntNode(); SwPosition aPos( aIdx, SwIndex( pCNd, pCNd->Len() )); - pD->Copy( aPam, aPos, false ); + pD->CopyRange( aPam, aPos, false ); rBlocks.PutDoc(); } } diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 00713be837..070de35a6d 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -46,7 +46,7 @@ #include <unotools/tempfile.hxx> #include <svtools/sfxecode.hxx> -#include <svtools/docpasswdrequest.hxx> +#include <comphelper/docpasswordrequest.hxx> #include <hintids.hxx> #include <svx/tstpitem.hxx> @@ -81,7 +81,6 @@ #include <fmtcntnt.hxx> #include <fmtcnct.hxx> #include <fmtpdsc.hxx> -#include <fmthbsh.hxx> #include <ftninfo.hxx> #include <fmtftn.hxx> #include <txtftn.hxx> @@ -579,7 +578,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, pObj->SetMergedItemSet(aSet); pObj->SetModel(pSdrModel); - if (bVerticalText && dynamic_cast< SdrTextObj* >( pObj ) ) + if (bVerticalText && dynamic_cast< SdrTextObj* >( pObj ) ) dynamic_cast< SdrTextObj* >( pObj )->SetVerticalWriting(sal_True); if ( bIsSimpleDrawingTextBox ) @@ -597,7 +596,7 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, } } - if ( ( mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) ) + if ( ( ( rObjData.nSpFlags & SP_FFLIPV ) || mnFix16Angle || nTextRotationAngle ) && dynamic_cast< SdrObjCustomShape* >( pObj ) ) { SdrObjCustomShape* pCustomShape = dynamic_cast< SdrObjCustomShape* >( pObj ); @@ -606,6 +605,10 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, { // text is already rotated, we have to take back the object rotation if DFF_Prop_RotateText is false fExtraTextRotation = -mnFix16Angle; } + if ( rObjData.nSpFlags & SP_FFLIPV ) // sj: in ppt the text is flipped, whereas in word the text + { // remains unchanged, so we have to take back the flipping here + fExtraTextRotation += 18000.0; // because our core will flip text if the shape is flipped. + } fExtraTextRotation += nTextRotationAngle; if ( !::basegfx::fTools::equalZero( fExtraTextRotation ) ) { @@ -950,7 +953,9 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos, pFrm->SetFmtAttr(aURL); } else - pDoc->Insert(aRegion, *pEntry->pAttr, 0); + { + pDoc->InsertPoolItem(aRegion, *pEntry->pAttr, 0); + } } } break; @@ -1068,7 +1073,7 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos, SwTxtNode* pTxt = rBkMrkPos.nNode.GetNode().GetTxtNode(); if( pTxt && rBkMrkPos.nContent.GetIndex() ) { - SwTxtAttr* pFtn = pTxt->GetTxtAttr( + SwTxtAttr* const pFtn = pTxt->GetTxtAttrForCharAt( rBkMrkPos.nContent.GetIndex()-1, RES_TXTATR_FTN ); if( pFtn ) { @@ -1083,7 +1088,7 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos, } } - pDoc->Insert(aPaM, *pEntry->pAttr, 0); + pDoc->InsertPoolItem(aPaM, *pEntry->pAttr, 0); MoveAttrs(*aPaM.GetPoint()); } break; @@ -1623,7 +1628,7 @@ long SwWW8ImplReader::Read_And(WW8PLCFManResult* pRes) sTxt, aDate ); aPostIt.SetTextObject(pOutliner); - rDoc.Insert(*pPaM, SwFmtFld(aPostIt), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aPostIt), 0); return 0; } @@ -2177,6 +2182,66 @@ CharSet SwWW8ImplReader::GetCurrentCharSet() switch (pLang->GetLanguage()) { case LANGUAGE_CZECH: + case LANGUAGE_HUNGARIAN: + case LANGUAGE_POLISH: + eSrcCharSet = RTL_TEXTENCODING_MS_1250; + break; + case LANGUAGE_RUSSIAN: + eSrcCharSet = RTL_TEXTENCODING_MS_1251; + break; + case LANGUAGE_GREEK: + eSrcCharSet = RTL_TEXTENCODING_MS_1253; + break; + case LANGUAGE_TURKISH: + eSrcCharSet = RTL_TEXTENCODING_MS_1254; + break; + default: + eSrcCharSet = RTL_TEXTENCODING_MS_1252; + break; + } + } + } + } + return eSrcCharSet; +} + +//Takashi Ono for CJK +CharSet SwWW8ImplReader::GetCurrentCJKCharSet() +{ + /* + #i2015 + If the hard charset is set use it, if not see if there is an open + character run that has set the charset, if not then fallback to the + current underlying paragraph style. + */ + CharSet eSrcCharSet = eHardCharSet; + if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) + { + if (!maFontSrcCJKCharSets.empty()) + eSrcCharSet = maFontSrcCJKCharSets.top(); + if ((eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) && (nCharFmt != -1)) + eSrcCharSet = pCollA[nCharFmt].GetCJKCharSet(); + if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) + eSrcCharSet = pCollA[nAktColl].GetCJKCharSet(); + if (eSrcCharSet == RTL_TEXTENCODING_DONTKNOW) + { // patch from cmc for #i52786# + /* + #i22206#/#i52786# + The (default) character set used for a run of text is the default + character set for the version of Word that last saved the document. + + This is a bit tentative, more might be required if the concept is correct. + When later version of word write older 6/95 documents the charset is + correctly set in the character runs involved, so its hard to reproduce + documents that require this to be sure of the process involved. + */ + const SvxLanguageItem *pLang = + (const SvxLanguageItem*)GetFmtAttr(RES_CHRATR_LANGUAGE); + if (pLang) + { + switch (pLang->GetLanguage()) + { + case LANGUAGE_CZECH: eSrcCharSet = RTL_TEXTENCODING_MS_1250; break; default: @@ -2221,7 +2286,7 @@ void SwWW8ImplReader::PostProcessAttrs() is only in use for 6/7 and for 8+ if we are in 8bit mode then the encoding is always 1252. - So a encoding converter that on an undefined character attempts to + So a encoding converter that on an undefined character attempts to convert from 1252 on the undefined character */ sal_Size Custom8BitToUnicode(rtl_TextToUnicodeConverter hConverter, @@ -2335,6 +2400,8 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs) const CharSet eSrcCharSet = bVer67 ? GetCurrentCharSet() : RTL_TEXTENCODING_MS_1252; + const CharSet eSrcCJKCharSet = bVer67 ? GetCurrentCJKCharSet() : + RTL_TEXTENCODING_MS_1252; // (re)alloc UniString data String sPlainCharsBuf; @@ -2395,7 +2462,7 @@ bool SwWW8ImplReader::ReadPlainChars(WW8_CP& rPos, long nEnd, long nCpOfs) sal_Char aTest[2]; aTest[0] = static_cast< sal_Char >((nUCode & 0xFF00) >> 8); aTest[1] = static_cast< sal_Char >(nUCode & 0x00FF); - String aTemp(aTest, 2, eSrcCharSet); + String aTemp(aTest, 2, eSrcCJKCharSet); ASSERT(aTemp.Len() == 1, "so much for that theory"); *pWork = aTemp.GetChar(0); } @@ -2442,13 +2509,15 @@ bool SwWW8ImplReader::AddTextToParagraph(const String& rAddString) { /* #ifdef DEBUG - ::std::clog << "<addTextToParagraph>" << dbg_out(rAddString) - << "</addTextToParagraph>" << ::std::endl; +//!! does not compile with debug=t -> unresolved external (dbg_out), +//!! sommeone who knows what he wants to get should fix this +// ::std::clog << "<addTextToParagraph>" << dbg_out(rAddString) +// << "</addTextToParagraph>" << ::std::endl; #endif */ if ((pNd->GetTxt().Len() + rAddString.Len()) < STRING_MAXLEN -1) { - rDoc.Insert (*pPaM, rAddString, true); + rDoc.InsertString(*pPaM, rAddString); } else { @@ -2457,16 +2526,16 @@ bool SwWW8ImplReader::AddTextToParagraph(const String& rAddString) { String sTempStr (rAddString,0, STRING_MAXLEN - pNd->GetTxt().Len() -1); - rDoc.Insert (*pPaM, sTempStr, true); + rDoc.InsertString(*pPaM, sTempStr); sTempStr = rAddString.Copy(sTempStr.Len(), rAddString.Len() - sTempStr.Len()); AppendTxtNode(*pPaM->GetPoint()); - rDoc.Insert (*pPaM,sTempStr, true ); + rDoc.InsertString(*pPaM, sTempStr); } else { AppendTxtNode(*pPaM->GetPoint()); - rDoc.Insert (*pPaM, rAddString, true); + rDoc.InsertString(*pPaM, rAddString); } } @@ -2487,7 +2556,9 @@ bool SwWW8ImplReader::ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, long nTextEnd, if( bSymbol ) // Spezialzeichen einfuegen { for(USHORT nCh = 0; nCh < nEnd - rPos; ++nCh) - rDoc.Insert( *pPaM, cSymbol ); + { + rDoc.InsertString( *pPaM, cSymbol ); + } pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_FONT ); } pStrm->SeekRel( nEnd- rPos ); @@ -2568,7 +2639,7 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) SwPageNumberField aFld( (SwPageNumberFieldType*)rDoc.GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM, SVX_NUM_ARABIC); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); } break; case 0xe: @@ -2580,7 +2651,8 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) { // Always insert a txtnode for a column break, e.g. ## AppendTxtNode(*pPaM->GetPoint()); - rDoc.Insert(*pPaM, SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0); + rDoc.InsertPoolItem(*pPaM, + SvxFmtBreakItem(SVX_BREAK_COLUMN_BEFORE, RES_BREAK), 0); } break; case 0x7: @@ -2610,7 +2682,7 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) SwPosition aEndPos = *pPaM->GetPoint(); SwPaM aFldPam(pFieldCtx->GetPtNode(), pFieldCtx->GetPtCntnt(), aEndPos.nNode, aEndPos.nContent.GetIndex()); IDocumentMarkAccess* const pMarkAccess = rDoc.getIDocumentMarkAccess(); - ::sw::mark::IFieldmark* pFieldmark = + ::sw::mark::IFieldmark* pFieldmark = dynamic_cast< ::sw::mark::IFieldmark*>(pMarkAccess->makeMark( aFldPam, pFieldCtx->GetBookmarkName(), @@ -2631,14 +2703,14 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) case 0xc: bRet = HandlePageBreakChar(); break; - case 0x1e: - rDoc.Insert( *pPaM, CHAR_HARDHYPHEN); // Non-breaking hyphen + case 0x1e: // Non-breaking hyphen + rDoc.InsertString( *pPaM, CHAR_HARDHYPHEN ); break; - case 0x1f: - rDoc.Insert( *pPaM, CHAR_SOFTHYPHEN); // Non-required hyphens + case 0x1f: // Non-required hyphens + rDoc.InsertString( *pPaM, CHAR_SOFTHYPHEN ); break; - case 0xa0: - rDoc.Insert( *pPaM, CHAR_HARDBLANK); // Non-breaking spaces + case 0xa0: // Non-breaking spaces + rDoc.InsertString( *pPaM, CHAR_HARDBLANK ); break; case 0x1: /* @@ -2720,12 +2792,8 @@ bool SwWW8ImplReader::ReadChar(long nPosCp, long nCpOfs) break; // Auto-Fussnoten-Nummer #if OSL_DEBUG_LEVEL > 1 default: - { - String sUnknown( '<' ); - sUnknown += String::CreateFromInt32( nWCharVal ); - sUnknown += '>'; - rDoc.Insert( *pPaM, sUnknown, true ); - } + ::std::clog << "<unknownValue val=\"" << nWCharVal << "\">" << ::std::endl; + break; #endif } @@ -3100,7 +3168,8 @@ bool SwWW8ImplReader::ReadText(long nStartCp, long nTextLen, ManTypes nType) AppendTxtNode(*pPaM->GetPoint()); } // <-- - rDoc.Insert(*pPaM, SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); + rDoc.InsertPoolItem(*pPaM, + SvxFmtBreakItem(SVX_BREAK_PAGE_BEFORE, RES_BREAK), 0); bPgSecBreak = false; } } @@ -3334,7 +3403,7 @@ void GiveNodePageDesc(SwNodeIndex &rIdx, const SwFmtPageDesc &rPgDesc, rIdx.GetNode().GetCntntNode(), 0); SwPaM aPage(aPamStart); - rDoc.Insert(aPage, rPgDesc, 0); + rDoc.InsertPoolItem(aPage, rPgDesc, 0); } } @@ -4173,8 +4242,8 @@ namespace uno::Reference< task::XInteractionHandler > xHandler( rMedium.GetInteractionHandler() ); if( xHandler.is() ) { - RequestDocumentPassword* pRequest = new RequestDocumentPassword( - task::PasswordRequestMode_PASSWORD_ENTER, + ::comphelper::DocPasswordRequest* pRequest = new ::comphelper::DocPasswordRequest( + ::comphelper::DocPasswordRequestType_MS, task::PasswordRequestMode_PASSWORD_ENTER, INetURLObject( rMedium.GetOrigURL() ).GetName( INetURLObject::DECODE_WITH_CHARSET ) ); uno::Reference< task::XInteractionRequest > xRequest( pRequest ); @@ -4350,7 +4419,7 @@ ULONG SwWW8ImplReader::LoadThroughDecryption(SwPaM& rPaM ,WW8Glossary *pGloss) if ( pMedium ) { SfxItemSet* pSet = pMedium->GetItemSet(); - if ( pSet ) + if ( pSet ) pSet->Put( SfxStringItem(SID_PASSWORD, sUniPassword) ); } } diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 80ac2c0ad0..a377602b87 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -54,12 +54,11 @@ #include <utility> #endif -#ifndef SW_TRACER #include "tracer.hxx" -#endif #include "ww8struc.hxx" // WW8_BRC #include "ww8scan.hxx" // WW8Fib #include "ww8glsy.hxx" +#include "wrtww8.hxx" #include "../inc/msfilter.hxx" class SwDoc; @@ -576,7 +575,7 @@ public: const ::com::sun::star::awt::Size& rSize, com::sun::star::uno::Reference < com::sun::star::drawing::XShape > *pShape,BOOL bFloatingCtrl); - bool ExportControl(Writer &rWrt, const SdrObject *pObj); + bool ExportControl(WW8Export &rWrt, const SdrObject *pObj); }; class SwMSDffManager : public SvxMSDffManager @@ -934,6 +933,7 @@ private: Stack of textencoding being used as we progress through the document text */ std::stack<rtl_TextEncoding> maFontSrcCharSets; + std::stack<rtl_TextEncoding> maFontSrcCJKCharSets; /* Winword numbering gets imported as SwNumRules, there is a problem that @@ -1174,6 +1174,7 @@ private: rtl_TextEncoding&); bool SetNewFontAttr(USHORT nFCode, bool bSetEnums, USHORT nWhich); void ResetCharSetVars(); + void ResetCJKCharSetVars(); const SfxPoolItem* GetFmtAttr( USHORT nWhich ); bool JoinNode(SwPaM &rPam, bool bStealAttr = false); @@ -1616,6 +1617,7 @@ public: // eigentlich private, geht aber leider nur public // Laden eines kompletten DocFiles ULONG LoadDoc( SwPaM&,WW8Glossary *pGloss=0); CharSet GetCurrentCharSet(); + CharSet GetCurrentCJKCharSet(); void PostProcessAttrs(); }; diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index bc6165aabd..635a2b7e6a 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -381,7 +381,7 @@ sal_uInt16 SwWW8ImplReader::End_Ftn() sChar.Append(pTxt->GetTxt().GetChar(--nPos)); pPaM->SetMark(); pPaM->GetMark()->nContent--; - rDoc.Delete( *pPaM ); + rDoc.DeleteRange( *pPaM ); pPaM->DeleteMark(); SwFmtFtn aFtn(rDesc.meType == MAN_EDN); pFN = pTxt->InsertItem(aFtn, nPos, nPos); @@ -435,7 +435,7 @@ sal_uInt16 SwWW8ImplReader::End_Ftn() pPaM->GetMark()->nContent++; pPaM->GetMark()->nContent++; pReffingStck->Delete(*pPaM); - rDoc.Delete( *pPaM ); + rDoc.DeleteRange( *pPaM ); pPaM->DeleteMark(); } } @@ -3579,6 +3579,45 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp) return bSuccess; } +bool lcl_PamContainsFly(SwPaM & rPam) +{ + bool bResult = false; + SwNodeRange aRg( rPam.Start()->nNode, rPam.End()->nNode ); + SwDoc * pDoc = rPam.GetDoc(); + + sal_uInt16 n = 0; + SwSpzFrmFmts * pSpzFmts = pDoc->GetSpzFrmFmts(); + sal_uInt16 nCount = pSpzFmts->Count(); + while (!bResult && n < nCount) + { + SwFrmFmt* pFly = (*pSpzFmts)[n]; + const SwFmtAnchor* pAnchor = &pFly->GetAnchor(); + + switch (pAnchor->GetAnchorId()) + { + case FLY_AT_CNTNT: + case FLY_AUTO_CNTNT: + { + const SwPosition* pAPos = pAnchor->GetCntntAnchor(); + + if (pAPos != NULL && + aRg.aStart <= pAPos->nNode && + pAPos->nNode <= aRg.aEnd) + { + bResult = true; + } + } + break; + default: + break; + } + + ++n; + } + + return bResult; +} + void SwWW8ImplReader::TabCellEnd() { if (nInTable && pTableDesc) @@ -3589,13 +3628,13 @@ void SwWW8ImplReader::TabCellEnd() && pWFlyPara == NULL && mpTableEndPaM.get() != NULL && (! SwPaM::Overlap(*pPaM, *mpTableEndPaM)) - && SwPaM::LessThan(*mpTableEndPaM, *pPaM)) + && SwPaM::LessThan(*mpTableEndPaM, *pPaM) + && mpTableEndPaM->GetPoint()->nNode.GetNode().IsTxtNode() + && !lcl_PamContainsFly(*mpTableEndPaM) + ) { - if (mpTableEndPaM->GetPoint()->nNode.GetNode().IsTxtNode()) - { - rDoc.DelFullPara(*mpTableEndPaM); - } - } + rDoc.DelFullPara(*mpTableEndPaM); + } } bFirstPara = true; // We have come to the end of a cell so FirstPara flag @@ -4686,4 +4725,11 @@ CharSet SwWW8StyInf::GetCharSet() const return eLTRFontSrcCharSet; } +CharSet SwWW8StyInf::GetCJKCharSet() const +{ + if ((pFmt) && (pFmt->GetFrmDir().GetValue() == FRMDIR_HORI_RIGHT_TOP)) + return eRTLFontSrcCharSet; + return eCJKFontSrcCharSet; +} + /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/ww8par2.hxx b/sw/source/filter/ww8/ww8par2.hxx index 8041b68f1e..d8730b0c55 100644 --- a/sw/source/filter/ww8/ww8par2.hxx +++ b/sw/source/filter/ww8/ww8par2.hxx @@ -224,6 +224,7 @@ public: return pOutlineNumrule; } CharSet GetCharSet() const; + CharSet GetCJKCharSet() const; }; class WW8RStyle: public WW8Style diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 3101d1a8ef..4e1ec2fcfd 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -207,7 +207,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormTextBox( WW8FieldDesc* pF, String& rStr ) aFld.SetHelp(aFormula.sHelp); aFld.SetToolTip(aFormula.sToolTip); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } else { WW8PLCFx_Book* pB = pPlcxMan->GetBook(); @@ -321,7 +321,7 @@ eF_ResT SwWW8ImplReader::Read_F_FormListBox( WW8FieldDesc* pF, String& rStr) aFld.SetSelectedItem(aFormula.maListEntries[nIndex]); } - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx index 013edcf0f2..3cded67e9f 100644 --- a/sw/source/filter/ww8/ww8par5.cxx +++ b/sw/source/filter/ww8/ww8par5.cxx @@ -61,7 +61,6 @@ #include <svx/fhgtitem.hxx> #include <svx/langitem.hxx> #include <fmtfld.hxx> -#include <fmthbsh.hxx> #include <fmtanchr.hxx> #include <pam.hxx> // fuer SwPam #include <doc.hxx> @@ -1062,7 +1061,8 @@ void SwWW8ImplReader::InsertTagField( const USHORT nId, const String& rTagText ) if( SwFltGetFlag(nFieldFlags, SwFltControlStack::TAGS_IN_TEXT)) { aName += rTagText; // als Txt taggen - rDoc.Insert(*pPaM, aName, false); + rDoc.InsertString(*pPaM, aName, + IDocumentContentOperations::INS_NOHINTEXPAND); } else { // normal tagggen @@ -1073,7 +1073,7 @@ void SwWW8ImplReader::InsertTagField( const USHORT nId, const String& rTagText ) USHORT nSubType = ( SwFltGetFlag( nFieldFlags, SwFltControlStack::TAGS_VISIBLE ) ) ? 0 : nsSwExtendedSubType::SUB_INVISIBLE; aFld.SetSubType(nSubType | nsSwGetSetExpType::GSE_STRING); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } } @@ -1133,7 +1133,7 @@ eF_ResT SwWW8ImplReader::Read_F_Input( WW8FieldDesc* pF, String& rStr ) SwInputField aFld( (SwInputFieldType*)rDoc.GetSysFldType( RES_INPUTFLD ), aDef, aQ, INP_TXT, 0 ); // sichtbar ( geht z.Zt. nicht anders ) - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1335,7 +1335,7 @@ eF_ResT SwWW8ImplReader::Read_F_InputVar( WW8FieldDesc* pF, String& rStr ) aFld.SetInputFlag(true); aFld.SetPromptText( aQ ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo); return FLD_OK; @@ -1351,7 +1351,7 @@ eF_ResT SwWW8ImplReader::Read_F_ANumber( WW8FieldDesc*, String& rStr ) SwSetExpField aFld( (SwSetExpFieldType*)pNumFldType, aEmptyStr, GetNumberPara( rStr ) ); aFld.SetValue( ++nFldNum ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1427,7 +1427,7 @@ eF_ResT SwWW8ImplReader::Read_F_Seq( WW8FieldDesc*, String& rStr ) else if (!bCountOn) aFld.SetFormula(aSequenceName); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1552,7 +1552,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr ) */ SwDocInfoField aFld( (SwDocInfoFieldType*) rDoc.GetSysFldType( RES_DOCINFOFLD ), DI_CUSTOM|nReg, aDocProperty, GetFieldResult( pF ) ); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1632,7 +1632,7 @@ eF_ResT SwWW8ImplReader::Read_F_DocInfo( WW8FieldDesc* pF, String& rStr ) rDoc.GetSysFldType( RES_DOCINFOFLD ), nSub|nReg, String(), nFormat ); if (bDateTime) ForceFieldLanguage(aFld, nLang); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1645,7 +1645,7 @@ eF_ResT SwWW8ImplReader::Read_F_Author( WW8FieldDesc*, String& ) SwDocInfoField aFld( (SwDocInfoFieldType*) rDoc.GetSysFldType( RES_DOCINFOFLD ), DI_CREATE|DI_SUB_AUTHOR, String() ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1653,7 +1653,7 @@ eF_ResT SwWW8ImplReader::Read_F_TemplName( WW8FieldDesc*, String& ) { SwTemplNameField aFld( (SwTemplNameFieldType*) rDoc.GetSysFldType( RES_TEMPLNAMEFLD ), FF_NAME ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1708,14 +1708,14 @@ eF_ResT SwWW8ImplReader::Read_F_DateTime( WW8FieldDesc*pF, String& rStr ) SwDateTimeField aFld((SwDateTimeFieldType*) rDoc.GetSysFldType(RES_DATETIMEFLD ), DATEFLD, nFormat); ForceFieldLanguage(aFld, nLang); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } else if (nDT == NUMBERFORMAT_TIME) { SwDateTimeField aFld((SwDateTimeFieldType*) rDoc.GetSysFldType(RES_DATETIMEFLD), TIMEFLD, nFormat); ForceFieldLanguage(aFld, nLang); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } return FLD_OK; @@ -1745,7 +1745,7 @@ eF_ResT SwWW8ImplReader::Read_F_FileName(WW8FieldDesc*, String &rStr) SwFileNameField aFld( (SwFileNameFieldType*)rDoc.GetSysFldType(RES_FILENAMEFLD), eType); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); return FLD_OK; } @@ -1759,7 +1759,7 @@ eF_ResT SwWW8ImplReader::Read_F_Anz( WW8FieldDesc* pF, String& rStr ) SwDocStatField aFld( (SwDocStatFieldType*) rDoc.GetSysFldType( RES_DOCSTATFLD ), nSub, GetNumberPara( rStr ) ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1771,7 +1771,7 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr ) SwChapterField aFld( (SwChapterFieldType*) rDoc.GetSysFldType( RES_CHAPTERFLD ), CF_NUMBER ); aFld.SetLevel( nPgChpLevel ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); static const sal_Char aDelim[] = "-.:\x97\x96"; BYTE nDelim = nPgChpDelim; @@ -1781,9 +1781,13 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr ) sal_Unicode c = ByteString::ConvertToUnicode( aDelim[ nDelim ], RTL_TEXTENCODING_MS_1252 ); if( '-' == c ) - rDoc.Insert( *pPaM, CHAR_HARDHYPHEN ); + { + rDoc.InsertString( *pPaM, CHAR_HARDHYPHEN ); + } else - rDoc.Insert( *pPaM, SwFmtHardBlank( c ), 0); + { + rDoc.InsertString( *pPaM, c ); // maybe insert ZWNBSP? + } } // Seitennummer @@ -1791,7 +1795,7 @@ eF_ResT SwWW8ImplReader::Read_F_CurPage( WW8FieldDesc*, String& rStr ) rDoc.GetSysFldType( RES_PAGENUMBERFLD ), PG_RANDOM, GetNumberPara(rStr, true)); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -1850,7 +1854,7 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, String& rStr ) NewAttr(aSz); } - rDoc.Insert(*pPaM, cChar); + rDoc.InsertString(*pPaM, cChar); if (nSize > 0) pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_CHRATR_FONTSIZE); @@ -1859,7 +1863,7 @@ eF_ResT SwWW8ImplReader::Read_F_Symbol( WW8FieldDesc*, String& rStr ) } else { - rDoc.Insert(*pPaM, CREATE_CONST_ASC("###"), true); + rDoc.InsertString(*pPaM, CREATE_CONST_ASC("###")); } return FLD_OK; @@ -1920,7 +1924,7 @@ eF_ResT SwWW8ImplReader::Read_F_Set( WW8FieldDesc* pF, String& rStr ) SwSetExpField aFld( (SwSetExpFieldType*)pFT, sVal, ULONG_MAX ); aFld.SetSubType(nsSwExtendedSubType::SUB_INVISIBLE | nsSwGetSetExpType::GSE_STRING); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); pReffedStck->SetAttr(*pPaM->GetPoint(), RES_FLTR_BOOKMARK, true, nNo); @@ -1970,7 +1974,7 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr ) SwGetRefField aFld( (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sBkmName,REF_BOOKMARK,0,REF_CHAPTER); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); } else { @@ -1993,7 +1997,7 @@ eF_ResT SwWW8ImplReader::Read_F_Ref( WW8FieldDesc*, String& rStr ) SwGetRefField aFld( (SwGetRefFieldType*) rDoc.GetSysFldType( RES_GETREFFLD ), sBkmName, REF_BOOKMARK, 0, REF_UPDOWN ); - rDoc.Insert(*pPaM, SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); } return FLD_OK; } @@ -2070,7 +2074,7 @@ eF_ResT SwWW8ImplReader::Read_F_PgRef( WW8FieldDesc*, String& rStr ) (SwGetRefFieldType*)rDoc.GetSysFldType( RES_GETREFFLD ), sName, REF_BOOKMARK, 0, REF_PAGE ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -2119,7 +2123,7 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, String& rStr) SwMacroField aFld( (SwMacroFieldType*) rDoc.GetSysFldType( RES_MACROFLD ), aName, aVText ); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); WW8_CP nOldCp = pPlcxMan->Where(); @@ -2280,7 +2284,7 @@ eF_ResT SwWW8ImplReader::Read_F_IncludeText( WW8FieldDesc* /*pF*/, String& rStr aSection.SetLinkFileName( aPara ); aSection.SetProtect(true); - SwSection* pSection = rDoc.Insert(*pPaM, aSection, 0 ,false); + SwSection*const pSection = rDoc.InsertSwSection(*pPaM, aSection, 0, false); ASSERT(pSection, "no section inserted"); if (!pSection) return FLD_TEXT; @@ -2327,7 +2331,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBField( WW8FieldDesc* pF, String& rStr ) aFld.InitContent(aResult); - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld( aFld ), 0); return FLD_OK; } @@ -2339,7 +2343,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBNext( WW8FieldDesc*, String& ) SwFieldType* pFT = rDoc.InsertFldType( aN ); SwDBNextSetField aFld( (SwDBNextSetFieldType*)pFT, aEmptyStr, aEmptyStr, SwDBData() ); // Datenbank: Nichts - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -2350,7 +2354,7 @@ eF_ResT SwWW8ImplReader::Read_F_DBNum( WW8FieldDesc*, String& ) SwFieldType* pFT = rDoc.InsertFldType( aN ); SwDBSetNumberField aFld( (SwDBSetNumberFieldType*)pFT, SwDBData() ); // Datenbank: Nichts - rDoc.Insert( *pPaM, SwFmtFld( aFld ), 0 ); + rDoc.InsertPoolItem( *pPaM, SwFmtFld( aFld ), 0 ); return FLD_OK; } @@ -2415,7 +2419,7 @@ void SwWW8ImplReader::Read_SubF_Combined( _ReadFieldParams& rReadParam) { SwCombinedCharField aFld((SwCombinedCharFieldType*) rDoc.GetSysFldType(RES_COMBINED_CHARS),sCombinedCharacters); - rDoc.Insert(*pPaM,SwFmtFld(aFld), 0); + rDoc.InsertPoolItem(*pPaM, SwFmtFld(aFld), 0); } } @@ -2521,8 +2525,8 @@ void SwWW8ImplReader::Read_SubF_Ruby( _ReadFieldParams& rReadParam) const SwCharFmt *pCharFmt=0; //Make a guess at which of asian of western we should be setting USHORT nScript; - if (pBreakIt->xBreak.is()) - nScript = pBreakIt->xBreak->getScriptType(sRuby, 0); + if (pBreakIt->GetBreakIter().is()) + nScript = pBreakIt->GetBreakIter()->getScriptType(sRuby, 0); else nScript = i18n::ScriptType::ASIAN; @@ -2573,7 +2577,7 @@ void SwWW8ImplReader::Read_SubF_Ruby( _ReadFieldParams& rReadParam) aRuby.SetAdjustment(nJustificationCode); NewAttr(aRuby); - rDoc.Insert( *pPaM, sText, true ); + rDoc.InsertString( *pPaM, sText ); pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_TXTATR_CJK_RUBY ); } } @@ -2634,6 +2638,28 @@ bool SwWW8ImplReader::AddExtraOutlinesAsExtraStyles(SwTOXBase& rBase) return bExtras; } +static void EnsureMaxLevelForTemplates(SwTOXBase& rBase) +{ + //If the TOC contains Template entries at levels > the evaluation level + //that was initially taken from the max normal outline level of the word TOC + //then we cannot use that for the evaluation level because writer cuts off + //all styles above that level, while word just cuts off the "standard" + //outline styles, we have no option but to expand to the highest level + //Word included. + if ((rBase.GetLevel() != MAXLEVEL) && (nsSwTOXElement::TOX_TEMPLATE & rBase.GetCreateType())) + { + for (USHORT nI = MAXLEVEL; nI > 0; --nI) + { + String sStyles(rBase.GetStyleNames(nI-1)); + if (rBase.GetStyleNames(nI-1).Len()) + { + rBase.SetLevel(nI); + break; + } + } + } +} + void lcl_toxMatchTSwitch(SwWW8ImplReader& rReader, SwTOXBase& rBase, _ReadFieldParams& rParam) { @@ -2727,6 +2753,19 @@ bool wwSectionManager::WillHavePageDescHere(SwNodeIndex aIdx) const return bRet; } +USHORT lcl_GetMaxValidWordTOCLevel(const SwForm &rForm) +{ + // GetFormMax() returns level + 1, hence the -1 + USHORT nRet = rForm.GetFormMax()-1; + + // If the max of this type of TOC is greater than the max of a word + // possible toc, then clip to the word max + if (nRet > WW8ListManager::nMaxLevel) + nRet = WW8ListManager::nMaxLevel; + + return nRet; +} + eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr ) { if (pF->nLRes < 3) @@ -2883,8 +2922,8 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr ) case 'o': { USHORT nVal; - if( !aReadParam.GetTokenSttFromTo(0, &nVal, MAXLEVEL) ) - nVal = aOrigForm.GetFormMax()-1; + if( !aReadParam.GetTokenSttFromTo(0, &nVal, WW8ListManager::nMaxLevel) ) + nVal = lcl_GetMaxValidWordTOCLevel(aOrigForm); if( nMaxLevel < nVal ) nMaxLevel = nVal; eCreateFrom |= nsSwTOXElement::TOX_OUTLINELEVEL; @@ -2896,7 +2935,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr ) case 'l': { USHORT nVal; - if( aReadParam.GetTokenSttFromTo(0, &nVal, MAXLEVEL) ) + if( aReadParam.GetTokenSttFromTo(0, &nVal, WW8ListManager::nMaxLevel) ) { if( nMaxLevel < nVal ) nMaxLevel = nVal; @@ -2969,7 +3008,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr ) // read START and END param USHORT nStart, nEnd; if( !aReadParam.GetTokenSttFromTo( &nStart, &nEnd, - MAXLEVEL ) ) + WW8ListManager::nMaxLevel ) ) { nStart = 1; nEnd = aOrigForm.GetFormMax()-1; @@ -3052,7 +3091,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr ) } if (!nMaxLevel) - nMaxLevel = MAXLEVEL; + nMaxLevel = WW8ListManager::nMaxLevel; pBase->SetLevel(nMaxLevel); const TOXTypes eType = pBase->GetTOXType()->GetType(); @@ -3110,6 +3149,7 @@ eF_ResT SwWW8ImplReader::Read_F_Tox( WW8FieldDesc* pF, String& rStr ) if (eCreateFrom) pBase->SetCreate(eCreateFrom); + EnsureMaxLevelForTemplates(*pBase); } break; case TOX_ILLUSTRATIONS: @@ -3387,7 +3427,7 @@ void lcl_ImportTox(SwDoc &rDoc, SwPaM &rPaM, const String &rStr, bool bIdx) if (sFldTxt.Len()) { aM.SetAlternativeText( sFldTxt ); - rDoc.Insert( rPaM, aM, 0 ); + rDoc.InsertPoolItem( rPaM, aM, 0 ); } } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index b243f0b29f..64143da9d8 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -698,7 +698,8 @@ SwSectionFmt *wwSectionManager::InsertSection( aSection.SetProtect(SectionIsProtected(rSection)); - rSection.mpSection = mrReader.rDoc.Insert( rMyPaM, aSection, &aSet ); + rSection.mpSection = + mrReader.rDoc.InsertSwSection( rMyPaM, aSection, &aSet ); ASSERT(rSection.mpSection, "section not inserted!"); if (!rSection.mpSection) return 0; @@ -778,6 +779,11 @@ void SwWW8ImplReader::HandleLineNumbering(const wwSection &rSection) ) { SwFmtLineNumber aLN; + if (const SwFmtLineNumber* pLN + = (const SwFmtLineNumber*)GetFmtAttr(RES_LINENUMBER)) + { + aLN.SetCountLines( pLN->IsCount() ); + } aLN.SetStartValue(1 + rSection.maSep.lnnMin); NewAttr(aLN); pCtrlStck->SetAttr(*pPaM->GetPoint(), RES_LINENUMBER); @@ -846,7 +852,7 @@ void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/) aSection.SetProtect(true); // --> CMC, OD 2004-06-18 #i19922# improvement: // return value of method <Insert> not used. - mrReader.rDoc.Insert(*mrReader.pPaM, aSection, 0 ,false); + mrReader.rDoc.InsertSwSection(*mrReader.pPaM, aSection, 0, false); } wwSection aLastSection(*mrReader.pPaM->GetPoint()); @@ -3212,7 +3218,7 @@ SwFrmFmt *SwWW8ImplReader::ContainsSingleInlineGraphic(const SwPaM &rRegion) if ( aBegin == aEnd && nBegin == nEnd - 1 && 0 != (pTNd = aBegin.GetNode().GetTxtNode()) && - 0 != (pTFlyAttr = pTNd->GetTxtAttr(nBegin, RES_TXTATR_FLYCNT)) + 0 != (pTFlyAttr = pTNd->GetTxtAttrForCharAt(nBegin, RES_TXTATR_FLYCNT)) ) { const SwFmtFlyCnt& rFly = pTFlyAttr->GetFlyCnt(); @@ -3552,11 +3558,32 @@ bool SwWW8ImplReader::SetNewFontAttr(USHORT nFCode, bool bSetEnums, //off the stack will keep in sync if (!pAktColl && IsListOrDropcap()) { - if (!maFontSrcCharSets.empty()) - eSrcCharSet = maFontSrcCharSets.top(); + if (nWhich == RES_CHRATR_CJK_FONT) + { + if (!maFontSrcCJKCharSets.empty()) + { + eSrcCharSet = maFontSrcCJKCharSets.top(); + } + else + { + eSrcCharSet = RTL_TEXTENCODING_DONTKNOW; + } + + maFontSrcCJKCharSets.push(eSrcCharSet); + } else - eSrcCharSet = RTL_TEXTENCODING_DONTKNOW; - maFontSrcCharSets.push(eSrcCharSet); + { + if (!maFontSrcCharSets.empty()) + { + eSrcCharSet = maFontSrcCharSets.top(); + } + else + { + eSrcCharSet = RTL_TEXTENCODING_DONTKNOW; + } + + maFontSrcCharSets.push(eSrcCharSet); + } } return false; } @@ -3586,7 +3613,10 @@ bool SwWW8ImplReader::SetNewFontAttr(USHORT nFCode, bool bSetEnums, else if (IsListOrDropcap()) { //Add character text encoding to stack - maFontSrcCharSets.push(eSrcCharSet); + if (nWhich == RES_CHRATR_CJK_FONT) + maFontSrcCJKCharSets.push(eSrcCharSet); + else + maFontSrcCharSets.push(eSrcCharSet); } } @@ -3602,6 +3632,13 @@ void SwWW8ImplReader::ResetCharSetVars() maFontSrcCharSets.pop(); } +void SwWW8ImplReader::ResetCJKCharSetVars() +{ + ASSERT(!maFontSrcCJKCharSets.empty(),"no charset to remove"); + if (!maFontSrcCJKCharSets.empty()) + maFontSrcCJKCharSets.pop(); +} + /* Font ein oder ausschalten: */ @@ -3632,7 +3669,10 @@ void SwWW8ImplReader::Read_FontCode( USHORT nId, const BYTE* pData, short nLen ) if( nLen < 0 ) // Ende des Attributes { pCtrlStck->SetAttr( *pPaM->GetPoint(), nId ); - ResetCharSetVars(); + if (nId == RES_CHRATR_CJK_FONT) + ResetCJKCharSetVars(); + else + ResetCharSetVars(); } else { @@ -3875,6 +3915,12 @@ void SwWW8ImplReader::Read_NoLineNumb(USHORT , const BYTE* pData, short nLen) return; } SwFmtLineNumber aLN; + if (const SwFmtLineNumber* pLN + = (const SwFmtLineNumber*)GetFmtAttr(RES_LINENUMBER)) + { + aLN.SetStartValue( pLN->GetStartValue() ); + } + aLN.SetCountLines( pData && (0 == *pData) ); NewAttr( aLN ); } diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 4ea643ea4e..3f7bf9e056 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -1498,8 +1498,15 @@ WW8_CP WW8ScannerBase::WW8Fc2Cp( WW8_FC nFcPos ) const } INT32 nFcStart = SVBT32ToUInt32( ((WW8_PCD*)pData)->fc ); if( 8 <= pWw8Fib->nVersion ) + { nFcStart = WW8PLCFx_PCD::TransformPieceAddress( nFcStart, bIsUnicode ); + } + else + { + if (pWw8Fib->fExtChar) + bIsUnicode=true; + } INT32 nLen = (nCpEnd - nCpStart) * (bIsUnicode ? 2 : 1); /* @@ -1581,7 +1588,10 @@ WW8_FC WW8ScannerBase::WW8Cp2Fc(WW8_CP nCpPos, bool* pIsUnicode, WW8_FC nRet = SVBT32ToUInt32( ((WW8_PCD*)pData)->fc ); if (8 > pWw8Fib->nVersion) - *pIsUnicode = false; + if (pWw8Fib->fExtChar) + *pIsUnicode=true; + else + *pIsUnicode = false; else nRet = WW8PLCFx_PCD::TransformPieceAddress( nRet, *pIsUnicode ); diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 395eeaa1e9..9ec0fc7b5f 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -79,13 +79,13 @@ namespace SL DEFCONSTSTRINGARRAY(MSMacroCmds); } -/* - winword strings are typically Belt and Braces strings preceeded with a - pascal style count, and ending with a c style 0 terminator. 16bit chars - and count for ww8+ and 8bit chars and count for ww7-. The count and 0 - can be checked for integrity to catch errors (e.g. lotus created documents) - where in error 8bit strings are used instead of 16bits strings for style - names. +/** + winword strings are typically Belt and Braces strings preceeded with a + pascal style count, and ending with a c style 0 terminator. 16bit chars + and count for ww8+ and 8bit chars and count for ww7-. The count and 0 + can be checked for integrity to catch errors (e.g. lotus created documents) + where in error 8bit strings are used instead of 16bits strings for style + names. */ template<class C> class wwString { @@ -98,7 +98,7 @@ typedef wwString<sal_uInt16> ww8String; struct SprmInfo { - sal_uInt16 nId; //A ww8 sprm is hardcoded as 16bits + sal_uInt16 nId; ///< A ww8 sprm is hardcoded as 16bits unsigned int nLen : 6; unsigned int nVari : 2; }; @@ -114,8 +114,10 @@ struct SprmInfoHash typedef ww::WrappedHash<SprmInfo, SprmInfoHash> wwSprmSearcher; typedef ww::WrappedHash<sal_uInt16> wwSprmSequence; -//wwSprmParser knows how to take a sequence of bytes and split it up into -//sprms and their arguments +/** + wwSprmParser knows how to take a sequence of bytes and split it up into + sprms and their arguments +*/ class wwSprmParser { private: @@ -134,20 +136,20 @@ private: public: //7- ids are very different to 8+ ones wwSprmParser(ww::WordVersion eVersion); - //Return the SPRM id at the beginning of this byte sequence + /// Return the SPRM id at the beginning of this byte sequence sal_uInt16 GetSprmId(const sal_uInt8* pSp) const; USHORT GetSprmSize(sal_uInt16 nId, const sal_uInt8* pSprm) const; - //Get known len of a sprms head, the bytes of the sprm id + any bytes - //reserved to hold a variable length + /// Get known len of a sprms head, the bytes of the sprm id + any bytes + /// reserved to hold a variable length USHORT DistanceToData(sal_uInt16 nId) const; - //Get len of a sprms data area, ignoring the bytes of the sprm id and - //ignoring any len bytes. Reports the remaining data after those bytes + /// Get len of a sprms data area, ignoring the bytes of the sprm id and + /// ignoring any len bytes. Reports the remaining data after those bytes USHORT GetSprmTailLen(sal_uInt16 nId, const sal_uInt8 * pSprm) const; - //The minimum acceptable sprm len possible for this type of parser + /// The minimum acceptable sprm len possible for this type of parser int MinSprmLen() const { return (IsSevenMinus(meVersion)) ? 2 : 3; } inline int getVersion() const { return meVersion; } //cmc, I'm dubious about the usage of this, how can it be 0 @@ -164,14 +166,14 @@ class WW8PLCFx_PCD; String WW8ReadPString( SvStream& rStrm, rtl_TextEncoding eEnc, bool bAtEndSeekRel1 = true); -/* +/** The following method reads a 2Byte unicode string. If bAtEndSeekRel1 is set, exactly ONE byte is skipped If nChars is set then that number of characters (not bytes) is read, if its not set, the first character read is the length */ String WW8Read_xstz(SvStream& rStrm, USHORT nChars, bool bAtEndSeekRel1); -/* +/** reads array of strings (see MS documentation: STring TaBle stored in File) returns NOT the original pascal strings but an array of converted char* @@ -183,23 +185,23 @@ void WW8ReadSTTBF(bool bVer8, SvStream& rStrm, UINT32 nStart, INT32 nLen, struct WW8FieldDesc { - long nLen; // Gesamtlaenge ( zum Text ueberlesen ) - WW8_CP nSCode; // Anfang Befehlscode - WW8_CP nLCode; // Laenge - WW8_CP nSRes; // Anfang Ergebnis - WW8_CP nLRes; // Laenge ( == 0, falls kein Ergebnis ) - USHORT nId; // WW-Id fuer Felder - BYTE nOpt; // WW-Flags ( z.B.: vom User geaendert ) - BYTE bCodeNest:1; // Befehl rekursiv verwendet - BYTE bResNest:1; // Befehl in Resultat eingefuegt + long nLen; ///< Gesamtlaenge ( zum Text ueberlesen ) + WW8_CP nSCode; ///< Anfang Befehlscode + WW8_CP nLCode; ///< Laenge + WW8_CP nSRes; ///< Anfang Ergebnis + WW8_CP nLRes; ///< Laenge ( == 0, falls kein Ergebnis ) + USHORT nId; ///< WW-Id fuer Felder + BYTE nOpt; ///< WW-Flags ( z.B.: vom User geaendert ) + BYTE bCodeNest:1; ///< Befehl rekursiv verwendet + BYTE bResNest:1; ///< Befehl in Resultat eingefuegt }; struct WW8PLCFxSave1 { ULONG nPLCFxPos; - ULONG nPLCFxPos2; // fuer PLCF_Cp_Fkp: PieceIter-Pos + ULONG nPLCFxPos2; ///< fuer PLCF_Cp_Fkp: PieceIter-Pos long nPLCFxMemOfs; - WW8_CP nStartCp; // for cp based iterator like PAP and CHP + WW8_CP nStartCp; ///< for cp based iterator like PAP and CHP long nCpOfs; WW8_FC nStartFC; WW8_CP nAttrStart; @@ -207,17 +209,17 @@ struct WW8PLCFxSave1 bool bLineEnd; }; -/* +/** u.a. fuer Felder, also genausoviele Attr wie Positionen, falls Ctor-Param bNoEnd = false */ class WW8PLCFspecial // Iterator fuer PLCFs { private: - INT32* pPLCF_PosArray; // Pointer auf Pos-Array und auf ganze Struktur - BYTE* pPLCF_Contents; // Pointer auf Inhalts-Array-Teil des Pos-Array - long nIMax; // Anzahl der Elemente - long nIdx; // Merker, wo wir gerade sind + INT32* pPLCF_PosArray; ///< Pointer auf Pos-Array und auf ganze Struktur + BYTE* pPLCF_Contents; ///< Pointer auf Inhalts-Array-Teil des Pos-Array + long nIMax; ///< Anzahl der Elemente + long nIdx; ///< Merker, wo wir gerade sind long nStru; public: WW8PLCFspecial( SvStream* pSt, long nFilePos, long nPLCF, @@ -246,7 +248,7 @@ public: WW8PLCFspecial& operator --( int ) { nIdx--; return *this; } }; -/* simple Iterator for SPRMs */ +/** simple Iterator for SPRMs */ class WW8SprmIter { private: @@ -463,7 +465,7 @@ public: } }; -/* +/** Iterator for Piece Table Exceptions of Fkps works only with FCs, not with CPs ! ( Low-Level ) */ @@ -587,7 +589,7 @@ public: bool HasFkp() const { return (0 != pFkp); } }; -// Iterator fuer Piece Table Exceptions of Fkps arbeitet auf CPs (High-Level) +/// Iterator fuer Piece Table Exceptions of Fkps arbeitet auf CPs (High-Level) class WW8PLCFx_Cp_FKP : public WW8PLCFx_Fc_FKP { private: @@ -619,7 +621,7 @@ public: virtual void Restore( const WW8PLCFxSave1& rSave ); }; -// Iterator for Piece Table Exceptions of Sepx +/// Iterator for Piece Table Exceptions of Sepx class WW8PLCFx_SEPX : public WW8PLCFx { private: @@ -652,7 +654,7 @@ public: BYTE*& p1, BYTE*& p2, BYTE*& p3, BYTE*& p4 ) const; }; -// Iterator fuer Fuss-/Endnoten und Anmerkungen +/// Iterator fuer Fuss-/Endnoten und Anmerkungen class WW8PLCFx_SubDoc : public WW8PLCFx { private: @@ -684,7 +686,7 @@ public: long Count() const { return ( pRef ) ? pRef->GetIMax() : 0; } }; -// Iterator fuer Fuss- und Endnoten +/// Iterator for footnotes and endnotes class WW8PLCFx_FLD : public WW8PLCFx { private: @@ -709,7 +711,7 @@ public: enum eBookStatus { BOOK_NORMAL = 0, BOOK_IGNORE = 0x1, BOOK_FIELD = 0x2 }; -// Iterator for Booknotes +/// Iterator for Booknotes class WW8PLCFx_Book : public WW8PLCFx { private: @@ -978,7 +980,8 @@ public: }; -/* +/** FIB - the File Information Block + The FIB contains a "magic word" and pointers to the various other parts of the file, as well as information about the length of the file. The FIB starts at the beginning of the file. @@ -986,7 +989,7 @@ public: class WW8Fib { public: - /* + /** Program-Version asked for by us: in Ctor we check if it matches the value of nFib @@ -1497,7 +1500,8 @@ namespace nsHdFtFlags const HdFtFlags WW8_FOOTER_FIRST = 0x20; } -class WW8Dop // Document Properties +/// Document Properties +class WW8Dop { public: /* Error Status */ diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx index 65f6014218..bb9c9cfc82 100644 --- a/sw/source/filter/ww8/ww8struc.hxx +++ b/sw/source/filter/ww8/ww8struc.hxx @@ -165,15 +165,17 @@ typedef sal_Int32 WW8_CP; const WW8_FC WW8_FC_MAX = SAL_MAX_INT32; const WW8_CP WW8_CP_MAX = SAL_MAX_INT32; -// STD: STyle Definition -// The STD contains the entire definition of a style. -// It has two parts, a fixed-length base (cbSTDBase bytes long) -// and a variable length remainder holding the name, and the upx and upe -// arrays (a upx and upe for each type stored in the style, std.cupx) -// Note that new fields can be added to the BASE of the STD without -// invalidating the file format, because the STSHI contains the length -// that is stored in the file. When reading STDs from an older version, -// new fields will be zero. +/** STD - STyle Definition + + The STD contains the entire definition of a style. + It has two parts, a fixed-length base (cbSTDBase bytes long) + and a variable length remainder holding the name, and the upx and upe + arrays (a upx and upe for each type stored in the style, std.cupx) + Note that new fields can be added to the BASE of the STD without + invalidating the file format, because the STSHI contains the length + that is stored in the file. When reading STDs from an older version, + new fields will be zero. +*/ struct WW8_STD { // Base part of STD: @@ -203,9 +205,7 @@ struct WW8_STD // char grupe[]; }; -/* - Basis zum Einlesen UND zum Arbeiten (wird jeweils unter - schiedlich beerbt) +/** Basis zum Einlesen UND zum Arbeiten (wird jeweils unter schiedlich beerbt) */ struct WW8_FFN_BASE // Font Descriptor { @@ -223,8 +223,7 @@ struct WW8_FFN_BASE // Font Descriptor BYTE ibszAlt; // 0x5 index into ffn.szFfn to the name of the alternate font }; -/* - Hiermit arbeiten wir im Parser (und Dumper) +/** Hiermit arbeiten wir im Parser (und Dumper) */ struct WW8_FFN : public WW8_FFN_BASE { diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index 3d30c029f0..ebecc1d1bd 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -646,7 +646,7 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) // delete 'deleted' redlines and forget about the whole thing if (nsRedlineType_t::REDLINE_DELETE == pRedlineInfo->eType) { - pDoc->Delete(aPaM); + pDoc->DeleteRange(aPaM); // And what about the "deleted nodes"? // They have to be deleted as well (#i80689)! if( bIgnoreRedlines && pRedlineInfo->pContentIndex != NULL ) @@ -657,7 +657,7 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) { SwNodeIndex aEnd( *pEnd, 1 ); SwPaM aDel( aIdx, aEnd ); - pDoc->Delete(aDel); + pDoc->DeleteRange(aDel); } } } diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index c215e1e41b..db83d59eaf 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -216,6 +216,24 @@ sal_Int32 ReadThroughComponent( } catch( xml::sax::SAXParseException& r ) { + // sax parser sends wrapped exceptions, + // try to find the original one + xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r); + sal_Bool bTryChild = sal_True; + + while( bTryChild ) + { + xml::sax::SAXException aTmp; + if ( aSaxEx.WrappedException >>= aTmp ) + aSaxEx = aTmp; + else + bTryChild = sal_False; + } + + packages::zip::ZipIOException aBrokenPackage; + if ( aSaxEx.WrappedException >>= aBrokenPackage ) + return ERRCODE_IO_BROKENPACKAGE; + if( bEncrypted ) return ERRCODE_SFX_WRONGPASSWORD; @@ -246,7 +264,10 @@ sal_Int32 ReadThroughComponent( } catch( xml::sax::SAXException& r) { - (void)r; + packages::zip::ZipIOException aBrokenPackage; + if ( r.WrappedException >>= aBrokenPackage ) + return ERRCODE_IO_BROKENPACKAGE; + if( bEncrypted ) return ERRCODE_SFX_WRONGPASSWORD; @@ -255,6 +276,7 @@ sal_Int32 ReadThroughComponent( aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); DBG_ERROR( aError.GetBuffer() ); #endif + return ERR_SWG_READ_ERROR; } catch( packages::zip::ZipIOException& r) @@ -873,35 +895,39 @@ ULONG XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, const S // <-- sal_uInt32 nWarnRDF = 0; - // RDF metadata - must be read before styles/content - // N.B.: embedded documents have their own manifest.rdf! - try - { - const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(xModelComp, - uno::UNO_QUERY_THROW); - const uno::Reference<rdf::XURI> xBaseURI( ::sfx2::createBaseURI( - aContext.getUNOContext(), xStorage, aBaseURL, StreamPath) ); - const uno::Reference<task::XInteractionHandler> xHandler( - pDocSh->GetMedium()->GetInteractionHandler() ); - xDMA->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); - } - catch (lang::WrappedTargetException & e) + if ( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() || + bInsertMode) ) { - ucb::InteractiveAugmentedIOException iaioe; - if (e.TargetException >>= iaioe) + // RDF metadata - must be read before styles/content + // N.B.: embedded documents have their own manifest.rdf! + try { - // import error that was not ignored by InteractionHandler! - nWarnRDF = ERR_SWG_READ_ERROR; + const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(xModelComp, + uno::UNO_QUERY_THROW); + const uno::Reference<rdf::XURI> xBaseURI( ::sfx2::createBaseURI( + aContext.getUNOContext(), xStorage, aBaseURL, StreamPath) ); + const uno::Reference<task::XInteractionHandler> xHandler( + pDocSh->GetMedium()->GetInteractionHandler() ); + xDMA->loadMetadataFromStorage(xStorage, xBaseURI, xHandler); } - else + catch (lang::WrappedTargetException & e) + { + ucb::InteractiveAugmentedIOException iaioe; + if (e.TargetException >>= iaioe) + { + // import error that was not ignored by InteractionHandler! + nWarnRDF = ERR_SWG_READ_ERROR; + } + else + { + nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something wrong? + } + } + catch (uno::Exception &) { nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong? } } - catch (uno::Exception &) - { - nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong? - } sal_uInt32 nWarn = 0; sal_uInt32 nWarn2 = 0; diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx index 22c222ea5d..20eb2e53ed 100644 --- a/sw/source/filter/xml/xmltbli.cxx +++ b/sw/source/filter/xml/xmltbli.cxx @@ -699,7 +699,7 @@ void SwXMLTableCellContext_Impl::EndElement() SwPaM aSrcPaM( *pSrcPaM->GetPoint(), *pSrcPaM->GetMark() ); SwPosition aDstPos( *pDstTxtCrsr->GetPaM()->GetPoint() ); - pDoc->Copy( aSrcPaM, aDstPos, false ); + pDoc->CopyRange( aSrcPaM, aDstPos, false ); nColRepeat--; } diff --git a/sw/source/filter/xml/xmltexte.cxx b/sw/source/filter/xml/xmltexte.cxx index 7ea9b69c3f..254cae1f7f 100644 --- a/sw/source/filter/xml/xmltexte.cxx +++ b/sw/source/filter/xml/xmltexte.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -289,7 +289,7 @@ void lcl_addOutplaceProperties( { MapMode aMode( MAP_100TH_MM ); // the API expects this map mode for the embedded objects Size aSize = rObj.GetSize( &aMode ); // get the size in the requested map mode - + if( aSize.Width() && aSize.Height() ) { Any aAny; @@ -464,8 +464,6 @@ void SwXMLTextParagraphExport::_exportTextEmbedded( aAny = rPropSet->getPropertyValue( sFrameStyleName ); aAny >>= sStyle; } - // svg:desc - exportAlternativeText( rPropSet, rPropSetInfo ); const XMLPropertyState *aStates[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; switch( nType ) @@ -766,6 +764,8 @@ void SwXMLTextParagraphExport::_exportTextEmbedded( // Lastly the stuff common to each of Applet/Plugin/Floating Frame exportEvents( rPropSet ); - exportAlternativeText( rPropSet, rPropSetInfo ); + // --> OD 2009-07-22 #i73249# + exportTitleAndDescription( rPropSet, rPropSetInfo ); + // <-- exportContour( rPropSet, rPropSetInfo ); } diff --git a/sw/source/ui/app/appopt.cxx b/sw/source/ui/app/appopt.cxx index 16a6440e34..26dbff2f8e 100644 --- a/sw/source/ui/app/appopt.cxx +++ b/sw/source/ui/app/appopt.cxx @@ -35,6 +35,8 @@ #include <cmdid.h> // Funktion-Ids #endif +#include <com/sun/star/i18n/ScriptType.hpp> + #define _SVSTDARR_STRINGSDTOR #include <svtools/svstdarr.hxx> @@ -54,6 +56,7 @@ #include <svx/optgrid.hxx> #include <svx/svxdlg.hxx> #include <svx/dialogs.hrc> +#include <i18npool/mslangid.hxx> #include <fontcfg.hxx> #include <optload.hxx> #include <optcomp.hxx> @@ -191,19 +194,25 @@ SfxItemSet* SwModule::CreateItemSet( USHORT nId ) pRet->Put(SwPtrItem(FN_PARAM_PRINTER, pPrt));*/ SvtLinguConfig aLinguCfg; + Locale aLocale; + LanguageType nLang; + + using namespace ::com::sun::star::i18n::ScriptType; Any aLang = aLinguCfg.GetProperty(C2U("DefaultLocale")); - Locale aLocale; aLang >>= aLocale; - pRet->Put(SvxLanguageItem(SvxLocaleToLanguage( aLocale ), SID_ATTR_LANGUAGE)); + nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aLocale), LATIN); + pRet->Put(SvxLanguageItem(nLang, SID_ATTR_LANGUAGE)); aLang = aLinguCfg.GetProperty(C2U("DefaultLocale_CJK")); aLang >>= aLocale; - pRet->Put(SvxLanguageItem(SvxLocaleToLanguage( aLocale ), SID_ATTR_CHAR_CJK_LANGUAGE)); + nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aLocale), ASIAN); + pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CJK_LANGUAGE)); aLang = aLinguCfg.GetProperty(C2U("DefaultLocale_CTL")); aLang >>= aLocale; - pRet->Put(SvxLanguageItem(SvxLocaleToLanguage( aLocale ), SID_ATTR_CHAR_CTL_LANGUAGE)); + nLang = MsLangId::resolveSystemLanguageByScriptType(MsLangId::convertLocaleToLanguage(aLocale), COMPLEX); + pRet->Put(SvxLanguageItem(nLang, SID_ATTR_CHAR_CTL_LANGUAGE)); } if(bTextDialog) pRet->Put(SwPtrItem(FN_PARAM_STDFONTS, GetStdFontConfig())); diff --git a/sw/source/ui/app/docsh.cxx b/sw/source/ui/app/docsh.cxx index 0d71a7f304..ec29858041 100644 --- a/sw/source/ui/app/docsh.cxx +++ b/sw/source/ui/app/docsh.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -435,7 +435,7 @@ sal_Bool SwDocShell::SaveAs( SfxMedium& rMedium ) if(pView) pView->GetEditWin().StopQuickHelp(); - //#i91811# mod if we have an active margin window, write back the text + //#i91811# mod if we have an active margin window, write back the text if (pView && pView->GetPostItMgr() && pView->GetPostItMgr()->GetActivePostIt()) pView->GetPostItMgr()->GetActivePostIt()->UpdateData(); @@ -582,7 +582,7 @@ BOOL SwDocShell::ConvertTo( SfxMedium& rMedium ) if(pView) pView->GetEditWin().StopQuickHelp(); - //#i91811# mod if we have an active margin window, write back the text + //#i91811# mod if we have an active margin window, write back the text if (pView && pView->GetPostItMgr() && pView->GetPostItMgr()->GetActivePostIt()) pView->GetPostItMgr()->GetActivePostIt()->UpdateData(); @@ -1083,15 +1083,10 @@ void SwDocShell::GetState(SfxItemSet& rSet) break; case SID_SOURCEVIEW: { - if(IsLoading()) - rSet.DisableItem(nWhich); - else - { - SfxViewShell* pCurrView = GetView() ? (SfxViewShell*)GetView() - : SfxViewShell::Current(); - BOOL bSourceView = 0 != PTR_CAST(SwSrcView, pCurrView); - rSet.Put(SfxBoolItem(SID_SOURCEVIEW, bSourceView)); - } + SfxViewShell* pCurrView = GetView() ? (SfxViewShell*)GetView() + : SfxViewShell::Current(); + BOOL bSourceView = 0 != PTR_CAST(SwSrcView, pCurrView); + rSet.Put(SfxBoolItem(SID_SOURCEVIEW, bSourceView)); } break; case SID_HTML_MODE: @@ -1116,18 +1111,10 @@ void SwDocShell::GetState(SfxItemSet& rSet) case SID_BROWSER_MODE: case FN_PRINT_LAYOUT: { - SfxViewShell* pViewShell = SfxViewShell::Current(); - BOOL bDisable = 0 != PTR_CAST(SwPagePreView, pViewShell) || - 0 != PTR_CAST(SwSrcView, pViewShell); - if (bDisable) - rSet.DisableItem( nWhich ); - else - { - sal_Bool bState = GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE); - if(FN_PRINT_LAYOUT == nWhich) - bState = !bState; - rSet.Put( SfxBoolItem( nWhich, bState)); - } + sal_Bool bState = GetDoc()->get(IDocumentSettingAccess::BROWSE_MODE); + if(FN_PRINT_LAYOUT == nWhich) + bState = !bState; + rSet.Put( SfxBoolItem( nWhich, bState)); } break; @@ -1337,44 +1324,42 @@ uno::Reference< frame::XController > /* -----------------------------12.02.01 12:08-------------------------------- ---------------------------------------------------------------------------*/ +static const char* pEventNames[] = +{ + "OnPageCountChange", + "OnMailMerge", + "OnMailMergeFinished", + "OnFieldMerge", + "OnFieldMergeFinished", + "OnLayoutFinished" +}; + Sequence< OUString > SwDocShell::GetEventNames() { Sequence< OUString > aRet = SfxObjectShell::GetEventNames(); sal_Int32 nLen = aRet.getLength(); - aRet.realloc(nLen + 2); + aRet.realloc(nLen + 6); OUString* pNames = aRet.getArray(); - pNames[nLen++] = OUString::createFromAscii("OnMailMerge"); - pNames[nLen] = OUString::createFromAscii("OnPageCountChange"); + pNames[nLen++] = GetEventName(0); + pNames[nLen++] = GetEventName(1); + pNames[nLen++] = GetEventName(2); + pNames[nLen++] = GetEventName(3); + pNames[nLen++] = GetEventName(4); + pNames[nLen] = GetEventName(5); + return aRet; } -/* -void SwTmpPersist::FillClass( SvGlobalName * pClassName, - ULONG * pClipFormat, - String * pAppName, - String * pLongUserName, - String * pUserName, - sal_Int32 nFileFormat ) const -{ - pDShell->SwDocShell::FillClass( pClassName, pClipFormat, pAppName, - pLongUserName, pUserName, nFileFormat ); -} -BOOL SwTmpPersist::Save() -{ - if( SaveChilds() ) - return SvPersist::Save(); - return FALSE; -} +static sal_Int32 nEvents=13; -BOOL SwTmpPersist::SaveCompleted( SvStorage * pStor ) +rtl::OUString SwDocShell::GetEventName( sal_Int32 nIndex ) { - if( SaveCompletedChilds( pStor ) ) - return SvPersist::SaveCompleted( pStor ); - return FALSE; -} */ + if ( nIndex<nEvents ) + return ::rtl::OUString::createFromAscii(pEventNames[nIndex]); + return rtl::OUString(); +} const ::sfx2::IXmlIdRegistry* SwDocShell::GetXmlIdRegistry() const { return pDoc ? &pDoc->GetXmlIdRegistry() : 0; } - diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 8cd955aa19..1b0a0c1c0e 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -943,10 +943,10 @@ void SwDocShell::Execute(SfxRequest& rReq) bDone = TRUE; SfxEventConfiguration* pEvent = SFX_APP()->GetEventConfig(); SvxMacro aMac(aEmptyStr, aEmptyStr, STARBASIC); - pEvent->ConfigureEvent(SFX_EVENT_OPENDOC, aMac, this); - pEvent->ConfigureEvent(SFX_EVENT_CLOSEDOC, aMac, this); - pEvent->ConfigureEvent(SFX_EVENT_ACTIVATEDOC, aMac, this); - pEvent->ConfigureEvent(SFX_EVENT_DEACTIVATEDOC, aMac, this); + pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ), aMac, this); + pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ), aMac, this); + pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), aMac, this); + pEvent->ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ), aMac, this); ReloadFromHtml(aTempFile.GetURL(), pSrcView); nSlot = 0; } @@ -983,6 +983,8 @@ void SwDocShell::Execute(SfxRequest& rReq) //pSavePrinter darf nicht wieder geloescht werden } pViewFrm->GetBindings().SetState(SfxBoolItem(SID_SOURCEVIEW, nSlot == SID_VIEWSHELL2)); + pViewFrm->GetBindings().Invalidate( SID_BROWSER_MODE ); + pViewFrm->GetBindings().Invalidate( FN_PRINT_LAYOUT ); } break; case SID_GET_COLORTABLE: @@ -1780,7 +1782,10 @@ void SwDocShell::ToggleBrowserMode(BOOL bSet, SwView* _pView ) SwView* pTempView = _pView ? _pView : (SwView*)GetView(); if( pTempView ) { - pTempView->GetViewFrame()->GetBindings().Invalidate(FN_SHADOWCURSOR); + SfxBindings& rBind = pTempView->GetViewFrame()->GetBindings(); + rBind.Invalidate(FN_SHADOWCURSOR); + rBind.Invalidate(SID_BROWSER_MODE); + rBind.Invalidate(FN_PRINT_LAYOUT); if( !GetDoc()->getPrinter( false ) ) { @@ -1793,8 +1798,8 @@ void SwDocShell::ToggleBrowserMode(BOOL bSet, SwView* _pView ) GetDoc()->CheckDefaultPageFmt(); // <-- - //Wenn wir die BrowseView einschalten, darf es nur diese eine - //Sicht auf das Dokument geben, alle anderen werden geschlossen. + // Currently there can be only one view (layout) if the document is viewed in Web layout + // So if there are more views we are in print layout and for toggling to Web layout all other views must be closed SfxViewFrame *pTmpFrm = SfxViewFrame::GetFirst(this, 0, FALSE); do { if( pTmpFrm != pTempView->GetViewFrame() ) diff --git a/sw/source/ui/app/docshini.cxx b/sw/source/ui/app/docshini.cxx index 5fde691f71..b2ce3411c4 100644 --- a/sw/source/ui/app/docshini.cxx +++ b/sw/source/ui/app/docshini.cxx @@ -37,6 +37,7 @@ #ifndef _SVX_DIALOGS_HRC #include <svx/dialogs.hrc> #endif +#include <i18npool/mslangid.hxx> #include <sot/storinfo.hxx> #include <sot/storage.hxx> #include <svtools/zforlist.hxx> @@ -58,6 +59,7 @@ #endif #include <linguistic/lngprops.hxx> #include <com/sun/star/document/UpdateDocMode.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> #include <rtl/logfile.hxx> #include <sfx2/docfilt.hxx> #include <svx/xtable.hxx> @@ -791,9 +793,9 @@ void SwDocShell::SubInitNew() SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 nVal = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + sal_Int16 nVal = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); aDfltSet.Put( SvxLanguageItem( nVal, RES_CHRATR_LANGUAGE ) ); aDfltSet.Put( SvxLanguageItem( eCJK, RES_CHRATR_CJK_LANGUAGE ) ); aDfltSet.Put( SvxLanguageItem( eCTL, RES_CHRATR_CTL_LANGUAGE ) ); diff --git a/sw/source/ui/app/docstyle.cxx b/sw/source/ui/app/docstyle.cxx index 1add147bc1..db72c86319 100644 --- a/sw/source/ui/app/docstyle.cxx +++ b/sw/source/ui/app/docstyle.cxx @@ -37,6 +37,7 @@ #include <hintids.hxx> #include <svtools/itemiter.hxx> #include <svtools/eitem.hxx> +#include <svtools/syslocale.hxx> #include <svx/boxitem.hxx> #include <svx/numitem.hxx> // --> OD 2008-02-13 #newlistlevelattrs# @@ -609,7 +610,7 @@ String SwDocStyleSheet::GetDescription(SfxMapUnit eUnit) { IntlWrapper aIntlWrapper( ::comphelper::getProcessServiceFactory(), - GetAppLocaleData().getLocale()); + SvtSysLocale().GetLocaleData().getLocale()); String sPlus(String::CreateFromAscii(" + ")); if ( SFX_STYLE_FAMILY_PAGE == nFamily ) diff --git a/sw/source/ui/app/mn.src b/sw/source/ui/app/mn.src index b92bbdf89c..bebfd0fa1c 100644 --- a/sw/source/ui/app/mn.src +++ b/sw/source/ui/app/mn.src @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -441,26 +441,26 @@ {\ Identifier = FN_DELETE_NOTE ;\ HelpID = FN_DELETE_NOTE ;\ - Text [ en-US ] = "Delete ~Note" ;\ + Text [ en-US ] = "Delete ~Comment" ;\ };\ MenuItem\ {\ Identifier = FN_DELETE_NOTE_AUTHOR ;\ HelpID = FN_DELETE_NOTE_AUTHOR ;\ - Text [ en-US ] = "Delete ~All Notes by $1" ;\ + Text [ en-US ] = "Delete ~All Comments by $1" ;\ };\ MenuItem\ {\ Identifier = FN_DELETE_ALL_NOTES ;\ HelpID = FN_DELETE_ALL_NOTES ;\ - Text [ en-US ] = "~Delete All Notes" ;\ + Text [ en-US ] = "~Delete All Comments" ;\ };\ /* MenuItem\ {\ Identifier = FN_HIDE_NOTE ;\ HelpID = FN_HIDE_NOTE ;\ - Text [ en-US ] = "~Hide note" ;\ + Text [ en-US ] = "~Hide comment" ;\ };\ MenuItem\ {\ @@ -472,7 +472,7 @@ {\ Identifier = FN_HIDE_ALL_NOTES ;\ HelpID = FN_HIDE_ALL_NOTES ;\ - Text [ en-US ] = "Hide all ~notes" ;\ + Text [ en-US ] = "Hide all ~comments" ;\ }; */ @@ -956,6 +956,10 @@ Menu MN_GRF_POPUPMENU { MN_ALIGN_FRAME MN_MOUSE_FRAME_WITH_CONTOUR + // --> OD 2009-07-14 #i73249# + SEPARATOR ; + MN_TITLE_DESCRIPTION_SHAPE + // <-- SEPARATOR ; MenuItem { @@ -989,6 +993,10 @@ Menu MN_OLE_POPUPMENU { MN_ALIGN_FRAME MN_MOUSE_FRAME_WITH_CONTOUR + // --> OD 2009-07-14 #i73249# + SEPARATOR ; + MN_TITLE_DESCRIPTION_SHAPE + // <-- SEPARATOR ; MenuItem { @@ -1013,6 +1021,10 @@ Menu MN_FRM_POPUPMENU { MN_ALIGN_FRAME MN_MOUSE_FRAME_WITHOUT_CONTOUR + // --> OD 2009-07-07 #i73249# + SEPARATOR ; + MN_TITLE_DESCRIPTION_SHAPE + // <-- SEPARATOR ; MN_FRM MN_FRM_CAPTION_ITEM diff --git a/sw/source/ui/app/swmodule.cxx b/sw/source/ui/app/swmodule.cxx index ccc5a9fd7f..779add8526 100644 --- a/sw/source/ui/app/swmodule.cxx +++ b/sw/source/ui/app/swmodule.cxx @@ -221,11 +221,6 @@ SwModule::SwModule( SfxObjectFactory* pWebFact, ERRCODE_AREA_SW_END, pSwResMgr ); - SfxEventConfiguration::RegisterEvent(SW_EVENT_MAIL_MERGE, SW_RES(STR_PRINT_MERGE_MACRO), String::CreateFromAscii("OnMailMerge")); - SfxEventConfiguration::RegisterEvent(SW_EVENT_MAIL_MERGE_END, SW_RES(STR_PRINT_MERGE_MACRO), String::CreateFromAscii("OnMailMergeFinished")); - SfxEventConfiguration::RegisterEvent(SW_EVENT_FIELD_MERGE, String(), String::CreateFromAscii("OnFieldMerge")); - SfxEventConfiguration::RegisterEvent(SW_EVENT_FIELD_MERGE_FINISHED, String(), String::CreateFromAscii("OnFieldMergeFinished")); - SfxEventConfiguration::RegisterEvent(SW_EVENT_PAGE_COUNT, SW_RES(STR_PAGE_COUNT_MACRO), String::CreateFromAscii("OnPageCountChange")); pModuleConfig = new SwModuleOptions; //Die brauchen wie sowieso diff --git a/sw/source/ui/cctrl/actctrl.cxx b/sw/source/ui/cctrl/actctrl.cxx index 94e9b0ff0e..2122bc9b46 100644 --- a/sw/source/ui/cctrl/actctrl.cxx +++ b/sw/source/ui/cctrl/actctrl.cxx @@ -71,6 +71,15 @@ long NumEditAction::Notify( NotifyEvent& rNEvt ) Beschreibung: KeyInput fuer ShortName - Edits ohne Spaces ------------------------------------------------------------------------*/ +NoSpaceEdit::NoSpaceEdit( Window* pParent, const ResId& rResId) + : Edit(pParent, rResId), + sForbiddenChars(String::CreateFromAscii(" ")) +{ +} + +NoSpaceEdit::~NoSpaceEdit() +{ +} void NoSpaceEdit::KeyInput(const KeyEvent& rEvt) { diff --git a/sw/source/ui/config/fontcfg.cxx b/sw/source/ui/config/fontcfg.cxx index 8b2a6de735..533a3869e8 100644 --- a/sw/source/ui/config/fontcfg.cxx +++ b/sw/source/ui/config/fontcfg.cxx @@ -33,10 +33,12 @@ #include <fontcfg.hxx> +#include <i18npool/mslangid.hxx> #include <vcl/outdev.hxx> #include <svtools/lingucfg.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/i18n/ScriptType.hpp> #include <swtypes.hxx> #include <unomid.h> @@ -116,9 +118,10 @@ SwStdFontConfig::SwStdFontConfig() : SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); + for(sal_Int16 i = 0; i < DEF_FONT_COUNT; i++) { sDefaultFonts[i] = GetDefaultFor(i, @@ -163,9 +166,10 @@ void SwStdFontConfig::Commit() SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); + for(sal_uInt16 nProp = 0; nProp < sal::static_int_cast< sal_uInt16, sal_Int32 >( aNames.getLength() ); nProp++) @@ -198,9 +202,10 @@ BOOL SwStdFontConfig::IsFontDefault(USHORT nFontType) const SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); + String sDefFont(GetDefaultFor(FONT_STANDARD, eWestern)); String sDefFontCJK(GetDefaultFor(FONT_STANDARD_CJK, eCJK)); String sDefFontCTL(GetDefaultFor(FONT_STANDARD_CTL, eCTL)); @@ -320,9 +325,11 @@ void SwStdFontConfig::ChangeInt( USHORT nFontType, sal_Int32 nHeight ) { SvtLinguOptions aLinguOpt; SvtLinguConfig().GetOptions( aLinguOpt ); - sal_Int16 eWestern = aLinguOpt.nDefaultLanguage, - eCJK = aLinguOpt.nDefaultLanguage_CJK, - eCTL = aLinguOpt.nDefaultLanguage_CTL; + + sal_Int16 eWestern = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN), + eCJK = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, ::com::sun::star::i18n::ScriptType::ASIAN), + eCTL = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, ::com::sun::star::i18n::ScriptType::COMPLEX); + // #i92090# default height value sets back to -1 const sal_Int32 nDefaultHeight = GetDefaultHeightFor(nFontType, lcl_LanguageOfType(nFontType, eWestern, eCJK, eCTL)); const bool bIsDefaultHeight = nHeight == nDefaultHeight; diff --git a/sw/source/ui/config/optdlg.src b/sw/source/ui/config/optdlg.src index d90585c533..9c5ef7b8ed 100644 --- a/sw/source/ui/config/optdlg.src +++ b/sw/source/ui/config/optdlg.src @@ -173,7 +173,7 @@ TabPage TP_CONTENT_OPT { Pos = MAP_APPFONT ( 12 , 119 ) ; Size = MAP_APPFONT ( 108 , 10 ) ; - Text [ en-US ] = "~Notes" ; + Text [ en-US ] = "~Comments" ; }; FixedLine FL_SETTINGS { @@ -323,7 +323,7 @@ TabPage TP_OPTPRINT_PAGE { Pos = MAP_APPFONT ( 180 , 27 ) ; Size = MAP_APPFONT ( 74 , 10 ) ; - Text [ en-US ] = "Notes ~only" ; + Text [ en-US ] = "Comments ~only" ; }; RadioButton RB_END { @@ -347,7 +347,7 @@ TabPage TP_OPTPRINT_PAGE { Pos = MAP_APPFONT ( 174 , 3 ) ; Size = MAP_APPFONT ( 80 , 8 ) ; - Text [ en-US ] = "Notes" ; + Text [ en-US ] = "Comments" ; Group = TRUE ; }; FixedLine FL_4 diff --git a/sw/source/ui/config/optload.cxx b/sw/source/ui/config/optload.cxx index e730f09ef5..8943eec2ed 100644 --- a/sw/source/ui/config/optload.cxx +++ b/sw/source/ui/config/optload.cxx @@ -782,7 +782,9 @@ IMPL_LINK( SwCaptionOptPage, ShowEntryHdl, SvxCheckListBox *, EMPTYARG ) break; } aPosBox.SelectEntryPos(pOpt->GetPos()); - aPosBox.Enable( pOpt->GetObjType() != GRAPHIC_CAP && aPosText.IsEnabled() ); + aPosBox.Enable( pOpt->GetObjType() != GRAPHIC_CAP && + pOpt->GetObjType() != OLE_CAP && + aPosText.IsEnabled() ); aPosBox.SelectEntryPos(pOpt->GetPos()); USHORT nLevelPos = ( pOpt->GetLevel() < MAXLEVEL ) ? pOpt->GetLevel() + 1 : 0; diff --git a/sw/source/ui/config/usrpref.cxx b/sw/source/ui/config/usrpref.cxx index da2bbfd992..ad1285e3d0 100644 --- a/sw/source/ui/config/usrpref.cxx +++ b/sw/source/ui/config/usrpref.cxx @@ -33,7 +33,7 @@ #include <tools/stream.hxx> - +#include <svtools/syslocale.hxx> #include "swtypes.hxx" #include "hintids.hxx" @@ -72,7 +72,7 @@ SwMasterUsrPref::SwMasterUsrPref(BOOL bWeb) : aCursorConfig(*this), pWebColorConfig(bWeb ? new SwWebColorConfig(*this) : 0) { - MeasurementSystem eSystem = GetAppLocaleData().getMeasurementSystemEnum(); + MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); eUserMetric = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH; eHScrollMetric = eUserMetric; eVScrollMetric = eUserMetric; diff --git a/sw/source/ui/config/viewopt.cxx b/sw/source/ui/config/viewopt.cxx index 1d259bc45c..fed94bcba8 100644 --- a/sw/source/ui/config/viewopt.cxx +++ b/sw/source/ui/config/viewopt.cxx @@ -58,6 +58,7 @@ #include <crstate.hxx> #include <svtools/colorcfg.hxx> #include <svtools/accessibilityoptions.hxx> +#include <svtools/syslocale.hxx> #include <svx/acorrcfg.hxx> @@ -237,7 +238,7 @@ SwViewOption::SwViewOption() : nCore2Options = VIEWOPT_CORE2_BLACKFONT | VIEWOPT_CORE2_HIDDENPARA; nUIOptions = VIEWOPT_2_MODIFIED | VIEWOPT_2_GRFKEEPZOOM |VIEWOPT_2_ANY_RULER; - if(MEASURE_METRIC != GetAppLocaleData().getMeasurementSystemEnum()) + if(MEASURE_METRIC != SvtSysLocale().GetLocaleData().getMeasurementSystemEnum()) aSnapSize.Width() = aSnapSize.Height() = 720; // 1/2" else aSnapSize.Width() = aSnapSize.Height() = 567; // 1 cm diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index efd27f3365..ff140629c2 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -1131,7 +1131,9 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, for( n = 0; n < nCols; ++n ) { if( aRbHeadlColnms.IsChecked() ) - rSh.SwEditShell::Insert( aColFlds[ n ]->sColumn ); + { + rSh.SwEditShell::Insert2( aColFlds[ n ]->sColumn ); + } rSh.GoNextCell(); } } @@ -1227,7 +1229,9 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection, { rtl::OUString sVal = xColumn->getString(); if(!xColumn->wasNull()) - rSh.SwEditShell::Insert( sVal ); + { + rSh.SwEditShell::Insert2( sVal ); + } } } catch(Exception& diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index 3616199de1..f168291911 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -629,7 +629,7 @@ void SwNewDBMgr::ImportDBEntry(SwWrtShell* pSh) if (i < nLength - 1) sStr += '\t'; } - pSh->SwEditShell::Insert(sStr); + pSh->SwEditShell::Insert2(sStr); pSh->SwFEShell::SplitNode(); // Zeilenvorschub } } @@ -1067,9 +1067,9 @@ BOOL SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell, SwDoc* pWorkDoc = ((SwDocShell*)(&xWorkDocSh))->GetDoc(); SwNewDBMgr* pOldDBMgr = pWorkDoc->GetNewDBMgr(); pWorkDoc->SetNewDBMgr( this ); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, xWorkDocSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), xWorkDocSh)); pWorkDoc->UpdateFlds(NULL, false); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, xWorkDocSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), xWorkDocSh)); // alle versteckten Felder/Bereiche entfernen pWorkDoc->RemoveInvisibleContent(); @@ -2432,19 +2432,19 @@ String SwNewDBMgr::LoadAndRegisterDataSource() if( bTextConnection ) { - uno::Reference < ui::dialogs::XExecutableDialog > xSettingsDlg( + uno::Reference < ui::dialogs::XExecutableDialog > xSettingsDlg( xMgr->createInstance( C2U( "com.sun.star.sdb.TextConnectionSettings" ) ), uno::UNO_QUERY); if( xSettingsDlg->execute() ) { uno::Any aSettings = xDataProperties->getPropertyValue( C2U( "Settings" ) ); uno::Reference < beans::XPropertySet > xDSSettings; aSettings >>= xDSSettings; - ::comphelper::copyProperties( - uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY ), + ::comphelper::copyProperties( + uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY ), xDSSettings ); xDSSettings->setPropertyValue( C2U("Extension"), uno::makeAny( ::rtl::OUString( sExt ))); } - } + } Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW); Reference<XStorable> xStore(xDS->getDatabaseDocument(), UNO_QUERY_THROW); @@ -2526,7 +2526,7 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, aDescriptor[daCursor] <<= xResSet; SfxObjectShellRef xDocShell = rSh.GetView().GetViewFrame()->GetObjectShell(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, xDocShell)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xDocShell)); { //copy rSh to aTempFile ::rtl::OUString sTempURL; @@ -2567,12 +2567,12 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, SwDoc* pWorkDoc = pView->GetWrtShell().GetDoc(); SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr(); pWorkDoc->SetNewDBMgr( this ); - + SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor ); aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter(); aMergeDesc.bCreateSingleFile= true; MergeNew(aMergeDesc); - + pWorkDoc->SetNewDBMgr( pWorkDBMgr ); //close the temporary file uno::Reference< util::XCloseable > xClose( xWorkDocSh->GetModel(), uno::UNO_QUERY ); @@ -2590,10 +2590,10 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh, } } } - //remove the temporary file + //remove the temporary file SWUnoHelper::UCB_DeleteFile( sTempURL ); } - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, rSh.GetView().GetViewFrame()->GetObjectShell())); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), rSh.GetView().GetViewFrame()->GetObjectShell())); // reset the cursor inside xResSet = NULL; @@ -2917,18 +2917,21 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, SwWrtShell& rWorkShell = pWorkView->GetWrtShell(); pWorkView->AttrChangedNotify( &rWorkShell );//Damit SelectShell gerufen wird. - // merge the data - SwDoc* pWorkDoc = rWorkShell.GetDoc(); - SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr(); - pWorkDoc->SetNewDBMgr( this ); - pWorkDoc->EmbedAllLinks(); - if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds()) - rWorkShell.Undo(); - // create a layout - rWorkShell.CalcLayout(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, rWorkShell.GetView().GetViewFrame()->GetObjectShell())); + // merge the data + SwDoc* pWorkDoc = rWorkShell.GetDoc(); + SwNewDBMgr* pWorkDBMgr = pWorkDoc->GetNewDBMgr(); + pWorkDoc->SetNewDBMgr( this ); + pWorkDoc->EmbedAllLinks(); + if(UNDO_UI_DELETE_INVISIBLECNTNT == rWorkShell.GetUndoIds()) + rWorkShell.Undo(); + // #i69485# lock fields to prevent access to the result set while calculating layout + rWorkShell.LockExpFlds(); + // create a layout + rWorkShell.CalcLayout(); + rWorkShell.UnlockExpFlds(); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), rWorkShell.GetView().GetViewFrame()->GetObjectShell())); rWorkShell.ViewShell::UpdateFlds(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, rWorkShell.GetView().GetViewFrame()->GetObjectShell())); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), rWorkShell.GetView().GetViewFrame()->GetObjectShell())); // strip invisible content and convert fields to text rWorkShell.RemoveInvisibleContent(); @@ -2953,11 +2956,13 @@ sal_Int32 SwNewDBMgr::MergeDocuments( SwMailMergeConfigItem& rMMConfig, String sNewPageDescName = lcl_FindUniqueName(pTargetShell, sStartingPageDesc, nDocNo ); pTargetShell->GetDoc()->MakePageDesc( sNewPageDescName ); SwPageDesc* pTargetPageDesc = pTargetShell->FindPageDescByName( sNewPageDescName ); - if(pSourcePageDesc && pTargetPageDesc) + const SwPageDesc* pWorkPageDesc = rWorkShell.FindPageDescByName( sStartingPageDesc ); + + if(pWorkPageDesc && pTargetPageDesc) { - pTargetDoc->CopyPageDesc( *pSourcePageDesc, *pTargetPageDesc, sal_False ); + pTargetDoc->CopyPageDesc( *pWorkPageDesc, *pTargetPageDesc, sal_False ); sModifiedStartingPageDesc = sNewPageDescName; - lcl_CopyFollowPageDesc( *pTargetShell, *pSourcePageDesc, *pTargetPageDesc, nDocNo ); + lcl_CopyFollowPageDesc( *pTargetShell, *pWorkPageDesc, *pTargetPageDesc, nDocNo ); } } if(nDocNo == 1 || bPageStylesWithHeaderFooter) diff --git a/sw/source/ui/dbui/mailmergehelper.cxx b/sw/source/ui/dbui/mailmergehelper.cxx index c299133d2e..31d8ad4274 100644 --- a/sw/source/ui/dbui/mailmergehelper.cxx +++ b/sw/source/ui/dbui/mailmergehelper.cxx @@ -627,8 +627,16 @@ SwMergeAddressItem SwAddressIterator::Next() aRet.bIsColumn = true; xub_StrLen nClose = sAddress.Search('>'); DBG_ASSERT(nClose != STRING_NOTFOUND, "closing '>' not found"); - aRet.sText = sAddress.Copy(1, nClose - 1); - sAddress.Erase(0, nClose + 1); + if( nClose != STRING_NOTFOUND ) + { + aRet.sText = sAddress.Copy(1, nClose - 1); + sAddress.Erase(0, nClose + 1); + } + else + { + aRet.sText = sAddress.Copy(1, 1); + sAddress.Erase(0, 1); + } } else { diff --git a/sw/source/ui/dbui/makefile.mk b/sw/source/ui/dbui/makefile.mk index b1aa16f694..40d6807c2e 100644 --- a/sw/source/ui/dbui/makefile.mk +++ b/sw/source/ui/dbui/makefile.mk @@ -79,6 +79,7 @@ EXCEPTIONSFILES= \ $(SLO)$/mmaddressblockpage.obj \ $(SLO)$/mmconfigitem.obj \ $(SLO)$/mmlayoutpage.obj \ + $(SLO)$/mmgreetingspage.obj \ $(SLO)$/mmoutputpage.obj SLOFILES = \ diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx index 874d71820c..03bd610213 100644 --- a/sw/source/ui/dbui/mmgreetingspage.cxx +++ b/sw/source/ui/dbui/mmgreetingspage.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -42,6 +42,7 @@ #include <vcl/msgbox.hxx> #include <mmgreetingspage.hrc> #include <dbui.hrc> +#include <com/sun/star/sdb/XColumn.hpp> #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <helpid.h> @@ -117,6 +118,7 @@ IMPL_LINK(SwGreetingsHandler, IndividualHdl_Impl, CheckBox*, EMPTYARG) m_pWizard->UpdateRoadmap(); m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE)); } + UpdatePreview(); return 0; } /*-- 30.04.2004 10:42:57--------------------------------------------------- @@ -133,12 +135,12 @@ IMPL_LINK(SwGreetingsHandler, GreetingHdl_Impl, PushButton*, pButton) { ListBox* pToInsert = pButton == m_pMalePB ? m_pMaleLB : m_pFemaleLB; pToInsert->SelectEntryPos(pToInsert->InsertEntry(pDlg->GetAddress())); - UpdatePreview(); if(m_bIsTabPage) { m_pWizard->UpdateRoadmap(); m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE)); } + UpdatePreview(); } delete pDlg; return 0; @@ -182,9 +184,54 @@ IMPL_LINK(SwMailMergeGreetingsPage, GreetingSelectHdl_Impl, ListBox*, EMPTYARG) -----------------------------------------------------------------------*/ void SwMailMergeGreetingsPage::UpdatePreview() { - String sPreview = m_aFemaleLB.GetSelectEntry(); - sPreview += '\n'; - sPreview += m_aMaleLB.GetSelectEntry(); + //find out which type of greeting should be selected: + bool bFemale = false; + bool bNoValue = !m_pFemaleColumnLB->IsEnabled(); + if( !bNoValue ) + { + ::rtl::OUString sFemaleValue = m_aFemaleFieldCB.GetText(); + ::rtl::OUString sFemaleColumn = m_aFemaleColumnLB.GetSelectEntry(); + Reference< sdbcx::XColumnsSupplier > xColsSupp( m_pWizard->GetConfigItem().GetResultSet(), UNO_QUERY); + Reference < container::XNameAccess> xColAccess = xColsSupp.is() ? xColsSupp->getColumns() : 0; + if(sFemaleValue.getLength() && sFemaleColumn.getLength() && + xColAccess.is() && + xColAccess->hasByName(sFemaleColumn)) + { + //get the content and exchange it in the address string + Any aCol = xColAccess->getByName(sFemaleColumn); + Reference< sdb::XColumn > xColumn; + aCol >>= xColumn; + if(xColumn.is()) + { + try + { + ::rtl::OUString sFemaleColumnValue = xColumn->getString(); + bFemale = sFemaleColumnValue == sFemaleValue; + //bNoValue = !sFemaleColumnValue.getLength(); + if( !bNoValue ) + { + //no last name value marks the greeting also als neutral + SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem(); + ::rtl::OUString sLastNameColumn = rConfig.GetAssignedColumn(MM_PART_LASTNAME); + if ( xColAccess->hasByName(sLastNameColumn) ) + { + aCol = xColAccess->getByName(sLastNameColumn); + aCol >>= xColumn; + ::rtl::OUString sLastNameColumnValue = xColumn->getString(); + bNoValue = !sLastNameColumnValue.getLength(); + } + } + } + catch( sdbc::SQLException& ) + { + DBG_ERROR("SQLException caught"); + } + } + } + } + + String sPreview = bFemale ? m_aFemaleLB.GetSelectEntry() : + bNoValue ? m_aNeutralCB.GetText() : m_aMaleLB.GetSelectEntry(); sPreview = SwAddressPreview::FillData(sPreview, m_pWizard->GetConfigItem()); m_aPreviewWIN.SetAddress(sPreview); @@ -284,6 +331,12 @@ SwMailMergeGreetingsPage::SwMailMergeGreetingsPage( SwMailMergeWizard* _pParent) Link aLBoxLink = LINK(this, SwMailMergeGreetingsPage, GreetingSelectHdl_Impl); m_aFemaleLB.SetSelectHdl(aLBoxLink); m_aMaleLB.SetSelectHdl(aLBoxLink); + m_aFemaleColumnLB.SetSelectHdl(aLBoxLink); + m_aFemaleFieldCB.SetSelectHdl(aLBoxLink); + m_aFemaleFieldCB.SetModifyHdl(aLBoxLink); + m_aNeutralCB.SetSelectHdl(aLBoxLink); + m_aNeutralCB.SetModifyHdl(aLBoxLink); + Link aDataLink = LINK(this, SwMailMergeGreetingsPage, InsertDataHdl_Impl); m_aPrevSetIB.SetClickHdl(aDataLink); m_aNextSetIB.SetClickHdl(aDataLink); @@ -348,13 +401,9 @@ sal_Bool SwMailMergeGreetingsPage::commitPage( CommitPageReason ) { const SwDBData& rDBData = rConfig.GetCurrentDBData(); Sequence< ::rtl::OUString> aAssignment = rConfig.GetColumnAssignment( rDBData ); - sal_Int32 nPos = m_aFemaleColumnLB.GetSelectEntryPos(); if(aAssignment.getLength() <= MM_PART_GENDER) aAssignment.realloc(MM_PART_GENDER + 1); - if( nPos > 0 ) - aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry(); - else - aAssignment[MM_PART_GENDER] = ::rtl::OUString(); + aAssignment[MM_PART_GENDER] = m_aFemaleColumnLB.GetSelectEntry(); rConfig.SetColumnAssignment( rDBData, aAssignment ); } if(m_aFemaleFieldCB.GetText() != m_aFemaleFieldCB.GetSavedValue()) diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx index 56a8af1fdf..ea475f8bb6 100644 --- a/sw/source/ui/dbui/mmlayoutpage.cxx +++ b/sw/source/ui/dbui/mmlayoutpage.cxx @@ -614,8 +614,6 @@ void SwMailMergeLayoutPage::InsertGreeting(SwWrtShell& rShell, SwMailMergeConfig sCondition += String(rFemaleGenderValue); sCondition.AppendAscii("\" OR NOT "); sCondition += String(sNameColumnBase); - sHideParagraphsExpression += '!'; - sHideParagraphsExpression += sNameColumnBase; break; case SwMailMergeConfigItem::NEUTRAL: sCondition = sNameColumnBase; diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index fc9675421d..711be9d13a 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -833,11 +833,11 @@ IMPL_LINK(SwMailMergeOutputPage, SaveOutputHdl_Impl, PushButton*, pButton) aSaveMonitor.aCancel.SetClickHdl(LINK(this, SwMailMergeOutputPage, SaveCancelHdl_Impl)); aSaveMonitor.aPrinter.SetText( INetURLObject( sPath ).getFSysPath( INetURLObject::FSYS_DETECT ) ); aSaveMonitor.ResizeControls(); - + m_bCancelSaving = false; aSaveMonitor.Show(); m_pWizard->enableButtons(WZB_CANCEL, sal_False); - + for(sal_uInt32 nDoc = nBegin; nDoc < nEnd && !m_bCancelSaving; ++nDoc) { SwDocMergeInfo& rInfo = rConfigItem.GetDocumentMergeInfo(nDoc); @@ -1007,7 +1007,7 @@ IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG) } SfxObjectShell* pObjSh = pTargetView->GetViewFrame()->GetObjectShell(); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, pObjSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), pObjSh)); rSh.GetNewDBMgr()->SetMergeType( DBMGR_MERGE_DOCUMENTS ); //SfxDispatcher *pDis = pTargetView->GetViewFrame()->GetDispatcher(); SfxBoolItem aMergeSilent(SID_SILENT, sal_False); @@ -1020,7 +1020,7 @@ IMPL_LINK(SwMailMergeOutputPage, PrintHdl_Impl, PushButton*, EMPTYARG) aProps[1]. Value <<= sPages; pTargetView->ExecPrint( aProps, false, true ); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, pObjSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), pObjSh)); pTargetView->SetMailMergeConfigItem(0, 0, sal_False); m_pWizard->enableButtons(WZB_CANCEL, sal_True); diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx index 66629b5030..34b04822c0 100644 --- a/sw/source/ui/dialog/ascfldlg.cxx +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -35,6 +35,8 @@ #endif #include <hintids.hxx> #include <rtl/textenc.h> +#include <i18npool/mslangid.hxx> +#include <com/sun/star/i18n/ScriptType.hpp> #include <svtools/lingucfg.hxx> #include <fontcfg.hxx> #include <swmodule.hxx> @@ -234,14 +236,14 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( Window* pParent, SwDocShell& rDocSh, switch(nAppScriptType) { case SCRIPTTYPE_ASIAN: - aOpt.SetLanguage(aLinguOpt.nDefaultLanguage_CJK); + aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CJK, SCRIPTTYPE_ASIAN)); break; case SCRIPTTYPE_COMPLEX: - aOpt.SetLanguage(aLinguOpt.nDefaultLanguage_CTL); + aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage_CTL, SCRIPTTYPE_COMPLEX)); break; //SCRIPTTYPE_LATIN: default: - aOpt.SetLanguage(aLinguOpt.nDefaultLanguage); + aOpt.SetLanguage(MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, SCRIPTTYPE_LATIN)); } } } diff --git a/sw/source/ui/dialog/uiregionsw.cxx b/sw/source/ui/dialog/uiregionsw.cxx index a446c5e08e..88e3df03a2 100644 --- a/sw/source/ui/dialog/uiregionsw.cxx +++ b/sw/source/ui/dialog/uiregionsw.cxx @@ -34,29 +34,22 @@ #undef SW_DLLIMPLEMENTATION #endif -#include "hintids.hxx" -#include "regionsw.hxx" +#include <hintids.hxx> +#include <regionsw.hxx> #include <svtools/urihelper.hxx> #include <svtools/PasswordHelper.hxx> #include <vcl/svapp.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <svtools/stritem.hxx> #include <svtools/eitem.hxx> -#ifndef _PASSWD_HXX //autogen #include <sfx2/passwd.hxx> -#endif #include <sfx2/docfilt.hxx> #include <sfx2/request.hxx> #include <sfx2/docfile.hxx> #include <sfx2/linkmgr.hxx> #include <sfx2/docinsert.hxx> #include <sfx2/filedlghelper.hxx> -#ifndef _SVX_SIZEITEM_HXX //autogen - #include <svx/sizeitem.hxx> -#endif #include <svx/htmlcfg.hxx> #include <comphelper/storagehelper.hxx> @@ -65,15 +58,9 @@ #include <section.hxx> #include <docary.hxx> #include <doc.hxx> // fuers SwSectionFmt-Array -#ifndef _BASESH_HXX #include <basesh.hxx> -#endif -#ifndef _WDOCSH_HXX #include <wdocsh.hxx> -#endif -#ifndef _VIEW_HXX #include <view.hxx> -#endif #include <swmodule.hxx> #include <wrtsh.hxx> #include <swundo.hxx> // fuer Undo-Ids @@ -82,27 +69,15 @@ #include <swunodef.hxx> #include <shellio.hxx> -#ifndef _HELPID_H #include <helpid.h> -#endif -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _REGIONSW_HRC #include <regionsw.hrc> -#endif -#ifndef _COMCORE_HRC #include <comcore.hrc> -#endif -#ifndef _GLOBALS_HRC #include <globals.hrc> -#endif #include <sfx2/bindings.hxx> #include <svx/htmlmode.hxx> #include <svx/dlgutil.hxx> -#ifndef _SVX_DIALOGS_HRC #include <svx/dialogs.hrc> -#endif #include <svx/svxdlg.hxx> #include <svx/flagsdef.hxx> @@ -115,7 +90,65 @@ SV_IMPL_PTRARR( SwSectionFmts, SwSectionFmtPtr ) SV_IMPL_OP_PTRARR_SORT( SectReprArr, SectReprPtr ) -static void lcl_ReadSections( SwWrtShell& rSh, SfxMedium& rMedium, ComboBox& rBox ); +static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox ); + +void lcl_FillList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames, const SwSectionFmt* pNewFmt ) +{ + const SwSectionFmt* pFmt; + if( !pNewFmt ) + { + USHORT nCount = rSh.GetSectionFmtCount(); + for(USHORT i=0;i<nCount;i++) + { + SectionType eTmpType; + if( !(pFmt = &rSh.GetSectionFmt(i))->GetParent() && + pFmt->IsInNodesArr() && + (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION + && TOX_HEADER_SECTION != eTmpType ) + { + String* pString = new String(pFmt->GetSection()->GetName()); + if(pAvailNames) + pAvailNames->InsertEntry(*pString); + rSubRegions.InsertEntry(*pString); + lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt ); + } + } + } + else + { + SwSections aTmpArr; + USHORT nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS); + if( nCnt ) + { + SectionType eTmpType; + for( USHORT n = 0; n < nCnt; ++n ) + if( (pFmt = aTmpArr[n]->GetFmt())->IsInNodesArr()&& + (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION + && TOX_HEADER_SECTION != eTmpType ) + { + String* pString = new String(pFmt->GetSection()->GetName()); + if(pAvailNames) + pAvailNames->InsertEntry(*pString); + rSubRegions.InsertEntry(*pString); + lcl_FillList( rSh, rSubRegions, pAvailNames, pFmt ); + } + } + } +} + +void lcl_FillSubRegionList( SwWrtShell& rSh, ComboBox& rSubRegions, ComboBox* pAvailNames ) +{ + lcl_FillList( rSh, rSubRegions, pAvailNames, 0 ); + IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); + for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); + ppMark != pMarkAccess->getMarksEnd(); + ppMark++) + { + const ::sw::mark::IMark* pBkmk = ppMark->get(); + if( pBkmk->IsExpanded() ) + rSubRegions.InsertEntry( pBkmk->GetName() ); + } +} /* -----------------25.06.99 15:38------------------- @@ -275,6 +308,7 @@ SwEditRegionDlg::SwEditRegionDlg( Window* pParent, SwWrtShell& rWrtSh ) aFilePB ( this, SW_RES( PB_FILE ) ), aSubRegionFT ( this, SW_RES( FT_SUBREG ) ) , aSubRegionED ( this, SW_RES( LB_SUBREG ) ) , + bSubRegionsFilled( false ), aProtectFL ( this, SW_RES( FL_PROTECT ) ), aProtectCB ( this, SW_RES( CB_PROTECT ) ), @@ -330,6 +364,8 @@ SwEditRegionDlg::SwEditRegionDlg( Window* pParent, SwWrtShell& rWrtSh ) aFilePB.SetClickHdl ( LINK( this, SwEditRegionDlg, FileSearchHdl )); aFileNameED.SetModifyHdl( LINK( this, SwEditRegionDlg, FileNameHdl )); aSubRegionED.SetModifyHdl( LINK( this, SwEditRegionDlg, FileNameHdl )); + aSubRegionED.AddEventListener( LINK( this, SwEditRegionDlg, SubRegionEventHdl )); + aSubRegionED.EnableAutocomplete( sal_True, sal_True ); aTree.SetHelpId(HID_REGION_TREE); aTree.SetSelectionMode( MULTIPLE_SELECTION ); @@ -667,6 +703,8 @@ IMPL_LINK( SwEditRegionDlg, GetFirstEntryHdl, SvTreeListBox *, pBox ) aDismiss.Enable(); String aFile = pRepr->GetFile(); String sSub = pRepr->GetSubRegion(); + bSubRegionsFilled = false; + aSubRegionED.Clear(); if(aFile.Len()||sSub.Len()) { aFileCB.Check(TRUE); @@ -1174,6 +1212,8 @@ IMPL_LINK( SwEditRegionDlg, FileNameHdl, Edit *, pEdit ) SectReprPtr pSectRepr = (SectRepr*)pEntry->GetUserData(); if(pEdit == &aFileNameED) { + bSubRegionsFilled = false; + aSubRegionED.Clear(); if( aDDECB.IsChecked() ) { String sLink( pEdit->GetText() ); @@ -1371,7 +1411,7 @@ IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg ) const SfxPoolItem* pItem; if ( SFX_ITEM_SET == pMedium->GetItemSet()->GetItemState( SID_PASSWORD, FALSE, &pItem ) ) sPassword = ( (SfxStringItem*)pItem )->GetValue(); - ::lcl_ReadSections( rSh, *pMedium, aSubRegionED ); + ::lcl_ReadSections( *pMedium, aSubRegionED ); delete pMedium; } } @@ -1390,6 +1430,36 @@ IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, sfx2::FileDialogHelper *, _pFileDlg ) Application::SetDefDialogParent( m_pOldDefDlgParent ); return 0; } +/*-- 03.09.2009 16:24:18--------------------------------------------------- + + -----------------------------------------------------------------------*/ +IMPL_LINK( SwEditRegionDlg, SubRegionEventHdl, VclWindowEvent *, pEvent ) +{ + if( !bSubRegionsFilled && pEvent && pEvent->GetId() == VCLEVENT_DROPDOWN_PRE_OPEN ) + { + //if necessary fill the names bookmarks/sections/tables now + + rtl::OUString sFileName = aFileNameED.GetText(); + if(sFileName.getLength()) + { + SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium(); + INetURLObject aAbs; + if( pMedium ) + aAbs = pMedium->GetURLObject(); + sFileName = URIHelper::SmartRel2Abs( + aAbs, sFileName, URIHelper::GetMaybeFileHdl() ); + + //load file and set the shell + SfxMedium aMedium( sFileName, STREAM_STD_READ ); + sFileName = aMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); + ::lcl_ReadSections( aMedium, aSubRegionED ); + } + else + lcl_FillSubRegionList( rSh, aSubRegionED, 0 ); + bSubRegionsFilled = true; + } + return 0; +} /* -----------------------------08.05.2002 15:00------------------------------ @@ -1404,7 +1474,7 @@ Image SwEditRegionDlg::BuildBitmap(BOOL bProtect,BOOL bHidden, BOOL bHighContras Beschreibung: Hilfsfunktion - Bereichsnamen aus dem Medium lesen --------------------------------------------------------------------*/ -static void lcl_ReadSections( SwWrtShell& /*rSh*/, SfxMedium& rMedium, ComboBox& rBox ) +static void lcl_ReadSections( SfxMedium& rMedium, ComboBox& rBox ) { rBox.Clear(); uno::Reference < embed::XStorage > xStg; @@ -1580,6 +1650,7 @@ SwInsertSectionTabPage::SwInsertSectionTabPage( aCurName.SetModifyHdl ( LINK( this, SwInsertSectionTabPage, NameEditHdl)); aDDECB.SetClickHdl ( LINK( this, SwInsertSectionTabPage, DDEHdl )); ChangeProtectHdl(&aProtectCB); + aSubRegionED.EnableAutocomplete( sal_True, sal_True ); } /* -----------------21.05.99 10:31------------------- * @@ -1603,16 +1674,7 @@ void SwInsertSectionTabPage::SetWrtShell(SwWrtShell& rSh) aDDECommandFT .Hide(); } - FillList(); - IDocumentMarkAccess* const pMarkAccess = m_pWrtSh->getIDocumentMarkAccess(); - for( IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); - ppMark != pMarkAccess->getMarksEnd(); - ppMark++) - { - const ::sw::mark::IMark* pBkmk = ppMark->get(); - if( pBkmk->IsExpanded() ) - aSubRegionED.InsertEntry( pBkmk->GetName() ); - } + lcl_FillSubRegionList( *m_pWrtSh, aSubRegionED, &aCurName ); SwSection* pSect = ((SwInsertSectionTabDialog*)GetTabDialog())->GetSection(); if( pSect ) // etwas vorgegeben ? @@ -1875,7 +1937,7 @@ IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFil m_sFilePasswd = ( (SfxStringItem*)pItem )->GetValue(); aFileNameED.SetText( INetURLObject::decode( m_sFileName, INET_HEX_ESCAPE, INetURLObject::DECODE_UNAMBIGUOUS, RTL_TEXTENCODING_UTF8 ) ); - ::lcl_ReadSections( *m_pWrtSh, *pMedium, aSubRegionED ); + ::lcl_ReadSections( *pMedium, aSubRegionED ); delete pMedium; } } @@ -1886,52 +1948,6 @@ IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, sfx2::FileDialogHelper *, _pFil return 0; } -/*-------------------------------------------------------------------- - Beschreibung: Liste der verwendeten Namen fuellen - --------------------------------------------------------------------*/ - -void SwInsertSectionTabPage::FillList( const SwSectionFmt* pNewFmt ) -{ - const SwSectionFmt* pFmt; - if( !pNewFmt ) - { - USHORT nCount = m_pWrtSh->GetSectionFmtCount(); - for(USHORT i=0;i<nCount;i++) - { - SectionType eTmpType; - if( !(pFmt = &m_pWrtSh->GetSectionFmt(i))->GetParent() && - pFmt->IsInNodesArr() && - (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION - && TOX_HEADER_SECTION != eTmpType ) - { - String* pString = new String(pFmt->GetSection()->GetName()); - aCurName.InsertEntry(*pString); - aSubRegionED.InsertEntry(*pString); - FillList( pFmt ); - } - } - } - else - { - SwSections aTmpArr; - USHORT nCnt = pNewFmt->GetChildSections(aTmpArr,SORTSECT_POS); - if( nCnt ) - { - SectionType eTmpType; - for( USHORT n = 0; n < nCnt; ++n ) - if( (pFmt = aTmpArr[n]->GetFmt())->IsInNodesArr()&& - (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION - && TOX_HEADER_SECTION != eTmpType ) - { - String* pString = new String(pFmt->GetSection()->GetName()); - aCurName.InsertEntry(*pString); - aSubRegionED.InsertEntry(*pString); - FillList( pFmt ); - } - } - } -} - // -------------------------------------------------------------- // Numerierungsformat Umsetzung: diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index 2ff17d0a04..e991938aad 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -3778,6 +3778,7 @@ BOOL SwTrnsfrDdeLink::WriteData( SvStream& rStrm ) // remove mark pServerObject->SetNoServer(); // this removes the connection between SwServerObject and mark + // N.B. ppMark was not loaded from file and cannot have xml:id pMarkAccess->deleteMark(ppMark); // recreate as Bookmark diff --git a/sw/source/ui/docvw/PostItMgr.cxx b/sw/source/ui/docvw/PostItMgr.cxx index 1e5eb8788b..6aa8f80c4d 100644 --- a/sw/source/ui/docvw/PostItMgr.cxx +++ b/sw/source/ui/docvw/PostItMgr.cxx @@ -74,6 +74,7 @@ #include <svtools/langtab.hxx> #include <svtools/smplhint.hxx> +#include <svx/svdview.hxx> #include <svx/eeitem.hxx> #include <svx/langitem.hxx> #include <svx/outliner.hxx> @@ -153,6 +154,14 @@ SwPostItMgr::SwPostItMgr(SwView* pView) mbWaitingForCalcRects = true; mnEventId = Application::PostUserEvent( LINK( this, SwPostItMgr, CalcHdl), 0 ); } + + //#i# + if (HasNotes() && !mpWrtShell->GetViewOptions()->IsPostIts()) + { + SfxRequest aRequest(mpView->GetViewFrame(),FN_VIEW_NOTES); + mpView->ExecViewOptions(aRequest); + } + } SwPostItMgr::~SwPostItMgr() @@ -307,8 +316,9 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) /* else if ( rHint.IsA(TYPE(SwRedlineHint) ) ) { - SwRedline* pRedline = const_cast<SwRedline*>(((SwRedlineHint&)rHint).GetRedline()); - switch ( ((SwRedlineHint&)rHint).Which() ) + const SwRedlineHint rRedlineHint = static_cast<const SwRedlineHint&>(rHint); + SwRedline* pRedline = const_cast<SwRedline*>(rRedlineHint.GetRedline()); + switch ( rRedlineHint.Which() ) { case SWREDLINE_INSERTED : { @@ -324,8 +334,9 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) break; } case SWREDLINE_FOCUS: - { - Focus(rBC); + { + if (rRedlineHint.GetView()== mpView) + Focus(rBC); break; } } @@ -333,8 +344,9 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) */ else if ( rHint.IsA(TYPE(SwFmtFldHint) ) ) { - SwFmtFld* pFld = const_cast <SwFmtFld*>( ((SwFmtFldHint&)rHint).GetField() ); - switch ( ((SwFmtFldHint&)rHint).Which() ) + const SwFmtFldHint& rFmtHint = static_cast<const SwFmtFldHint&>(rHint); + SwFmtFld* pFld = const_cast <SwFmtFld*>( rFmtHint.GetField() ); + switch ( rFmtHint.Which() ) { case SWFMTFLD_INSERTED : { @@ -351,9 +363,10 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) if (bEmpty && !mvPostItFlds.empty()) PrepareView(true); } - else { + else + { DBG_ERROR( "Inserted field not in document!" ); - } + } break; } case SWFMTFLD_REMOVED: @@ -370,19 +383,23 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) break; } case SWFMTFLD_FOCUS: - { - Focus(rBC); + { + if (rFmtHint.GetView()== mpView) + Focus(rBC); break; } case SWFMTFLD_CHANGED: { - SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); + SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( pFmtFld == (*i)->GetBroadCaster() ) + if ( pFmtFld == (*i)->GetBroadCaster() ) { if ((*i)->pPostIt) + { (*i)->pPostIt->SetPostItText(); + mbLayout = true; + } break; } } @@ -390,10 +407,10 @@ void SwPostItMgr::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) } case SWFMTFLD_LANGUAGE: { - SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); + SwFmtFld* pFmtFld = dynamic_cast<SwFmtFld*>(&rBC); for(std::list<SwMarginItem*>::iterator i = mvPostItFlds.begin(); i!= mvPostItFlds.end() ; i++) { - if ( pFmtFld == (*i)->GetBroadCaster() ) + if ( pFmtFld == (*i)->GetBroadCaster() ) { if ((*i)->pPostIt) { @@ -1914,3 +1931,27 @@ sal_uInt16 SwPostItMgr::SearchReplace(const SwFmtFld &pFld, const ::com::sun::st } return aResult; } + +void SwPostItMgr::AssureStdModeAtShell() +{ + //#i103373# #i103645# + // deselect any drawing or frame and leave editing mode + SdrView* pSdrView = mpWrtShell->GetDrawView(); + if ( pSdrView && pSdrView->IsTextEdit() ) + { + sal_Bool bLockView = mpWrtShell->IsViewLocked(); + mpWrtShell->LockView( sal_True ); + mpWrtShell->EndTextEdit(); + mpWrtShell->LockView( bLockView ); + } + + if( mpWrtShell->IsSelFrmMode() || mpWrtShell->IsObjSelected()) + { + mpWrtShell->UnSelectFrm(); + mpWrtShell->LeaveSelFrmMode(); + mpWrtShell->EnterStdMode(); + + mpWrtShell->DrawSelChanged(); + mpView->StopShellTimer(); + } +} diff --git a/sw/source/ui/docvw/docvw.src b/sw/source/ui/docvw/docvw.src index 602749b602..74da4994c7 100644 --- a/sw/source/ui/docvw/docvw.src +++ b/sw/source/ui/docvw/docvw.src @@ -315,12 +315,12 @@ String STR_POSTIT_YESTERDAY String STR_DELETE_ALL_NOTES { - Text [ en-US ] = "All Notes" ; + Text [ en-US ] = "All Comments" ; }; String STR_DELETE_AUTHOR_NOTES { - Text [ en-US ] = "Notes by " ; + Text [ en-US ] = "Comments by " ; }; String STR_NODATE diff --git a/sw/source/ui/docvw/edtwin.cxx b/sw/source/ui/docvw/edtwin.cxx index 75486a6215..0f45470c91 100644 --- a/sw/source/ui/docvw/edtwin.cxx +++ b/sw/source/ui/docvw/edtwin.cxx @@ -1405,8 +1405,8 @@ void SwEditWin::KeyInput(const KeyEvent &rKEvt) if( rKeyCode.GetFullCode() == (KEY_A | KEY_MOD1 |KEY_SHIFT) && rSh.HasDrawView() && (0 != (nLclSelectionType = rSh.GetSelectionType()) && - ((nLclSelectionType & nsSelectionType::SEL_FRM) || - ((nLclSelectionType & nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM) && + ((nLclSelectionType & (nsSelectionType::SEL_FRM|nsSelectionType::SEL_GRF)) || + ((nLclSelectionType & (nsSelectionType::SEL_DRW|nsSelectionType::SEL_DRW_FORM)) && rSh.GetDrawView()->GetMarkedObjectList().GetMarkCount() == 1)))) { SdrHdlList& rHdlList = (SdrHdlList&)rSh.GetDrawView()->GetHdlList(); @@ -5568,11 +5568,12 @@ void QuickHelpData::Stop( SwWrtShell& rSh ) void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord ) { - pCalendarWrapper->LoadDefaultCalendar( rSh.GetCurLang() ); + salhelper::SingletonRef<SwCalendarWrapper>* pCalendar = s_getCalendarWrapper(); + (*pCalendar)->LoadDefaultCalendar( rSh.GetCurLang() ); { uno::Sequence< i18n::CalendarItem > aNames( - pCalendarWrapper->getMonths() ); + (*pCalendar)->getMonths() ); for( int n = 0; n < 2; ++n ) { for( long nPos = 0, nEnd = aNames.getLength(); nPos < nEnd; ++nPos ) @@ -5592,7 +5593,7 @@ void QuickHelpData::FillStrArr( SwWrtShell& rSh, const String& rWord ) } } if( !n ) // get data for the second loop - aNames = pCalendarWrapper->getDays(); + aNames = (*pCalendar)->getDays(); } } diff --git a/sw/source/ui/docvw/edtwin2.cxx b/sw/source/ui/docvw/edtwin2.cxx index 1b9aecd3ce..b277c13949 100644 --- a/sw/source/ui/docvw/edtwin2.cxx +++ b/sw/source/ui/docvw/edtwin2.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -94,6 +94,11 @@ #include <PostItMgr.hxx> #include <fmtfld.hxx> +// --> OD 2009-08-18 #i104300# +#include <IDocumentMarkAccess.hxx> +#include <ndtxt.hxx> +// <-- + /*-------------------------------------------------------------------- Beschreibung: KeyEvents --------------------------------------------------------------------*/ @@ -205,6 +210,38 @@ void SwEditWin::RequestHelp(const HelpEvent &rEvt) sSuffix.EqualsAscii( pMarkToOLE )) sTxt = sTxt.Copy( 0, nFound - 1); } + // --> OD 2009-08-18 #i104300# + // special handling if target is a cross-reference bookmark + { + String sTmpSearchStr = sTxt.Copy( 1, sTxt.Len() ); + IDocumentMarkAccess* const pMarkAccess = + rSh.getIDocumentMarkAccess(); + IDocumentMarkAccess::const_iterator_t ppBkmk = + pMarkAccess->findBookmark( sTmpSearchStr ); + if ( ppBkmk != pMarkAccess->getBookmarksEnd() && + IDocumentMarkAccess::GetType( *(ppBkmk->get()) ) + == IDocumentMarkAccess::CROSSREF_HEADING_BOOKMARK ) + { + SwTxtNode* pTxtNode = ppBkmk->get()->GetMarkStart().nNode.GetNode().GetTxtNode(); + if ( pTxtNode ) + { + sTxt = pTxtNode->GetExpandTxt( 0, pTxtNode->Len(), true, true ); + + if( sTxt.Len() ) + { + sTxt.EraseAllChars( 0xad ); + for( sal_Unicode* p = sTxt.GetBufferAccess(); *p; ++p ) + { + if( *p < 0x20 ) + *p = 0x20; + else if(*p == 0x2011) + *p = '-'; + } + } + } + } + } + // <-- // --> OD 2007-07-26 #i80029# BOOL bExecHyperlinks = rView.GetDocShell()->IsReadOnly(); if ( !bExecHyperlinks ) diff --git a/sw/source/ui/docvw/postit.cxx b/sw/source/ui/docvw/postit.cxx index 3c6b08e79c..157a6e1997 100644 --- a/sw/source/ui/docvw/postit.cxx +++ b/sw/source/ui/docvw/postit.cxx @@ -91,6 +91,7 @@ #include <vcl/svapp.hxx> #include <vcl/gradient.hxx> #include <vcl/salbtype.hxx> // FRound +#include <vcl/msgbox.hxx> #include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/tuple/b2dtuple.hxx> @@ -269,6 +270,8 @@ void PostItTxt::KeyInput( const KeyEvent& rKeyEvt ) bool bIsProtected = mpMarginWin->IsProtected(); if (!bIsProtected || (bIsProtected && !mpMarginWin->Engine()->GetEditEngine().DoesKeyChangeText(rKeyEvt)) ) bDone = mpOutlinerView->PostKeyEvent( rKeyEvt ); + else + InfoBox( this, SW_RES( MSG_READONLY_CONTENT )).Execute(); } if (bDone) mpMarginWin->ResizeIfNeccessary(aOldHeight,mpMarginWin->GetPostItTextHeight()); @@ -436,33 +439,6 @@ void PostItTxt::Command( const CommandEvent& rCEvt ) mpMarginWin->DocView()->HandleWheelCommands(rCEvt); } } - else if (rCEvt.GetCommand() == COMMAND_SELECTIONCHANGE) - { - if ( mpOutlinerView ) - { - const CommandSelectionChangeData *pData = rCEvt.GetSelectionChangeData(); - ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); - aSelection.nStartPos = sal::static_int_cast<sal_uInt16, ULONG>(pData->GetStart()); - aSelection.nEndPos = sal::static_int_cast<sal_uInt16, ULONG>(pData->GetEnd()); - mpOutlinerView->GetEditView().SetSelection(aSelection); - } - } - else if (rCEvt.GetCommand() == COMMAND_PREPARERECONVERSION) - { - if ( mpOutlinerView && mpOutlinerView->HasSelection() ) - { - EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); - ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); - aSelection.Adjust(); - if( aSelection.nStartPara != aSelection.nEndPara ) - { - xub_StrLen aParaLen = aEditEngine->GetTextLen( aSelection.nStartPara ); - aSelection.nEndPara = aSelection.nStartPara; - aSelection.nEndPos = aParaLen; - mpOutlinerView->GetEditView().SetSelection( aSelection ); - } - } - } else { if ( mpOutlinerView ) @@ -477,40 +453,6 @@ void PostItTxt::DataChanged( const DataChangedEvent& aData) Window::DataChanged( aData ); } -XubString PostItTxt::GetSurroundingText() const -{ - if( mpOutlinerView ) - { - EditEngine *aEditEngine = mpOutlinerView->GetEditView().GetEditEngine(); - if( mpOutlinerView->HasSelection() ) - return mpOutlinerView->GetSelected(); - else - { - ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); - XubString aStr = aEditEngine->GetText(aSelection.nStartPara); - return aStr; - } - } - else - return XubString::EmptyString(); -} - -Selection PostItTxt::GetSurroundingTextSelection() const -{ - if( mpOutlinerView ) - { - if( mpOutlinerView->HasSelection() ) - return Selection( 0, mpOutlinerView->GetSelected().Len() ); - else - { - ESelection aSelection = mpOutlinerView->GetEditView().GetSelection(); - return Selection( aSelection.nStartPos, aSelection.nEndPos ); - } - } - else - return Selection( 0, 0 ); -} - IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) { if ( pWinEvent && pWinEvent->ISA( VclWindowEvent ) ) @@ -549,6 +491,22 @@ IMPL_LINK( PostItTxt, WindowEventListener, VclSimpleEvent*, pWinEvent ) return sal_True; } +XubString PostItTxt::GetSurroundingText() const +{ + if( mpOutlinerView ) + return mpOutlinerView->GetSurroundingText(); + else + return XubString::EmptyString(); +} + +Selection PostItTxt::GetSurroundingTextSelection() const +{ + if( mpOutlinerView ) + return mpOutlinerView->GetSurroundingTextSelection(); + else + return Selection( 0, 0 ); +} + /************** SwMarginWin***********************************++*/ SwMarginWin::SwMarginWin(Window* pParent, WinBits nBits,SwPostItMgr* aMgr,SwPostItBits aBits) : Window(pParent, nBits), @@ -735,6 +693,15 @@ void SwMarginWin::ShowAnkorOnly(const Point &aPoint) mpShadow->setVisible(false); } +SfxItemSet SwMarginWin::DefaultItem() +{ + SfxItemSet aItem( mpView->GetDocShell()->GetPool() ); + aItem.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); + aItem.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), + EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); + return aItem; +} + void SwMarginWin::InitControls() { // actual window which holds the user text @@ -779,11 +746,7 @@ void SwMarginWin::InitControls() mpPostItTxt->SetTextView(mpOutlinerView); mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,1,1) ) ); - SfxItemSet item(aShell->GetPool()); - item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - mpOutlinerView->SetAttribs(item); + mpOutlinerView->SetAttribs(DefaultItem()); // TODO: ?? EEHorizontalTextDirection aDefHoriTextDir = Application::GetSettings().GetLayoutRTL() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R; @@ -965,7 +928,7 @@ void SwMarginWin::SetPosAndSize() { mpAnkor->SetAnkorState(AS_ALL); SwMarginWin* pWin = GetTopReplyNote(); - if (IsFollow() && pWin ) + if (pWin) pWin->Ankor()->SetAnkorState(AS_END); } } @@ -973,9 +936,9 @@ void SwMarginWin::SetPosAndSize() void SwMarginWin::DoResize() { - long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); - unsigned long aWidth = GetSizePixel().Width(); - long aHeight = GetSizePixel().Height(); + long aTextHeight = LogicToPixel( mpOutliner->CalcTextSize()).Height(); + long aHeight = GetSizePixel().Height(); + unsigned long aWidth = GetSizePixel().Width(); if (mbMeta) { @@ -998,8 +961,7 @@ void SwMarginWin::DoResize() { mpVScrollbar->Hide(); } - - mpPostItTxt->SetPosSizePixel(0, 0, aWidth, aHeight); + mpMeta->SetPosSizePixel(0,aHeight,GetSizePixel().Width()-GetMetaButtonAreaWidth(),GetMetaHeight()); mpOutliner->SetPaperSize( PixelToLogic( Size(aWidth,aHeight) ) ) ; mpOutlinerView->SetOutputArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) ); @@ -1007,11 +969,21 @@ void SwMarginWin::DoResize() { // if we do not have a scrollbar anymore, we want to see the complete text mpOutlinerView->SetVisArea( PixelToLogic( Rectangle(0,0,aWidth,aHeight) ) ); } - mpVScrollbar->SetPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight ); + + if (!Application::GetSettings().GetLayoutRTL()) + { + mpPostItTxt->SetPosSizePixel(0, 0, aWidth, aHeight); + mpVScrollbar->SetPosSizePixel( aWidth, 0, GetScrollbarWidth(), aHeight); + } + else + { + mpPostItTxt->SetPosSizePixel((aTextHeight > aHeight) && !IsPreview() ? GetScrollbarWidth() : 0 , 0, aWidth, aHeight); + mpVScrollbar->SetPosSizePixel( 0, 0, GetScrollbarWidth(), aHeight); + } + mpVScrollbar->SetVisibleSize( PixelToLogic(Size(0,aHeight)).Height() ); mpVScrollbar->SetPageSize( PixelToLogic(Size(0,aHeight)).Height() * 8 / 10 ); mpVScrollbar->SetLineSize( mpOutliner->GetTextHeight() / 10 ); - //mpVScrollbar->SetThumbPos( mpOutlinerView->GetVisArea().Top()+ mpOutlinerView->GetEditView().GetCursor()->GetOffsetY()); SetScrollbar(); mpVScrollbar->SetRange( Range(0, mpOutliner->GetTextHeight())); @@ -1025,10 +997,6 @@ void SwMarginWin::DoResize() Point aRight = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH-1)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+17*fy.GetNumerator()/fy.GetDenominator() ) ); Point aBottom = PixelToLogic( Point( aBase.X() - (METABUTTON_WIDTH+2)*fx.GetNumerator()/fx.GetDenominator(), aBase.Y()+20*fy.GetNumerator()/fy.GetDenominator() ) ); - //Point aLeft = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+5,mpMeta->GetPosPixel().Y()+17)); - //Point aRight = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+11,mpMeta->GetPosPixel().Y()+17)); - //Point aBottom = PixelToLogic(Point(mpMeta->GetPosPixel().X()+mpMeta->GetPosPixel().X()+GetSizePixel().Width()-(GetMetaButtonWidth()+10)+8,mpMeta->GetPosPixel().Y()+20)); - aPopupTriangle.clear(); aPopupTriangle.append(basegfx::B2DPoint(aLeft.X(),aLeft.Y())); aPopupTriangle.append(basegfx::B2DPoint(aRight.X(),aRight.Y())); @@ -1220,6 +1188,8 @@ void SwMarginWin::HideNote() void SwMarginWin::ActivatePostIt() { + mpMgr->AssureStdModeAtShell(); + mpOutliner->ClearModifyFlag(); mpOutliner->GetUndoManager().Clear(); @@ -1280,11 +1250,13 @@ void SwMarginWin::ToggleInsMode() void SwMarginWin::ExecuteCommand(USHORT nSlot) { + mpMgr->AssureStdModeAtShell(); + switch (nSlot) { case FN_POSTIT: case FN_REPLY: - { + { // if this note is empty, it will be deleted once losing the focus, so no reply, but only a new note // will be created SwView* pView = DocView(); @@ -1444,9 +1416,7 @@ void SwMarginWin::ResetAttributes() { mpOutlinerView->RemoveAttribsKeepLanguages(TRUE); mpOutliner->RemoveFields(TRUE); - SfxItemSet aSet( mpView->GetDocShell()->GetPool() ); - aSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - mpOutlinerView->SetAttribs(aSet); + mpOutlinerView->SetAttribs(DefaultItem()); } sal_Int32 SwMarginWin::GetScrollbarWidth() @@ -1504,7 +1474,7 @@ void SwMarginWin::SetViewState(ShadowState bState) { mpAnkor->SetAnkorState(AS_ALL); SwMarginWin* pWin = GetTopReplyNote(); - if (IsFollow() && pWin) + if (pWin) pWin->Ankor()->SetAnkorState(AS_END); mpAnkor->setLineSolid(true); } @@ -1567,7 +1537,7 @@ bool SwMarginWin::IsAnyStackParentVisible() SwMarginWin* SwMarginWin::GetTopReplyNote() { SwMarginWin* pTopNote = 0; - SwMarginWin* pMarginWin = mpMgr->GetNextPostIt(KEY_PAGEUP, this); + SwMarginWin* pMarginWin = IsFollow() ? mpMgr->GetNextPostIt(KEY_PAGEUP, this) : 0; while (pMarginWin) { pTopNote = pMarginWin; @@ -1627,11 +1597,7 @@ void SwPostIt::SetPostItText() else { Engine()->Clear(); - SfxItemSet item( DocView()->GetDocShell()->GetPool() ); - item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - View()->SetAttribs(item); + View()->SetAttribs(DefaultItem()); View()->InsertText(mpFld->GetPar2(),false); } @@ -1646,19 +1612,19 @@ void SwPostIt::UpdateData() { if ( Engine()->IsModified() ) { - SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); - if ( pPos ) - { - SwField* pOldField = mpFld->Copy(); - mpFld->SetPar2(Engine()->GetEditEngine().GetText()); - mpFld->SetTextObject(Engine()->CreateParaObject()); - DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true)); - delete pOldField; - delete pPos; - // so we get a new layout of notes (ankor position is still the same and we would otherwise not get one) - Mgr()->SetLayout(); - DocView()->GetDocShell()->SetModified(); - } + SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld(); + SwPosition aPosition( pTxtFld->GetTxtNode() ); + aPosition.nContent = *pTxtFld->GetStart(); + SwField* pOldField = mpFld->Copy(); + mpFld->SetPar2(Engine()->GetEditEngine().GetText()); + mpFld->SetTextObject(Engine()->CreateParaObject()); + DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); + delete pOldField; + // so we get a new layout of notes (anchor position is still the same and we would otherwise not get one) + Mgr()->SetLayout(); + // #i98686# if we have several views, all notes should update their text + mpFmtFld->Broadcast(SwFmtFldHint( 0, SWFMTFLD_CHANGED)); + DocView()->GetDocShell()->SetModified(); } Engine()->ClearModifyFlag(); Engine()->GetUndoManager().Clear(); @@ -1698,11 +1664,12 @@ sal_uInt32 SwPostIt::MoveCaret() //returns true, if there is another note right before this note bool SwPostIt::CalcFollow() { - SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); - const SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); - SwTxtAttr* pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex()-1,RES_TXTATR_FIELD ) : 0; + SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld(); + SwPosition aPosition( pTxtFld->GetTxtNode() ); + aPosition.nContent = *pTxtFld->GetStart(); + SwTxtAttr * const pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt( + aPosition.nContent.GetIndex() - 1, RES_TXTATR_FIELD ); const SwField* pFld = pTxtAttr ? pTxtAttr->GetFld().GetFld() : 0; - delete pPos; return pFld && (pFld->Which()== RES_POSTITFLD); } @@ -1710,18 +1677,20 @@ bool SwPostIt::CalcFollow() sal_uInt32 SwPostIt::CountFollowing() { sal_uInt32 aCount = 1; // we start with 1, so we have to subtract one at the end again - SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); - const SwTxtNode* pTxtNd = pPos->nNode.GetNode().GetTxtNode(); - - SwTxtAttr* pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex()+1,RES_TXTATR_FIELD ) : 0; + SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld(); + SwPosition aPosition( pTxtFld->GetTxtNode() ); + aPosition.nContent = *pTxtFld->GetStart(); + + SwTxtAttr * pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt( + aPosition.nContent.GetIndex() + 1, RES_TXTATR_FIELD ); SwField* pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; while (pFld && (pFld->Which()== RES_POSTITFLD)) { - aCount++; - pTxtAttr = pTxtNd ? pTxtNd->GetTxtAttr( pPos->nContent.GetIndex() + aCount,RES_TXTATR_FIELD ) : 0; + aCount++; + pTxtAttr = pTxtFld->GetTxtNode().GetTxtAttrForCharAt( + aPosition.nContent.GetIndex() + aCount, RES_TXTATR_FIELD ); pFld = pTxtAttr ? const_cast<SwField*>(pTxtAttr->GetFld().GetFld()) : 0; } - delete pPos; return aCount - 1; } @@ -1820,24 +1789,18 @@ void SwPostIt::InitAnswer(OutlinerParaObject* pText) //remove all attributes and reset our standard ones View()->GetEditView().RemoveAttribsKeepLanguages(true); - SfxItemSet aNormalSet( DocView()->GetDocShell()->GetPool() ); - aNormalSet.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - aNormalSet.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - View()->SetAttribs(aNormalSet); + View()->SetAttribs(DefaultItem()); // lets insert an undo step so the initial text can be easily deleted // but do not use UpdateData() directly, would set modified state again and reentrance into Mgr Engine()->SetModifyHdl( Link() ); - SwPosition * pPos = mpFmtFld->GetTxtFld()->GetPosition(); - if ( pPos ) - { - SwField* pOldField = mpFld->Copy(); - mpFld->SetPar2(Engine()->GetEditEngine().GetText()); - mpFld->SetTextObject(Engine()->CreateParaObject()); - DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(*pPos, *pOldField, *mpFld, 0, true)); - delete pOldField; - delete pPos; - } + SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld(); + SwPosition aPosition( pTxtFld->GetTxtNode() ); + aPosition.nContent = *pTxtFld->GetStart(); + SwField* pOldField = mpFld->Copy(); + mpFld->SetPar2(Engine()->GetEditEngine().GetText()); + mpFld->SetTextObject(Engine()->CreateParaObject()); + DocView()->GetDocShell()->GetDoc()->AppendUndo(new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); + delete pOldField; Engine()->SetModifyHdl( LINK( this, SwPostIt, ModifyHdl ) ); Engine()->ClearModifyFlag(); Engine()->GetUndoManager().Clear(); @@ -1899,11 +1862,7 @@ void SwRedComment::SetPostItText() Engine()->EnableUndo( FALSE ); Engine()->Clear(); - SfxItemSet item( DocView()->GetDocShell()->GetPool() ); - item.Put(SvxFontHeightItem(200,100,EE_CHAR_FONTHEIGHT)); - item.Put(SvxFontItem(FAMILY_SWISS,GetSettings().GetStyleSettings().GetFieldFont().GetName(), - EMPTYSTRING,PITCH_DONTKNOW,RTL_TEXTENCODING_DONTKNOW,EE_CHAR_FONTINFO)); - View()->SetAttribs(item); + View()->SetAttribs(DefaultItem()); View()->InsertText(pRedline->GetComment(),false); Engine()->ClearModifyFlag(); diff --git a/sw/source/ui/docvw/srcedtw.cxx b/sw/source/ui/docvw/srcedtw.cxx index 759fac9391..ac6786427e 100644 --- a/sw/source/ui/docvw/srcedtw.cxx +++ b/sw/source/ui/docvw/srcedtw.cxx @@ -395,8 +395,10 @@ void TextViewOutWin::MouseButtonUp( const MouseEvent &rEvt ) if ( pTextView ) { pTextView->MouseButtonUp( rEvt ); - ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()-> - GetBindings().Invalidate( SID_TABLE_CELL ); + SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings(); + rBindings.Invalidate( SID_TABLE_CELL ); + rBindings.Invalidate( SID_CUT ); + rBindings.Invalidate( SID_COPY ); } } @@ -459,6 +461,7 @@ void TextViewOutWin::KeyInput( const KeyEvent& rKEvt ) if(bChange) bDone = pTextView->KeyInput( rKEvt ); + SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings(); if ( !bDone ) { if ( !SfxViewShell::Current()->KeyInput( rKEvt ) ) @@ -466,7 +469,6 @@ void TextViewOutWin::KeyInput( const KeyEvent& rKEvt ) } else { - SfxBindings& rBindings = ((SwSrcEditWindow*)GetParent())->GetSrcView()->GetViewFrame()->GetBindings(); rBindings.Invalidate( SID_TABLE_CELL ); if ( rKEvt.GetKeyCode().GetGroup() == KEYGROUP_CURSOR ) rBindings.Update( SID_BASICIDE_STAT_POS ); @@ -478,6 +480,10 @@ void TextViewOutWin::KeyInput( const KeyEvent& rKEvt ) if( rKEvt.GetKeyCode().GetCode() == KEY_INSERT ) rBindings.Invalidate( SID_ATTR_INSERT ); } + + rBindings.Invalidate( SID_CUT ); + rBindings.Invalidate( SID_COPY ); + SwDocShell* pDocShell = pSrcEditWin->GetSrcView()->GetDocShell(); if(pSrcEditWin->GetTextEngine()->IsModified()) { diff --git a/sw/source/ui/fldui/fldmgr.cxx b/sw/source/ui/fldui/fldmgr.cxx index 289b4ab7bb..67c921f011 100644 --- a/sw/source/ui/fldui/fldmgr.cxx +++ b/sw/source/ui/fldui/fldmgr.cxx @@ -1615,7 +1615,7 @@ USHORT SwFldMgr::GetCurrLanguage() const SwWrtShell* pSh = pWrtShell ? pWrtShell : ::lcl_GetShell(); if( pSh ) return pSh->GetCurLang(); - return SvxLocaleToLanguage( GetAppLocaleData().getLocale() ); + return SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() ); } void SwFieldType::_GetFldName() diff --git a/sw/source/ui/fldui/fldtdlg.cxx b/sw/source/ui/fldui/fldtdlg.cxx index 63570d7538..3e2d031c0a 100644 --- a/sw/source/ui/fldui/fldtdlg.cxx +++ b/sw/source/ui/fldui/fldtdlg.cxx @@ -136,7 +136,7 @@ SwFldDlg::SwFldDlg(SfxBindings* pB, SwChildWinWrapper* pCW, Window *pParent) ::comphelper::getProcessServiceFactory(), rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "/org.openoffice.Office.DataAccess/ApplicationIntegration/InstalledFeatures/Writer" ) ), + "/org.openoffice.Office.DataAccess/Policies/Features/Writer" ) ), -1, utl::OConfigurationTreeRoot::CM_READONLY); diff --git a/sw/source/ui/inc/actctrl.hxx b/sw/source/ui/inc/actctrl.hxx index 296cd947f4..70ddedadcc 100644 --- a/sw/source/ui/inc/actctrl.hxx +++ b/sw/source/ui/inc/actctrl.hxx @@ -66,10 +66,8 @@ protected: virtual void Modify(); public: - NoSpaceEdit( Window* pParent, const ResId& rResId) - : Edit(pParent, rResId), - sForbiddenChars(String::CreateFromAscii(" ")) - {} + NoSpaceEdit( Window* pParent, const ResId& rResId); + virtual ~NoSpaceEdit(); void SetForbiddenChars(const String& rSet){sForbiddenChars = rSet;} const String& GetForbiddenChars(){return sForbiddenChars;} }; diff --git a/sw/source/ui/inc/fldmgr.hxx b/sw/source/ui/inc/fldmgr.hxx index f1e2002d6e..6b6396409f 100644 --- a/sw/source/ui/inc/fldmgr.hxx +++ b/sw/source/ui/inc/fldmgr.hxx @@ -229,7 +229,7 @@ inline const String& SwFldMgr::GetCurFldPar1() const inline const String& SwFldMgr::GetCurFldPar2() const { return aCurPar2; } -inline ULONG SwFldMgr::GetCurFldFmt() const +inline ULONG SwFldMgr::GetCurFldFmt() const { return nCurFmt; } diff --git a/sw/source/ui/inc/insrc.hxx b/sw/source/ui/inc/insrc.hxx deleted file mode 100644 index 025a027923..0000000000 --- a/sw/source/ui/inc/insrc.hxx +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: insrc.hxx,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _INSRC_HXX -#define _INSRC_HXX - -#include <svx/stddlg.hxx> - -#ifndef _FIXED_HXX //autogen -#include <vcl/fixed.hxx> -#endif - -#ifndef _FIELD_HXX //autogen -#include <vcl/field.hxx> -#endif - -#ifndef _BUTTON_HXX //autogen -#include <vcl/button.hxx> -#endif - -#ifndef _GROUP_HXX //autogen -#include <vcl/group.hxx> -#endif -#include <tools/string.hxx> - -#ifndef _BUTTON_HXX //autogen -#include <vcl/button.hxx> -#endif - -class SwView; -class SwInsRowColDlg : public SvxStandardDialog -{ - FixedText aCount; - NumericField aCountEdit; - FixedLine aInsFL; - - RadioButton aBeforeBtn; - RadioButton aAfterBtn; - FixedLine aPosFL; - - String aRow; - String aCol; - - OKButton aOKBtn; - CancelButton aCancelBtn; - HelpButton aHelpBtn; - - SwView& rView; - BOOL bColumn; - -protected: - virtual void Apply(); - -public: - SwInsRowColDlg( SwView& rView, BOOL bCol ); -}; - -#endif - diff --git a/sw/source/ui/inc/regionsw.hxx b/sw/source/ui/inc/regionsw.hxx index 0d9e77616b..a7347c0aa7 100644 --- a/sw/source/ui/inc/regionsw.hxx +++ b/sw/source/ui/inc/regionsw.hxx @@ -33,35 +33,23 @@ #include <hintids.hxx> #include <vcl/field.hxx> #include <vcl/lstbox.hxx> -#ifndef _EDIT_HXX //autogen #include <vcl/edit.hxx> -#endif -#ifndef _BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif -#ifndef _FIXED_HXX //autogen #include <vcl/fixed.hxx> -#endif -#ifndef _COMBOBOX_HXX //autogen #include <vcl/combobox.hxx> -#endif -#ifndef _GROUP_HXX //autogen #include <vcl/group.hxx> -#endif #include <svtools/svtreebx.hxx> #include <sfx2/basedlgs.hxx> #include <sfx2/tabdlg.hxx> #include <svx/brshitem.hxx> -#ifndef _CONDEDIT_HXX #include <condedit.hxx> -#endif #include <section.hxx> #include <fmtclds.hxx> #include <fmtftntx.hxx> #include <fmtclbl.hxx> #include <numberingtypelistbox.hxx> -#include "svx/frmdiritem.hxx" +#include <svx/frmdiritem.hxx> #include <vcl/image.hxx> #include <svx/paraprev.hxx> #include <svx/lrspitem.hxx> @@ -179,6 +167,7 @@ class SwEditRegionDlg : public SfxModalDialog PushButton aFilePB; FixedText aSubRegionFT; ComboBox aSubRegionED; + bool bSubRegionsFilled; FixedLine aProtectFL; TriStateBox aProtectCB; @@ -239,6 +228,7 @@ class SwEditRegionDlg : public SfxModalDialog DECL_LINK( FileNameHdl, Edit* ); DECL_LINK( DDEHdl, CheckBox* ); DECL_LINK( DlgClosedHdl, sfx2::FileDialogHelper* ); + DECL_LINK( SubRegionEventHdl, VclWindowEvent * ); BOOL CheckPasswd(CheckBox* pBox = 0); @@ -308,8 +298,6 @@ class SwInsertSectionTabPage : public SfxTabPage DECL_LINK( DDEHdl, CheckBox* ); DECL_LINK( DlgClosedHdl, sfx2::FileDialogHelper* ); - void FillList( const SwSectionFmt* pFmt = 0 ); - public: SwInsertSectionTabPage(Window *pParent, const SfxItemSet &rAttrSet); virtual ~SwInsertSectionTabPage(); diff --git a/sw/source/ui/inc/wrtsh.hxx b/sw/source/ui/inc/wrtsh.hxx index f9d49cd931..b3929abdcc 100644 --- a/sw/source/ui/inc/wrtsh.hxx +++ b/sw/source/ui/inc/wrtsh.hxx @@ -165,6 +165,8 @@ public: // Selektion von Rahmen aufheben void UnSelectFrm(); + void Invalidate(); + // Tabellenzellen selektieren fuer Bearbeiten von Formeln in der Ribbonbar inline void SelTblCells( const Link &rLink, BOOL bMark = TRUE ); inline void EndSelTblCells(); diff --git a/sw/source/ui/lingu/olmenu.cxx b/sw/source/ui/lingu/olmenu.cxx index 8af28e1241..52540f21dd 100644 --- a/sw/source/ui/lingu/olmenu.cxx +++ b/sw/source/ui/lingu/olmenu.cxx @@ -62,6 +62,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/frame/XModuleManager.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/i18n/ScriptType.hpp> #include <svx/dlgutil.hxx> #include <svtools/itemset.hxx> #include <svx/langitem.hxx> @@ -168,7 +169,7 @@ LanguageType lcl_CheckLanguage( SvtLinguOptions aLinguOpt; SvtLinguConfig().GetOptions( aLinguOpt ); // The default document language from "Tools/Options - Language Settings - Languages: Western" - aLangList[0] = aLinguOpt.nDefaultLanguage; + aLangList[0] = MsLangId::resolveSystemLanguageByScriptType(aLinguOpt.nDefaultLanguage, ::com::sun::star::i18n::ScriptType::LATIN); // The one from "Tools/Options - Language Settings - Languages: User interface" aLangList[1] = rSettings.GetUILanguage(); // The one from "Tools/Options - Language Settings - Languages: Locale setting" diff --git a/sw/source/ui/misc/pgfnote.cxx b/sw/source/ui/misc/pgfnote.cxx index 5135dcaa5f..d684116f4e 100644 --- a/sw/source/ui/misc/pgfnote.cxx +++ b/sw/source/ui/misc/pgfnote.cxx @@ -48,6 +48,7 @@ #include <vcl/field.hxx> #include <vcl/svapp.hxx> #include <unotools/localedatawrapper.hxx> +#include <svtools/syslocale.hxx> #include <svx/sizeitem.hxx> #include <svx/pageitem.hxx> #include <svtools/eitem.hxx> @@ -183,7 +184,7 @@ SwFootNotePage::SwFootNotePage(Window *pParent, const SfxItemSet &rSet) : SetMetric( aMaxHeightEdit, aMetric ); SetMetric( aDistEdit, aMetric ); SetMetric( aLineDistEdit, aMetric ); - MeasurementSystem eSys = GetAppLocaleData().getMeasurementSystemEnum(); + MeasurementSystem eSys = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum(); long nHeightValue = MEASURE_METRIC != eSys ? 1440 : 1134; aMaxHeightEdit.SetValue(aMaxHeightEdit.Normalize(nHeightValue),FUNIT_TWIP);; } diff --git a/sw/source/ui/misc/redlndlg.src b/sw/source/ui/misc/redlndlg.src index 1ca0e0b99e..05066494ca 100644 --- a/sw/source/ui/misc/redlndlg.src +++ b/sw/source/ui/misc/redlndlg.src @@ -64,7 +64,7 @@ ModalDialog DLG_MOD_REDLINE_ACCEPT { HelpID = HID_REDLINE_AUTOFMT_ACCEPT ; REDLNDLG - Text [ en-US ] = "Accept or Reject AutoFormat Changes"; + Text [ en-US ] = "Accept or Reject AutoCorrect Changes"; }; Menu MN_REDLINE_POPUP diff --git a/sw/source/ui/ribbar/inputwin.cxx b/sw/source/ui/ribbar/inputwin.cxx index d4d5d20963..cd98771445 100644 --- a/sw/source/ui/ribbar/inputwin.cxx +++ b/sw/source/ui/ribbar/inputwin.cxx @@ -461,8 +461,8 @@ IMPL_LINK( SwInputWindow, SelTblCellsNotify, SwWrtShell *, pCaller ) aPam.Move( fnMoveForward, fnGoSection ); IDocumentContentOperations* pIDCO = pWrtShell->getIDocumentContentOperations(); - pIDCO->Delete( aPam ); - pIDCO->Insert( aPam, sNew, true ); + pIDCO->DeleteRange( aPam ); + pIDCO->InsertString( aPam, sNew ); pWrtShell->EndAllAction(); sOldFml = sNew; } @@ -499,7 +499,7 @@ IMPL_LINK( SwInputWindow, ModifyHdl, InputEdit*, EMPTYARG ) sNew += CH_LRE; sNew += aEdit.GetText(); sNew += CH_PDF; - pWrtShell->SwEditShell::Insert( sNew ); + pWrtShell->SwEditShell::Insert2( sNew ); pWrtShell->EndAllAction(); sOldFml = sNew; } diff --git a/sw/source/ui/shells/annotsh.cxx b/sw/source/ui/shells/annotsh.cxx index adf7f14ddb..68b8e87c3b 100755 --- a/sw/source/ui/shells/annotsh.cxx +++ b/sw/source/ui/shells/annotsh.cxx @@ -347,7 +347,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; } - pOLV->InsertText( String(cIns), TRUE ); + pOLV->InsertText( String(cIns)); rReq.Done(); break; } @@ -799,16 +799,18 @@ void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq) switch (nSlot) { case SID_CUT: - pOLV->Cut(); + if ( (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) && pOLV->HasSelection() ) + pOLV->Cut(); break; case SID_COPY: - pOLV->Copy(); + if( pOLV->HasSelection() ) + pOLV->Copy(); break; case SID_PASTE: if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) pOLV->Paste(); break; - case FN_PASTESPECIAL: + case SID_PASTE_SPECIAL: { if (pPostItMgr->GetActivePostIt()->GetStatus()!=SwPostItHelper::DELETED) { @@ -886,7 +888,7 @@ void SwAnnotationShell::StateClpbrd(SfxItemSet &rSet) break; } case SID_PASTE: - case FN_PASTESPECIAL: + case SID_PASTE_SPECIAL: { if( !bPastePossible ) rSet.DisableItem( nWhich ); @@ -1380,6 +1382,8 @@ void SwAnnotationShell::ExecUndo(SfxRequest &rReq) } } + rView.GetViewFrame()->GetBindings().InvalidateAll(sal_False); + if (rView.GetPostItMgr()->GetActivePostIt()) rView.GetPostItMgr()->GetActivePostIt()->ResizeIfNeccessary(aOldHeight,rView.GetPostItMgr()->GetActivePostIt()->GetPostItTextHeight()); } @@ -1595,7 +1599,7 @@ void SwAnnotationShell::InsertSymbol(SfxRequest& rReq) aFontSet.Set( aOldSet ); // String einfuegen - pOLV->InsertText( sSym, TRUE ); + pOLV->InsertText( sSym); // attributieren (Font setzen) SfxItemSet aSetFont( *aFontSet.GetPool(), aFontSet.GetRanges() ); diff --git a/sw/source/ui/shells/basesh.cxx b/sw/source/ui/shells/basesh.cxx index 168441d479..84b6f53a57 100644 --- a/sw/source/ui/shells/basesh.cxx +++ b/sw/source/ui/shells/basesh.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -301,11 +301,9 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) if ( rSh.HasSelection() ) { SwTransferable* pTransfer = new SwTransferable( rSh ); -/*??*/ uno::Reference< - datatransfer::XTransferable > xRef( - pTransfer ); +/*??*/ uno::Reference< datatransfer::XTransferable > xRef( pTransfer ); - if ( nId == SID_CUT ) + if ( nId == SID_CUT && !rSh.IsSelObjProtected(FLYPROTECT_CONTENT|FLYPROTECT_PARENT) ) pTransfer->Cut(); else { @@ -395,7 +393,7 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) aReq.Done(); } } - + if (rSh.IsFrmSelected() || rSh.IsObjSelected()) rSh.EnterSelFrmMode(); pView->AttrChangedNotify( &rSh ); @@ -404,8 +402,8 @@ void SwBaseShell::ExecClpbrd(SfxRequest &rReq) return; } break; - - case FN_PASTESPECIAL: + + case SID_PASTE_SPECIAL: { TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( @@ -481,10 +479,10 @@ void SwBaseShell::StateClpbrd(SfxItemSet &rSet) rSet.DisableItem( SID_PASTE ); break; - case FN_PASTESPECIAL: + case SID_PASTE_SPECIAL: if( !GetView().IsPasteSpecialAllowed() ) { - rSet.DisableItem( FN_PASTESPECIAL ); + rSet.DisableItem( SID_PASTE_SPECIAL ); rSet.DisableItem( SID_PASTE_UNFORMATTED ); } break; @@ -539,6 +537,8 @@ void SwBaseShell::ExecUndo(SfxRequest &rReq) default: DBG_ERROR("falscher Dispatcher"); } + + GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); } /*-------------------------------------------------------------------- @@ -2547,7 +2547,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) //Hintergrundattribute der Tabelle holen und in den Set packen SvxBrushItem aBrush(RES_BACKGROUND); rSh.GetBoxBackground( aBrush ); - pDlg = pFact->CreateSfxDialog( pMDI, aSet, + pDlg = pFact->CreateSfxDialog( pMDI, aSet, rView.GetViewFrame()->GetFrame()->GetFrameInterface(), RC_SWDLG_BACKGROUND ); DBG_ASSERT(pDlg, "Dialogdiet fail!"); @@ -2566,7 +2566,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) rSh.GetFlyFrmAttr( aSet ); - pDlg = pFact->CreateSfxDialog( pMDI, aSet, + pDlg = pFact->CreateSfxDialog( pMDI, aSet, rView.GetViewFrame()->GetFrame()->GetFrameInterface(), RC_SWDLG_BACKGROUND ); DBG_ASSERT(pDlg, "Dialogdiet fail!"); @@ -2581,7 +2581,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) // Umrandungsattribute ganz normal ueber Shell setzen rSh.GetCurAttr( aSet ); - pDlg = pFact->CreateSfxDialog( pMDI, aSet, + pDlg = pFact->CreateSfxDialog( pMDI, aSet, rView.GetViewFrame()->GetFrame()->GetFrameInterface(), RC_SWDLG_BACKGROUND ); DBG_ASSERT(pDlg, "Dialogdiet fail!"); diff --git a/sw/source/ui/shells/drwtxtex.cxx b/sw/source/ui/shells/drwtxtex.cxx index fc15241d12..60059cdeb1 100644 --- a/sw/source/ui/shells/drwtxtex.cxx +++ b/sw/source/ui/shells/drwtxtex.cxx @@ -736,9 +736,9 @@ ASK_ESCAPE: SvtCTLOptions aCTLOptions; sal_Bool bEnabled = aCTLOptions.IsCTLFontEnabled(); GetView().GetViewFrame()->GetBindings().SetVisibleState( nWhich, bEnabled ); - if(!bEnabled) - rSet.DisableItem(nWhich); - } + if(!bEnabled) + rSet.DisableItem(nWhich); + } break; default: nSlotId = 0; // don't know this slot @@ -828,15 +828,20 @@ void SwDrawTextShell::ExecClpbrd(SfxRequest &rReq) return; OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView(); + + ESelection aSel(pOLV->GetSelection()); + const sal_Bool bCopy = (aSel.nStartPara != aSel.nEndPara) || (aSel.nStartPos != aSel.nEndPos); sal_uInt16 nId = rReq.GetSlot(); switch( nId ) { case SID_CUT: - pOLV->Cut(); + if (bCopy) + pOLV->Cut(); return; case SID_COPY: - pOLV->Copy(); + if (bCopy) + pOLV->Copy(); return; case SID_PASTE: @@ -888,8 +893,8 @@ void SwDrawTextShell::StateClpbrd(SfxItemSet &rSet) } break; - case FN_PASTESPECIAL: - rSet.DisableItem( FN_PASTESPECIAL ); + case SID_PASTE_SPECIAL: + rSet.DisableItem( SID_PASTE_SPECIAL ); break; // --> OD 2008-06-20 #151110# case SID_CLIPBOARD_FORMAT_ITEMS: diff --git a/sw/source/ui/shells/drwtxtsh.cxx b/sw/source/ui/shells/drwtxtsh.cxx index 9098c55dcf..ad6ab1d2e7 100644 --- a/sw/source/ui/shells/drwtxtsh.cxx +++ b/sw/source/ui/shells/drwtxtsh.cxx @@ -514,7 +514,7 @@ void SwDrawTextShell::ExecDraw(SfxRequest &rReq) case SID_INSERT_ZWSP : cIns = CHAR_ZWSP ; break; case SID_INSERT_ZWNBSP: cIns = CHAR_ZWNBSP; break; } - pOLV->InsertText( String(cIns), TRUE ); + pOLV->InsertText( String(cIns)); rReq.Done(); } break; @@ -640,6 +640,7 @@ void SwDrawTextShell::ExecUndo(SfxRequest &rReq) pUndoManager->Redo(0); } bCallBase = FALSE; + GetView().GetViewFrame()->GetBindings().InvalidateAll(sal_False); } break; } @@ -856,7 +857,7 @@ void SwDrawTextShell::InsertSymbol(SfxRequest& rReq) aFontSet.Set( aOldSet ); // String einfuegen - pOLV->InsertText( sSym, TRUE ); + pOLV->InsertText( sSym ); // attributieren (Font setzen) SfxItemSet aFontAttribSet( *aFontSet.GetPool(), aFontSet.GetRanges() ); diff --git a/sw/source/ui/shells/frmsh.cxx b/sw/source/ui/shells/frmsh.cxx index 9b1c2bb95d..57f2babbfb 100644 --- a/sw/source/ui/shells/frmsh.cxx +++ b/sw/source/ui/shells/frmsh.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -50,6 +50,10 @@ #include <sfx2/request.hxx> #include <sfx2/objface.hxx> #include <svx/hlnkitem.hxx> +// --> OD 2009-07-07 #i73249# +#include <svx/svdview.hxx> +#include <vcl/msgbox.hxx> +// <-- #include <fmturl.hxx> @@ -82,6 +86,9 @@ #include <shells.hrc> #include "swabstdlg.hxx" #include "misc.hrc" +// --> OD 2009-07-14 #i73249# +#include <svx/dialogs.hrc> +// <-- using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -414,8 +421,13 @@ void SwFrameShell::Execute(SfxRequest &rReq) } aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell()))); aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName())); - if(nSel & nsSelectionType::SEL_OLE) - aSet.Put(SfxStringItem(FN_SET_FRM_ALT_NAME, rSh.GetAlternateText())); + if( nSel & nsSelectionType::SEL_OLE ) + { + // --> OD 2009-07-13 #i73249# +// aSet.Put(SfxStringItem(FN_SET_FRM_ALT_NAME, rSh.GetAlternateText())); + aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) ); + // <-- + } const SwRect &rPg = rSh.GetAnyCurRect(RECT_PAGE); SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height()); @@ -472,7 +484,10 @@ void SwFrameShell::Execute(SfxRequest &rReq) } if (SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_ALT_NAME, TRUE, &pItem)) { - rSh.SetAlternateText(((const SfxStringItem*)pItem)->GetValue()); + // --> OD 2009-07-13 #i73249# +// rSh.SetAlternateText(((const SfxStringItem*)pItem)->GetValue()); + rSh.SetObjTitle(((const SfxStringItem*)pItem)->GetValue()); + // <-- } // Vorlagen-AutoUpdate SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); @@ -587,6 +602,40 @@ void SwFrameShell::Execute(SfxRequest &rReq) rReq.SetReturnValue(SfxBoolItem(nSlot, bMirror)); } break; + // --> OD 2009-07-14 #i73249# + case FN_TITLE_DESCRIPTION_SHAPE: + { + bUpdateMgr = FALSE; + SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); + if ( pSdrView && + pSdrView->GetMarkedObjectCount() == 1 ) + { + String aDescription(rSh.GetObjDescription()); + String aTitle(rSh.GetObjTitle()); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractSvxObjectTitleDescDialog* pDlg = + pFact->CreateSvxObjectTitleDescDialog( NULL, + aTitle, + aDescription, + RID_SVXDLG_OBJECT_TITLE_DESC ); + OSL_ENSURE(pDlg, "Dialogdiet fail!"); + + if ( pDlg->Execute() == RET_OK ) + { + pDlg->GetDescription(aDescription); + pDlg->GetTitle(aTitle); + + rSh.SetObjDescription(aDescription); + rSh.SetObjTitle(aTitle); + } + + delete pDlg; + } + } + break; + // <-- default: ASSERT( !this, "falscher Dispatcher" ); return; @@ -822,6 +871,20 @@ void SwFrameShell::GetState(SfxItemSet& rSet) rSet.DisableItem( nWhich ); } break; + // --> OD 2009-07-07 #i73249# + case FN_TITLE_DESCRIPTION_SHAPE: + { + SwWrtShell &rWrtSh = GetShell(); + SdrView* pSdrView = rWrtSh.GetDrawViewWithValidMarkList(); + if ( !pSdrView || + pSdrView->GetMarkedObjectCount() != 1 ) + { + rSet.DisableItem( nWhich ); + } + + } + break; + // <-- default: /* do nothing */; break; diff --git a/sw/source/ui/shells/grfsh.cxx b/sw/source/ui/shells/grfsh.cxx index 8616e718e1..e0e5ec9178 100644 --- a/sw/source/ui/shells/grfsh.cxx +++ b/sw/source/ui/shells/grfsh.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -154,8 +154,13 @@ void SwGrfShell::Execute(SfxRequest &rReq) aSet.Put( aFrmSize ); aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName())); - if(nSlot == FN_FORMAT_GRAFIC_DLG) - aSet.Put(SfxStringItem(FN_SET_FRM_ALT_NAME, rSh.GetAlternateText())); + if ( nSlot == FN_FORMAT_GRAFIC_DLG ) + { + // --> OD 2009-07-13 #i73249# +// aSet.Put(SfxStringItem(FN_SET_FRM_ALT_NAME, rSh.GetAlternateText())); + aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) ); + // <-- + } pRect = &rSh.GetAnyCurRect(RECT_PAGE_PRT); aFrmSize.SetWidth( pRect->Width() ); @@ -324,10 +329,15 @@ void SwGrfShell::Execute(SfxRequest &rReq) sFilterNm, 0 ); } } - if( SFX_ITEM_SET == pSet->GetItemState( + if ( SFX_ITEM_SET == pSet->GetItemState( FN_SET_FRM_ALT_NAME, TRUE, &pItem )) - rSh.SetAlternateText( - ((const SfxStringItem*)pItem)->GetValue() ); + { + // --> OD 2009-07-13 #i73249# +// rSh.SetAlternateText( +// ((const SfxStringItem*)pItem)->GetValue() ); + rSh.SetObjTitle( ((const SfxStringItem*)pItem)->GetValue() ); + // <-- + } SfxItemSet aGrfSet( rSh.GetAttrPool(), RES_GRFATR_BEGIN, RES_GRFATR_END-1 ); diff --git a/sw/source/ui/shells/shells.src b/sw/source/ui/shells/shells.src index 9140062f21..92434115d7 100644 --- a/sw/source/ui/shells/shells.src +++ b/sw/source/ui/shells/shells.src @@ -98,7 +98,7 @@ String STR_REDLINE_DELETED }; String STR_REDLINE_AUTOFMT { - Text [ en-US ] = "AutoFormat"; + Text [ en-US ] = "AutoCorrect"; Text [ x-comment ] = " "; }; String STR_REDLINE_FORMATED @@ -118,12 +118,12 @@ String STR_REDLINE_FMTCOLLSET }; String STR_REDLINE_TITLE { - Text [ en-US ] = "AutoFormat"; + Text [ en-US ] = "AutoCorrect"; Text [ x-comment ] = " "; }; String STR_REDLINE_MSG { - Text [ en-US ] = "AutoFormat completed.\nYou can accept or reject all changes,\nor accept or reject particular changes."; + Text [ en-US ] = "AutoCorrect completed.\nYou can accept or reject all changes,\nor accept or reject particular changes."; Text [ x-comment ] = " "; }; String STR_REDLINE_ACCEPT_ALL diff --git a/sw/source/ui/shells/textfld.cxx b/sw/source/ui/shells/textfld.cxx index 094ddf318c..529ac59604 100644 --- a/sw/source/ui/shells/textfld.cxx +++ b/sw/source/ui/shells/textfld.cxx @@ -382,7 +382,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) SwFmtFld* pSwFmtFld = static_cast<SwFmtFld*>(pFirst); if ( pSwFmtFld->GetFld() == pPostIt ) { - pSwFmtFld->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS ) ); + pSwFmtFld->Broadcast( SwFmtFldHint( 0, SWFMTFLD_FOCUS, &GetView() ) ); break; } pFirst = aIter++; @@ -402,7 +402,7 @@ void SwTextShell::ExecField(SfxRequest &rReq) sComment = pRedline->GetComment(); if ( sComment == String(rtl::OUString::createFromAscii("")) ) GetView().GetDocShell()->Broadcast(SwRedlineHint(pRedline,SWREDLINE_INSERTED)); - const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS)); + const_cast<SwRedline*>(pRedline)->Broadcast(SwRedlineHint(pRedline,SWREDLINE_FOCUS,&GetView())); } */ diff --git a/sw/source/ui/shells/textsh.cxx b/sw/source/ui/shells/textsh.cxx index 4602dd3cdd..965b0f5d32 100644 --- a/sw/source/ui/shells/textsh.cxx +++ b/sw/source/ui/shells/textsh.cxx @@ -819,7 +819,11 @@ void SwTextShell::StateInsert( SfxItemSet &rSet ) rSh.Push(); const BOOL bCrsrInHidden = rSh.SelectHiddenRange(); - rSh.Pop(FALSE); + // --> OD 2009-08-05 #i103839#, #b6855246# + // Do not call method <SwCrsrShell::Pop(..)> with 1st parameter = <FALSE> + // in order to avoid that the view jumps to the visible cursor. + rSh.Pop(); + // <-- while ( nWhich ) { @@ -827,8 +831,11 @@ void SwTextShell::StateInsert( SfxItemSet &rSet ) { case SID_INSERT_SOUND: case SID_INSERT_VIDEO: + /*!SvxPluginFileDlg::IsAvailable( nWhich ) || + + discussed with mba: for performance reasons we skip the IsAvailable call here + */ if ( GetShell().IsSelFrmMode() || - !SvxPluginFileDlg::IsAvailable( nWhich ) || SFX_CREATE_MODE_EMBEDDED == eCreateMode || bCrsrInHidden ) { rSet.DisableItem( nWhich ); diff --git a/sw/source/ui/shells/textsh1.cxx b/sw/source/ui/shells/textsh1.cxx index 156fada7ee..a0ccd838ac 100644 --- a/sw/source/ui/shells/textsh1.cxx +++ b/sw/source/ui/shells/textsh1.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -373,7 +373,7 @@ void SwTextShell::Execute(SfxRequest &rReq) if (bForParagraph) SwLangHelper::SelectCurrentPara( rWrtSh ); - + if (!bForSelection) // document language to be changed... { rWrtSh.SelAll(); @@ -789,7 +789,7 @@ void SwTextShell::Execute(SfxRequest &rReq) GetView().GetViewFrame()->ToggleChildWindow(SID_HYPERLINK_DIALOG); break; case FN_REMOVE_HYPERLINK: - { + { BOOL bSel = rWrtSh.HasSelection(); if(!bSel) { @@ -1044,7 +1044,14 @@ void SwTextShell::Execute(SfxRequest &rReq) // --> OD 2008-03-18 #refactorlists# String sContinuedListId; const SwNumRule* pRule = - rWrtSh.SearchNumRule( FALSE, TRUE, FALSE, -1, sContinuedListId ); + rWrtSh.SearchNumRule( false, true, false, -1, sContinuedListId ); + // --> OD 2009-08-26 #i86492# + // Search also for bullet list + if ( !pRule ) + { + pRule = rWrtSh.SearchNumRule( false, false, false, -1, sContinuedListId ); + } + // <-- if ( pRule ) { rWrtSh.SetCurNumRule( *pRule, false, sContinuedListId ); @@ -1623,14 +1630,23 @@ void SwTextShell::GetState( SfxItemSet &rSet ) break; case FN_NUM_CONTINUE: { - if ( rSh.GetCurNumRule() ) - rSet.DisableItem(nWhich); - else + // --> OD 2009-08-26 #i86492# + // Allow continuation of previous list, even if at current cursor + // a list is active. +// if ( rSh.GetCurNumRule() ) +// rSet.DisableItem(nWhich); +// else + // <-- { - // --> OD 2008-03-18 #refactorlists# + // --> OD 2009-08-26 #i86492# + // Search also for bullet list String aDummy; const SwNumRule* pRule = - rSh.SearchNumRule( FALSE, TRUE, FALSE, -1, aDummy ); + rSh.SearchNumRule( false, true, false, -1, aDummy ); + if ( !pRule ) + { + pRule = rSh.SearchNumRule( false, false, false, -1, aDummy ); + } // <-- if ( !pRule ) rSet.DisableItem(nWhich); diff --git a/sw/source/ui/table/insrc.cxx b/sw/source/ui/table/insrc.cxx deleted file mode 100644 index 387678dec8..0000000000 --- a/sw/source/ui/table/insrc.cxx +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: insrc.cxx,v $ - * $Revision: 1.10 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sw.hxx" -#ifdef SW_DLLIMPLEMENTATION -#undef SW_DLLIMPLEMENTATION -#endif - - -#include <sfx2/dispatch.hxx> -#include <svtools/eitem.hxx> -#include <svtools/intitem.hxx> - -#include "cmdid.h" -#include "swtypes.hxx" -#include "insrc.hxx" -#include "view.hxx" -#include "table.hrc" -#include "insrc.hrc" - -void SwInsRowColDlg::Apply() -{ - USHORT nSlot = bColumn ? FN_TABLE_INSERT_COL : FN_TABLE_INSERT_ROW; - SfxUInt16Item aCountItem( nSlot, static_cast< UINT16 >(aCountEdit.GetValue()) ); - SfxBoolItem aAfter( FN_PARAM_INSERT_AFTER, aAfterBtn.IsChecked() ); - rView.GetViewFrame()->GetDispatcher()->Execute( nSlot, - SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, - &aCountItem, &aAfter, 0L); -} - - - -SwInsRowColDlg::SwInsRowColDlg(SwView& rVw, BOOL bCol ) - : SvxStandardDialog( rVw.GetWindow(), SW_RES(DLG_INS_ROW_COL) ), - aCount( this, SW_RES( FT_COUNT ) ), - aCountEdit( this, SW_RES( ED_COUNT ) ), - aInsFL( this, SW_RES( FL_INS ) ), - aBeforeBtn( this, SW_RES( CB_POS_BEFORE ) ), - aAfterBtn( this, SW_RES( CB_POS_AFTER ) ), - aPosFL( this, SW_RES( FL_POS ) ), - aRow(SW_RES(STR_ROW)), - aCol(SW_RES(STR_COL)), - aOKBtn( this, SW_RES( BT_OK ) ), - aCancelBtn( this, SW_RES( BT_CANCEL ) ), - aHelpBtn( this, SW_RES( BT_HELP ) ), - rView(rVw), - bColumn( bCol ) -{ - FreeResource(); - String aTmp( GetText() ); - if( bColumn ) - { - aTmp += aCol; - SetHelpId( FN_TABLE_INSERT_COL_DLG ); - } - else - { - aTmp += aRow; - SetHelpId( FN_TABLE_INSERT_ROW_DLG ); - } - SetText( aTmp ); -} - - - - diff --git a/sw/source/ui/table/insrc.src b/sw/source/ui/table/insrc.src deleted file mode 100644 index 49eda12dc9..0000000000 --- a/sw/source/ui/table/insrc.src +++ /dev/null @@ -1,155 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: insrc.src,v $ - * $Revision: 1.32 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "table.hrc" -#include "insrc.hrc" -#include "helpid.h" - // #define DLG_INS_ROW_COL 256 -ModalDialog DLG_INS_ROW_COL -{ - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 136 , 84 ) ; - /* ### ACHTUNG: Neuer Text in Resource? Einfügen : Einf³gen */ - Text [ en-US ] = "Insert" ; - Moveable = TRUE ; - OKButton BT_OK - { - Pos = MAP_APPFONT ( 80 , 6 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - DefButton = TRUE ; - }; - CancelButton BT_CANCEL - { - Pos = MAP_APPFONT ( 80 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - }; - HelpButton BT_HELP - { - Pos = MAP_APPFONT ( 80 , 43 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - }; - RadioButton CB_POS_BEFORE - { - Pos = MAP_APPFONT ( 12 , 49 ) ; - Size = MAP_APPFONT ( 56 , 10 ) ; - Text [ en-US ] = "~Before" ; - TabStop = TRUE ; - }; - RadioButton CB_POS_AFTER - { - Pos = MAP_APPFONT ( 12 , 62 ) ; - Size = MAP_APPFONT ( 56 , 10 ) ; - Text [ en-US ] = "A~fter" ; - TabStop = TRUE ; - Check = TRUE ; - }; - NumericField ED_COUNT - { - Border = TRUE ; - Pos = MAP_APPFONT ( 44 , 14 ) ; - Size = MAP_APPFONT ( 24 , 12 ) ; - TabStop = TRUE ; - Left = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Minimum = 1 ; - Maximum = 99 ; - Value = 1 ; - First = 1 ; - Last = 5 ; - }; - FixedLine FL_INS - { - Pos = MAP_APPFONT ( 6 , 3 ) ; - Size = MAP_APPFONT ( 68 , 8 ) ; - Text [ en-US ] = "Insert" ; - }; - FixedLine FL_POS - { - Pos = MAP_APPFONT ( 6 , 38 ) ; - Size = MAP_APPFONT ( 68 , 8 ) ; - Text [ en-US ] = "Position"; - }; - FixedText FT_COUNT - { - Pos = MAP_APPFONT ( 12 , 16 ) ; - Size = MAP_APPFONT ( 30 , 8 ) ; - Text [ en-US ] = "~Number" ; - Left = TRUE ; - }; - String STR_ROW - { - Text [ en-US ] = " Rows" ; - }; - String STR_COL - { - Text [ en-US ] = " Columns" ; - }; -}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index 8c44f8d8a8..d4b1a48e01 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -1575,6 +1575,10 @@ void SwPagePreView::GetState( SfxItemSet& rSet ) { switch(nWhich) { + case SID_BROWSER_MODE: + case FN_PRINT_LAYOUT: + rSet.DisableItem(nWhich); + break; case FN_START_OF_DOCUMENT: { if ( pPagePrevwLay->IsPageVisible( 1 ) ) @@ -2299,13 +2303,11 @@ void SwPagePreView::DocSzChgd( const Size &rSz ) aDocSz = rSz; - // die neue Anzahl von Seiten bestimmen - USHORT nNewCnt = GetViewShell()->GetNumPages(); - if( nNewCnt == mnPageCount ) - return; + // --> OD 2009-08-20 #i96726# + // Due to the multiple page layout it is needed to trigger recalculation + // of the page preview layout, even if the count of pages is not changing. + mnPageCount = GetViewShell()->GetNumPages(); - // dann eine neue Startseite berechnen - mnPageCount = nNewCnt; if( aVisArea.GetWidth() ) { ChgPage( SwPagePreViewWin::MV_CALC, TRUE ); @@ -2313,6 +2315,7 @@ void SwPagePreView::DocSzChgd( const Size &rSz ) aViewWin.Invalidate(); } + // <-- } /*-------------------------------------------------------------------- @@ -2421,6 +2424,10 @@ SfxPrinter* SwPagePreView::GetPrinter( BOOL bCreate ) USHORT SwPagePreView::SetPrinter( SfxPrinter *pNew, USHORT nDiffFlags, bool ) { ViewShell &rSh = *GetViewShell(); + SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false ); + if ( pOld && pOld->IsPrinting() ) + return SFX_PRINTERROR_BUSY; + SwEditShell &rESh = (SwEditShell&)rSh; //Buh... if( ( SFX_PRINTER_PRINTER | SFX_PRINTER_JOBSETUP ) & nDiffFlags ) { diff --git a/sw/source/ui/uiview/srcview.cxx b/sw/source/ui/uiview/srcview.cxx index 15ae539e0a..531589c7bd 100644 --- a/sw/source/ui/uiview/srcview.cxx +++ b/sw/source/ui/uiview/srcview.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -57,6 +57,7 @@ #include <sfx2/app.hxx> #include <sfx2/objface.hxx> #include <sfx2/viewfrm.hxx> +#include <sfx2/bindings.hxx> #include <sfx2/docfilt.hxx> #include <sfx2/fcontnr.hxx> #include <sfx2/request.hxx> @@ -457,17 +458,21 @@ void SwSrcView::Execute(SfxRequest& rReq) break; case SID_UNDO: pTextView->Undo(); + GetViewFrame()->GetBindings().InvalidateAll(FALSE); break; case SID_REDO: pTextView->Redo(); + GetViewFrame()->GetBindings().InvalidateAll(FALSE); break; case SID_REPEAT: break; case SID_CUT: - pTextView->Cut(); + if(pTextView->HasSelection()) + pTextView->Cut(); break; case SID_COPY: - pTextView->Copy(); + if(pTextView->HasSelection()) + pTextView->Copy(); break; case SID_PASTE: pTextView->Paste(); @@ -588,6 +593,8 @@ void SwSrcView::GetState(SfxItemSet& rSet) case SID_DIRECTEXPORTDOCASPDF: case SID_EXPORTDOC: case SID_REPEAT: + case SID_BROWSER_MODE: + case FN_PRINT_LAYOUT: rSet.DisableItem(nWhich); break; case SID_CUT: @@ -845,7 +852,7 @@ sal_Int32 SwSrcView::PrintSource( void SwSrcView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) { if ( rHint.ISA(SfxSimpleHint) && - ( + ( ((SfxSimpleHint&) rHint).GetId() == SFX_HINT_MODECHANGED || ( ((SfxSimpleHint&) rHint).GetId() == SFX_HINT_TITLECHANGED && diff --git a/sw/source/ui/uiview/uivwimp.cxx b/sw/source/ui/uiview/uivwimp.cxx index f6feb0ec0d..1930856661 100644 --- a/sw/source/ui/uiview/uivwimp.cxx +++ b/sw/source/ui/uiview/uivwimp.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -335,48 +335,14 @@ void SAL_CALL SwClipboardChangeListener::changedContents( const CLIP_NMSPC::Clip SfxBindings& rBind = pView->GetViewFrame()->GetBindings(); rBind.Invalidate( SID_PASTE ); - rBind.Invalidate( FN_PASTESPECIAL ); + rBind.Invalidate( SID_PASTE_SPECIAL ); rBind.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); } } void SwClipboardChangeListener::AddRemoveListener( BOOL bAdd ) { - try - { - do { - -#ifdef _DONT_WORD_FOR_WEBTOP_ -JP 4.7.2001: change for WebTop - get Clipboard from the Window. - Reference< XMultiServiceFactory > xFact( - ::comphelper::getProcessServiceFactory() ); - if( !xFact.is() ) - break; - Reference< XClipboard > xClipboard( xFact->createInstance( - ::rtl::OUString::createFromAscii( - "com.sun.star.datatransfer.clipboard.SystemClipboard" )), - UNO_QUERY ); -#else - Reference< XClipboard > xClipboard( - pView->GetEditWin().GetClipboard() ); -#endif - if( !xClipboard.is() ) - break; - - Reference< XClipboardNotifier > xClpbrdNtfr( xClipboard, UNO_QUERY ); - if( xClpbrdNtfr.is() ) - { - Reference< XClipboardListener > xClipEvtLstnr( this ); - if( bAdd ) - xClpbrdNtfr->addClipboardListener( xClipEvtLstnr ); - else - xClpbrdNtfr->removeClipboardListener( xClipEvtLstnr ); - } - } while ( FALSE ); - } - catch( const uno::Exception& ) - { - } + pView->AddRemoveClipboardListener( Reference< XClipboardListener >( this ), bAdd ); } diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 100e93cd93..4cfc987535 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -56,93 +56,46 @@ #include <svx/extrusionbar.hxx> #include <svx/fontworkbar.hxx> #include <unotxvw.hxx> -#ifndef _CMDID_H #include <cmdid.h> -#endif -#ifndef _SWHINTS_HXX #include <swhints.hxx> -#endif #include <swmodule.hxx> #include <inputwin.hxx> #include <chartins.hxx> #include <uivwimp.hxx> #include <uitool.hxx> #include <edtwin.hxx> -#ifndef _TEXTSH_HXX #include <textsh.hxx> -#endif -#ifndef _LISTSH_HXX #include <listsh.hxx> -#endif -#ifndef _TABSH_HXX #include <tabsh.hxx> -#endif -#ifndef _GRFSH_HXX #include <grfsh.hxx> -#endif -#ifndef _MEDIASH_HXX #include <mediash.hxx> -#endif -#ifndef _DOCSH_HXX #include <docsh.hxx> -#endif #include <frmsh.hxx> -#ifndef _OLESH_HXX #include <olesh.hxx> -#endif -#ifndef _DRAWSH_HXX #include <drawsh.hxx> -#endif -#ifndef _DRAWBASE_HXX #include <drawbase.hxx> -#endif -#ifndef _DRFORMSH_HXX #include <drformsh.hxx> -#endif -#ifndef _DRWTXTSH_HXX #include <drwtxtsh.hxx> -#endif -#ifndef _BEZIERSH_HXX #include <beziersh.hxx> -#endif -#ifndef _GLOBDOC_HXX #include <globdoc.hxx> -#endif #include <scroll.hxx> -#ifndef _GLOBDOC_HXX #include <globdoc.hxx> -#endif #include <navipi.hxx> #include <gloshdl.hxx> #include <usrpref.hxx> -#ifndef _SRCVIEW_HXX #include <srcview.hxx> -#endif #include <doc.hxx> -#ifndef _WDOCSH_HXX +#include <drawdoc.hxx> #include <wdocsh.hxx> -#endif -#ifndef _WVIEW_HXX #include <wview.hxx> -#endif #include <workctrl.hxx> #include <wrtsh.hxx> -#ifndef _BARCFG_HXX #include <barcfg.hxx> -#endif -#ifndef _PVIEW_HXX #include <pview.hxx> -#endif #include <swdtflvr.hxx> -#ifndef _VIEW_HRC #include <view.hrc> -#endif -#ifndef _GLOBDOC_HRC #include <globdoc.hrc> -#endif -#ifndef _FRMUI_HRC #include <frmui.hrc> -#endif #include <cfgitems.hxx> #include <prtopt.hxx> #include <swprtopt.hxx> @@ -152,9 +105,7 @@ #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/scanner/ScannerContext.hpp> #include <com/sun/star/scanner/XScannerManager.hpp> -#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ #include <toolkit/unohlp.hxx> -#endif #include <rtl/ustrbuf.hxx> #include <xmloff/xmluconv.hxx> @@ -673,7 +624,7 @@ void SwView::_CheckReadonlyState() SID_UNDO, SID_REDO, SID_REPEAT, SID_PASTE, SID_PASTE_UNFORMATTED, - FN_PASTESPECIAL, SID_SBA_BRW_INSERT, + SID_PASTE_SPECIAL, SID_SBA_BRW_INSERT, SID_BACKGROUND_COLOR, FN_INSERT_BOOKMARK, SID_CHARMAP, FN_INSERT_SOFT_HYPHEN, FN_INSERT_HARDHYPHEN, FN_INSERT_HARD_SPACE, FN_INSERT_BREAK, @@ -1471,7 +1422,7 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue > { pValue->Value >>= bSelectedFrame; bGotIsSelectedFrame = sal_True; - } + } pValue++; } if (bGotVisibleBottom) @@ -1781,7 +1732,18 @@ void SwView::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) CreateTab(); else KillTab(); - SfxBoolItem aItem( SID_FM_DESIGN_MODE, !GetDocShell()->IsReadOnly()); + bool bReadonly = GetDocShell()->IsReadOnly(); + //#i76332# if document is to be opened in alive-mode then this has to be regarded while switching from readonly-mode to edit-mode + if( !bReadonly ) + { + SwDrawDocument * pDrawDoc = 0; + if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (GetDocShell()->GetDoc()->GetDrawModel() ) ) ) + { + if( !pDrawDoc->GetOpenInDesignMode() ) + break;// don't touch the design mode + } + } + SfxBoolItem aItem( SID_FM_DESIGN_MODE, !bReadonly); GetDispatcher().Execute( SID_FM_DESIGN_MODE, SFX_CALLMODE_ASYNCHRON, &aItem, 0L ); } diff --git a/sw/source/ui/uiview/view2.cxx b/sw/source/ui/uiview/view2.cxx index 41a9ada943..493daabe92 100644 --- a/sw/source/ui/uiview/view2.cxx +++ b/sw/source/ui/uiview/view2.cxx @@ -650,7 +650,7 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) break; case FN_REDLINE_ACCEPT_DIRECT: case FN_REDLINE_REJECT_DIRECT: - { + { SwContentAtPos aCntntAtPos( SwContentAtPos::SW_REDLINE ); Point aCrsrPos = pWrtShell->GetCrsrDocPos( sal_True ); if( pWrtShell->GetContentAtPos( aCrsrPos, aCntntAtPos ) ) @@ -1067,23 +1067,23 @@ void __EXPORT SwView::Execute(SfxRequest &rReq) } break; case SID_RECHECK_DOCUMENT: - { + { SwDocShell* pDocShell = GetDocShell(); SwDoc* pDoc = pDocShell->GetDoc(); uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( pDoc->GetGCIterator() ); if( xGCIterator.is() ) { xGCIterator->resetIgnoreRules(); - } + } // reset ignore lists pDoc->SpellItAgainSam( sal_True, sal_False, sal_False ); - // clear ignore dictionary + // clear ignore dictionary uno::Reference< linguistic2::XDictionary > xDictionary( SvxGetIgnoreAllList(), uno::UNO_QUERY ); if( xDictionary.is() ) xDictionary->clear(); // put cursor to the start of the document pWrtShell->SttDoc(); - } + } // no break; - but call spell/grammar dialog case FN_SPELL_GRAMMAR_DIALOG: { @@ -1233,7 +1233,7 @@ void SwView::StateStatusLine(SfxItemSet &rSet) if (nPageCnt != nCnt) // Basic benachrichtigen { nPageCnt = nCnt; - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, GetViewFrame()->GetObjectShell()), FALSE); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_PAGE_COUNT, SwDocShell::GetEventName(STR_SW_EVENT_PAGE_COUNT), GetViewFrame()->GetObjectShell()), FALSE); } } break; @@ -1404,7 +1404,7 @@ void SwView::StateStatusLine(SfxItemSet &rSet) } } } - + //#outline level, removed by zhaojianwei //const SwNumRule* pNumRule = rShell.GetCurNumRule(); //if (pNumRule) // Cursor in Numerierung @@ -1443,11 +1443,11 @@ void SwView::StateStatusLine(SfxItemSet &rSet) // } //}//<-removed end ,zhaojianwei - //-->#outline level,added by zhaojianwei + //-->#outline level,added by zhaojianwei const SwNumRule* pNumRule = rShell.GetCurNumRule(); const bool bOutlineNum = pNumRule ? pNumRule->IsOutlineRule() : 0; //((SwTxtFmtColl*)rShell.GetCrsr()->GetNode()->GetTxtNode()->GetFmtColl())->IsAssignedToListLevelOfOutlineStyle(); - + if (pNumRule && !bOutlineNum ) // Cursor in Numerierung { BYTE nNumLevel = rShell.GetNumLevel(); @@ -1481,9 +1481,9 @@ void SwView::StateStatusLine(SfxItemSet &rSet) } } } - if( sStr.Len() ) + if( sStr.Len() ) sStr.AppendAscii(sStatusDelim); - sStr += SW_RESSTR(STR_NUM_LEVEL); + sStr += SW_RESSTR(STR_NUM_LEVEL); sStr += String::CreateFromInt32( nNumLevel + 1 ); } @@ -1495,9 +1495,9 @@ void SwView::StateStatusLine(SfxItemSet &rSet) sStr.AppendAscii(sStatusComma); if( bOutlineNum ) { - sStr += SW_RESSTR(STR_OUTLINE_NUMBERING); + sStr += SW_RESSTR(STR_OUTLINE_NUMBERING); sStr.AppendAscii(sStatusDelim); - sStr += SW_RESSTR(STR_NUM_LEVEL); + sStr += SW_RESSTR(STR_NUM_LEVEL); } else sStr += SW_RESSTR(STR_NUM_OUTLINE); @@ -2469,8 +2469,8 @@ IMPL_LINK( SwView, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg ) } void SwView::ExecuteScan( SfxRequest& rReq ) -{ - if (pViewImpl) +{ + if (pViewImpl) pViewImpl->ExecuteScan(rReq) ; } diff --git a/sw/source/ui/uiview/viewprt.cxx b/sw/source/ui/uiview/viewprt.cxx index 0db891129f..48435f5f1d 100644 --- a/sw/source/ui/uiview/viewprt.cxx +++ b/sw/source/ui/uiview/viewprt.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -143,6 +143,10 @@ void SetPrinter( IDocumentDeviceAccess* pIDDA, SfxPrinter* pNew, BOOL bWeb ) USHORT __EXPORT SwView::SetPrinter(SfxPrinter* pNew, USHORT nDiffFlags, bool ) { SwWrtShell &rSh = GetWrtShell(); + SfxPrinter* pOld = rSh.getIDocumentDeviceAccess()->getPrinter( false ); + if ( pOld && pOld->IsPrinting() ) + return SFX_PRINTERROR_BUSY; + if ( (SFX_PRINTER_JOBSETUP | SFX_PRINTER_PRINTER) & nDiffFlags ) { rSh.getIDocumentDeviceAccess()->setPrinter( pNew, true, true ); diff --git a/sw/source/ui/uno/swdetect.cxx b/sw/source/ui/uno/swdetect.cxx index f20309a4ab..c48834b40d 100644 --- a/sw/source/ui/uno/swdetect.cxx +++ b/sw/source/ui/uno/swdetect.cxx @@ -217,7 +217,7 @@ SwFilterDetect::~SwFilterDetect() BOOL bIsStorage = aMedium.IsStorage(); if ( bIsStorage ) { - uno::Reference< embed::XStorage > xStorage = aMedium.GetStorage(); + uno::Reference< embed::XStorage > xStorage = aMedium.GetStorage( sal_False ); if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE ) { // error during storage creation means _here_ that the medium diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx index a2133bea18..4801259cd7 100644 --- a/sw/source/ui/uno/unoatxt.cxx +++ b/sw/source/ui/uno/unoatxt.cxx @@ -416,7 +416,8 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR if(pxCursor) { SwPaM* pUnoCrsr = pxCursor->GetPaM(); - bRet |= (true == pxCursor->GetDoc()->Copy( *pUnoCrsr, aPos, false )); + bRet = pxCursor->GetDoc()->CopyRange( *pUnoCrsr, aPos, false ) + || bRet; } else { @@ -424,7 +425,8 @@ sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextR if(pBkmk && pBkmk->IsExpanded()) { SwPaM aTmp(pBkmk->GetOtherMarkPos(), pBkmk->GetMarkPos()); - bRet |= (true == pxRange->GetDoc()->Copy(aTmp, aPos, false)); + bRet = pxRange->GetDoc()->CopyRange(aTmp, aPos, false) + || bRet; } } } diff --git a/sw/source/ui/uno/unomailmerge.cxx b/sw/source/ui/uno/unomailmerge.cxx index 92ad479309..d5b883053a 100644 --- a/sw/source/ui/uno/unomailmerge.cxx +++ b/sw/source/ui/uno/unomailmerge.cxx @@ -1,7 +1,7 @@ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * + * * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite @@ -831,9 +831,9 @@ uno::Any SAL_CALL SwXMailMerge::execute( DBG_ASSERT( !pOldSrc || pOldSrc == this, "Ooops... different event source already set." ); pMgr->SetMailMergeEvtSrc( this ); // launch events for listeners - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, xCurDocSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xCurDocSh)); BOOL bSucc = pMgr->MergeNew( aMergeDesc ); - SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, xCurDocSh)); + SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), xCurDocSh)); pMgr->SetMailMergeEvtSrc( pOldSrc ); diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx index 4818a7973a..2f7716bac1 100644 --- a/sw/source/ui/uno/unomod.cxx +++ b/sw/source/ui/uno/unomod.cxx @@ -125,7 +125,10 @@ enum SwPrintSettingsPropertyHandles HANDLE_PRINTSET_PAPER_FROM_SETUP, HANDLE_PRINTSET_TABLES, HANDLE_PRINTSET_SINGLE_JOBS, - HANDLE_PRINTSET_EMPTY_PAGES + HANDLE_PRINTSET_EMPTY_PAGES, + HANDLE_PRINTSET_PROSPECT_RTL, + HANDLE_PRINTSET_PLACEHOLDER, + HANDLE_PRINTSET_HIDDEN_TEXT }; static ChainablePropertySetInfo * lcl_createViewSettingsInfo() @@ -186,14 +189,17 @@ static ChainablePropertySetInfo * lcl_createPrintSettingsInfo() { RTL_CONSTASCII_STRINGPARAM ( "PrintControls" ), HANDLE_PRINTSET_CONTROLS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintDrawings" ), HANDLE_PRINTSET_DRAWINGS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintGraphics" ), HANDLE_PRINTSET_GRAPHICS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, + { RTL_CONSTASCII_STRINGPARAM ( "PrintHiddenText"), HANDLE_PRINTSET_HIDDEN_TEXT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintLeftPages" ), HANDLE_PRINTSET_LEFT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintPageBackground" ), HANDLE_PRINTSET_PAGE_BACKGROUND , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintProspect" ), HANDLE_PRINTSET_PROSPECT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, + { RTL_CONSTASCII_STRINGPARAM ( "PrintProspectRTL" ), HANDLE_PRINTSET_PROSPECT_RTL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintReversed" ), HANDLE_PRINTSET_REVERSED , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintRightPages" ), HANDLE_PRINTSET_RIGHT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintFaxName" ), HANDLE_PRINTSET_FAX_NAME , CPPUTYPE_OUSTRING, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintPaperFromSetup" ), HANDLE_PRINTSET_PAPER_FROM_SETUP , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintTables" ), HANDLE_PRINTSET_TABLES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, + { RTL_CONSTASCII_STRINGPARAM ( "PrintTextPlaceholder"), HANDLE_PRINTSET_PLACEHOLDER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintSingleJobs" ), HANDLE_PRINTSET_SINGLE_JOBS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { RTL_CONSTASCII_STRINGPARAM ( "PrintEmptyPages" ), HANDLE_PRINTSET_EMPTY_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0}, { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 } @@ -456,6 +462,24 @@ void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, throw lang::IllegalArgumentException(); } break; + case HANDLE_PRINTSET_PROSPECT_RTL: + { + bVal = *(sal_Bool*)rValue.getValue(); + mpPrtOpt->SetPrintProspect_RTL(bVal); + } + break; + case HANDLE_PRINTSET_PLACEHOLDER: + { + bVal = *(sal_Bool*)rValue.getValue(); + mpPrtOpt->SetPrintTextPlaceholder(bVal); + } + break; + case HANDLE_PRINTSET_HIDDEN_TEXT: + { + bVal = *(sal_Bool*)rValue.getValue(); + mpPrtOpt->SetPrintHiddenText(bVal); + } + break; default: throw UnknownPropertyException(); } @@ -550,6 +574,21 @@ void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, rValue <<= mpPrtOpt->GetFaxName(); } break; + case HANDLE_PRINTSET_PROSPECT_RTL: + { + rValue <<= mpPrtOpt->IsPrintProspect_RTL(); + } + break; + case HANDLE_PRINTSET_PLACEHOLDER: + { + rValue <<= mpPrtOpt->IsPrintTextPlaceholder(); + } + break; + case HANDLE_PRINTSET_HIDDEN_TEXT: + { + rValue <<= mpPrtOpt->IsPrintHiddenText(); + } + break; default: throw UnknownPropertyException(); } @@ -1024,3 +1063,4 @@ Sequence< OUString > SwXViewSettings::getSupportedServiceNames(void) throw( Runt pArray[0] = C2U("com.sun.star.text.ViewSettings"); return aRet; } + diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx index df5d1cfaee..a03fc19f68 100644 --- a/sw/source/ui/uno/unotxdoc.cxx +++ b/sw/source/ui/uno/unotxdoc.cxx @@ -87,7 +87,13 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/beans/XFastPropertySet.hpp> #include <com/sun/star/document/RedlineDisplayType.hpp> +#include <com/sun/star/document/XDocumentEventBroadcaster.hpp> +#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/script/XInvocation.hpp> +#include <com/sun/star/reflection/XIdlClassProvider.hpp> #include <svx/linkmgr.hxx> #include <svx/unofill.hxx> #include <svx/unolingu.hxx> @@ -245,15 +251,23 @@ sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rI Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType ) throw(RuntimeException) { Any aRet = SwXTextDocumentBaseClass::queryInterface(rType); - if(aRet.getValueType() == getVoidCppuType()) + if ( !aRet.hasValue() ) aRet = SfxBaseModel::queryInterface(rType); - if(aRet.getValueType() == getVoidCppuType() && + if ( !aRet.hasValue() && rType == ::getCppuType((Reference<lang::XMultiServiceFactory>*)0)) { Reference<lang::XMultiServiceFactory> xTmp = this; aRet <<= xTmp; } - if(aRet.getValueType() == getVoidCppuType()) + + if ( !aRet.hasValue() + && rType != ::getCppuType((Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0) + && rType != ::getCppuType((Reference< com::sun::star::frame::XController>*)0) + && rType != ::getCppuType((Reference< com::sun::star::frame::XFrame>*)0) + && rType != ::getCppuType((Reference< com::sun::star::script::XInvocation>*)0) + && rType != ::getCppuType((Reference< com::sun::star::reflection::XIdlClassProvider>*)0) + && rType != ::getCppuType((Reference< com::sun::star::beans::XFastPropertySet>*)0) + && rType != ::getCppuType((Reference< com::sun::star::awt::XWindow>*)0)) { GetNumberFormatter(); if(xNumFmtAgg.is()) diff --git a/sw/source/ui/utlui/content.cxx b/sw/source/ui/utlui/content.cxx index eaf9bb5c66..10a94901f5 100644 --- a/sw/source/ui/utlui/content.cxx +++ b/sw/source/ui/utlui/content.cxx @@ -906,16 +906,17 @@ SwContentTree::SwContentTree(Window* pParent, const ResId& rResId) : sRename(SW_RES(ST_RENAME)), sReadonlyIdx(SW_RES(ST_READONLY_IDX)), sInvisible(SW_RES(ST_INVISIBLE)), - sPostItShow(SW_RES(ST_POSTIT_SHOW)), - sPostItHide(SW_RES(ST_POSTIT_HIDE)), - sPostItDelete(SW_RES(ST_POSTIT_DELETE)), + + sPostItShow(SW_RES(ST_POSTIT_SHOW)), + sPostItHide(SW_RES(ST_POSTIT_HIDE)), + sPostItDelete(SW_RES(ST_POSTIT_DELETE)), pHiddenShell(0), - pActiveShell(0), - pConfig(SW_MOD()->GetNavigationConfig()), + pActiveShell(0), + pConfig(SW_MOD()->GetNavigationConfig()), nActiveBlock(0), - nHiddenBlock(0), + nHiddenBlock(0), nRootType(USHRT_MAX), nLastSelType(USHRT_MAX), @@ -2929,6 +2930,7 @@ void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode) break; case CONTENT_TYPE_POSTIT: + pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell(); if(nMode == EDIT_MODE_DELETE) { if (((SwPostItContent*)pCnt)->IsPostIt()) @@ -3097,6 +3099,7 @@ void SwContentTree::GotoContent(SwContent* pCnt) } break; case CONTENT_TYPE_POSTIT: + pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell(); if (((SwPostItContent*)pCnt)->IsPostIt()) pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt()); else diff --git a/sw/source/ui/utlui/initui.cxx b/sw/source/ui/utlui/initui.cxx index aca79b9e1c..9f90efe028 100644 --- a/sw/source/ui/utlui/initui.cxx +++ b/sw/source/ui/utlui/initui.cxx @@ -54,6 +54,7 @@ #ifndef _DBMGR_HXX #include <dbmgr.hxx> #endif +#include <svtools/syslocale.hxx> #include <unomid.h> @@ -261,7 +262,7 @@ ImpAutoFmtNameListLoader::ImpAutoFmtNameListLoader( SvStringsDtor& rLst ) p->SearchAndReplace(C2S("%1"), C2S(",,")); p->SearchAndReplace(C2S("%2"), C2S("''")); #else - LocaleDataWrapper& rLclD = GetAppLocaleData(); + const LocaleDataWrapper& rLclD = SvtSysLocale().GetLocaleData(); //unter richtigen Betriebssystemen funktioniert es auch so p->SearchAndReplace(C2S("%1"), rLclD.getDoubleQuotationMarkStart()); p->SearchAndReplace(C2S("%2"), rLclD.getDoubleQuotationMarkEnd()); diff --git a/sw/source/ui/utlui/numfmtlb.cxx b/sw/source/ui/utlui/numfmtlb.cxx index 18f57d6ec1..d6ea01d58b 100644 --- a/sw/source/ui/utlui/numfmtlb.cxx +++ b/sw/source/ui/utlui/numfmtlb.cxx @@ -120,7 +120,7 @@ void NumFormatListBox::Init(short nFormatType, BOOL bUsrFmts) if (pView) eCurLanguage = pView->GetWrtShell().GetCurLang(); else - eCurLanguage = SvxLocaleToLanguage( GetAppLocaleData().getLocale() ); + eCurLanguage = SvxLocaleToLanguage( SvtSysLocale().GetLocaleData().getLocale() ); if (bUsrFmts == FALSE) { diff --git a/sw/source/ui/utlui/uitool.cxx b/sw/source/ui/utlui/uitool.cxx index ec6d4a7a64..e9dcc6785a 100644 --- a/sw/source/ui/utlui/uitool.cxx +++ b/sw/source/ui/utlui/uitool.cxx @@ -39,6 +39,7 @@ #include <unotools/collatorwrapper.hxx> #include <svtools/urihelper.hxx> #include <svtools/stritem.hxx> +#include <svtools/syslocale.hxx> #include <sfx2/app.hxx> #include <sfx2/docfile.hxx> #include <sfx2/docfilt.hxx> @@ -732,7 +733,7 @@ SwTwips GetTableWidth( SwFrmFmt* pFmt, SwTabCols& rCols, USHORT *pPercent, String GetAppLangDateTimeString( const DateTime& rDT ) { - LocaleDataWrapper& rAppLclData = GetAppLocaleData(); + const LocaleDataWrapper& rAppLclData = SvtSysLocale().GetLocaleData(); String sRet( rAppLclData.getDate( rDT )); ( sRet += ' ' ) += rAppLclData.getTime( rDT, FALSE, FALSE ); return sRet; diff --git a/sw/source/ui/utlui/utlui.src b/sw/source/ui/utlui/utlui.src index 7a45772630..34d9186fa6 100644 --- a/sw/source/ui/utlui/utlui.src +++ b/sw/source/ui/utlui/utlui.src @@ -226,7 +226,7 @@ String STR_CONTENT_TYPE_DRAWOBJECT }; String STR_CONTENT_TYPE_POSTIT { - Text [ en-US ] = "Notes" ; + Text [ en-US ] = "Comments" ; }; String STR_CONTENT_TYPE_SINGLE_OUTLINE { @@ -270,7 +270,7 @@ String STR_CONTENT_TYPE_SINGLE_INDEX }; String STR_CONTENT_TYPE_SINGLE_POSTIT { - Text [ en-US ] = "Note" ; + Text [ en-US ] = "Comment" ; }; String STR_CONTENT_TYPE_SINGLE_DRAWOBJECT { diff --git a/sw/source/ui/wrtsh/select.cxx b/sw/source/ui/wrtsh/select.cxx index f4d35d9d48..21f1882f9e 100644 --- a/sw/source/ui/wrtsh/select.cxx +++ b/sw/source/ui/wrtsh/select.cxx @@ -73,6 +73,13 @@ using namespace ::com::sun::star::util; static long nStartDragX = 0, nStartDragY = 0; static BOOL bStartDrag = FALSE; +void SwWrtShell::Invalidate() +{ + // to avoid making the slot volatile, invalidate it everytime if something could have been changed + // this is still much cheaper than asking for the state every 200 ms (and avoid background processing) + GetView().GetViewFrame()->GetBindings().Invalidate( FN_STAT_SELMODE ); +} + BOOL SwWrtShell::SelNearestWrd() { MV_KONTEXT(this); @@ -140,8 +147,9 @@ long SwWrtShell::SelAll() { const BOOL bLockedView = IsViewLocked(); LockView( TRUE ); - { + if(bBlockMode) + LeaveBlockMode(); MV_KONTEXT(this); BOOL bMoveTable = FALSE; SwPosition *pStartPos = 0; @@ -191,9 +199,7 @@ long SwWrtShell::SelAll() } } EndSelect(); - LockView( bLockedView ); - return 1; } @@ -337,6 +343,7 @@ void SwWrtShell::UnSelectFrm() // Rahmenselektion aufheben mit garantiert ungueltiger Position Point aPt(LONG_MIN, LONG_MIN); SelectObj(aPt, 0); + GetView().LeaveDrawCreate(); SwTransferable::ClearSelection( *this ); } @@ -375,6 +382,7 @@ long SwWrtShell::ResetSelect(const Point *,BOOL) */ GetChgLnk().Call(this); } + Invalidate(); SwTransferable::ClearSelection( *this ); return 1; } @@ -409,6 +417,7 @@ void SwWrtShell::SttSelect() fnKillSel = &SwWrtShell::Ignore; fnSetCrsr = &SwWrtShell::SetCrsr; bInSelect = TRUE; + Invalidate(); SwTransferable::CreateSelection( *this ); } /* @@ -577,6 +586,7 @@ void SwWrtShell::EnterStdMode() fnKillSel = &SwWrtShell::ResetSelect; } } + Invalidate(); SwTransferable::ClearSelection( *this ); } @@ -655,6 +665,7 @@ void SwWrtShell::EnterAddMode() bExtMode = FALSE; if(SwCrsrShell::HasSelection()) CreateCrsr(); + Invalidate(); } @@ -665,6 +676,7 @@ void SwWrtShell::LeaveAddMode() fnKillSel = &SwWrtShell::ResetSelect; fnSetCrsr = &SwWrtShell::SetCrsrKillSel; bAddMode = FALSE; + Invalidate(); } /* @@ -677,6 +689,7 @@ void SwWrtShell::EnterBlockMode() EnterStdMode(); bBlockMode = TRUE; CrsrToBlockCrsr(); + Invalidate(); } @@ -686,6 +699,7 @@ void SwWrtShell::LeaveBlockMode() bBlockMode = FALSE; BlockCrsrToCrsr(); EndSelect(); + Invalidate(); } // Einfuegemodus @@ -700,6 +714,7 @@ void SwWrtShell::SetInsMode( BOOL bOn ) GetView().GetViewFrame()->GetBindings().SetState( aTmp ); StartAction(); EndAction(); + Invalidate(); } //Overwrite mode is incompatible with red-lining void SwWrtShell::SetRedlineModeAndCheckInsMode( USHORT eMode ) @@ -744,6 +759,7 @@ void SwWrtShell::EnterSelFrmMode(const Point *pPos) fnDrag = &SwWrtShell::BeginFrmDrag; fnEndDrag = &SwWrtShell::UpdateLayoutFrm; SwBaseShell::SetFrmMode( FLY_DRAG_START, this ); + Invalidate(); } @@ -756,6 +772,7 @@ void SwWrtShell::LeaveSelFrmMode() bStartDrag = FALSE; Edit(); SwBaseShell::SetFrmMode( FLY_DRAG_END, this ); + Invalidate(); } /*------------------------------------------------------------------------ Beschreibung: Rahmengebundenes Macro ausfuehren @@ -799,6 +816,7 @@ long SwWrtShell::UpdateLayoutFrm(const Point *pPt, BOOL ) long SwWrtShell::ToggleAddMode() { bAddMode ? LeaveAddMode(): EnterAddMode(); + Invalidate(); return !bAddMode; } @@ -806,6 +824,7 @@ long SwWrtShell::ToggleAddMode() long SwWrtShell::ToggleBlockMode() { bBlockMode ? LeaveBlockMode(): EnterBlockMode(); + Invalidate(); return !bBlockMode; } @@ -813,6 +832,7 @@ long SwWrtShell::ToggleBlockMode() long SwWrtShell::ToggleExtMode() { bExtMode ? LeaveExtMode() : EnterExtMode(); + Invalidate(); return !bExtMode; } /* diff --git a/sw/source/ui/wrtsh/wrtsh1.cxx b/sw/source/ui/wrtsh/wrtsh1.cxx index 3e8b72843b..6294722f46 100644 --- a/sw/source/ui/wrtsh/wrtsh1.cxx +++ b/sw/source/ui/wrtsh/wrtsh1.cxx @@ -70,7 +70,6 @@ #include <svx/extrusionbar.hxx> #include <svx/fontworkbar.hxx> #include <fmtftn.hxx> -#include <fmthbsh.hxx> #include <fmtpdsc.hxx> #ifndef _WDOCSH_HXX #include <wdocsh.hxx> @@ -245,6 +244,7 @@ void SwWrtShell::Insert( const String &rStr ) BOOL bStarted = FALSE, bHasSel = HasSelection(), bCallIns = bIns /*|| bHasSel*/; + bool bDeleted = false; if( bHasSel || ( !bIns && SelectHiddenRange() ) ) { @@ -268,7 +268,7 @@ void SwWrtShell::Insert( const String &rStr ) StartUndo(UNDO_REPLACE, &aRewriter); bStarted = TRUE; - DelRight(); + bDeleted = DelRight() != 0; } /* @@ -283,7 +283,8 @@ JP 21.01.98: Ueberschreiben ueberschreibt nur die Selektion, nicht das } else */ - bCallIns ? SwEditShell::Insert( rStr ) : SwEditShell::Overwrite( rStr ); + bCallIns ? + SwEditShell::Insert2( rStr, bDeleted ) : SwEditShell::Overwrite( rStr ); if( bStarted ) @@ -669,10 +670,10 @@ void SwWrtShell::MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& try { sal_Int32 nState = xObj->getCurrentState(); - if ( nState == ::com::sun::star::embed::EmbedStates::INPLACE_ACTIVE + if ( nState == ::com::sun::star::embed::EmbedStates::INPLACE_ACTIVE || nState == ::com::sun::star::embed::EmbedStates::UI_ACTIVE ) { - SfxInPlaceClient* pCli = + SfxInPlaceClient* pCli = GetView().FindIPClient( xObj.GetObject(), &(GetView().GetEditWin()) ); if ( pCli ) { @@ -1103,7 +1104,7 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) pDoc->FindNumRulePtr(pColl->GetNumRule( FALSE ).GetValue()); if ( !pDirectCollRule ) { - pCollRule = 0L; + pCollRule = 0; } } // --> OD 2006-11-20 #i71764# @@ -1141,12 +1142,9 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) { // check, if numbering of the outline level of the pararaph // style is active. If not, activate this outline level. - //nActivateOutlineLvl = pColl->GetOutlineLevel(); //#outline level,zhaojianwei - //ASSERT( /*nActivateOutlineLvl >= 0 &&*/ nActivateOutlineLvl < MAXLEVEL, nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel(); ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(), //<-end,zhaojianwei "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" ); - //if ( /*nActivateOutlineLvl >= 0 &&*/ nActivateOutlineLvl < MAXLEVEL && //#outline level,zhaojianwei if ( pColl->IsAssignedToListLevelOfOutlineStyle() && //<-end,zhaojianwei pCollRule->Get( static_cast<USHORT>(nActivateOutlineLvl) ).GetNumberingType() == SVX_NUM_NUMBER_NONE ) @@ -1162,31 +1160,40 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) } else { + // --> OD 2009-08-27 #i101234# // activate outline numbering, because from the precondition // it's known, that <SwEdit::HasNumber()> == FALSE bActivateOutlineRule = true; - //nActivateOutlineLvl = pColl->GetOutlineLevel(); //#outline level,zhaojianwei nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei } } else if ( !pNumRule ) { - // activate outline numbering, because from the precondition - // it's known, that <SwEdit::HasNumber()> == FALSE - bActivateOutlineRule = true; - //nActivateOutlineLvl = pColl->GetOutlineLevel(); //#outline level,zhaojianwei + // --> OD 2009-08-27 #i101234# + // Check, if corresponding list level of the outline numbering + // has already a numbering format set. nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei,need further consideration + if ( pCollRule->Get( static_cast<USHORT>(nActivateOutlineLvl) ).GetNumberingType() + == SVX_NUM_NUMBER_NONE ) + { + // activate outline numbering, because from the precondition + // it's known, that <SwEdit::HasNumber()> == FALSE + bActivateOutlineRule = true; + } + else + { + // turning on outline numbering at current cursor position + bContinueFoundNumRule = true; + } + // <-- } else { // check, if numbering of the outline level of the pararaph // style is active. If not, activate this outline level. - //nActivateOutlineLvl = pColl->GetOutlineLevel(); nActivateOutlineLvl = pColl->GetAssignedOutlineStyleLevel();//#outline level,zhaojianwei - //ASSERT( /*nActivateOutlineLvl >= 0 &&*/ nActivateOutlineLvl < MAXLEVEL, ASSERT( pColl->IsAssignedToListLevelOfOutlineStyle(),//#outline level,zhaojianwei "<SwWrtShell::NumOrBulletOn(..)> - paragraph style with outline rule, but no outline level" ); - //if ( /*nActivateOutlineLvl >= 0 &&*/ nActivateOutlineLvl < MAXLEVEL && if ( pColl->IsAssignedToListLevelOfOutlineStyle() &&//#outline level,zhaojianwei pCollRule->Get( static_cast<USHORT>(nActivateOutlineLvl) ).GetNumberingType() == SVX_NUM_NUMBER_NONE ) @@ -1212,12 +1219,12 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) { if ( !pNumRule->IsAutoRule() ) { - pNumRule = 0L; + pNumRule = 0; } else if ( pNumRule == GetDoc()->GetOutlineNumRule() && !bActivateOutlineRule && !bContinueFoundNumRule ) { - pNumRule = 0L; + pNumRule = 0; } } // <-- @@ -1229,7 +1236,7 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) if ( !pNumRule ) { pNumRule = GetDoc()->SearchNumRule( *GetCrsr()->GetPoint(), - FALSE, bNum, FALSE, 0, + false, bNum, false, 0, sContinuedListId ); bContinueFoundNumRule = pNumRule != 0; } @@ -1290,11 +1297,12 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) } else { + // --> OD 2009-08-27 #i95907# + const SvxNumberFormat::SvxNumPositionAndSpaceMode ePosAndSpaceMode( + numfunc::GetDefaultPositionAndSpaceMode() ); // --> OD 2008-02-11 #newlistlevelattrs# - SwNumRule aNumRule( GetUniqueNumRuleName(), - // --> OD 2008-06-06 #i89178# - numfunc::GetDefaultPositionAndSpaceMode() ); - // <-- + SwNumRule aNumRule( GetUniqueNumRuleName(), ePosAndSpaceMode ); + // <-- // <-- // Zeichenvorlage an die Numerierung haengen SwCharFmt* pChrFmt; @@ -1315,9 +1323,10 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) pChrFmt = GetCharFmtFromPool( RES_POOLCHR_BUL_LEVEL ); } - SwTxtNode * pTxtNode = - GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); - USHORT nWidthOfTabs = pTxtNode->GetWidthOfLeadingTabs(); + const SwTxtNode* pTxtNode = GetCrsr()->GetPoint()->nNode.GetNode().GetTxtNode(); + const SwTwips nWidthOfTabs = pTxtNode + ? pTxtNode->GetWidthOfLeadingTabs() + : 0; GetDoc()->RemoveLeadingWhiteSpace( *GetCrsr()->GetPoint() ); const bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh); @@ -1339,16 +1348,21 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) aFmt.SetNumberingType(SVX_NUM_CHAR_SPECIAL); } - if(bHtml && nLvl) - { - // 1/2" fuer HTML - aFmt.SetLSpace(720); - aFmt.SetAbsLSpace(nLvl * 720); - } - else if ( nWidthOfTabs > 0 ) + // --> OD 2009-08-26 #i95907# + if ( ePosAndSpaceMode == SvxNumberFormat::LABEL_WIDTH_AND_POSITION ) { - aFmt.SetAbsLSpace(nWidthOfTabs + nLvl * 720); + if(bHtml && nLvl) + { + // 1/2" fuer HTML + aFmt.SetLSpace(720); + aFmt.SetAbsLSpace(nLvl * 720); + } + else if ( nWidthOfTabs > 0 ) + { + aFmt.SetAbsLSpace(nWidthOfTabs + nLvl * 720); + } } + // <-- // --> FME 2005-01-21 #i38904# Default alignment for // numbering/bullet should be rtl in rtl paragraph: @@ -1361,6 +1375,21 @@ void SwWrtShell::NumOrBulletOn(BOOL bNum) aNumRule.Set( nLvl, aFmt ); } + // --> OD 2009-08-26 #i95907# + if ( pTxtNode && + ePosAndSpaceMode == SvxNumberFormat::LABEL_ALIGNMENT ) + { + short nTxtNodeFirstLineOffset( 0 ); + pTxtNode->GetFirstLineOfsWithNum( nTxtNodeFirstLineOffset ); + const SwTwips nTxtNodeIndent = pTxtNode->GetLeftMarginForTabCalculation() + + nTxtNodeFirstLineOffset; + if ( ( nTxtNodeIndent + nWidthOfTabs ) != 0 ) + { + const SwTwips nIndentChange = nTxtNodeIndent + nWidthOfTabs; + aNumRule.ChangeIndent( nIndentChange ); + } + } + // <-- // --> OD 2008-02-08 #newlistlevelattrs# // reset indent attribute on applying list style // --> OD 2008-03-17 #refactorlists# diff --git a/sw/source/ui/wrtsh/wrtsh2.cxx b/sw/source/ui/wrtsh/wrtsh2.cxx index 28fd1b6934..0927372db9 100644 --- a/sw/source/ui/wrtsh/wrtsh2.cxx +++ b/sw/source/ui/wrtsh/wrtsh2.cxx @@ -93,10 +93,13 @@ void SwWrtShell::Insert(SwField &rFld) StartUndo(UNDO_INSERT, &aRewriter); + bool bDeleted = false; if( HasSelection() ) - DelRight(); + { + bDeleted = DelRight() != 0; + } - SwEditShell::Insert(rFld); + SwEditShell::Insert2(rFld, bDeleted); EndUndo(UNDO_INSERT); EndAllAction(); } diff --git a/sw/uiconfig/sglobal/accelerator/en-GB/default.xml b/sw/uiconfig/sglobal/accelerator/en-GB/default.xml index 2bc37195b9..c07ff3fcf0 100644 --- a/sw/uiconfig/sglobal/accelerator/en-GB/default.xml +++ b/sw/uiconfig/sglobal/accelerator/en-GB/default.xml @@ -111,5 +111,5 @@ <accel:item accel:code="KEY_J" accel:shift="true" accel:mod1="true" xlink:href=".uno:FullScreen"/> <accel:item accel:code="KEY_X" accel:shift="true" accel:mod1="true" xlink:href=".uno:RemoveDirectCharFormats"/> <accel:item accel:code="KEY_DIVIDE" accel:mod1="true" xlink:href=".uno:InsertZWSP"/> - <accel:item accel:code="KEY_N" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> + <accel:item accel:code="KEY_C" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> </accel:acceleratorlist> diff --git a/sw/uiconfig/sglobal/accelerator/en-US/default.xml b/sw/uiconfig/sglobal/accelerator/en-US/default.xml index 2bc37195b9..c07ff3fcf0 100644 --- a/sw/uiconfig/sglobal/accelerator/en-US/default.xml +++ b/sw/uiconfig/sglobal/accelerator/en-US/default.xml @@ -111,5 +111,5 @@ <accel:item accel:code="KEY_J" accel:shift="true" accel:mod1="true" xlink:href=".uno:FullScreen"/> <accel:item accel:code="KEY_X" accel:shift="true" accel:mod1="true" xlink:href=".uno:RemoveDirectCharFormats"/> <accel:item accel:code="KEY_DIVIDE" accel:mod1="true" xlink:href=".uno:InsertZWSP"/> - <accel:item accel:code="KEY_N" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> + <accel:item accel:code="KEY_C" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> </accel:acceleratorlist> diff --git a/sw/uiconfig/swform/accelerator/en-US/default.xml b/sw/uiconfig/swform/accelerator/en-US/default.xml index 5abee2cd7f..82fcdd073b 100644 --- a/sw/uiconfig/swform/accelerator/en-US/default.xml +++ b/sw/uiconfig/swform/accelerator/en-US/default.xml @@ -116,5 +116,5 @@ <accel:item accel:code="KEY_X" accel:shift="true" accel:mod1="true" xlink:href=".uno:RemoveDirectCharFormats"/> <accel:item accel:code="KEY_Y" accel:mod1="true" xlink:href=".uno:Redo"/> <accel:item accel:code="KEY_Z" accel:mod1="true" xlink:href=".uno:Undo"/> - <accel:item accel:code="KEY_N" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> + <accel:item accel:code="KEY_C" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> </accel:acceleratorlist> diff --git a/sw/uiconfig/swreport/accelerator/en-GB/default.xml b/sw/uiconfig/swreport/accelerator/en-GB/default.xml index 0e5e41657c..83f88ade9d 100644 --- a/sw/uiconfig/swreport/accelerator/en-GB/default.xml +++ b/sw/uiconfig/swreport/accelerator/en-GB/default.xml @@ -111,5 +111,5 @@ <accel:item accel:code="KEY_J" accel:shift="true" accel:mod1="true" xlink:href=".uno:FullScreen"/> <accel:item accel:code="KEY_X" accel:shift="true" accel:mod1="true" xlink:href=".uno:RemoveDirectCharFormats"/> <accel:item accel:code="KEY_DIVIDE" accel:mod1="true" xlink:href=".uno:InsertZWSP"/> - <accel:item accel:code="KEY_N" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> + <accel:item accel:code="KEY_C" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> </accel:acceleratorlist> diff --git a/sw/uiconfig/swreport/accelerator/en-US/default.xml b/sw/uiconfig/swreport/accelerator/en-US/default.xml index 0e5e41657c..83f88ade9d 100644 --- a/sw/uiconfig/swreport/accelerator/en-US/default.xml +++ b/sw/uiconfig/swreport/accelerator/en-US/default.xml @@ -111,5 +111,5 @@ <accel:item accel:code="KEY_J" accel:shift="true" accel:mod1="true" xlink:href=".uno:FullScreen"/> <accel:item accel:code="KEY_X" accel:shift="true" accel:mod1="true" xlink:href=".uno:RemoveDirectCharFormats"/> <accel:item accel:code="KEY_DIVIDE" accel:mod1="true" xlink:href=".uno:InsertZWSP"/> - <accel:item accel:code="KEY_N" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> + <accel:item accel:code="KEY_C" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> </accel:acceleratorlist> diff --git a/sw/uiconfig/swriter/accelerator/en-GB/default.xml b/sw/uiconfig/swriter/accelerator/en-GB/default.xml index 22f5da3172..cb04b7f52a 100644 --- a/sw/uiconfig/swriter/accelerator/en-GB/default.xml +++ b/sw/uiconfig/swriter/accelerator/en-GB/default.xml @@ -111,5 +111,5 @@ <accel:item accel:code="KEY_J" accel:shift="true" accel:mod1="true" xlink:href=".uno:FullScreen"/> <accel:item accel:code="KEY_X" accel:shift="true" accel:mod1="true" xlink:href=".uno:RemoveDirectCharFormats"/> <accel:item accel:code="KEY_DIVIDE" accel:mod1="true" xlink:href=".uno:InsertZWSP"/> - <accel:item accel:code="KEY_N" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> + <accel:item accel:code="KEY_C" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> </accel:acceleratorlist> diff --git a/sw/uiconfig/swriter/accelerator/en-US/default.xml b/sw/uiconfig/swriter/accelerator/en-US/default.xml index 22f5da3172..cb04b7f52a 100644 --- a/sw/uiconfig/swriter/accelerator/en-US/default.xml +++ b/sw/uiconfig/swriter/accelerator/en-US/default.xml @@ -111,5 +111,5 @@ <accel:item accel:code="KEY_J" accel:shift="true" accel:mod1="true" xlink:href=".uno:FullScreen"/> <accel:item accel:code="KEY_X" accel:shift="true" accel:mod1="true" xlink:href=".uno:RemoveDirectCharFormats"/> <accel:item accel:code="KEY_DIVIDE" accel:mod1="true" xlink:href=".uno:InsertZWSP"/> - <accel:item accel:code="KEY_N" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> + <accel:item accel:code="KEY_C" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> </accel:acceleratorlist> diff --git a/sw/uiconfig/swxform/accelerator/en-GB/default.xml b/sw/uiconfig/swxform/accelerator/en-GB/default.xml index 0e5e41657c..83f88ade9d 100644 --- a/sw/uiconfig/swxform/accelerator/en-GB/default.xml +++ b/sw/uiconfig/swxform/accelerator/en-GB/default.xml @@ -111,5 +111,5 @@ <accel:item accel:code="KEY_J" accel:shift="true" accel:mod1="true" xlink:href=".uno:FullScreen"/> <accel:item accel:code="KEY_X" accel:shift="true" accel:mod1="true" xlink:href=".uno:RemoveDirectCharFormats"/> <accel:item accel:code="KEY_DIVIDE" accel:mod1="true" xlink:href=".uno:InsertZWSP"/> - <accel:item accel:code="KEY_N" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> + <accel:item accel:code="KEY_C" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> </accel:acceleratorlist> diff --git a/sw/uiconfig/swxform/accelerator/en-US/default.xml b/sw/uiconfig/swxform/accelerator/en-US/default.xml index 0e5e41657c..83f88ade9d 100644 --- a/sw/uiconfig/swxform/accelerator/en-US/default.xml +++ b/sw/uiconfig/swxform/accelerator/en-US/default.xml @@ -111,5 +111,5 @@ <accel:item accel:code="KEY_J" accel:shift="true" accel:mod1="true" xlink:href=".uno:FullScreen"/> <accel:item accel:code="KEY_X" accel:shift="true" accel:mod1="true" xlink:href=".uno:RemoveDirectCharFormats"/> <accel:item accel:code="KEY_DIVIDE" accel:mod1="true" xlink:href=".uno:InsertZWSP"/> - <accel:item accel:code="KEY_N" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> + <accel:item accel:code="KEY_C" accel:mod1="true" accel:mod2="true" xlink:href=".uno:InsertAnnotation"/> </accel:acceleratorlist> diff --git a/sw/util/makefile.mk b/sw/util/makefile.mk index 4fc3be91b9..4b3abf042b 100644 --- a/sw/util/makefile.mk +++ b/sw/util/makefile.mk @@ -102,6 +102,7 @@ LIB1OBJFILES= $(OUT)$/slo$/swmodule.obj \ # dynamic libraries SHL1STDLIBS+= \ $(LNGLIB) \ + $(SVXCORELIB) \ $(SVXLIB) \ $(SFXLIB) \ $(XMLOFFLIB) \ @@ -179,6 +180,7 @@ DEF3NAME= $(SHL3TARGET) SHL3STDLIBS= \ $(ISWLIB) \ + $(SVXCORELIB) \ $(SVXLIB) \ $(SFX2LIB) \ $(SVTOOLLIB) \ @@ -188,6 +190,7 @@ SHL3STDLIBS= \ $(SVLLIB) \ $(UNOTOOLSLIB) \ $(TOOLSLIB) \ + $(I18NISOLANGLIB) \ $(COMPHELPERLIB) \ $(UCBHELPERLIB) \ $(CPPUHELPERLIB) \ @@ -317,7 +320,8 @@ DEF4NAME=$(SHL4TARGET) SHL4STDLIBS= \ $(ISWLIB) \ - $(SVXLIB) \ + $(SVXCORELIB) \ + $(SVXMSFILTERLIB) \ $(SFXLIB) \ $(GOODIESLIB) \ $(BASEGFXLIB) \ |