diff options
author | Jian Hong Cheng <chengjh@apache.org> | 2012-08-24 02:28:19 +0000 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2013-03-14 10:45:58 +0100 |
commit | 8675c8de07255bb77d2191fa62285904aa536c4f (patch) | |
tree | 27e0d1360cd7327593a3bf6272180f07a783c91a /sw/source/core | |
parent | 8a548d2332c162d8713d266ed15aa2ff6e6a2076 (diff) |
Fix issue #i119405: Numbering text style changed after importing the *.doc
* main/sw/inc/doc.hxx
* main/sw/inc/IDocumentContentOperations.hxx
* main/sw/inc/ndtxt.hxx
* main/sw/source/core/doc/docfmt.cxx
* main/sw/source/core/txtnode/thints.cxx
* main/sw/source/filter/inc/fltshell.hxx
* main/sw/source/filter/ww1/fltshell.cxx
* main/sw/source/filter/ww8/ww8par.cxx
* main/sw/source/filter/ww8/ww8par.hxx
* main/sw/source/filter/ww8/ww8par3.cxx
MS Word Binary compatibility
Patch by: Fan Zheng,<zheng.easyfan@gmail.com>
Found by: Jian Hong Cheng,<chengjh@apache.org>
Review by: Jian Hong Cheng,<chengjh@apache.org>
Signed-off-by: Fridrich Štrba <fridrich.strba@bluewin.ch>
Conflicts:
sw/source/filter/inc/fltshell.hxx
sw/source/filter/ww1/fltshell.cxx
sw/source/filter/ww8/ww8par.cxx
sw/source/filter/ww8/ww8par.hxx
(cherry picked from commit ee3b12ab1d62faedcd2d62fcb8011b7454ea0474)
Change-Id: I2f72969a54db53e6a51edcf3a3216647cec9424c
(cherry picked from commit 1c22545edf9085b9f2656ca92781158b6b123db3)
Signed-off-by: Fridrich Štrba <fridrich.strba@bluewin.ch>
Diffstat (limited to 'sw/source/core')
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 54 | ||||
-rw-r--r-- | sw/source/core/txtnode/thints.cxx | 70 |
2 files changed, 120 insertions, 4 deletions
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 484c93c1aa46..352a4511f8de 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -495,7 +495,7 @@ void SwDoc::ResetAttrs( const SwPaM &rRg, static bool lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, - const SetAttrMode nFlags, SwUndoAttr *const pUndo) + const SetAttrMode nFlags, SwUndoAttr *const pUndo,bool bExpandCharToPara=false) { // Divide the Sets (for selections in Nodes) const SfxItemSet* pCharSet = 0; @@ -899,6 +899,24 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, // Only selection in a Node. if( pStt->nNode == pEnd->nNode ) { + //The data parameter flag: bExpandCharToPara, comes from the data member of SwDoc, + //Which is set in SW MS word Binary filter WW8ImplRreader. With this flag on, means that + //current setting attribute set is a character range properties set and comes from a MS word + //binary file, And the setting range include a paragraph end position (0X0D); + //More specifications, as such property inside the character range properties set recorded in + //MS word binary file are dealed and inserted into data model (SwDoc) one by one, so we + //only dealing the scenario that the char properties set with 1 item inside; + + if (bExpandCharToPara && pCharSet && pCharSet->Count() ==1 ) + { + SwTxtNode* pCurrentNd = pStt->nNode.GetNode().GetTxtNode(); + + if (pCurrentNd) + { + pCurrentNd->TryCharSetExpandToNum(*pCharSet); + + } + } DELETECHARSETS return bRet; } @@ -1002,13 +1020,41 @@ lcl_InsAttr(SwDoc *const pDoc, const SwPaM &rRg, const SfxItemSet& rChgSet, ++nNodes; } + //The data parameter flag: bExpandCharToPara, comes from the data member of SwDoc, + //Which is set in SW MS word Binary filter WW8ImplRreader. With this flag on, means that + //current setting attribute set is a character range properties set and comes from a MS word + //binary file, And the setting range include a paragraph end position (0X0D); + //More specifications, as such property inside the character range properties set recorded in + //MS word binary file are dealed and inserted into data model (SwDoc) one by one, so we + //only dealing the scenario that the char properties set with 1 item inside; + if (bExpandCharToPara && pCharSet && pCharSet->Count() ==1) + { + SwPosition aStartPos (*rRg.Start()); + SwPosition aEndPos (*rRg.End()); + + if (aEndPos.nNode.GetNode().GetTxtNode() && aEndPos.nContent != aEndPos.nNode.GetNode().GetTxtNode()->Len()) + aEndPos.nNode--; + + for (;aStartPos<=aEndPos;aStartPos.nNode++) + { + SwTxtNode* pCurrentNd = aStartPos.nNode.GetNode().GetTxtNode(); + + if (pCurrentNd) + { + pCurrentNd->TryCharSetExpandToNum(*pCharSet); + + } + + } + } + DELETECHARSETS return (nNodes != 0) || bRet; } - +//Add a para for the char attribute exp... bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, - const SetAttrMode nFlags ) + const SetAttrMode nFlags, bool bExpandCharToPara) { SwDataChanged aTmp( rRg ); SwUndoAttr* pUndoAttr = 0; @@ -1020,7 +1066,7 @@ bool SwDoc::InsertPoolItem( const SwPaM &rRg, const SfxPoolItem &rHt, SfxItemSet aSet( GetAttrPool(), rHt.Which(), rHt.Which() ); aSet.Put( rHt ); - bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr ); + bool bRet = lcl_InsAttr( this, rRg, aSet, nFlags, pUndoAttr,bExpandCharToPara ); if (GetIDocumentUndoRedo().DoesUndo()) { diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index cf549e3a8758..a2be20b37751 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1607,6 +1607,76 @@ void SwTxtNode::DelSoftHyph( const xub_StrLen nStt, const xub_StrLen nEnd ) } } +//In MS Word, the font underline setting of the paragraph end position wont affect the formatting of numbering, so we ignore it +bool lcl_IsIgnoredCharFmtForNumbering(const sal_uInt16 nWhich) +{ + return (nWhich == RES_CHRATR_UNDERLINE); +} + +//In MS Word, following properties of the paragraph end position wont affect the formatting of bullets, so we ignore them: +//Font underline; +//Font Italic of Western, CJK and CTL; +//Font Bold of Wertern, CJK and CTL; +bool lcl_IsIgnoredCharFmtForBullets(const sal_uInt16 nWhich) +{ + return (nWhich == RES_CHRATR_UNDERLINE || nWhich == RES_CHRATR_POSTURE || nWhich == RES_CHRATR_WEIGHT + || nWhich == RES_CHRATR_CJK_POSTURE || nWhich == RES_CHRATR_CJK_WEIGHT + || nWhich == RES_CHRATR_CTL_POSTURE || nWhich == RES_CHRATR_CTL_WEIGHT); +} + +//Condition for expanding char set to character style of specified number rule level: +//The item inside the set should not conflict to any exist and non-default item inside paragraph properties set (SwCntntNode::SwPAttrSet); +//The node should have applied a number rule; +//The node should be counted in a list, if not, make it to be; +//The item should not conflict to any exist and non-default item inside the character of specified number rule level; +//The item should not be ignored depend on the exact number rule type; +bool SwTxtNode::TryCharSetExpandToNum(const SfxItemSet& aCharSet) +{ + bool bRet = false; + SfxItemIter aIter( aCharSet ); + const SfxPoolItem* pItem = aIter.FirstItem(); + const sal_uInt16 nWhich = pItem->Which(); + + const SfxPoolItem& rInnerItem = GetAttr(nWhich,false); + + if (!IsDefaultItem(&rInnerItem) && !IsInvalidItem(&rInnerItem)) + return bRet; + + if ( !IsInList() && GetNumRule() && GetListId().Len() > 0 ) + { + return bRet; + } + + SwNumRule* pCurrNum = GetNumRule(false); + + int nLevel = GetActualListLevel(); + + if (nLevel != -1 && pCurrNum) + { + const SwNumFmt* pCurrNumFmt = pCurrNum->GetNumFmt(static_cast<sal_uInt16>(nLevel)); + if (pCurrNumFmt) + { + if (pCurrNumFmt->IsItemize() && lcl_IsIgnoredCharFmtForBullets(nWhich)) + return bRet; + if (pCurrNumFmt->IsEnumeration() && lcl_IsIgnoredCharFmtForNumbering(nWhich)) + return bRet; + SwCharFmt* pCurrCharFmt =pCurrNumFmt->GetCharFmt(); + + if (pCurrCharFmt && pCurrCharFmt->GetItemState(nWhich,false) != SFX_ITEM_SET) + { + pCurrCharFmt->SetFmtAttr(*pItem); + SwNumFmt aNewNumFmt(*pCurrNumFmt); + aNewNumFmt.SetCharFmt(pCurrCharFmt); + pCurrNum->Set(nLevel,aNewNumFmt); + bRet = true; + } + } + } + + + return bRet; +} + // setze diese Attribute am TextNode. Wird der gesamte Bereich umspannt, // dann setze sie nur im AutoAttrSet (SwCntntNode:: SetAttr) sal_Bool SwTxtNode::SetAttr( const SfxItemSet& rSet, xub_StrLen nStt, |