diff options
Diffstat (limited to 'sw')
32 files changed, 502 insertions, 237 deletions
diff --git a/sw/JunitTest_sw_complex.mk b/sw/JunitTest_sw_complex.mk index df81b22f71..bbd05ffa80 100755 --- a/sw/JunitTest_sw_complex.mk +++ b/sw/JunitTest_sw_complex.mk @@ -64,7 +64,11 @@ $(eval $(call gb_JunitTest_add_classes,sw_complex,\ complex.writer.TextPortionEnumerationTest \ )) -# currently fails (should run again in os146) (except on windows) -# complex.writer.CheckBookmarks \ +# CheckBookmarks currently fails on windows because the hashes are different +ifneq ($(OS),WNT) +$(eval $(call gb_JunitTest_add_classes,sw_complex,\ + complex.writer.CheckBookmarks \ +)) +endif # vim: set noet sw=4 ts=4: diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx index 9d60315230..0a02af3bca 100644 --- a/sw/source/core/crsr/bookmrk.cxx +++ b/sw/source/core/crsr/bookmrk.cxx @@ -109,7 +109,7 @@ namespace sw { namespace mark , m_aName(rName) { lcl_FixPosition(*m_pPos1); - if(aPaM.HasMark()) + if (aPaM.HasMark() && (*aPaM.GetMark() != *aPaM.GetPoint())) { MarkBase::SetOtherMarkPos(*(aPaM.GetMark())); lcl_FixPosition(*m_pPos2); diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index 0869e934fa..1bf7035221 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -311,15 +311,33 @@ void SwAttrCheckArr::SetNewSet( const SwTxtNode& rTxtNd, const SwPaM& rPam ) pItem = aIter.NextItem(); } } + +static bool +lcl_IsAttributeIgnorable(xub_StrLen const nNdStart, xub_StrLen const nNdEnd, + _SwSrchChrAttr const& rTmp) +{ + // #i115528#: if there is a paragraph attribute, it has been added by the + // SwAttrCheckArr ctor, and nFound is 1. + // if the paragraph is entirely covered by hints that override the paragraph + // attribute, then this function must find an attribute to decrement nFound! + // so check for an empty search range, let attributes that start/end there + // cover it, and hope for the best... + return ((nNdEnd == nNdStart) + ? ((rTmp.nEnd < nNdStart) || (nNdEnd < rTmp.nStt)) + : ((rTmp.nEnd <= nNdStart) || (nNdEnd <= rTmp.nStt))); +} + int SwAttrCheckArr::SetAttrFwd( const SwTxtAttr& rAttr ) { _SwSrchChrAttr aTmp( rAttr.GetAttr(), *rAttr.GetStart(), *rAttr.GetAnyEnd() ); - // alle die nicht im Bereich sind -> ignorieren - if( aTmp.nEnd <= nNdStt || aTmp.nStt >= nNdEnd ) + + // ignore all attributes not in search range + if (lcl_IsAttributeIgnorable(nNdStt, nNdEnd, aTmp)) + { return Found(); + } const SfxPoolItem* pItem; - // -------------------------------------------------------------- // Hier wird jetzt ausdruecklich auch in Zeichenvorlagen gesucht // -------------------------------------------------------------- @@ -473,9 +491,12 @@ int SwAttrCheckArr::SetAttrFwd( const SwTxtAttr& rAttr ) int SwAttrCheckArr::SetAttrBwd( const SwTxtAttr& rAttr ) { _SwSrchChrAttr aTmp( rAttr.GetAttr(), *rAttr.GetStart(), *rAttr.GetAnyEnd() ); - // alle die nicht im Bereich sind -> ignorieren - if( aTmp.nEnd < nNdStt || aTmp.nStt >= nNdEnd ) + + // ignore all attributes not in search range + if (lcl_IsAttributeIgnorable(nNdStt, nNdEnd, aTmp)) + { return Found(); + } const SfxPoolItem* pItem; // -------------------------------------------------------------- diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx index f409d6b0e7..ba86116714 100644 --- a/sw/source/core/doc/doccorr.cxx +++ b/sw/source/core/doc/doccorr.cxx @@ -210,10 +210,22 @@ void SwDoc::CorrAbs(const SwNodeIndex& rOldNode, getIDocumentMarkAccess()->correctMarksAbsolute(rOldNode, rNewPos, nOffset); { // fix redlines SwRedlineTbl& rTbl = *pRedlineTbl; - for( sal_uInt16 n = 0; n < rTbl.Count(); ++n ) + for (sal_uInt16 n = 0; n < rTbl.Count(); ) { // is on position ?? - lcl_PaMCorrAbs(*rTbl[ n ], *aPam.Start(), *aPam.End(), aNewPos); + SwRedline *const pRedline( rTbl[ n ] ); + bool const bChanged = + lcl_PaMCorrAbs(*pRedline, *aPam.Start(), *aPam.End(), aNewPos); + // clean up empty redlines: docredln.cxx asserts these as invalid + if (bChanged && (*pRedline->GetPoint() == *pRedline->GetMark()) + && (pRedline->GetContentIdx() == NULL)) + { + rTbl.DeleteAndDestroy(n); + } + else + { + ++n; + } } } diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index e09ae79f13..ce1911cce6 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -2515,8 +2515,6 @@ SetRedlineMode( eOld ); rPam.GetMark()->nNode = aPtNd; rPam.GetMark()->nContent.Assign( aPtNd.GetNode().GetCntntNode(), nPtCnt ); - if( bJoinTxt ) - rPam.Move( fnMoveBackward ); if( pUndoRpl ) { @@ -2642,8 +2640,15 @@ bool SwDoc::DelFullPara( SwPaM& rPam ) return sal_False; } } - // text::Bookmarks usw. verschieben - CorrAbs( aRg.aStart, aRg.aEnd, *rPam.GetPoint(), sal_True ); + // move bookmarks, redlines etc. + if (aRg.aStart == aRg.aEnd) // only first CorrAbs variant handles this + { + CorrAbs( aRg.aStart, *rPam.GetPoint(), 0, sal_True ); + } + else + { + CorrAbs( aRg.aStart, aRg.aEnd, *rPam.GetPoint(), sal_True ); + } // was ist mit Fly's ?? { diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 9b7d965950..89e3d4c2f2 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -493,45 +493,14 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, SwTxtNode* pTNd = aTmpStt.GetNode().GetTxtNode(); if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() ) { - SfxItemIter aIter( *pTNd->GetpSwAttrSet() ); - const SfxPoolItem* pItem = aIter.GetCurItem(); - SfxItemSet aCharSet( GetAttrPool(), RES_CHRATR_BEGIN, RES_CHRATR_END ); - - while( sal_True ) + if (pHst) { - if( IsInRange( aCharFmtSetRange, pItem->Which() )) - { - pTNd->GetOrCreateSwpHints(); - - aCharSet.Put( *pItem ); - - if( pHst ) - { - SwRegHistory aRegH( pTNd, *pTNd, pHst ); - pTNd->ResetAttr( pItem->Which() ); - } - else - pTNd->ResetAttr( pItem->Which() ); - } - if( aIter.IsAtEnd() ) - break; - pItem = aIter.NextItem(); + SwRegHistory history(pTNd, *pTNd, pHst); + pTNd->FmtToTxtAttr(pTNd); } - - if ( aCharSet.Count() ) + else { - if ( pHst ) - { - SwRegHistory history( pTNd, *pTNd, pHst ); - history.InsertItems( aCharSet, 0, pTNd->GetTxt().Len(), - nsSetAttrMode::SETATTR_NOFORMATATTR ); - } - else - { - SwTxtAttr* pNew = - MakeTxtAttr( *this, aCharSet, 0, pTNd->GetTxt().Len() ); - pTNd->InsertHint( pNew ); - } + pTNd->FmtToTxtAttr(pTNd); } } @@ -545,29 +514,14 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, SwTxtNode* pTNd = aTmpEnd.GetNode().GetTxtNode(); if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() ) { - SfxItemIter aIter( *pTNd->GetpSwAttrSet() ); - const SfxPoolItem* pItem = aIter.GetCurItem(); - while( sal_True ) + if (pHst) { - if( IsInRange( aCharFmtSetRange, pItem->Which() )) - { - SwTxtAttr* pTAttr = MakeTxtAttr( *this, - const_cast<SfxPoolItem&>(*pItem), - 0, pTNd->GetTxt().Len() ); - SwpHints & rHints = pTNd->GetOrCreateSwpHints(); - rHints.SwpHintsArray::Insert( pTAttr ); - if ( pHst ) - { - SwRegHistory aRegH( pTNd, *pTNd, pHst ); - pTNd->ResetAttr( pItem->Which() ); - pHst->Add( pTAttr, aTmpEnd.GetIndex(), true ); - } - else - pTNd->ResetAttr( pItem->Which() ); - } - if( aIter.IsAtEnd() ) - break; - pItem = aIter.NextItem(); + SwRegHistory history(pTNd, *pTNd, pHst); + pTNd->FmtToTxtAttr(pTNd); + } + else + { + pTNd->FmtToTxtAttr(pTNd); } } } diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index eaa4c9bfc4..7e26349598 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -2352,7 +2352,10 @@ void SwFrm::AppendDrawObj( SwAnchoredObject& _rNewObj ) // Assure the control objects and group objects containing controls are on the control layer if ( ::CheckControlLayer( _rNewObj.DrawObj() ) ) { - const IDocumentDrawModelAccess* pIDDMA = GetUpper()->GetFmt()->getIDocumentDrawModelAccess(); + const IDocumentDrawModelAccess* pIDDMA = (IsFlyFrm()) + ? static_cast<SwFlyFrm*>(this)->GetFmt()-> + getIDocumentDrawModelAccess() + : GetUpper()->GetFmt()->getIDocumentDrawModelAccess(); const SdrLayerID aCurrentLayer(_rNewObj.DrawObj()->GetLayer()); const SdrLayerID aControlLayerID(pIDDMA->GetControlsId()); const SdrLayerID aInvisibleControlLayerID(pIDDMA->GetInvisibleControlsId()); diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 15a753f219..f811afce9e 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -2101,7 +2101,7 @@ struct RemovePresentAttrs const SwTxtAttr* const pAutoStyle(i_rAttrSpan.second); SfxItemIter aIter(m_rAttrSet); const SfxPoolItem* pItem(aIter.GetCurItem()); - while (true) + while (pItem) { const sal_uInt16 nWhich(pItem->Which()); if (CharFmt::IsItemIncluded(nWhich, pAutoStyle)) @@ -2143,7 +2143,8 @@ lcl_CollectHintSpans(const SwpHints& i_rHints, const sal_uInt16 nLength, const AttrSpan_t aSpan(*pHint->GetStart(), *pHint->GetEnd()); o_rSpanMap.insert(AttrSpanMap_t::value_type(aSpan, pHint)); - if (aSpan.first != nLastEnd) + // < not != because there may be multiple CHARFMT at same range + if (nLastEnd < aSpan.first) { // insert dummy span covering the gap o_rSpanMap.insert(AttrSpanMap_t::value_type( diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 766458b65c..9f938d9861 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2078,6 +2078,8 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 )); } + aPam.DeleteMark(); // mark position node will be deleted! + aIntPam.DeleteMark(); // mark position node will be deleted! pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet, 0, pParentFrmFmt ); diff --git a/sw/source/core/unocore/unoportenum.cxx b/sw/source/core/unocore/unoportenum.cxx index 21e4f76e76..37bf8aab70 100644 --- a/sw/source/core/unocore/unoportenum.cxx +++ b/sw/source/core/unocore/unoportenum.cxx @@ -155,12 +155,16 @@ namespace ++ppMark) { ::sw::mark::IMark* const pBkmk = ppMark->get(); - bool hasOther = pBkmk->IsExpanded(); + ::sw::mark::CrossRefBookmark *const pCrossRefMark( + dynamic_cast< ::sw::mark::CrossRefBookmark*>(pBkmk)); + bool const hasOther = pBkmk->IsExpanded(); const SwPosition& rStartPos = pBkmk->GetMarkStart(); if(rStartPos.nNode == nOwnNode) { - const sal_uInt8 nType = hasOther ? BKM_TYPE_START : BKM_TYPE_START_END; + // #i109272#: cross reference marks: need special handling! + sal_uInt8 const nType = (hasOther || pCrossRefMark) + ? BKM_TYPE_START : BKM_TYPE_START_END; rBkmArr.insert(SwXBookmarkPortion_ImplSharedPtr( new SwXBookmarkPortion_Impl( SwXBookmark::CreateXBookmark(rDoc, *pBkmk), @@ -173,8 +177,10 @@ namespace auto_ptr<SwPosition> pCrossRefEndPos; const SwPosition* pEndPos = NULL; if(hasOther) + { pEndPos = &rEndPos; - else if(dynamic_cast< ::sw::mark::CrossRefBookmark*>(pBkmk)) + } + else if (pCrossRefMark) { // Crossrefbookmarks only remember the start position but have to span the whole paragraph pCrossRefEndPos = auto_ptr<SwPosition>(new SwPosition(rEndPos)); diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 8dc3194510..f7f9a1dfa7 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1754,13 +1754,15 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) // DelFullPara is called const uno::Reference< text::XTextRange> xInsertTextRange = new SwXTextRange(aStartPam, this); + aStartPam.DeleteMark(); // mark position node may be deleted! pNewFrame->attach( xInsertTextRange ); pNewFrame->setName(m_pImpl->m_pDoc->GetUniqueFrameName()); } - if (!aStartPam.GetTxt().Len()) + SwTxtNode *const pTxtNode(aStartPam.GetNode()->GetTxtNode()); + OSL_ASSERT(pTxtNode); + if (!pTxtNode || !pTxtNode->Len()) // don't remove if it contains text! { - bool bMoved = false; { // has to be in a block to remove the SwIndexes before // DelFullPara is called SwPaM aMovePam( *aStartPam.GetNode() ); @@ -1772,14 +1774,8 @@ throw (lang::IllegalArgumentException, uno::RuntimeException) m_pImpl->m_pDoc->SetAttr( aNewAnchor, *pNewFrame->GetFrmFmt() ); } - bMoved = true; - } - if (bMoved) - { - aStartPam.DeleteMark(); -// SwPaM aDelPam( *aStartPam.GetNode() ); - m_pImpl->m_pDoc->DelFullPara(aStartPam/*aDelPam*/); } + m_pImpl->m_pDoc->DelFullPara(aStartPam); } } catch (lang::IllegalArgumentException& rIllegal) diff --git a/sw/source/filter/ww1/fltshell.cxx b/sw/source/filter/ww1/fltshell.cxx index 37d08784ba..2fbb19d8d5 100644 --- a/sw/source/filter/ww1/fltshell.cxx +++ b/sw/source/filter/ww1/fltshell.cxx @@ -137,13 +137,14 @@ void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos) sal_Bool SwFltStackEntry::MakeRegion(SwDoc* pDoc, SwPaM& rRegion, sal_Bool bCheck ) { - // wird ueberhaupt ein Bereich umspannt ?? - // - ist kein Bereich, dann nicht returnen wenn am Anfang vom Absatz - // - Felder aussortieren, koennen keinen Bereich haben !! - if ( - nMkNode.GetIndex() == nPtNode.GetIndex() && nMkCntnt == nPtCntnt && - nPtCntnt && RES_TXTATR_FIELD != pAttr->Which() - ) + // does this range actually contain something? + // empty range is allowed if at start of empty paragraph + // fields are special: never have range, so leave them + SwCntntNode *const pCntntNode( + SwNodeIndex(nMkNode, +1).GetNode().GetCntntNode()); + if ((nMkNode.GetIndex() == nPtNode.GetIndex()) && (nMkCntnt == nPtCntnt) + && ((0 != nPtCntnt) || (pCntntNode && (0 != pCntntNode->Len()))) + && (RES_TXTATR_FIELD != pAttr->Which())) { return sal_False; } diff --git a/sw/source/filter/ww8/WW8TableInfo.cxx b/sw/source/filter/ww8/WW8TableInfo.cxx index 9f1727d3a5..609fcc6a17 100644 --- a/sw/source/filter/ww8/WW8TableInfo.cxx +++ b/sw/source/filter/ww8/WW8TableInfo.cxx @@ -251,8 +251,8 @@ WidthsPtr WW8TableNodeInfoInner::getWidthsOfRow() pWidths = WidthsPtr(new Widths); // number of cell written sal_uInt32 nBoxes = rTabBoxes.Count(); - if ( nBoxes > 32 ) - nBoxes = 32; + if ( nBoxes > MAXTABLECELLS ) + nBoxes = MAXTABLECELLS; for (sal_uInt32 n = 0; n < nBoxes; n++) { @@ -282,8 +282,8 @@ RowSpansPtr WW8TableNodeInfoInner::getRowSpansOfRow() const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes(); sal_uInt32 nBoxes = rTabBoxes.Count(); - if (nBoxes > 32) - nBoxes = 32; + if (nBoxes > MAXTABLECELLS) + nBoxes = MAXTABLECELLS; for (sal_uInt32 n = 0; n < nBoxes; ++n) { diff --git a/sw/source/filter/ww8/WW8TableInfo.hxx b/sw/source/filter/ww8/WW8TableInfo.hxx index 3f74d4a5fc..0afa0978f2 100644 --- a/sw/source/filter/ww8/WW8TableInfo.hxx +++ b/sw/source/filter/ww8/WW8TableInfo.hxx @@ -46,6 +46,8 @@ namespace ww8 { using namespace ::std; +const unsigned int MAXTABLECELLS = 63; + class WW8TableNodeInfo; typedef boost::shared_ptr<SwRect> SwRectPtr; typedef ::std::vector<const SwTableBox *> TableBoxVector; diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 44fb2a29c0..2699cae7aa 100755 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -179,7 +179,7 @@ MSWordAttrIter::~MSWordAttrIter() // Mit OutAttr() werden die Attribute an der angegebenen SwPos // ausgegeben. -class SwAttrIter : public MSWordAttrIter +class WW8SwAttrIter : public MSWordAttrIter { private: const SwTxtNode& rNd; @@ -210,10 +210,10 @@ private: void IterToCurrent(); //No copying - SwAttrIter(const SwAttrIter&); - SwAttrIter& operator=(const SwAttrIter&); + WW8SwAttrIter(const WW8SwAttrIter&); + WW8SwAttrIter& operator=(const WW8SwAttrIter&); public: - SwAttrIter( MSWordExportBase& rWr, const SwTxtNode& rNd ); + WW8SwAttrIter( MSWordExportBase& rWr, const SwTxtNode& rNd ); bool IsTxtAttr( xub_StrLen nSwPos ); bool IsRedlineAtEnd( xub_StrLen nPos ) const; @@ -249,7 +249,7 @@ public: } }; -void SwAttrIter::IterToCurrent() +void WW8SwAttrIter::IterToCurrent() { ASSERT(maCharRuns.begin() != maCharRuns.end(), "Impossible"); mnScript = maCharRunIter->mnScript; @@ -257,7 +257,7 @@ void SwAttrIter::IterToCurrent() mbCharIsRTL = maCharRunIter->mbRTL; } -SwAttrIter::SwAttrIter(MSWordExportBase& rWr, const SwTxtNode& rTxtNd) : +WW8SwAttrIter::WW8SwAttrIter(MSWordExportBase& rWr, const SwTxtNode& rTxtNd) : MSWordAttrIter(rWr), rNd(rTxtNd), maCharRuns(GetPseudoCharRuns(rTxtNd, 0, !rWr.HackIsWW8OrHigher())), @@ -324,7 +324,7 @@ xub_StrLen lcl_getMinPos( xub_StrLen pos1, xub_StrLen pos2 ) return min; } -xub_StrLen SwAttrIter::SearchNext( xub_StrLen nStartPos ) +xub_StrLen WW8SwAttrIter::SearchNext( xub_StrLen nStartPos ) { xub_StrLen nPos; xub_StrLen nMinPos = STRING_MAXLEN; @@ -457,7 +457,7 @@ xub_StrLen SwAttrIter::SearchNext( xub_StrLen nStartPos ) return nMinPos; } -void SwAttrIter::OutAttr( xub_StrLen nSwPos ) +void WW8SwAttrIter::OutAttr( xub_StrLen nSwPos ) { m_rExport.AttrOutput().RTLAndCJKState( IsCharRTL(), GetScript() ); @@ -501,9 +501,7 @@ void SwAttrIter::OutAttr( xub_StrLen nSwPos ) : nSwPos == *pHt->GetStart() ) { sal_uInt16 nWhich = pHt->GetAttr().Which(); - if (nWhich == nFontId) - pFont = &(item_cast<SvxFontItem>(pHt->GetAttr())); - else if( nWhich == RES_TXTATR_AUTOFMT ) + if (nWhich == RES_TXTATR_AUTOFMT) { const SwFmtAutoFmt& rAutoFmt = static_cast<const SwFmtAutoFmt&>(pHt->GetAttr()); const boost::shared_ptr<SfxItemSet> pSet = rAutoFmt.GetStyleHandle(); @@ -583,7 +581,7 @@ void SwAttrIter::OutAttr( xub_StrLen nSwPos ) } } -void SwAttrIter::OutFlys(xub_StrLen nSwPos) +void WW8SwAttrIter::OutFlys(xub_StrLen nSwPos) { /* #i2916# @@ -605,7 +603,7 @@ void SwAttrIter::OutFlys(xub_StrLen nSwPos) } } -bool SwAttrIter::IsTxtAttr( xub_StrLen nSwPos ) +bool WW8SwAttrIter::IsTxtAttr( xub_StrLen nSwPos ) { // search for attrs with CH_TXTATR if (const SwpHints* pTxtAttrs = rNd.GetpSwpHints()) @@ -621,7 +619,7 @@ bool SwAttrIter::IsTxtAttr( xub_StrLen nSwPos ) return false; } -bool SwAttrIter::IsDropCap( int nSwPos ) +bool WW8SwAttrIter::IsDropCap( int nSwPos ) { // see if the current position falls on a DropCap int nDropChars = mrSwFmtDrop.GetChars(); @@ -640,7 +638,7 @@ bool SwAttrIter::IsDropCap( int nSwPos ) return false; } -bool SwAttrIter::RequiresImplicitBookmark() +bool WW8SwAttrIter::RequiresImplicitBookmark() { SwImplBookmarksIter bkmkIterEnd = m_rExport.maImplicitBookmarks.end(); for ( SwImplBookmarksIter aIter = m_rExport.maImplicitBookmarks.begin(); aIter != bkmkIterEnd; ++aIter ) @@ -659,7 +657,7 @@ bool SwAttrIter::RequiresImplicitBookmark() // Attribut-Anfangposition fragen kann. // Es koennen nur Attribute mit Ende abgefragt werden. // Es wird mit bDeep gesucht -const SfxPoolItem* SwAttrIter::HasTextItem( sal_uInt16 nWhich ) const +const SfxPoolItem* WW8SwAttrIter::HasTextItem( sal_uInt16 nWhich ) const { const SfxPoolItem* pRet = 0; const SwpHints* pTxtAttrs = rNd.GetpSwpHints(); @@ -692,7 +690,7 @@ void WW8Export::GetCurrentItems(WW8Bytes& rItems) const rItems.Insert((*pO)[nI], rItems.Count()); } -const SfxPoolItem& SwAttrIter::GetItem(sal_uInt16 nWhich) const +const SfxPoolItem& WW8SwAttrIter::GetItem(sal_uInt16 nWhich) const { const SfxPoolItem* pRet = HasTextItem(nWhich); return pRet ? *pRet : rNd.SwCntntNode::GetAttr(nWhich); @@ -1073,7 +1071,7 @@ String BookmarkToWriter(const String &rBookmark) INetURLObject::DECODE_UNAMBIGUOUS, RTL_TEXTENCODING_ASCII_US); } -void SwAttrIter::OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool) +void WW8SwAttrIter::OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool) { if ( m_rExport.HasRefToObject( REF_SETREFATTR, &rAttr.GetRefName(), 0 ) ) m_rExport.AppendBookmark( m_rExport.GetBookmarkName( REF_SETREFATTR, @@ -1173,7 +1171,7 @@ void AttributeOutputBase::TOXMark( const SwTxtNode& rNode, const SwTOXMark& rAtt FieldVanish( sTxt, eType ); } -int SwAttrIter::OutAttrWithRange(xub_StrLen nPos) +int WW8SwAttrIter::OutAttrWithRange(xub_StrLen nPos) { int nRet = 0; if ( const SwpHints* pTxtAttrs = rNd.GetpSwpHints() ) @@ -1234,7 +1232,7 @@ int SwAttrIter::OutAttrWithRange(xub_StrLen nPos) return nRet; } -bool SwAttrIter::IsRedlineAtEnd( xub_StrLen nEnd ) const +bool WW8SwAttrIter::IsRedlineAtEnd( xub_StrLen nEnd ) const { bool bRet = false; // search next Redline @@ -1256,7 +1254,7 @@ bool SwAttrIter::IsRedlineAtEnd( xub_StrLen nEnd ) const return bRet; } -const SwRedlineData* SwAttrIter::GetRedline( xub_StrLen nPos ) +const SwRedlineData* WW8SwAttrIter::GetRedline( xub_StrLen nPos ) { if( pCurRedline ) { @@ -1451,7 +1449,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 SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, +String WW8SwAttrIter::GetSnippet(const String &rStr, xub_StrLen nAktPos, xub_StrLen nLen) const { String aSnippet(rStr, nAktPos, nLen); @@ -1647,7 +1645,7 @@ void WW8AttributeOutput::FormatDrop( const SwTxtNode& rNode, const SwFmtDrop &rS m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() ); } -xub_StrLen MSWordExportBase::GetNextPos( SwAttrIter* aAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos ) +xub_StrLen MSWordExportBase::GetNextPos( WW8SwAttrIter* aAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos ) { // Get the bookmarks for the normal run xub_StrLen nNextPos = aAttrIter->WhereNext(); @@ -1661,7 +1659,7 @@ xub_StrLen MSWordExportBase::GetNextPos( SwAttrIter* aAttrIter, const SwTxtNode& return std::min( nNextPos, nNextBookmark ); } -void MSWordExportBase::UpdatePosition( SwAttrIter* aAttrIter, xub_StrLen nAktPos, xub_StrLen /*nEnd*/ ) +void MSWordExportBase::UpdatePosition( WW8SwAttrIter* aAttrIter, xub_StrLen nAktPos, xub_StrLen /*nEnd*/ ) { xub_StrLen nNextPos; @@ -1799,7 +1797,7 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode ) // have to remember it in nStyle sal_uInt16 nStyle = nStyleBeforeFly; - SwAttrIter aAttrIter( *this, rNode ); + WW8SwAttrIter aAttrIter( *this, rNode ); rtl_TextEncoding eChrSet = aAttrIter.GetCharSet(); if ( bStartTOX ) @@ -1842,7 +1840,7 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode ) String aStr( rNode.GetTxt() ); xub_StrLen nAktPos = 0; - xub_StrLen nEnd = aStr.Len(); + xub_StrLen const nEnd = aStr.Len(); bool bRedlineAtEnd = false; int nOpenAttrWithRange = 0; @@ -1934,6 +1932,15 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode ) if ( aAttrIter.IsDropCap( nNextAttr ) ) AttrOutput().FormatDrop( rNode, aAttrIter.GetSwFmtDrop(), nStyle, pTextNodeInfo, pTextNodeInfoInner ); + if (0 != nEnd) + { + // Output the character attributes + // #i51277# do this before writing flys at end of paragraph + AttrOutput().StartRunProperties(); + aAttrIter.OutAttr( nAktPos ); + AttrOutput().EndRunProperties( pRedlineData ); + } + // At the end of line, output the attributes until the CR. // Exception: footnotes at the end of line if ( nNextAttr == nEnd ) @@ -1958,11 +1965,16 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode ) } } } - - // Output the character attributes - AttrOutput().StartRunProperties(); - aAttrIter.OutAttr( nAktPos ); // nAktPos - 1 ?? - AttrOutput().EndRunProperties( pRedlineData ); + + if (0 == nEnd) + { + // Output the character attributes + // do it after WriteCR for an empty paragraph (otherwise + // WW8_WrFkp::Append throws SPRMs away...) + AttrOutput().StartRunProperties(); + aAttrIter.OutAttr( nAktPos ); + AttrOutput().EndRunProperties( pRedlineData ); + } // Exception: footnotes at the end of line if ( nNextAttr == nEnd ) diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index dd7f0c3270..3f315b39a9 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -2166,6 +2166,8 @@ void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner->getTableBoxesOfRow(); // number of cell written sal_uInt32 nBoxes = pTableBoxes->size(); + if (nBoxes > ww8::MAXTABLECELLS) + nBoxes = ww8::MAXTABLECELLS; // sprm header m_rWW8Export.InsUInt16( NS_sprm::LN_TDefTable ); @@ -3383,7 +3385,7 @@ sal_uLong SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed, 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), + pBmpPal(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 ), @@ -3399,8 +3401,6 @@ MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM MSWordExportBase::~MSWordExportBase() { delete pBmpPal; - if (pKeyMap) - delete[] (NfKeywordTable*)pKeyMap; delete pOLEExp; delete pOCXExp; delete pOleMap; @@ -3884,4 +3884,35 @@ void MSWordExportBase::OutputEndNode( const SwEndNode &rNode ) #endif } +const NfKeywordTable & MSWordExportBase::GetNfKeywordTable() +{ + if (pKeyMap.get() == NULL) + { + pKeyMap.reset(new NfKeywordTable); + NfKeywordTable & rKeywordTable = *pKeyMap; + rKeywordTable[NF_KEY_D] = ::rtl::OUString::createFromAscii("d"); + rKeywordTable[NF_KEY_DD] = ::rtl::OUString::createFromAscii("dd"); + rKeywordTable[NF_KEY_DDD] = ::rtl::OUString::createFromAscii("ddd"); + rKeywordTable[NF_KEY_DDDD] = ::rtl::OUString::createFromAscii("dddd"); + rKeywordTable[NF_KEY_M] = ::rtl::OUString::createFromAscii("M"); + rKeywordTable[NF_KEY_MM] = ::rtl::OUString::createFromAscii("MM"); + rKeywordTable[NF_KEY_MMM] = ::rtl::OUString::createFromAscii("MMM"); + rKeywordTable[NF_KEY_MMMM] = ::rtl::OUString::createFromAscii("MMMM"); + rKeywordTable[NF_KEY_NN] = ::rtl::OUString::createFromAscii("ddd"); + rKeywordTable[NF_KEY_NNN] = ::rtl::OUString::createFromAscii("dddd"); + rKeywordTable[NF_KEY_NNNN] = ::rtl::OUString::createFromAscii("dddd"); + rKeywordTable[NF_KEY_YY] = ::rtl::OUString::createFromAscii("yy"); + rKeywordTable[NF_KEY_YYYY] = ::rtl::OUString::createFromAscii("yyyy"); + rKeywordTable[NF_KEY_H] = ::rtl::OUString::createFromAscii("H"); + rKeywordTable[NF_KEY_HH] = ::rtl::OUString::createFromAscii("HH"); + rKeywordTable[NF_KEY_MI] = ::rtl::OUString::createFromAscii("m"); + rKeywordTable[NF_KEY_MMI] = ::rtl::OUString::createFromAscii("mm"); + rKeywordTable[NF_KEY_S] = ::rtl::OUString::createFromAscii("s"); + rKeywordTable[NF_KEY_SS] = ::rtl::OUString::createFromAscii("ss"); + rKeywordTable[NF_KEY_AMPM] = ::rtl::OUString::createFromAscii("AM/PM"); + } + + return *pKeyMap; +} + /* vi:set tabstop=4 shiftwidth=4 expandtab: */ diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index fcf17da3f5..be83605310 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -58,7 +58,7 @@ namespace msfilter class MSCodec_Std97; } -class SwAttrIter; +class WW8SwAttrIter; class AttributeOutputBase; class DocxAttributeOutput; class RtfAttributeOutput; @@ -472,7 +472,7 @@ public: WW8_WrtBookmarks* pBkmks; WW8_WrtRedlineAuthor* pRedlAuthors; BitmapPalette* pBmpPal; - void* pKeyMap; + boost::shared_ptr<NfKeywordTable> pKeyMap; SvxMSExportOLEObjects* pOLEExp; SwMSConvertControls* pOCXExp; WW8OleMaps* pOleMap; @@ -752,10 +752,10 @@ protected: 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 ); + virtual xub_StrLen GetNextPos( WW8SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos ); /// Update the information for GetNextPos(). - virtual void UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd ); + virtual void UpdatePosition( WW8SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd ); /// Output SwTxtNode void OutputTextNode( const SwTxtNode& ); @@ -817,6 +817,8 @@ protected: bool GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt, xub_StrLen nEnd, IMarkVector& rArr ); + const NfKeywordTable & GetNfKeywordTable(); + public: MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam ); virtual ~MSWordExportBase(); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 8f11ff16e8..31c9808232 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -437,10 +437,19 @@ void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode //section. bool bBreakSet = false; + const SwPageDesc * pPageDesc = rNd.FindPageDesc(sal_False); + + if (pAktPageDesc != pPageDesc) + { + bBreakSet = true; + bNewPageDesc = true; + pAktPageDesc = pPageDesc; + } + if ( pSet && pSet->Count() ) { - if ( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) - && ( (SwFmtPageDesc*)pItem )->KnowsPageDesc() ) + if ( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) && + dynamic_cast<const SwFmtPageDesc*>(pItem)->GetRegisteredIn() != NULL) { bBreakSet = true; bNewPageDesc = true; @@ -2419,19 +2428,13 @@ bool MSWordExportBase::GetNumberFmt(const SwField& rFld, String& rStr) const SvNumberformat* pNumFmt = pNFmtr->GetEntry( nFmtIdx ); if( pNumFmt ) { - //sal_uInt16 nLng = rFld.GetLanguage(); - LocaleDataWrapper aLocDat( pNFmtr->GetServiceManager(), - MsLangId::convertLanguageToLocale( LANGUAGE_ENGLISH_US ) ); + sal_uInt16 nLng = rFld.GetLanguage(); + LocaleDataWrapper aLocDat(pNFmtr->GetServiceManager(), + MsLangId::convertLanguageToLocale(nLng)); - if( !pKeyMap ) - { - pKeyMap = new NfKeywordTable; - NfKeywordTable& rKeyMap = *(NfKeywordTable*)pKeyMap; - pNFmtr->FillKeywordTable( rKeyMap, LANGUAGE_ENGLISH_US ); - } - - String sFmt(pNumFmt->GetMappedFormatstring(*(NfKeywordTable*)pKeyMap, + String sFmt(pNumFmt->GetMappedFormatstring(GetNfKeywordTable(), aLocDat)); + if (sFmt.Len()) { sw::ms::SwapQuotesInField(sFmt); diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx index ba92c69202..7a23a98e15 100644 --- a/sw/source/filter/xml/swxml.cxx +++ b/sw/source/filter/xml/swxml.cxx @@ -925,18 +925,19 @@ sal_uLong XMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPaM, con } } - sal_uInt32 nWarn = 0; - sal_uInt32 nWarn2 = 0; // read storage streams + + // #i103539#: always read meta.xml for generator + sal_uInt32 const nWarn = ReadThroughComponent( + xStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory, + (bOASIS ? "com.sun.star.comp.Writer.XMLOasisMetaImporter" + : "com.sun.star.comp.Writer.XMLMetaImporter"), + aEmptyArgs, rName, sal_False ); + + sal_uInt32 nWarn2 = 0; if( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() || bInsertMode) ) { - nWarn = ReadThroughComponent( - xStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory, - (bOASIS ? "com.sun.star.comp.Writer.XMLOasisMetaImporter" - : "com.sun.star.comp.Writer.XMLMetaImporter"), - aEmptyArgs, rName, sal_False ); - nWarn2 = ReadThroughComponent( xStorage, xModelComp, "settings.xml", NULL, xServiceFactory, (bOASIS ? "com.sun.star.comp.Writer.XMLOasisSettingsImporter" diff --git a/sw/source/filter/xml/xmlbrshi.hxx b/sw/source/filter/xml/xmlbrshi.hxx index 83328ca87d..994f7c578a 100644 --- a/sw/source/filter/xml/xmlbrshi.hxx +++ b/sw/source/filter/xml/xmlbrshi.hxx @@ -25,8 +25,12 @@ * ************************************************************************/ -#ifndef _XMLBRSHI_HXX -#define _XMLBRSHI_HXX +#ifndef SW_XMLBRSHI_HXX +#define SW_XMLBRSHI_HXX + +#include <com/sun/star/io/XOutputStream.hpp> + +#include <xmloff/xmlictxt.hxx> class SvXMLImport; class SvXMLUnitConverter; diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index ce282d4d2d..5a930513fd 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -419,23 +419,23 @@ SvXMLImportContext *SwXMLImport::CreateContext( pContext = CreateMetaContext(rLocalName); } else if ( XML_NAMESPACE_OFFICE==nPrefix && + IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) ) + { + pContext = new SwXMLDocStylesContext_Impl( *this, nPrefix, rLocalName, + xAttrList ); + } + else if ( XML_NAMESPACE_OFFICE==nPrefix && IsXMLToken( rLocalName, XML_DOCUMENT ) ) { uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.xml.dom.SAXDocumentBuilder")), uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - GetModel(), UNO_QUERY_THROW); + uno::Reference<document::XDocumentProperties> const xDocProps( + GetDocumentProperties()); // flat OpenDocument file format pContext = new SwXMLOfficeDocContext_Impl( *this, nPrefix, rLocalName, - xAttrList, xDPS->getDocumentProperties(), xDocBuilder); - } - else if ( XML_NAMESPACE_OFFICE==nPrefix && - IsXMLToken( rLocalName, XML_DOCUMENT_STYLES ) ) - { - pContext = new SwXMLDocStylesContext_Impl( *this, nPrefix, rLocalName, - xAttrList ); + xAttrList, xDocProps, xDocBuilder); } // <-- else diff --git a/sw/source/filter/xml/xmlimp.hxx b/sw/source/filter/xml/xmlimp.hxx index e5f4c8ff0e..520d3c7a1b 100644 --- a/sw/source/filter/xml/xmlimp.hxx +++ b/sw/source/filter/xml/xmlimp.hxx @@ -25,14 +25,18 @@ * ************************************************************************/ -#ifndef _XMLIMP_HXX -#define _XMLIMP_HXX +#ifndef SW_XMLIMP_HXX +#define SW_XMLIMP_HXX + +#include <com/sun/star/document/XDocumentProperties.hpp> #include <sot/storage.hxx> + #include <xmloff/xmlictxt.hxx> -#include "xmlitmap.hxx" #include <xmloff/xmlimp.hxx> +#include "xmlitmap.hxx" + class SwDoc; class SwPaM; class SvXMLUnitConverter; @@ -182,6 +186,7 @@ public: inline const SvXMLUnitConverter& GetTwipUnitConverter() const; inline const SvXMLImportItemMapper& GetTableItemMapper() const; + inline SvXMLImportItemMapper& GetTableItemMapper(); SvXMLImportContext *CreateTableItemImportContext( sal_uInt16 nPrefix, const ::rtl::OUString& rLocalName, const ::com::sun::star::uno::Reference< @@ -210,6 +215,11 @@ public: // initialize XForms virtual void initXForms(); + + // get the document properties, but only if they actually need importing + ::com::sun::star::uno::Reference< + ::com::sun::star::document::XDocumentProperties> + GetDocumentProperties() const; }; inline const SvXMLUnitConverter& SwXMLImport::GetTwipUnitConverter() const @@ -222,6 +232,11 @@ inline const SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper() const return *pTableItemMapper; } +inline SvXMLImportItemMapper& SwXMLImport::GetTableItemMapper() +{ + return *pTableItemMapper; +} + inline void SwXMLImport::SetProgressValue( sal_Int32 nValue ) { if ( bShowProgress ) diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx index a3d42a2784..7860205683 100644 --- a/sw/source/filter/xml/xmlimpit.cxx +++ b/sw/source/filter/xml/xmlimpit.cxx @@ -78,11 +78,17 @@ SvXMLImportItemMapper::~SvXMLImportItemMapper() { } +void +SvXMLImportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries ) +{ + mrMapEntries = rMapEntries; +} + /** fills the given itemset with the attributes in the given list */ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet, uno::Reference< xml::sax::XAttributeList > xAttrList, const SvXMLUnitConverter& rUnitConverter, - const SvXMLNamespaceMap& rNamespaceMap ) const + const SvXMLNamespaceMap& rNamespaceMap ) { sal_Int16 nAttr = xAttrList->getLength(); @@ -193,7 +199,7 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet, delete pUnknownItem; } - finished( rSet ); + finished(rSet, rUnitConverter); } /** this method is called for every item that has the @@ -204,7 +210,7 @@ SvXMLImportItemMapper::handleSpecialItem( const SvXMLItemMapEntry& /*rEntry*/, SfxItemSet& /*rSet*/, const OUString& /*rValue*/, const SvXMLUnitConverter& /*rUnitConverter*/, - const SvXMLNamespaceMap& /*rNamespaceMap*/ ) const + const SvXMLNamespaceMap& /*rNamespaceMap*/ ) { DBG_ERROR( "unsuported special item in xml import" ); return sal_False; @@ -216,13 +222,14 @@ sal_Bool SvXMLImportItemMapper::handleNoItem( const SvXMLItemMapEntry& /*rEntry* SfxItemSet& /*rSet*/, const OUString& /*rValue*/, const SvXMLUnitConverter& /*rUnitConverter*/, - const SvXMLNamespaceMap& /*rNamespaceMap*/ ) const + const SvXMLNamespaceMap& /*rNamespaceMap*/ ) { DBG_ERROR( "unsuported no item in xml import" ); return sal_False; } -void SvXMLImportItemMapper::finished( SfxItemSet& ) const +void +SvXMLImportItemMapper::finished(SfxItemSet &, SvXMLUnitConverter const&) const { // nothing to do here } diff --git a/sw/source/filter/xml/xmlimpit.hxx b/sw/source/filter/xml/xmlimpit.hxx index b852555b21..17dd9f4814 100644 --- a/sw/source/filter/xml/xmlimpit.hxx +++ b/sw/source/filter/xml/xmlimpit.hxx @@ -58,7 +58,7 @@ public: void importXML( SfxItemSet& rSet, ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > xAttrList, const SvXMLUnitConverter& rUnitConverter, - const SvXMLNamespaceMap& rNamespaceMap ) const; + const SvXMLNamespaceMap& rNamespaceMap ); /** this method is called for every item that has the MID_SW_FLAG_SPECIAL_ITEM_IMPORT flag set */ @@ -67,7 +67,7 @@ public: SfxItemSet& rSet, const ::rtl::OUString& rValue, const SvXMLUnitConverter& rUnitConverter, - const SvXMLNamespaceMap& rNamespaceMap ) const; + const SvXMLNamespaceMap& rNamespaceMap ); /** this method is called for every item that has the MID_SW_FLAG_NO_ITEM_IMPORT flag set */ @@ -75,13 +75,14 @@ public: SfxItemSet& rSet, const ::rtl::OUString& rValue, const SvXMLUnitConverter& rUnitConverter, - const SvXMLNamespaceMap& rNamespaceMap ) const; + const SvXMLNamespaceMap& rNamespaceMap ); /** This method is called when all attributes have benn processed. It * may be used to remove items that are incomplete */ - virtual void finished( SfxItemSet& rSet ) const; + virtual void finished(SfxItemSet & rSet, + SvXMLUnitConverter const& rUnitConverter) const; - inline void setMapEntries( SvXMLItemMapEntriesRef rMapEntries ); + virtual void setMapEntries( SvXMLItemMapEntriesRef rMapEntries ); inline SvXMLItemMapEntriesRef getMapEntries() const; @@ -94,12 +95,6 @@ public: const SvXMLUnitConverter& rUnitConverter ); }; -inline void -SvXMLImportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries ) -{ - mrMapEntries = rMapEntries; -} - inline SvXMLItemMapEntriesRef SvXMLImportItemMapper::getMapEntries() const { diff --git a/sw/source/filter/xml/xmlitem.cxx b/sw/source/filter/xml/xmlitem.cxx index 49869ccd33..4af2149488 100644 --- a/sw/source/filter/xml/xmlitem.cxx +++ b/sw/source/filter/xml/xmlitem.cxx @@ -39,15 +39,14 @@ SvXMLItemSetContext::SvXMLItemSetContext( SvXMLImport& rImp, sal_uInt16 nPrfx, const OUString& rLName, const uno::Reference< xml::sax::XAttributeList >& xAttrList, SfxItemSet& rISet, - const SvXMLImportItemMapper& rIMap, + SvXMLImportItemMapper& rIMap, const SvXMLUnitConverter& rUnitConverter ): SvXMLImportContext( rImp, nPrfx, rLName ), rItemSet( rISet ), rIMapper( rIMap ), rUnitConv( rUnitConverter ) - { - rIMapper.importXML( rItemSet, xAttrList, rUnitConv, + rIMap.importXML( rItemSet, xAttrList, rUnitConv, GetImport().GetNamespaceMap() ); } diff --git a/sw/source/filter/xml/xmlitem.hxx b/sw/source/filter/xml/xmlitem.hxx index a09fbcaff1..1847ee49c8 100644 --- a/sw/source/filter/xml/xmlitem.hxx +++ b/sw/source/filter/xml/xmlitem.hxx @@ -53,7 +53,7 @@ public: const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList, SfxItemSet& rItemSet, - const SvXMLImportItemMapper& rIMappper, + SvXMLImportItemMapper& rIMap, const SvXMLUnitConverter& rUnitConv ); virtual ~SvXMLItemSetContext(); diff --git a/sw/source/filter/xml/xmlitemi.cxx b/sw/source/filter/xml/xmlitemi.cxx index 3a0ff6c52f..2b11661449 100644 --- a/sw/source/filter/xml/xmlitemi.cxx +++ b/sw/source/filter/xml/xmlitemi.cxx @@ -28,37 +28,35 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sw.hxx" - - -#include <hintids.hxx> #include <rtl/ustring.hxx> + #include <rsc/rscsfx.hxx> -#include "xmlitmap.hxx" -#include "xmlimpit.hxx" -#include "xmlitem.hxx" + #include <xmloff/i18nmap.hxx> #include <xmloff/xmluconv.hxx> -#ifndef _XMLOFF_FAMILIES_HXX #include <xmloff/families.hxx> -#endif -#include <svx/unomid.hxx> +#include <xmloff/xmlnmspe.hxx> +#include <xmloff/xmltoken.hxx> + #include <editeng/boxitem.hxx> #include <editeng/fontitem.hxx> #include <editeng/tstpitem.hxx> #include <editeng/boxitem.hxx> #include <editeng/brshitem.hxx> #include <editeng/langitem.hxx> +#include <editeng/memberids.hrc> -#ifndef _XMLOFF_XMLTABI_HXX -//#include <xmloff/xmltabi.hxx> -#endif -#include "xmlbrshi.hxx" +#include <svx/unomid.hxx> + +#include <hintids.hxx> #include <paratr.hxx> #include <doc.hxx> -#ifndef _UNOMID_H #include <unomid.h> -#endif +#include "xmlbrshi.hxx" #include "xmlimp.hxx" +#include "xmlitmap.hxx" +#include "xmlimpit.hxx" +#include "xmlitem.hxx" using ::rtl::OUString; using namespace ::com::sun::star; @@ -82,32 +80,93 @@ public: SfxItemSet& rSet, const OUString& rValue, const SvXMLUnitConverter& rUnitConverter, - const SvXMLNamespaceMap& rNamespaceMap ) const; - virtual void finished( SfxItemSet& rSet ) const; + const SvXMLNamespaceMap& rNamespaceMap ); + + virtual sal_Bool + handleNoItem(SvXMLItemMapEntry const& rEntry, + SfxItemSet & rSet, + ::rtl::OUString const& rValue, + SvXMLUnitConverter const& rUnitConverter, + SvXMLNamespaceMap const& rNamespaceMap); + + virtual void finished(SfxItemSet & rSet, + SvXMLUnitConverter const& rUnitConverter) const; + + virtual void setMapEntries( SvXMLItemMapEntriesRef rMapEntries ); + +private: + void Reset(); + + ::rtl::OUString m_FoMarginValue; + enum { LEFT = 0, RIGHT = 1, TOP = 2, BOTTOM = 3 }; + bool m_bHaveMargin[4]; }; SwXMLImportTableItemMapper_Impl::SwXMLImportTableItemMapper_Impl( SvXMLItemMapEntriesRef rMapEntries ) : SvXMLImportItemMapper( rMapEntries, RES_UNKNOWNATR_CONTAINER) { + Reset(); } SwXMLImportTableItemMapper_Impl::~SwXMLImportTableItemMapper_Impl() { } +void SwXMLImportTableItemMapper_Impl::Reset() +{ + m_FoMarginValue = ::rtl::OUString(); + for (int i = 0; i < 3; ++i) + { + m_bHaveMargin[i] = false; + } +} + +void SwXMLImportTableItemMapper_Impl::setMapEntries( + SvXMLItemMapEntriesRef rMapEntries ) +{ + Reset(); + SvXMLImportItemMapper::setMapEntries(rMapEntries); +} + sal_Bool SwXMLImportTableItemMapper_Impl::handleSpecialItem( const SvXMLItemMapEntry& rEntry, SfxPoolItem& rItem, SfxItemSet& rItemSet, const OUString& rValue, const SvXMLUnitConverter& rUnitConv, - const SvXMLNamespaceMap& ) const + const SvXMLNamespaceMap& ) { sal_Bool bRet = sal_False; sal_uInt16 nMemberId = static_cast< sal_Int16 >(rEntry.nMemberId & MID_SW_FLAG_MASK); switch( rItem.Which() ) { + case RES_LR_SPACE: + switch (nMemberId) + { + case MID_L_MARGIN: + m_bHaveMargin[LEFT] = true; + break; + case MID_R_MARGIN: + m_bHaveMargin[RIGHT] = true; + break; + } + bRet = SvXMLImportItemMapper::PutXMLValue( + rItem, rValue, nMemberId, rUnitConv); + break; + case RES_UL_SPACE: + switch (nMemberId) + { + case MID_UP_MARGIN: + m_bHaveMargin[TOP] = true; + break; + case MID_LO_MARGIN: + m_bHaveMargin[BOTTOM] = true; + break; + } + bRet = SvXMLImportItemMapper::PutXMLValue( + rItem, rValue, nMemberId, rUnitConv); + break; case RES_FRM_SIZE: switch( nMemberId ) { @@ -125,8 +184,72 @@ sal_Bool SwXMLImportTableItemMapper_Impl::handleSpecialItem( return bRet; } -void SwXMLImportTableItemMapper_Impl::finished( SfxItemSet& /*rSet*/ ) const + +sal_Bool SwXMLImportTableItemMapper_Impl::handleNoItem( + SvXMLItemMapEntry const& rEntry, + SfxItemSet & rSet, + ::rtl::OUString const& rValue, + SvXMLUnitConverter const& rUnitConverter, + SvXMLNamespaceMap const& rNamespaceMap) +{ + if ((XML_NAMESPACE_FO == rEntry.nNameSpace) && + (xmloff::token::XML_MARGIN == rEntry.eLocalName)) + { + m_FoMarginValue = rValue; + return true; + } + else + { + return SvXMLImportItemMapper::handleNoItem( + rEntry, rSet, rValue, rUnitConverter, rNamespaceMap); + } +} + +void SwXMLImportTableItemMapper_Impl::finished( + SfxItemSet & rSet, SvXMLUnitConverter const& rUnitConverter) const { + if (m_FoMarginValue.getLength()) + { + sal_uInt16 const Ids[4][2] = { + { RES_LR_SPACE, MID_L_MARGIN }, + { RES_LR_SPACE, MID_R_MARGIN }, + { RES_UL_SPACE, MID_UP_MARGIN }, + { RES_UL_SPACE, MID_LO_MARGIN }, + }; + for (int i = 0; i < 4; ++i) + { + if (m_bHaveMargin[i]) + { + continue; // already read fo:margin-top etc. + } + // first get item from itemset + SfxPoolItem const* pItem = 0; + SfxItemState eState = + rSet.GetItemState(Ids[i][0], sal_True, &pItem); + + // if not set, try the pool + if ((SFX_ITEM_SET != eState) && (SFX_WHICH_MAX > Ids[i][0])) + { + pItem = &rSet.GetPool()->GetDefaultItem(Ids[i][0]); + } + + // do we have an item? + if (eState >= SFX_ITEM_DEFAULT && pItem) + { + SfxPoolItem *const pNewItem = pItem->Clone(); + bool const bPut = PutXMLValue( + *pNewItem, m_FoMarginValue, Ids[i][1], rUnitConverter); + if (bPut) + { + rSet.Put(*pNewItem); + } + } + else + { + OSL_ENSURE(false, "could not get item"); + } + } + } } // --------------------------------------------------------------------- @@ -142,7 +265,7 @@ public: const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList, SfxItemSet& rItemSet, - const SvXMLImportItemMapper& rIMapper, + SvXMLImportItemMapper & rIMapper, const SvXMLUnitConverter& rUnitConv ); virtual ~SwXMLItemSetContext_Impl(); @@ -159,7 +282,7 @@ SwXMLItemSetContext_Impl::SwXMLItemSetContext_Impl( const OUString& rLName, const Reference< xml::sax::XAttributeList > & xAttrList, SfxItemSet& _rItemSet, - const SvXMLImportItemMapper& _rIMapper, + SvXMLImportItemMapper & _rIMapper, const SvXMLUnitConverter& _rUnitConv ) : SvXMLItemSetContext( rImport, nPrfx, rLName, xAttrList, _rItemSet, _rIMapper, _rUnitConv ) diff --git a/sw/source/filter/xml/xmlitemm.cxx b/sw/source/filter/xml/xmlitemm.cxx index e82ef86449..70bf72a32b 100644 --- a/sw/source/filter/xml/xmlitemm.cxx +++ b/sw/source/filter/xml/xmlitemm.cxx @@ -48,6 +48,8 @@ using namespace ::xmloff::token; { XML_NAMESPACE_##p, XML_##l, w, MID_SW_FLAG_SPECIAL_ITEM_IMPORT|m } #define M_E_SE( p, l, w, m ) \ { XML_NAMESPACE_##p, XML_##l, w, MID_SW_FLAG_SPECIAL_ITEM_EXPORT|m } +#define M_E_SIE( p, l, w, m ) \ + { XML_NAMESPACE_##p, XML_##l, w, MID_SW_FLAG_SPECIAL_ITEM_EXPORT|MID_SW_FLAG_SPECIAL_ITEM_IMPORT|m } #define M_END { 0, XML_TOKEN_INVALID, 0, 0 } @@ -61,11 +63,12 @@ SvXMLItemMapEntry aXMLTableItemMap[] = // RES_PAPER_BIN // not required // TODO: RES_LR_SPACE - M_E_SE( FO, MARGIN_LEFT, RES_LR_SPACE, MID_L_MARGIN ), - M_E_SE( FO, MARGIN_RIGHT, RES_LR_SPACE, MID_R_MARGIN ), + M_E_SE( FO, MARGIN, -1, MID_SW_FLAG_NO_ITEM_IMPORT), + M_E_SIE( FO, MARGIN_LEFT, RES_LR_SPACE, MID_L_MARGIN ), + M_E_SIE( FO, MARGIN_RIGHT, RES_LR_SPACE, MID_R_MARGIN ), // RES_UL_SPACE - MAP_ENTRY( FO, MARGIN_TOP, RES_UL_SPACE, MID_UP_MARGIN ), - MAP_ENTRY( FO, MARGIN_BOTTOM, RES_UL_SPACE, MID_LO_MARGIN ), + M_E_SI( FO, MARGIN_TOP, RES_UL_SPACE, MID_UP_MARGIN ), + M_E_SI( FO, MARGIN_BOTTOM, RES_UL_SPACE, MID_LO_MARGIN ), // RES_PAGEDESC MAP_ENTRY( STYLE, PAGE_NUMBER, RES_PAGEDESC, MID_PAGEDESC_PAGENUMOFFSET), // RES_BREAK diff --git a/sw/source/filter/xml/xmlmeta.cxx b/sw/source/filter/xml/xmlmeta.cxx index 225ab05390..351006c08d 100644 --- a/sw/source/filter/xml/xmlmeta.cxx +++ b/sw/source/filter/xml/xmlmeta.cxx @@ -57,22 +57,34 @@ using namespace ::xmloff::token; // --------------------------------------------------------------------- +uno::Reference<document::XDocumentProperties> +SwXMLImport::GetDocumentProperties() const +{ + if (IsOrganizerMode() || IsStylesOnlyMode() || + IsBlockMode() || IsInsertMode()) + { + return 0; + } + uno::Reference<document::XDocumentPropertiesSupplier> const xDPS( + GetModel(), UNO_QUERY_THROW); + return xDPS->getDocumentProperties(); +} + SvXMLImportContext *SwXMLImport::CreateMetaContext( const OUString& rLocalName ) { SvXMLImportContext *pContext = 0; - if( !(IsStylesOnlyMode() || IsInsertMode()) ) + if (getImportFlags() & IMPORT_META) { - uno::Reference<xml::sax::XDocumentHandler> xDocBuilder( + uno::Reference<xml::sax::XDocumentHandler> const xDocBuilder( mxServiceFactory->createInstance(::rtl::OUString::createFromAscii( "com.sun.star.xml.dom.SAXDocumentBuilder")), - uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentPropertiesSupplier> xDPS( - GetModel(), UNO_QUERY_THROW); + uno::UNO_QUERY_THROW); + uno::Reference<document::XDocumentProperties> const xDocProps( + GetDocumentProperties()); pContext = new SvXMLMetaDocumentContext(*this, - XML_NAMESPACE_OFFICE, rLocalName, - xDPS->getDocumentProperties(), xDocBuilder); + XML_NAMESPACE_OFFICE, rLocalName, xDocProps, xDocBuilder); } if( !pContext ) diff --git a/sw/source/ui/docvw/AnnotationWin.cxx b/sw/source/ui/docvw/AnnotationWin.cxx index 4675805e52..7419ee060e 100644 --- a/sw/source/ui/docvw/AnnotationWin.cxx +++ b/sw/source/ui/docvw/AnnotationWin.cxx @@ -111,15 +111,23 @@ void SwAnnotationWin::UpdateData() { if ( Engine()->IsModified() ) { - SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld(); - SwPosition aPosition( pTxtFld->GetTxtNode() ); - aPosition.nContent = *pTxtFld->GetStart(); - SwField* pOldField = mpFld->Copy(); + IDocumentUndoRedo & rUndoRedo( + DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo()); + ::std::auto_ptr<SwField> pOldField; + if (rUndoRedo.DoesUndo()) + { + pOldField.reset(mpFld->Copy()); + } mpFld->SetPar2(Engine()->GetEditEngine().GetText()); mpFld->SetTextObject(Engine()->CreateParaObject()); - DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo().AppendUndo( - new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); - delete pOldField; + if (rUndoRedo.DoesUndo()) + { + SwTxtFld *const pTxtFld = mpFmtFld->GetTxtFld(); + SwPosition aPosition( pTxtFld->GetTxtNode() ); + aPosition.nContent = *pTxtFld->GetStart(); + rUndoRedo.AppendUndo( + new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); + } // 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 @@ -242,15 +250,23 @@ void SwAnnotationWin::InitAnswer(OutlinerParaObject* pText) // 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() ); - SwTxtFld* pTxtFld = mpFmtFld->GetTxtFld(); - SwPosition aPosition( pTxtFld->GetTxtNode() ); - aPosition.nContent = *pTxtFld->GetStart(); - SwField* pOldField = mpFld->Copy(); + IDocumentUndoRedo & rUndoRedo( + DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo()); + ::std::auto_ptr<SwField> pOldField; + if (rUndoRedo.DoesUndo()) + { + pOldField.reset(mpFld->Copy()); + } mpFld->SetPar2(Engine()->GetEditEngine().GetText()); mpFld->SetTextObject(Engine()->CreateParaObject()); - DocView().GetDocShell()->GetDoc()->GetIDocumentUndoRedo().AppendUndo( - new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); - delete pOldField; + if (rUndoRedo.DoesUndo()) + { + SwTxtFld *const pTxtFld = mpFmtFld->GetTxtFld(); + SwPosition aPosition( pTxtFld->GetTxtNode() ); + aPosition.nContent = *pTxtFld->GetStart(); + rUndoRedo.AppendUndo( + new SwUndoFieldFromDoc(aPosition, *pOldField, *mpFld, 0, true)); + } Engine()->SetModifyHdl( LINK( this, SwAnnotationWin, ModifyHdl ) ); Engine()->ClearModifyFlag(); Engine()->GetUndoManager().Clear(); diff --git a/sw/source/ui/index/idxmrk.src b/sw/source/ui/index/idxmrk.src index e0a1a4df9c..fc38d7c6d2 100644 --- a/sw/source/ui/index/idxmrk.src +++ b/sw/source/ui/index/idxmrk.src @@ -287,6 +287,14 @@ ModalDialog DLG_EDIT_IDXMARK #define COL_BUTTONS_2 (COL_BUTTONS+26) #define WINDOW_HEIGHT 118 IDX_DIALOG_WINDOW + #undef IDX_WIN_WIDTH + #undef GB_HEIGHT + #undef DCB_INDEX_WIDTH + #undef PHONETIC_HIDDEN + #undef LIST_WIDTH + #undef COL_BUTTONS + #undef COL_BUTTONS_2 + #undef WINDOW_HEIGHT }; ModalDialog DLG_EDIT_IDXMARK_CJK { @@ -306,6 +314,14 @@ ModalDialog DLG_EDIT_IDXMARK_CJK #define COL_BUTTONS_2 (COL_BUTTONS+26) #define WINDOW_HEIGHT 118 IDX_DIALOG_WINDOW + #undef IDX_WIN_WIDTH + #undef GB_HEIGHT + #undef DCB_INDEX_WIDTH + #undef PHONETIC_HIDDEN + #undef LIST_WIDTH + #undef COL_BUTTONS + #undef COL_BUTTONS_2 + #undef WINDOW_HEIGHT }; ModelessDialog DLG_INSIDXMARK { @@ -328,6 +344,14 @@ ModelessDialog DLG_INSIDXMARK #define COL_BUTTONS_2 (COL_BUTTONS+26) #define WINDOW_HEIGHT 138 IDX_DIALOG_WINDOW + #undef IDX_WIN_WIDTH + #undef GB_HEIGHT + #undef DCB_INDEX_WIDTH + #undef PHONETIC_HIDDEN + #undef LIST_WIDTH + #undef COL_BUTTONS + #undef COL_BUTTONS_2 + #undef WINDOW_HEIGHT }; ModelessDialog DLG_INSIDXMARK_CJK { @@ -349,6 +373,14 @@ ModelessDialog DLG_INSIDXMARK_CJK #define COL_BUTTONS_2 (COL_BUTTONS+26) #define WINDOW_HEIGHT 138 IDX_DIALOG_WINDOW + #undef IDX_WIN_WIDTH + #undef GB_HEIGHT + #undef DCB_INDEX_WIDTH + #undef PHONETIC_HIDDEN + #undef LIST_WIDTH + #undef COL_BUTTONS + #undef COL_BUTTONS_2 + #undef WINDOW_HEIGHT }; ModalDialog DLG_NEW_USER_IDX { @@ -529,6 +561,7 @@ ModalDialog DLG_EDIT_AUTHMARK Size = MAP_APPFONT ( 218 , 118 ) ; #define RADIO_BUTTON_HEIGHT 0 AUTH_DIALOG_WINDOW + #undef RADIO_BUTTON_HEIGHT }; ModelessDialog DLG_INSAUTHMARK { @@ -543,6 +576,7 @@ ModelessDialog DLG_INSAUTHMARK Size = MAP_APPFONT ( 218 , 118 + RADIO_BUTTON_HEIGHT) ; // Moveable = TRUE ; AUTH_DIALOG_WINDOW + #undef RADIO_BUTTON_HEIGHT }; ModalDialog DLG_CREATE_AUTH_ENTRY { diff --git a/sw/source/ui/ribbar/inputwin.cxx b/sw/source/ui/ribbar/inputwin.cxx index 0016a4ac45..934bde75cd 100755 --- a/sw/source/ui/ribbar/inputwin.cxx +++ b/sw/source/ui/ribbar/inputwin.cxx @@ -165,6 +165,7 @@ void SwInputWindow::CleanupUglyHackWithUndo() { SW_MOD()->GetUndoOptions().SetUndoCount(0); } + m_bResetUndo = false; // #i117122# once is enough :) } } |