1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
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" // Fuer GetXXXFmt
38 #include "hints.hxx"
39
40 /*************************************
41 * Formate
42 *************************************/
43 // Char
44 // OPT: inline
45
46
GetCharFmtCount() const47 sal_uInt16 SwEditShell::GetCharFmtCount() const
48 {
49 return GetDoc()->GetCharFmts()->Count();
50 }
51
52
GetCharFmt(sal_uInt16 nFmt) const53 SwCharFmt& SwEditShell::GetCharFmt(sal_uInt16 nFmt) const
54 {
55 return *((*(GetDoc()->GetCharFmts()))[nFmt]);
56 }
57
58
GetCurCharFmt() const59 SwCharFmt* SwEditShell::GetCurCharFmt() const
60 {
61 SwCharFmt *pFmt = 0;
62 SfxItemSet aSet( GetDoc()->GetAttrPool(), RES_TXTATR_CHARFMT,
63 RES_TXTATR_CHARFMT );
64 const SfxPoolItem* pItem;
65 if( GetCurAttr( aSet ) && SFX_ITEM_SET ==
66 aSet.GetItemState( RES_TXTATR_CHARFMT, sal_False, &pItem ) )
67 pFmt = ((SwFmtCharFmt*)pItem)->GetCharFmt();
68
69 return pFmt;
70 }
71
72
FillByEx(SwCharFmt * pCharFmt,sal_Bool bReset)73 void SwEditShell::FillByEx(SwCharFmt* pCharFmt, sal_Bool bReset)
74 {
75 if ( bReset )
76 {
77 // --> OD 2007-01-25 #i73790# - method renamed
78 pCharFmt->ResetAllFmtAttr();
79 // <--
80 }
81
82 SwPaM* pPam = GetCrsr();
83 const SwCntntNode* pCNd = pPam->GetCntntNode();
84 if( pCNd->IsTxtNode() )
85 {
86 xub_StrLen nStt, nEnd;
87 if( pPam->HasMark() )
88 {
89 const SwPosition* pPtPos = pPam->GetPoint();
90 const SwPosition* pMkPos = pPam->GetMark();
91 if( pPtPos->nNode == pMkPos->nNode ) // im selben Node ?
92 {
93 nStt = pPtPos->nContent.GetIndex();
94 if( nStt < pMkPos->nContent.GetIndex() )
95 nEnd = pMkPos->nContent.GetIndex();
96 else
97 {
98 nEnd = nStt;
99 nStt = pMkPos->nContent.GetIndex();
100 }
101 }
102 else
103 {
104 nStt = pMkPos->nContent.GetIndex();
105 if( pPtPos->nNode < pMkPos->nNode )
106 {
107 nEnd = nStt;
108 nStt = 0;
109 }
110 else
111 nEnd = ((SwTxtNode*)pCNd)->GetTxt().Len();
112 }
113 }
114 else
115 nStt = nEnd = pPam->GetPoint()->nContent.GetIndex();
116
117 SfxItemSet aSet( pDoc->GetAttrPool(),
118 pCharFmt->GetAttrSet().GetRanges() );
119 ((SwTxtNode*)pCNd)->GetAttr( aSet, nStt, nEnd );
120 pCharFmt->SetFmtAttr( aSet );
121 }
122 else if( pCNd->HasSwAttrSet() )
123 pCharFmt->SetFmtAttr( *pCNd->GetpSwAttrSet() );
124 }
125
126 // Frm
GetTblFrmFmtCount(sal_Bool bUsed) const127 sal_uInt16 SwEditShell::GetTblFrmFmtCount(sal_Bool bUsed) const
128 {
129 return GetDoc()->GetTblFrmFmtCount(bUsed);
130 }
131
GetTblFrmFmt(sal_uInt16 nFmt,sal_Bool bUsed) const132 SwFrmFmt& SwEditShell::GetTblFrmFmt(sal_uInt16 nFmt, sal_Bool bUsed ) const
133 {
134 return GetDoc()->GetTblFrmFmt(nFmt, bUsed );
135 }
136
GetUniqueTblName() const137 String SwEditShell::GetUniqueTblName() const
138 {
139 return GetDoc()->GetUniqueTblName();
140 }
141
142
MakeCharFmt(const String & rName,SwCharFmt * pDerivedFrom)143 SwCharFmt* SwEditShell::MakeCharFmt( const String& rName,
144 SwCharFmt* pDerivedFrom )
145 {
146 if( !pDerivedFrom )
147 pDerivedFrom = GetDoc()->GetDfltCharFmt();
148
149 return GetDoc()->MakeCharFmt( rName, pDerivedFrom );
150 }
151
152 //----------------------------------
153 // inlines im Product
154
155
GetTxtCollFromPool(sal_uInt16 nId)156 SwTxtFmtColl* SwEditShell::GetTxtCollFromPool( sal_uInt16 nId )
157 {
158 return GetDoc()->GetTxtCollFromPool( nId );
159 }
160
161
162 // return das geforderte automatische Format - Basis-Klasse !
GetFmtFromPool(sal_uInt16 nId)163 SwFmt* SwEditShell::GetFmtFromPool( sal_uInt16 nId )
164 {
165 return GetDoc()->GetFmtFromPool( nId );
166 }
167
168
GetPageDescFromPool(sal_uInt16 nId)169 SwPageDesc* SwEditShell::GetPageDescFromPool( sal_uInt16 nId )
170 {
171 return GetDoc()->GetPageDescFromPool( nId );
172 }
173
174
IsUsed(const SwModify & rModify) const175 sal_Bool SwEditShell::IsUsed( const SwModify& rModify ) const
176 {
177 return pDoc->IsUsed( rModify );
178 }
179
FindFlyByName(const String & rName,sal_uInt8 nNdTyp) const180 const SwFlyFrmFmt* SwEditShell::FindFlyByName( const String& rName, sal_uInt8 nNdTyp ) const
181 {
182 return pDoc->FindFlyByName(rName, nNdTyp);
183 }
184
FindCharFmtByName(const String & rName) const185 SwCharFmt* SwEditShell::FindCharFmtByName( const String& rName ) const
186 {
187 return pDoc->FindCharFmtByName( rName );
188 }
189
FindTxtFmtCollByName(const String & rName) const190 SwTxtFmtColl* SwEditShell::FindTxtFmtCollByName( const String& rName ) const
191 {
192 return pDoc->FindTxtFmtCollByName( rName );
193 }
194