1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <IDocumentStylePoolAccess.hxx>
24 #include <fchrfmt.hxx>
26 #include <charfmt.hxx>
29 sal_uInt16
SwEditShell::GetCharFormatCount() const
31 return GetDoc()->GetCharFormats()->size();
34 SwCharFormat
& SwEditShell::GetCharFormat(sal_uInt16 nFormat
) const
36 return *((*(GetDoc()->GetCharFormats()))[nFormat
]);
39 SwCharFormat
* SwEditShell::GetCurCharFormat() const
41 SwCharFormat
*pFormat
= nullptr;
42 SfxItemSetFixed
<RES_TXTATR_CHARFMT
, RES_TXTATR_CHARFMT
> aSet( GetDoc()->GetAttrPool() );
43 const SwFormatCharFormat
* pItem
;
44 if( GetCurAttr( aSet
) &&
45 (pItem
= aSet
.GetItemIfSet( RES_TXTATR_CHARFMT
, false ) ) )
46 pFormat
= pItem
->GetCharFormat();
51 void SwEditShell::FillByEx(SwCharFormat
* pCharFormat
)
53 SwPaM
* pPam
= GetCursor();
54 const SwContentNode
* pCNd
= pPam
->GetPointContentNode();
55 if( pCNd
->IsTextNode() )
57 SwTextNode
const*const pTextNode(pCNd
->GetTextNode());
62 const SwPosition
* pPtPos
= pPam
->GetPoint();
63 const SwPosition
* pMkPos
= pPam
->GetMark();
64 if( pPtPos
->GetNode() == pMkPos
->GetNode() ) // in the same node?
66 nStt
= pPtPos
->GetContentIndex();
67 if( nStt
< pMkPos
->GetContentIndex() )
68 nEnd
= pMkPos
->GetContentIndex();
72 nStt
= pMkPos
->GetContentIndex();
77 nStt
= pMkPos
->GetContentIndex();
78 if( pPtPos
->GetNode() < pMkPos
->GetNode() )
84 nEnd
= pTextNode
->GetText().getLength();
88 nStt
= nEnd
= pPam
->GetPoint()->GetContentIndex();
90 SfxItemSet
aSet( mxDoc
->GetAttrPool(),
91 pCharFormat
->GetAttrSet().GetRanges() );
92 pTextNode
->GetParaAttr(aSet
, nStt
, nEnd
, false, true, false, GetLayout());
93 pCharFormat
->SetFormatAttr( aSet
);
95 else if( pCNd
->HasSwAttrSet() )
96 pCharFormat
->SetFormatAttr( *pCNd
->GetpSwAttrSet() );
99 size_t SwEditShell::GetTableFrameFormatCount(bool bUsed
) const
101 return GetDoc()->GetTableFrameFormatCount(bUsed
);
104 SwFrameFormat
& SwEditShell::GetTableFrameFormat(size_t nFormat
, bool bUsed
) const
106 return GetDoc()->GetTableFrameFormat(nFormat
, bUsed
);
109 OUString
SwEditShell::GetUniqueTableName() const
111 return GetDoc()->GetUniqueTableName();
114 SwCharFormat
* SwEditShell::MakeCharFormat( const OUString
& rName
)
116 SwCharFormat
* pDerivedFrom
= GetDoc()->GetDfltCharFormat();
118 return GetDoc()->MakeCharFormat( rName
, pDerivedFrom
);
121 SwTextFormatColl
* SwEditShell::GetTextCollFromPool( sal_uInt16 nId
)
123 return GetDoc()->getIDocumentStylePoolAccess().GetTextCollFromPool( nId
);
126 /// return the requested automatic format - base-class !
127 SwFormat
* SwEditShell::GetFormatFromPool( sal_uInt16 nId
)
129 return GetDoc()->getIDocumentStylePoolAccess().GetFormatFromPool( nId
);
132 SwPageDesc
* SwEditShell::GetPageDescFromPool( sal_uInt16 nId
)
134 return GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool( nId
);
137 bool SwEditShell::IsUsed( const sw::BroadcastingModify
& rModify
) const
139 return mxDoc
->IsUsed( rModify
);
142 const SwFlyFrameFormat
* SwEditShell::FindFlyByName( const OUString
& rName
) const
144 return mxDoc
->FindFlyByName(rName
);
147 SwCharFormat
* SwEditShell::FindCharFormatByName( const OUString
& rName
) const
149 return mxDoc
->FindCharFormatByName( rName
);
152 SwTextFormatColl
* SwEditShell::FindTextFormatCollByName( const OUString
& rName
) const
154 return mxDoc
->FindTextFormatCollByName( rName
);
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */