Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <tools/gen.hxx>
31 : :
32 : : #include <postithelper.hxx>
33 : : #include <PostItMgr.hxx>
34 : : #include <AnnotationWin.hxx>
35 : :
36 : : #include <fmtfld.hxx>
37 : : #include <txtfld.hxx>
38 : : #include <docufld.hxx>
39 : : #include <ndtxt.hxx>
40 : : #include <cntfrm.hxx>
41 : : #include <pagefrm.hxx>
42 : : #include <rootfrm.hxx>
43 : : #include <txtfrm.hxx>
44 : : #include <tabfrm.hxx>
45 : : #include <IDocumentRedlineAccess.hxx>
46 : : #include <redline.hxx>
47 : : #include <scriptinfo.hxx>
48 : : #include <editeng/charhiddenitem.hxx>
49 : : #include <switerator.hxx>
50 : :
51 : : namespace {
52 : :
53 : : struct LayoutInfoOrder
54 : : {
55 : 0 : bool operator()( const SwLayoutInfo& rLayoutInfo,
56 : : const SwLayoutInfo& rNewLayoutInfo )
57 : : {
58 [ # # ]: 0 : if ( rLayoutInfo.mnPageNumber != rNewLayoutInfo.mnPageNumber )
59 : : {
60 : : // corresponding <SwFrm> instances are on different pages
61 : 0 : return rLayoutInfo.mnPageNumber < rNewLayoutInfo.mnPageNumber;
62 : : }
63 : : else
64 : : {
65 : : // corresponding <SwFrm> instances are in different repeating table header rows
66 : : OSL_ENSURE( rLayoutInfo.mpAnchorFrm->FindTabFrm(),
67 : : "<LayoutInfoOrder::operator()> - table frame not found" );
68 : : OSL_ENSURE( rNewLayoutInfo.mpAnchorFrm->FindTabFrm(),
69 : : "<LayoutInfoOrder::operator()> - table frame not found" );
70 : 0 : const SwTabFrm* pLayoutInfoTabFrm( rLayoutInfo.mpAnchorFrm->FindTabFrm() );
71 : 0 : const SwTabFrm* pNewLayoutInfoTabFrm( rNewLayoutInfo.mpAnchorFrm->FindTabFrm() );
72 : 0 : const SwTabFrm* pTmpTabFrm( pNewLayoutInfoTabFrm );
73 [ # # ][ # # ]: 0 : while ( pTmpTabFrm && pTmpTabFrm->GetFollow() )
[ # # ]
74 : : {
75 : 0 : pTmpTabFrm = static_cast<const SwTabFrm*>(pTmpTabFrm->GetFollow()->GetFrm());
76 [ # # ]: 0 : if ( pTmpTabFrm == pLayoutInfoTabFrm )
77 : : {
78 : 0 : return false;
79 : : }
80 : : }
81 : 0 : return true;
82 : : }
83 : : }
84 : : };
85 : :
86 : : } // eof anonymous namespace
87 : :
88 : 99 : SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos( std::vector< SwLayoutInfo >& rInfo, SwPosition& rPos )
89 : : {
90 : 99 : SwLayoutStatus aRet = INVISIBLE;
91 : 99 : const SwTxtNode* pTxtNode = rPos.nNode.GetNode().GetTxtNode();
92 : 99 : SwCntntNode* pNode = rPos.nNode.GetNode().GetCntntNode(); // getfirstcontentnode // getnext...
93 [ - + ]: 99 : if( !pNode )
94 : 0 : return aRet;
95 [ + - ]: 99 : SwIterator<SwTxtFrm,SwCntntNode> aIter( *pNode );
96 [ + - ][ + - ]: 198 : for( SwTxtFrm* pTxtFrm = aIter.First(); pTxtFrm; pTxtFrm = aIter.Next() )
[ + + ]
97 : : {
98 [ + - ]: 99 : if( !pTxtFrm->IsFollow() )
99 : : {
100 [ + - ]: 99 : pTxtFrm = ((SwTxtFrm*)pTxtFrm)->GetFrmAtPos( rPos );
101 [ + - ][ + - ]: 99 : SwPageFrm *pPage = pTxtFrm ? pTxtFrm->FindPageFrm() : 0;
102 : : // #i103490#
103 [ + - ][ + + ]: 99 : if ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
[ + - ][ + + ]
104 : : {
105 : 81 : SwLayoutInfo aInfo;
106 [ + - ]: 81 : pTxtFrm->GetCharRect( aInfo.mPosition, rPos, 0 );
107 : 81 : aInfo.mpAnchorFrm = pTxtFrm;
108 : 81 : aInfo.mPageFrame = pPage->Frm();
109 : 81 : aInfo.mPagePrtArea = pPage->Prt();
110 : 81 : aInfo.mPagePrtArea.Pos() += aInfo.mPageFrame.Pos();
111 : 81 : aInfo.mnPageNumber = pPage->GetPhyPageNum();
112 [ + - ]: 81 : aInfo.meSidebarPosition = pPage->SidebarPosition();
113 : 81 : aInfo.mRedlineAuthor = 0;
114 : :
115 [ + - ]: 81 : if( aRet == INVISIBLE )
116 : : {
117 : 81 : aRet = VISIBLE;
118 [ + - ]: 81 : const IDocumentRedlineAccess* pIDRA = pNode->getIDocumentRedlineAccess();
119 [ + - ][ + - ]: 81 : if( IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) )
120 : : {
121 [ + - ]: 81 : const SwRedline* pRedline = pIDRA->GetRedline( rPos, 0 );
122 [ - + ]: 81 : if( pRedline )
123 : : {
124 [ # # ][ # # ]: 0 : if( nsRedlineType_t::REDLINE_INSERT == pRedline->GetType() )
125 : 0 : aRet = INSERTED;
126 [ # # ][ # # ]: 0 : else if( nsRedlineType_t::REDLINE_DELETE == pRedline->GetType() )
127 : 0 : aRet = DELETED;
128 [ # # ]: 0 : aInfo.mRedlineAuthor = pRedline->GetAuthor();
129 : : }
130 : : }
131 : : }
132 : :
133 : : {
134 : : std::vector< SwLayoutInfo >::iterator aInsPosIter =
135 : : std::lower_bound( rInfo.begin(), rInfo.end(),
136 [ + - ]: 81 : aInfo, LayoutInfoOrder() );
137 : :
138 [ + - ]: 81 : rInfo.insert( aInsPosIter, aInfo );
139 : : }
140 : : }
141 : : }
142 : : }
143 [ + + ][ + - ]: 99 : return ((aRet==VISIBLE) && SwScriptInfo::IsInHiddenRange( *pTxtNode , rPos.nContent.GetIndex()) ) ? HIDDEN : aRet;
[ + - ][ + - ]
144 : : }
145 : :
146 : 5456 : long SwPostItHelper::getLayoutHeight( const SwRootFrm* pRoot )
147 : : {
148 [ + - ]: 5456 : long nRet = pRoot ? pRoot->Frm().Height() : 0;
149 : 5456 : return nRet;
150 : : }
151 : :
152 : 236 : void SwPostItHelper::setSidebarChanged( SwRootFrm* pRoot, bool bBrowseMode )
153 : : {
154 [ + - ]: 236 : if( pRoot )
155 : : {
156 : 236 : pRoot->SetSidebarChanged();
157 [ + + ]: 236 : if( bBrowseMode )
158 : 146 : pRoot->InvalidateBrowseWidth();
159 : : }
160 : 236 : }
161 : :
162 : 0 : unsigned long SwPostItHelper::getPageInfo( SwRect& rPageFrm, const SwRootFrm* pRoot, const Point& rPoint )
163 : : {
164 : 0 : unsigned long nRet = 0;
165 : 0 : const SwFrm* pPage = pRoot->GetPageAtPos( rPoint, 0, true );
166 [ # # ]: 0 : if( pPage )
167 : : {
168 : 0 : nRet = pPage->GetPhyPageNum();
169 : 0 : rPageFrm = pPage->Frm();
170 : : }
171 : 0 : return nRet;
172 : : }
173 : :
174 : 99 : SwPosition SwAnnotationItem::GetAnchorPosition() const
175 : : {
176 : 99 : SwTxtFld* pFld = pFmtFld->GetTxtFld();
177 : : //if( pFld )
178 : : //{
179 : 99 : SwTxtNode* pTNd = pFld->GetpTxtNode();
180 : : // if( pTNd )
181 : : // {
182 : 99 : SwPosition aPos( *pTNd );
183 [ + - ][ + - ]: 99 : aPos.nContent.Assign( pTNd, *pFld->GetStart() );
184 : 99 : return aPos;
185 : : // }
186 : : //}
187 : : }
188 : :
189 : 99 : bool SwAnnotationItem::UseElement()
190 : : {
191 : 99 : return pFmtFld->IsFldInDoc();
192 : : }
193 : :
194 : 18 : sw::sidebarwindows::SwSidebarWin* SwAnnotationItem::GetSidebarWindow(
195 : : SwEditWin& rEditWin,
196 : : WinBits nBits,
197 : : SwPostItMgr& aMgr,
198 : : SwPostItBits aBits)
199 : : {
200 : : return new sw::annotation::SwAnnotationWin( rEditWin, nBits,
201 : : aMgr, aBits,
202 : : *this,
203 [ + - ]: 18 : pFmtFld );
204 : : }
205 : :
206 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|