xref: /AOO41X/main/sw/source/filter/writer/wrt_fn.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
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 #include <svl/itemiter.hxx>
27 #include <svl/whiter.hxx>
28 
29 
30 #include "shellio.hxx"
31 #include "wrt_fn.hxx"
32 #include "pam.hxx"
33 #include "node.hxx"
34 #include "format.hxx"
35 
36 
37 
Out(const SwAttrFnTab pTab,const SfxPoolItem & rHt,Writer & rWrt)38 Writer& Out( const SwAttrFnTab pTab, const SfxPoolItem& rHt, Writer & rWrt )
39 {
40     sal_uInt16 nId = rHt.Which();
41     ASSERT(  nId < POOLATTR_END && nId >= POOLATTR_BEGIN, "SwAttrFnTab::Out()" );
42     FnAttrOut pOut;
43     if( 0 != ( pOut = pTab[ nId - RES_CHRATR_BEGIN] ))
44         (*pOut)( rWrt, rHt );
45     return rWrt;
46 
47 }
48 
Out_SfxItemSet(const SwAttrFnTab pTab,Writer & rWrt,const SfxItemSet & rSet,sal_Bool bDeep,sal_Bool bTstForDefault)49 Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt,
50                         const SfxItemSet& rSet, sal_Bool bDeep,
51                         sal_Bool bTstForDefault )
52 {
53     // erst die eigenen Attribute ausgeben
54     const SfxItemPool& rPool = *rSet.GetPool();
55     const SfxItemSet* pSet = &rSet;
56     if( !pSet->Count() )        // Optimierung - leere Sets
57     {
58         if( !bDeep )
59             return rWrt;
60         while( 0 != ( pSet = pSet->GetParent() ) && !pSet->Count() )
61             ;
62         if( !pSet )
63             return rWrt;
64     }
65     const SfxPoolItem* pItem;
66     FnAttrOut pOut;
67     if( !bDeep || !pSet->GetParent() )
68     {
69         ASSERT( rSet.Count(), "Wurde doch schon behandelt oder?" );
70         SfxItemIter aIter( *pSet );
71         pItem = aIter.GetCurItem();
72         do {
73             if( 0 != ( pOut = pTab[ pItem->Which() - RES_CHRATR_BEGIN] ))
74                     (*pOut)( rWrt, *pItem );
75         } while( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
76     }
77     else
78     {
79         SfxWhichIter aIter( *pSet );
80         sal_uInt16 nWhich = aIter.FirstWhich();
81         while( nWhich )
82         {
83             if( SFX_ITEM_SET == pSet->GetItemState( nWhich, bDeep, &pItem ) &&
84                 ( !bTstForDefault || (
85                     *pItem != rPool.GetDefaultItem( nWhich )
86                     || ( pSet->GetParent() &&
87                         *pItem != pSet->GetParent()->Get( nWhich ))
88                 )) && 0 != ( pOut = pTab[ nWhich - RES_CHRATR_BEGIN] ))
89                     (*pOut)( rWrt, *pItem );
90             nWhich = aIter.NextWhich();
91         }
92     }
93     return rWrt;
94 }
95 
96 
97 
Out(const SwNodeFnTab pTab,SwNode & rNode,Writer & rWrt)98 Writer& Out( const SwNodeFnTab pTab, SwNode& rNode, Writer & rWrt )
99 {
100     // es muss ein CntntNode sein !!
101     SwCntntNode * pCNd = rNode.GetCntntNode();
102     if( !pCNd )
103         return rWrt;
104 
105     sal_uInt16 nId = RES_TXTNODE;
106     switch (pCNd->GetNodeType())
107     {
108         case ND_TEXTNODE:
109             nId = RES_TXTNODE;
110              break;
111         case ND_GRFNODE:
112             nId = RES_GRFNODE;
113             break;
114         case ND_OLENODE:
115             nId = RES_OLENODE;
116             break;
117         default:
118             ASSERT(false, "was fuer ein Node ist es denn nun?");
119             break;
120     }
121     FnNodeOut pOut;
122     if( 0 != ( pOut = pTab[ nId - RES_NODE_BEGIN ] ))
123         (*pOut)( rWrt, *pCNd );
124     return rWrt;
125 }
126 
127 
128