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 : : #include "doc.hxx"
30 : : #include "editsh.hxx"
31 : : #include "swtable.hxx"
32 : : #include "pam.hxx"
33 : : #include <docary.hxx>
34 : : #include <fchrfmt.hxx>
35 : : #include <frmfmt.hxx>
36 : : #include <charfmt.hxx>
37 : : #include "ndtxt.hxx" // for GetXXXFmt
38 : : #include "hints.hxx"
39 : :
40 : : /*************************************
41 : : * Formate
42 : : *************************************/
43 : : // Char
44 : : // OPT: inline
45 : :
46 : :
47 : 0 : sal_uInt16 SwEditShell::GetCharFmtCount() const
48 : : {
49 : 0 : return GetDoc()->GetCharFmts()->size();
50 : : }
51 : :
52 : :
53 : 0 : SwCharFmt& SwEditShell::GetCharFmt(sal_uInt16 nFmt) const
54 : : {
55 : 0 : return *((*(GetDoc()->GetCharFmts()))[nFmt]);
56 : : }
57 : :
58 : :
59 : 3671 : SwCharFmt* SwEditShell::GetCurCharFmt() const
60 : : {
61 : 3671 : SwCharFmt *pFmt = 0;
62 : 3671 : SfxItemSet aSet( GetDoc()->GetAttrPool(), RES_TXTATR_CHARFMT,
63 [ + - ]: 3671 : RES_TXTATR_CHARFMT );
64 : : const SfxPoolItem* pItem;
65 [ + - ][ + - ]: 7342 : if( GetCurAttr( aSet ) && SFX_ITEM_SET ==
[ + + ][ + + ]
66 [ + - ]: 3671 : aSet.GetItemState( RES_TXTATR_CHARFMT, sal_False, &pItem ) )
67 : 71 : pFmt = ((SwFmtCharFmt*)pItem)->GetCharFmt();
68 : :
69 [ + - ]: 3671 : return pFmt;
70 : : }
71 : :
72 : :
73 : 0 : void SwEditShell::FillByEx(SwCharFmt* pCharFmt, sal_Bool bReset)
74 : : {
75 [ # # ]: 0 : if ( bReset )
76 : : {
77 : : // #i73790# - method renamed
78 : 0 : pCharFmt->ResetAllFmtAttr();
79 : : }
80 : :
81 : 0 : SwPaM* pPam = GetCrsr();
82 : 0 : const SwCntntNode* pCNd = pPam->GetCntntNode();
83 [ # # ]: 0 : if( pCNd->IsTxtNode() )
84 : : {
85 : : xub_StrLen nStt, nEnd;
86 [ # # ]: 0 : if( pPam->HasMark() )
87 : : {
88 : 0 : const SwPosition* pPtPos = pPam->GetPoint();
89 : 0 : const SwPosition* pMkPos = pPam->GetMark();
90 [ # # ]: 0 : if( pPtPos->nNode == pMkPos->nNode ) // in the same node?
91 : : {
92 : 0 : nStt = pPtPos->nContent.GetIndex();
93 [ # # ]: 0 : if( nStt < pMkPos->nContent.GetIndex() )
94 : 0 : nEnd = pMkPos->nContent.GetIndex();
95 : : else
96 : : {
97 : 0 : nEnd = nStt;
98 : 0 : nStt = pMkPos->nContent.GetIndex();
99 : : }
100 : : }
101 : : else
102 : : {
103 : 0 : nStt = pMkPos->nContent.GetIndex();
104 [ # # ]: 0 : if( pPtPos->nNode < pMkPos->nNode )
105 : : {
106 : 0 : nEnd = nStt;
107 : 0 : nStt = 0;
108 : : }
109 : : else
110 : 0 : nEnd = ((SwTxtNode*)pCNd)->GetTxt().Len();
111 : : }
112 : : }
113 : : else
114 : 0 : nStt = nEnd = pPam->GetPoint()->nContent.GetIndex();
115 : :
116 : 0 : SfxItemSet aSet( pDoc->GetAttrPool(),
117 [ # # ]: 0 : pCharFmt->GetAttrSet().GetRanges() );
118 [ # # ]: 0 : ((SwTxtNode*)pCNd)->GetAttr( aSet, nStt, nEnd );
119 [ # # ][ # # ]: 0 : pCharFmt->SetFmtAttr( aSet );
120 : : }
121 [ # # ]: 0 : else if( pCNd->HasSwAttrSet() )
122 : 0 : pCharFmt->SetFmtAttr( *pCNd->GetpSwAttrSet() );
123 : 0 : }
124 : :
125 : : // Frm
126 : 0 : sal_uInt16 SwEditShell::GetTblFrmFmtCount(sal_Bool bUsed) const
127 : : {
128 : 0 : return GetDoc()->GetTblFrmFmtCount(bUsed);
129 : : }
130 : :
131 : 0 : SwFrmFmt& SwEditShell::GetTblFrmFmt(sal_uInt16 nFmt, sal_Bool bUsed ) const
132 : : {
133 : 0 : return GetDoc()->GetTblFrmFmt(nFmt, bUsed );
134 : : }
135 : :
136 : 0 : String SwEditShell::GetUniqueTblName() const
137 : : {
138 : 0 : return GetDoc()->GetUniqueTblName();
139 : : }
140 : :
141 : :
142 : 0 : SwCharFmt* SwEditShell::MakeCharFmt( const String& rName,
143 : : SwCharFmt* pDerivedFrom )
144 : : {
145 [ # # ]: 0 : if( !pDerivedFrom )
146 : 0 : pDerivedFrom = GetDoc()->GetDfltCharFmt();
147 : :
148 : 0 : return GetDoc()->MakeCharFmt( rName, pDerivedFrom );
149 : : }
150 : :
151 : : //----------------------------------
152 : : // inlines in product
153 : :
154 : :
155 : 0 : SwTxtFmtColl* SwEditShell::GetTxtCollFromPool( sal_uInt16 nId )
156 : : {
157 : 0 : return GetDoc()->GetTxtCollFromPool( nId );
158 : : }
159 : :
160 : :
161 : : // return the demanded automatic format - base-class !
162 : 0 : SwFmt* SwEditShell::GetFmtFromPool( sal_uInt16 nId )
163 : : {
164 : 0 : return GetDoc()->GetFmtFromPool( nId );
165 : : }
166 : :
167 : :
168 : 0 : SwPageDesc* SwEditShell::GetPageDescFromPool( sal_uInt16 nId )
169 : : {
170 : 0 : return GetDoc()->GetPageDescFromPool( nId );
171 : : }
172 : :
173 : :
174 : 0 : sal_Bool SwEditShell::IsUsed( const SwModify& rModify ) const
175 : : {
176 : 0 : return pDoc->IsUsed( rModify );
177 : : }
178 : :
179 : 0 : const SwFlyFrmFmt* SwEditShell::FindFlyByName( const String& rName, sal_uInt8 nNdTyp ) const
180 : : {
181 : 0 : return pDoc->FindFlyByName(rName, nNdTyp);
182 : : }
183 : :
184 : 0 : SwCharFmt* SwEditShell::FindCharFmtByName( const String& rName ) const
185 : : {
186 : 0 : return pDoc->FindCharFmtByName( rName );
187 : : }
188 : :
189 : 0 : SwTxtFmtColl* SwEditShell::FindTxtFmtCollByName( const String& rName ) const
190 : : {
191 : 0 : return pDoc->FindTxtFmtCollByName( rName );
192 : : }
193 : :
194 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|