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 <svl/itemiter.hxx>
21 : #include <svl/whiter.hxx>
22 :
23 : #include "shellio.hxx"
24 : #include "wrt_fn.hxx"
25 : #include "node.hxx"
26 : #include "format.hxx"
27 :
28 0 : Writer& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, Writer & rWrt )
29 : {
30 0 : sal_uInt16 nId = rHt.Which();
31 : OSL_ENSURE( nId < POOLATTR_END && nId >= POOLATTR_BEGIN, "SwAttrFnTab::Out()" );
32 : FnAttrOut pOut;
33 0 : if( 0 != ( pOut = pTab[ nId - RES_CHRATR_BEGIN] ))
34 0 : (*pOut)( rWrt, rHt );
35 0 : return rWrt;
36 :
37 : }
38 :
39 0 : Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt,
40 : const SfxItemSet& rSet, sal_Bool bDeep,
41 : sal_Bool bTstForDefault )
42 : {
43 : // at first give the own attributes out
44 0 : const SfxItemPool& rPool = *rSet.GetPool();
45 0 : const SfxItemSet* pSet = &rSet;
46 0 : if( !pSet->Count() ) // Optimizing - empty Sets
47 : {
48 0 : if( !bDeep )
49 0 : return rWrt;
50 0 : while( 0 != ( pSet = pSet->GetParent() ) && !pSet->Count() )
51 : ;
52 0 : if( !pSet )
53 0 : return rWrt;
54 : }
55 0 : const SfxPoolItem* pItem(0);
56 : FnAttrOut pOut;
57 0 : if( !bDeep || !pSet->GetParent() )
58 : {
59 : OSL_ENSURE( rSet.Count(), "It has been handled already, right?" );
60 0 : SfxItemIter aIter( *pSet );
61 0 : pItem = aIter.GetCurItem();
62 0 : do {
63 0 : if( 0 != ( pOut = pTab[ pItem->Which() - RES_CHRATR_BEGIN] ))
64 0 : (*pOut)( rWrt, *pItem );
65 0 : } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
66 : }
67 : else
68 : {
69 0 : SfxWhichIter aIter( *pSet );
70 0 : sal_uInt16 nWhich = aIter.FirstWhich();
71 0 : while( nWhich )
72 : {
73 0 : if( SFX_ITEM_SET == pSet->GetItemState( nWhich, bDeep, &pItem ) &&
74 0 : ( !bTstForDefault || (
75 0 : *pItem != rPool.GetDefaultItem( nWhich )
76 0 : || ( pSet->GetParent() &&
77 0 : *pItem != pSet->GetParent()->Get( nWhich ))
78 0 : )) && 0 != ( pOut = pTab[ nWhich - RES_CHRATR_BEGIN] ))
79 0 : (*pOut)( rWrt, *pItem );
80 0 : nWhich = aIter.NextWhich();
81 0 : }
82 : }
83 0 : return rWrt;
84 : }
85 :
86 0 : Writer& Out( const SwNodeFnTab pTab, SwNode& rNode, Writer & rWrt )
87 : {
88 : // It must be a CntntNode!
89 0 : SwCntntNode * pCNd = rNode.GetCntntNode();
90 0 : if( !pCNd )
91 0 : return rWrt;
92 :
93 0 : sal_uInt16 nId = RES_TXTNODE;
94 0 : switch (pCNd->GetNodeType())
95 : {
96 : case ND_TEXTNODE:
97 0 : nId = RES_TXTNODE;
98 0 : break;
99 : case ND_GRFNODE:
100 0 : nId = RES_GRFNODE;
101 0 : break;
102 : case ND_OLENODE:
103 0 : nId = RES_OLENODE;
104 0 : break;
105 : default:
106 : OSL_FAIL("What kind of node is it now?");
107 0 : break;
108 : }
109 : FnNodeOut pOut;
110 0 : if( 0 != ( pOut = pTab[ nId - RES_NODE_BEGIN ] ))
111 0 : (*pOut)( rWrt, *pCNd );
112 0 : return rWrt;
113 : }
114 :
115 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|