nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / edit / edfmt.cxx
blobec03360cdc8f029ecaea4e9871770a63ecc41a77
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <doc.hxx>
21 #include <IDocumentStylePoolAccess.hxx>
22 #include <editsh.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>
30 sal_uInt16 SwEditShell::GetCharFormatCount() const
32 return GetDoc()->GetCharFormats()->size();
35 SwCharFormat& SwEditShell::GetCharFormat(sal_uInt16 nFormat) const
37 return *((*(GetDoc()->GetCharFormats()))[nFormat]);
40 SwCharFormat* SwEditShell::GetCurCharFormat() const
42 SwCharFormat *pFormat = nullptr;
43 SfxItemSet aSet( GetDoc()->GetAttrPool(), svl::Items<RES_TXTATR_CHARFMT,
44 RES_TXTATR_CHARFMT>{} );
45 const SfxPoolItem* pItem;
46 if( GetCurAttr( aSet ) && SfxItemState::SET ==
47 aSet.GetItemState( RES_TXTATR_CHARFMT, false, &pItem ) )
48 pFormat = static_cast<const SwFormatCharFormat*>(pItem)->GetCharFormat();
50 return pFormat;
53 void SwEditShell::FillByEx(SwCharFormat* pCharFormat)
55 SwPaM* pPam = GetCursor();
56 const SwContentNode* pCNd = pPam->GetContentNode();
57 if( pCNd->IsTextNode() )
59 SwTextNode const*const pTextNode(pCNd->GetTextNode());
60 sal_Int32 nStt;
61 sal_Int32 nEnd;
62 if( pPam->HasMark() )
64 const SwPosition* pPtPos = pPam->GetPoint();
65 const SwPosition* pMkPos = pPam->GetMark();
66 if( pPtPos->nNode == pMkPos->nNode ) // in the same node?
68 nStt = pPtPos->nContent.GetIndex();
69 if( nStt < pMkPos->nContent.GetIndex() )
70 nEnd = pMkPos->nContent.GetIndex();
71 else
73 nEnd = nStt;
74 nStt = pMkPos->nContent.GetIndex();
77 else
79 nStt = pMkPos->nContent.GetIndex();
80 if( pPtPos->nNode < pMkPos->nNode )
82 nEnd = nStt;
83 nStt = 0;
85 else
86 nEnd = pTextNode->GetText().getLength();
89 else
90 nStt = nEnd = pPam->GetPoint()->nContent.GetIndex();
92 SfxItemSet aSet( mxDoc->GetAttrPool(),
93 pCharFormat->GetAttrSet().GetRanges() );
94 pTextNode->GetParaAttr(aSet, nStt, nEnd, false, true, false, GetLayout());
95 pCharFormat->SetFormatAttr( aSet );
97 else if( pCNd->HasSwAttrSet() )
98 pCharFormat->SetFormatAttr( *pCNd->GetpSwAttrSet() );
101 size_t SwEditShell::GetTableFrameFormatCount(bool bUsed) const
103 return GetDoc()->GetTableFrameFormatCount(bUsed);
106 SwFrameFormat& SwEditShell::GetTableFrameFormat(size_t nFormat, bool bUsed ) const
108 return GetDoc()->GetTableFrameFormat(nFormat, bUsed );
111 OUString SwEditShell::GetUniqueTableName() const
113 return GetDoc()->GetUniqueTableName();
116 SwCharFormat* SwEditShell::MakeCharFormat( const OUString& rName )
118 SwCharFormat* pDerivedFrom = GetDoc()->GetDfltCharFormat();
120 return GetDoc()->MakeCharFormat( rName, pDerivedFrom );
123 SwTextFormatColl* SwEditShell::GetTextCollFromPool( sal_uInt16 nId )
125 return GetDoc()->getIDocumentStylePoolAccess().GetTextCollFromPool( nId );
128 /// return the requested automatic format - base-class !
129 SwFormat* SwEditShell::GetFormatFromPool( sal_uInt16 nId )
131 return GetDoc()->getIDocumentStylePoolAccess().GetFormatFromPool( nId );
134 SwPageDesc* SwEditShell::GetPageDescFromPool( sal_uInt16 nId )
136 return GetDoc()->getIDocumentStylePoolAccess().GetPageDescFromPool( nId );
139 bool SwEditShell::IsUsed( const sw::BroadcastingModify& rModify ) const
141 return mxDoc->IsUsed( rModify );
144 const SwFlyFrameFormat* SwEditShell::FindFlyByName( const OUString& rName ) const
146 return mxDoc->FindFlyByName(rName);
149 SwCharFormat* SwEditShell::FindCharFormatByName( const OUString& rName ) const
151 return mxDoc->FindCharFormatByName( rName );
154 SwTextFormatColl* SwEditShell::FindTextFormatCollByName( const OUString& rName ) const
156 return mxDoc->FindTextFormatCollByName( rName );
159 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */