Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <postithelper.hxx>
21 : #include <PostItMgr.hxx>
22 : #include <AnnotationWin.hxx>
23 :
24 : #include <fmtfld.hxx>
25 : #include <txtfld.hxx>
26 : #include <docufld.hxx>
27 : #include <ndtxt.hxx>
28 : #include <cntfrm.hxx>
29 : #include <pagefrm.hxx>
30 : #include <rootfrm.hxx>
31 : #include <txtfrm.hxx>
32 : #include <tabfrm.hxx>
33 : #include <IDocumentRedlineAccess.hxx>
34 : #include <redline.hxx>
35 : #include <scriptinfo.hxx>
36 : #include <editeng/charhiddenitem.hxx>
37 : #include <switerator.hxx>
38 :
39 : class Point;
40 :
41 1408 : SwPostItHelper::SwLayoutStatus SwPostItHelper::getLayoutInfos(
42 : SwLayoutInfo& o_rInfo,
43 : const SwPosition& rAnchorPos,
44 : const SwPosition* pAnnotationStartPos )
45 : {
46 1408 : SwLayoutStatus aRet = INVISIBLE;
47 1408 : SwTxtNode* pTxtNode = rAnchorPos.nNode.GetNode().GetTxtNode();
48 1408 : if ( pTxtNode == NULL )
49 0 : return aRet;
50 :
51 1408 : SwIterator<SwTxtFrm,SwCntntNode> aIter( *pTxtNode );
52 2816 : for( SwTxtFrm* pTxtFrm = aIter.First(); pTxtFrm != NULL; pTxtFrm = aIter.Next() )
53 : {
54 1408 : if( !pTxtFrm->IsFollow() )
55 : {
56 1408 : pTxtFrm = pTxtFrm->GetFrmAtPos( rAnchorPos );
57 1408 : SwPageFrm *pPage = pTxtFrm ? pTxtFrm->FindPageFrm() : 0;
58 1408 : if ( pPage != NULL && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
59 : {
60 1270 : aRet = VISIBLE;
61 :
62 1270 : o_rInfo.mpAnchorFrm = pTxtFrm;
63 1270 : pTxtFrm->GetCharRect( o_rInfo.mPosition, rAnchorPos, 0 );
64 1270 : if ( pAnnotationStartPos != NULL )
65 : {
66 890 : o_rInfo.mnStartNodeIdx = pAnnotationStartPos->nNode.GetIndex();
67 890 : o_rInfo.mnStartContent = pAnnotationStartPos->nContent.GetIndex();
68 : }
69 : else
70 : {
71 380 : o_rInfo.mnStartNodeIdx = 0;
72 380 : o_rInfo.mnStartContent = -1;
73 : }
74 1270 : o_rInfo.mPageFrame = pPage->Frm();
75 1270 : o_rInfo.mPagePrtArea = pPage->Prt();
76 1270 : o_rInfo.mPagePrtArea.Pos() += o_rInfo.mPageFrame.Pos();
77 1270 : o_rInfo.mnPageNumber = pPage->GetPhyPageNum();
78 1270 : o_rInfo.meSidebarPosition = pPage->SidebarPosition();
79 1270 : o_rInfo.mRedlineAuthor = 0;
80 :
81 1270 : const IDocumentRedlineAccess* pIDRA = pTxtNode->getIDocumentRedlineAccess();
82 1270 : if( IDocumentRedlineAccess::IsShowChanges( pIDRA->GetRedlineMode() ) )
83 : {
84 1270 : const SwRangeRedline* pRedline = pIDRA->GetRedline( rAnchorPos, 0 );
85 1270 : if( pRedline )
86 : {
87 0 : if( nsRedlineType_t::REDLINE_INSERT == pRedline->GetType() )
88 0 : aRet = INSERTED;
89 0 : else if( nsRedlineType_t::REDLINE_DELETE == pRedline->GetType() )
90 0 : aRet = DELETED;
91 0 : o_rInfo.mRedlineAuthor = pRedline->GetAuthor();
92 : }
93 : }
94 : }
95 : }
96 : }
97 :
98 1270 : return ( (aRet==VISIBLE) && SwScriptInfo::IsInHiddenRange( *pTxtNode , rAnchorPos.nContent.GetIndex()) )
99 : ? HIDDEN
100 2706 : : aRet;
101 : }
102 :
103 45156 : long SwPostItHelper::getLayoutHeight( const SwRootFrm* pRoot )
104 : {
105 45156 : long nRet = pRoot ? pRoot->Frm().Height() : 0;
106 45156 : return nRet;
107 : }
108 :
109 318 : void SwPostItHelper::setSidebarChanged( SwRootFrm* pRoot, bool bBrowseMode )
110 : {
111 318 : if( pRoot )
112 : {
113 318 : pRoot->SetSidebarChanged();
114 318 : if( bBrowseMode )
115 156 : pRoot->InvalidateBrowseWidth();
116 : }
117 318 : }
118 :
119 0 : unsigned long SwPostItHelper::getPageInfo( SwRect& rPageFrm, const SwRootFrm* pRoot, const Point& rPoint )
120 : {
121 0 : unsigned long nRet = 0;
122 0 : const SwFrm* pPage = pRoot->GetPageAtPos( rPoint, 0, true );
123 0 : if( pPage )
124 : {
125 0 : nRet = pPage->GetPhyPageNum();
126 0 : rPageFrm = pPage->Frm();
127 : }
128 0 : return nRet;
129 : }
130 :
131 3080 : SwPosition SwAnnotationItem::GetAnchorPosition() const
132 : {
133 3080 : SwTxtFld* pTxtFld = mrFmtFld.GetTxtFld();
134 3080 : SwTxtNode* pTxtNode = pTxtFld->GetpTxtNode();
135 :
136 3080 : SwPosition aPos( *pTxtNode );
137 3080 : aPos.nContent.Assign( pTxtNode, pTxtFld->GetStart() );
138 3080 : return aPos;
139 : }
140 :
141 1408 : bool SwAnnotationItem::UseElement()
142 : {
143 1408 : return mrFmtFld.IsFldInDoc();
144 : }
145 :
146 130 : sw::sidebarwindows::SwSidebarWin* SwAnnotationItem::GetSidebarWindow(
147 : SwEditWin& rEditWin,
148 : WinBits nBits,
149 : SwPostItMgr& aMgr,
150 : SwPostItBits aBits)
151 : {
152 : return new sw::annotation::SwAnnotationWin( rEditWin, nBits,
153 : aMgr, aBits,
154 : *this,
155 130 : &mrFmtFld );
156 270 : }
157 :
158 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|