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