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