1 /*************************************************************************
3 * The Contents of this file are made available subject to the terms of
4 * either of the following licenses
6 * - GNU Lesser General Public License Version 2.1
7 * - Sun Industry Standards Source License Version 1.1
9 * Sun Microsystems Inc., October, 2000
11 * GNU Lesser General Public License Version 2.1
12 * =============================================
13 * Copyright 2000 by Sun Microsystems, Inc.
14 * 901 San Antonio Road, Palo Alto, CA 94303, USA
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License version 2.1, as published by the Free Software Foundation.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 * Sun Industry Standards Source License Version 1.1
32 * =================================================
33 * The contents of this file are subject to the Sun Industry Standards
34 * Source License Version 1.1 (the "License"); You may not use this file
35 * except in compliance with the License. You may obtain a copy of the
36 * License at http://www.openoffice.org/license.html.
38 * Software provided under this License is provided on an "AS IS" basis,
39 * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
40 * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
41 * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
42 * See the License for the specific provisions governing your rights and
43 * obligations concerning the Software.
45 * The Initial Developer of the Original Code is: IBM Corporation
47 * Copyright: 2008 by IBM Corporation
49 * All Rights Reserved.
51 * Contributor(s): _______________________________________
54 ************************************************************************/
55 /*************************************************************************
57 * For LWP filter architecture prototype
58 ************************************************************************/
59 /*************************************************************************
62 ************************************************************************/
63 #include "lwpchangemgr.hxx"
64 #include <rtl/ustring.hxx>
65 #include "lwppara.hxx"
66 #include "lwpfribheader.hxx"
67 #include "lwpfribptr.hxx"
68 #include "lwpfrib.hxx"
69 #include "lwpstory.hxx"
70 #include "lwpfribsection.hxx"
71 #include "lwpsection.hxx"
72 #include "lwpfribbreaks.hxx"
73 #include "lwpfribframe.hxx"
74 #include "lwpfribtable.hxx"
75 #include "lwphyperlinkmgr.hxx"
76 #include "lwpfootnote.hxx"
77 #include "lwpnotes.hxx"
78 #include "lwpfribmark.hxx"
79 #include "xfilter/xftextspan.hxx"
80 #include "xfilter/xftextcontent.hxx"
81 #include "xfilter/xftabstop.hxx"
82 #include "xfilter/xflinebreak.hxx"
83 #include "xfilter/xfstylemanager.hxx"
84 #include "xfilter/xfhyperlink.hxx"
86 LwpChangeMgr::LwpChangeMgr()
90 m_HeadFootFribMap
.clear();
91 m_pFribMap
= &m_DocFribMap
;
94 LwpChangeMgr::~LwpChangeMgr()
98 m_HeadFootFribMap
.clear();
102 void LwpChangeMgr::AddChangeFrib(LwpFrib
* pFrib
)
105 OUString sID
= A2OUSTR("ct")+ Int32ToOUString(m_nCounter
);
106 m_pFribMap
->insert(std::pair
<LwpFrib
*,OUString
>(pFrib
,sID
));
109 OUString
LwpChangeMgr::GetChangeID(LwpFrib
* pFrib
)
111 std::map
<LwpFrib
*,OUString
>::iterator iter
;
112 iter
= m_pFribMap
->find(pFrib
);
113 if (iter
== m_pFribMap
->end())
119 void LwpChangeMgr::ConvertAllChange(IXFStream
* pStream
)
121 std::map
<LwpFrib
*,OUString
>::iterator iter
;
122 for (iter
=m_DocFribMap
.begin();iter
!=m_DocFribMap
.end();iter
++)
124 if (iter
->first
->GetRevisionType() == LwpFrib::REV_INSERT
)
126 XFChangeInsert
* pInsert
= new XFChangeInsert
;
127 pInsert
->SetChangeID(iter
->second
);
128 pInsert
->SetEditor(iter
->first
->GetEditor());
129 m_ChangeList
.push_back(pInsert
);
131 else if (iter
->first
->GetRevisionType() == LwpFrib::REV_DELETE
)
133 XFChangeDelete
* pDelete
= new XFChangeDelete
;
134 pDelete
->SetChangeID(iter
->second
);
135 pDelete
->SetEditor(iter
->first
->GetEditor());
136 /// ConvertFribContent(pDelete,iter->first); //delete tmp,note by ,2005/7/1
137 m_ChangeList
.push_back(pDelete
);
141 std::vector
<XFChangeRegion
*>::iterator iter1
;
142 pStream
->GetAttrList()->Clear();
143 if (m_ChangeList
.size() == 0)
145 //Add by ,for disable change tracking,2005/11/21
146 pStream
->GetAttrList()->AddAttribute( A2OUSTR("text:track-changes"),A2OUSTR("false"));
148 pStream
->StartElement( A2OUSTR("text:tracked-changes") );
149 for (iter1
=m_ChangeList
.begin();iter1
!=m_ChangeList
.end();iter1
++)
150 (*iter1
)->ToXml(pStream
);
152 pStream
->EndElement(A2OUSTR("text:tracked-changes"));
154 // m_DocFribMap.clear();
156 for (iter1
=m_ChangeList
.begin();iter1
!=m_ChangeList
.end();iter1
++)
161 m_ChangeList
.clear();
163 void LwpChangeMgr::SetHeadFootFribMap(sal_Bool bFlag
)
165 if (bFlag
== sal_True
)
166 m_pFribMap
= &m_HeadFootFribMap
;
169 m_HeadFootFribMap
.clear();
170 m_pFribMap
= &m_DocFribMap
;
174 void LwpChangeMgr::SetHeadFootChange(XFContentContainer
* pCont
)
176 std::map
<LwpFrib
*,OUString
>::iterator iter
;
177 XFChangeList
* pChangeList
= new XFChangeList
;
179 for (iter
=m_HeadFootFribMap
.begin();iter
!=m_HeadFootFribMap
.end();iter
++)
181 if (iter
->first
->GetRevisionType() == LwpFrib::REV_INSERT
)
183 XFChangeInsert
* pInsert
= new XFChangeInsert
;
184 pInsert
->SetChangeID(iter
->second
);
185 pInsert
->SetEditor(iter
->first
->GetEditor());
186 pChangeList
->Add(pInsert
);
188 else if (iter
->first
->GetRevisionType() == LwpFrib::REV_DELETE
)
190 XFChangeDelete
* pDelete
= new XFChangeDelete
;
191 pDelete
->SetChangeID(iter
->second
);
192 pDelete
->SetEditor(iter
->first
->GetEditor());
193 pChangeList
->Add(pDelete
);
197 pCont
->Add(pChangeList
);
199 // m_HeadFootFribMap.clear();
202 void LwpChangeMgr::ConvertFribContent(XFContentContainer
* pCont
, LwpFrib
* pFrib
)
204 XFParagraph
* pXFPara
= new XFParagraph
;
205 LwpPara
* pPara
= pFrib
->GetMyPara();
207 pXFPara
->SetStyleName(pPara
->GetStyleName());
209 switch(pFrib
->GetType())//copy code from class lwpfribptr
213 LwpFribText
* textFrib
= static_cast<LwpFribText
*>(pFrib
);
214 textFrib
->XFConvert(pXFPara
,pPara
->GetStory());
219 LwpFribTab
* tabFrib
= static_cast<LwpFribTab
*>(pFrib
);
220 if (pFrib
->m_ModFlag
)
222 XFTextSpan
*pSpan
= new XFTextSpan();
223 pSpan
->SetStyleName(tabFrib
->GetStyleName());
224 XFTabStop
*pTab
= new XFTabStop();
230 XFTabStop
*pTab
= new XFTabStop();
235 /* case FRIB_TAG_SECTION:
238 LwpFribSection* pSectionFrib = static_cast<LwpFribSection*>(pFrib);
239 pSectionFrib->ParseSection();
242 case FRIB_TAG_PAGEBREAK:
244 LwpFribPageBreak* pPageBreak = static_cast<LwpFribPageBreak*>(pFrib);
245 LwpPageLayout* pLayout = static_cast<LwpPageLayout*>(pPageBreak->GetLayout()->obj());
248 pPageBreak->ParseLayout();
252 if (pPageBreak->IsLastFrib() == sal_True)
254 pXFPara->SetStyleName( pPageBreak->GetStyleName() );
259 XFParagraph *pNewPara = new XFParagraph();
260 pNewPara->SetStyleName(pFrib->GetStyleName());
261 pPara->AddXFContent(pNewPara);
266 case FRIB_TAG_COLBREAK:
268 XFParagraph *pNewPara = new XFParagraph();
269 pNewPara->SetStyleName(pFrib->GetStyleName());
270 pPara->AddXFContent(pNewPara);
273 */ case FRIB_TAG_LINEBREAK
:
275 XFLineBreak
*pLineBreak
= new XFLineBreak();
276 pXFPara
->Add(pLineBreak
);
279 case FRIB_TAG_UNICODE
: //fall through
280 case FRIB_TAG_UNICODE2
: //fall through
281 case FRIB_TAG_UNICODE3
: //fall through
283 LwpFribUnicode
* unicodeFrib
= static_cast<LwpFribUnicode
*>(pFrib
);
284 unicodeFrib
->XFConvert(pXFPara
,pPara
->GetStory());
287 case FRIB_TAG_HARDSPACE
:
289 rtl::OUString
sHardSpace(sal_Unicode(0x00a0));
290 LwpHyperlinkMgr
* pHyperlink
=
291 pPara
->GetStory()->GetHyperlinkMgr();
292 if (pHyperlink
->GetHyperlinkFlag())
293 pFrib
->ConvertHyperLink(pXFPara
,pHyperlink
,sHardSpace
);
295 pFrib
->ConvertChars(pXFPara
,sHardSpace
);
298 case FRIB_TAG_SOFTHYPHEN
:
300 rtl::OUString
sSoftHyphen(sal_Unicode(0x00ad));
301 pFrib
->ConvertChars(pXFPara
,sSoftHyphen
);
304 /* case FRIB_TAG_FRAME:
306 LwpFribFrame* frameFrib= static_cast<LwpFribFrame*>(pFrib);
307 LwpObject* pLayout = frameFrib->GetLayout();
308 if (pLayout->GetTag() == VO_DROPCAPLAYOUT)
310 pPara->GetFoundry()->GetDropcapMgr()->SetXFPara(pXFPara);
311 //LwpObject* pDropCap = frameFrib->GetLayout();
312 //pDropCap ->XFConvert(m_pXFPara);
314 //pLayout->XFConvert(m_pXFPara);
315 frameFrib->XFConvert(pXFPara);
318 */ case FRIB_TAG_CHBLOCK
:
320 LwpFribCHBlock
* chbFrib
= static_cast<LwpFribCHBlock
*>(pFrib
);
321 chbFrib
->XFConvert(pXFPara
,pPara
->GetStory());
324 /* case FRIB_TAG_TABLE:
326 LwpFribTable* tableFrib = static_cast<LwpFribTable*>(pFrib);
327 //tableFrib->XFConvert(m_pPara->GetXFContainer());
328 tableFrib->XFConvert(pXFPara);
331 */ case FRIB_TAG_BOOKMARK
:
333 LwpFribBookMark
* bookmarkFrib
= static_cast<LwpFribBookMark
*>(pFrib
);
334 bookmarkFrib
->XFConvert(pXFPara
);
337 case FRIB_TAG_FOOTNOTE
:
339 LwpFribFootnote
* pFootnoteFrib
= static_cast<LwpFribFootnote
*>(pFrib
);
340 pFootnoteFrib
->XFConvert(pXFPara
);
345 LwpFribField
* fieldFrib
= static_cast<LwpFribField
*>(pFrib
);
346 fieldFrib
->XFConvert(pXFPara
);
351 LwpFribNote
* pNoteFrib
= static_cast<LwpFribNote
*>(pFrib
);
352 pNoteFrib
->XFConvert(pXFPara
);
355 case FRIB_TAG_PAGENUMBER
:
357 LwpFribPageNumber
* pagenumFrib
= static_cast<LwpFribPageNumber
*>(pFrib
);
358 pagenumFrib
->XFConvert(pXFPara
);
361 case FRIB_TAG_DOCVAR
:
363 LwpFribDocVar
* docFrib
= static_cast<LwpFribDocVar
*>(pFrib
);
364 docFrib
->XFConvert(pXFPara
);
367 case FRIB_TAG_RUBYMARKER
:
369 LwpFribRubyMarker
* rubyFrib
= static_cast<LwpFribRubyMarker
*>(pFrib
);
370 rubyFrib
->XFConvert(pXFPara
);
373 case FRIB_TAG_RUBYFRAME
:
375 LwpFribRubyFrame
* rubyfrmeFrib
= static_cast<LwpFribRubyFrame
*>(pFrib
);
376 rubyfrmeFrib
->XFConvert(pXFPara
);