1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include "xmlimpit.hxx"
27cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
28cdf0e10cSrcweir #include <svl/itempool.hxx>
29cdf0e10cSrcweir #include <svl/poolitem.hxx>
30cdf0e10cSrcweir #include <svl/itemset.hxx>
31cdf0e10cSrcweir #include <xmloff/attrlist.hxx>
32cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
33cdf0e10cSrcweir #include <xmloff/xmlnmspe.hxx>
34cdf0e10cSrcweir #include <editeng/xmlcnitm.hxx>
35cdf0e10cSrcweir #include <editeng/memberids.hrc>
36cdf0e10cSrcweir
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include "hintids.hxx"
39cdf0e10cSrcweir #include "unomid.h"
40cdf0e10cSrcweir #include <svx/unomid.hxx>
41cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
42cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
43cdf0e10cSrcweir #include <editeng/shaditem.hxx>
44cdf0e10cSrcweir #include <editeng/boxitem.hxx>
45cdf0e10cSrcweir #include <editeng/brkitem.hxx>
46cdf0e10cSrcweir #include <editeng/keepitem.hxx>
47cdf0e10cSrcweir #include <editeng/brshitem.hxx>
48cdf0e10cSrcweir #include "fmtpdsc.hxx"
49cdf0e10cSrcweir #include "fmtornt.hxx"
50cdf0e10cSrcweir #include "fmtfsize.hxx"
51cdf0e10cSrcweir
52cdf0e10cSrcweir #ifndef _FMTLSPLT_HXX
53cdf0e10cSrcweir #include "fmtlsplt.hxx"
54cdf0e10cSrcweir #endif
55cdf0e10cSrcweir #include <xmloff/prhdlfac.hxx>
56cdf0e10cSrcweir #include <xmloff/xmltypes.hxx>
57cdf0e10cSrcweir #include "xmlithlp.hxx"
58cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
59cdf0e10cSrcweir
60cdf0e10cSrcweir using ::rtl::OUString;
61cdf0e10cSrcweir using namespace ::com::sun::star;
62cdf0e10cSrcweir using namespace ::xmloff::token;
63cdf0e10cSrcweir using uno::Any;
64cdf0e10cSrcweir
SvXMLImportItemMapper(SvXMLItemMapEntriesRef rMapEntries,sal_uInt16 nUnknWhich)65cdf0e10cSrcweir SvXMLImportItemMapper::SvXMLImportItemMapper(
66cdf0e10cSrcweir SvXMLItemMapEntriesRef rMapEntries,
67cdf0e10cSrcweir sal_uInt16 nUnknWhich ) :
68cdf0e10cSrcweir mrMapEntries( rMapEntries ),
69cdf0e10cSrcweir nUnknownWhich( nUnknWhich )
70cdf0e10cSrcweir {
71cdf0e10cSrcweir }
72cdf0e10cSrcweir
~SvXMLImportItemMapper()73cdf0e10cSrcweir SvXMLImportItemMapper::~SvXMLImportItemMapper()
74cdf0e10cSrcweir {
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
77cdf0e10cSrcweir void
setMapEntries(SvXMLItemMapEntriesRef rMapEntries)78cdf0e10cSrcweir SvXMLImportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir mrMapEntries = rMapEntries;
81cdf0e10cSrcweir }
82cdf0e10cSrcweir
83cdf0e10cSrcweir /** fills the given itemset with the attributes in the given list */
importXML(SfxItemSet & rSet,uno::Reference<xml::sax::XAttributeList> xAttrList,const SvXMLUnitConverter & rUnitConverter,const SvXMLNamespaceMap & rNamespaceMap)84cdf0e10cSrcweir void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
85cdf0e10cSrcweir uno::Reference< xml::sax::XAttributeList > xAttrList,
86cdf0e10cSrcweir const SvXMLUnitConverter& rUnitConverter,
87cdf0e10cSrcweir const SvXMLNamespaceMap& rNamespaceMap )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir sal_Int16 nAttr = xAttrList->getLength();
90cdf0e10cSrcweir
91cdf0e10cSrcweir SvXMLAttrContainerItem *pUnknownItem = 0;
92cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttr; i++ )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir const OUString& rAttrName = xAttrList->getNameByIndex( i );
95cdf0e10cSrcweir OUString aLocalName, aPrefix, aNamespace;
96cdf0e10cSrcweir sal_uInt16 nPrefix =
97cdf0e10cSrcweir rNamespaceMap.GetKeyByAttrName( rAttrName, &aPrefix, &aLocalName,
98cdf0e10cSrcweir &aNamespace );
99cdf0e10cSrcweir if( XML_NAMESPACE_XMLNS == nPrefix )
100cdf0e10cSrcweir continue;
101cdf0e10cSrcweir
102cdf0e10cSrcweir const OUString& rValue = xAttrList->getValueByIndex( i );
103cdf0e10cSrcweir
104cdf0e10cSrcweir // find a map entry for this attribute
105cdf0e10cSrcweir SvXMLItemMapEntry* pEntry = mrMapEntries->getByName( nPrefix, aLocalName );
106cdf0e10cSrcweir
107cdf0e10cSrcweir if( pEntry )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir // we have a valid map entry here, so lets use it...
110cdf0e10cSrcweir if( 0 == (pEntry->nMemberId & (MID_SW_FLAG_NO_ITEM_IMPORT|
111cdf0e10cSrcweir MID_SW_FLAG_ELEMENT_ITEM_IMPORT)) )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir // first get item from itemset
114cdf0e10cSrcweir const SfxPoolItem* pItem = 0;
115cdf0e10cSrcweir SfxItemState eState = rSet.GetItemState( pEntry->nWhichId, sal_True,
116cdf0e10cSrcweir &pItem );
117cdf0e10cSrcweir
118cdf0e10cSrcweir // if its not set, try the pool
119cdf0e10cSrcweir if(SFX_ITEM_SET != eState && SFX_WHICH_MAX > pEntry->nWhichId )
120cdf0e10cSrcweir pItem = &rSet.GetPool()->GetDefaultItem(pEntry->nWhichId);
121cdf0e10cSrcweir
122cdf0e10cSrcweir // do we have an item?
123cdf0e10cSrcweir if(eState >= SFX_ITEM_DEFAULT && pItem)
124cdf0e10cSrcweir {
125cdf0e10cSrcweir SfxPoolItem *pNewItem = pItem->Clone();
126cdf0e10cSrcweir sal_Bool bPut = sal_False;
127cdf0e10cSrcweir
128cdf0e10cSrcweir if( 0 == (pEntry->nMemberId&MID_SW_FLAG_SPECIAL_ITEM_IMPORT) )
129cdf0e10cSrcweir {
130cdf0e10cSrcweir // bPut = pNewItem->importXML( rValue,
131cdf0e10cSrcweir // pEntry->nMemberId & MID_SW_FLAG_MASK,
132cdf0e10cSrcweir // rUnitConverter );
133cdf0e10cSrcweir bPut = PutXMLValue( *pNewItem, rValue,
134cdf0e10cSrcweir static_cast<sal_uInt16>( pEntry->nMemberId & MID_SW_FLAG_MASK ),
135cdf0e10cSrcweir rUnitConverter );
136cdf0e10cSrcweir
137cdf0e10cSrcweir }
138cdf0e10cSrcweir else
139cdf0e10cSrcweir {
140cdf0e10cSrcweir bPut = handleSpecialItem( *pEntry, *pNewItem, rSet,
141cdf0e10cSrcweir rValue, rUnitConverter,
142cdf0e10cSrcweir rNamespaceMap );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir if( bPut )
146cdf0e10cSrcweir rSet.Put( *pNewItem );
147cdf0e10cSrcweir
148cdf0e10cSrcweir delete pNewItem;
149cdf0e10cSrcweir }
150cdf0e10cSrcweir else
151cdf0e10cSrcweir {
152cdf0e10cSrcweir DBG_ERROR( "Could not get a needed item for xml import!" );
153cdf0e10cSrcweir }
154cdf0e10cSrcweir }
155cdf0e10cSrcweir else if( 0 != (pEntry->nMemberId & MID_SW_FLAG_NO_ITEM_IMPORT) )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir handleNoItem( *pEntry, rSet, rValue, rUnitConverter,
158cdf0e10cSrcweir rNamespaceMap );
159cdf0e10cSrcweir }
160cdf0e10cSrcweir }
161cdf0e10cSrcweir else if( USHRT_MAX != nUnknownWhich )
162cdf0e10cSrcweir {
163cdf0e10cSrcweir if( !pUnknownItem )
164cdf0e10cSrcweir {
165cdf0e10cSrcweir const SfxPoolItem* pItem = 0;
166cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( nUnknownWhich, sal_True,
167cdf0e10cSrcweir &pItem ) )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir SfxPoolItem *pNew = pItem->Clone();
170cdf0e10cSrcweir pUnknownItem = PTR_CAST( SvXMLAttrContainerItem, pNew );
171cdf0e10cSrcweir DBG_ASSERT( pUnknownItem,
172cdf0e10cSrcweir "SvXMLAttrContainerItem expected" );
173cdf0e10cSrcweir if( !pUnknownItem )
174cdf0e10cSrcweir delete pNew;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir else
177cdf0e10cSrcweir {
178cdf0e10cSrcweir pUnknownItem = new SvXMLAttrContainerItem( nUnknownWhich );
179cdf0e10cSrcweir }
180cdf0e10cSrcweir }
181cdf0e10cSrcweir if( pUnknownItem )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir if( XML_NAMESPACE_NONE == nPrefix )
184cdf0e10cSrcweir pUnknownItem->AddAttr( aLocalName, rValue );
185cdf0e10cSrcweir else
186cdf0e10cSrcweir pUnknownItem->AddAttr( aPrefix, aNamespace, aLocalName,
187cdf0e10cSrcweir rValue );
188cdf0e10cSrcweir }
189cdf0e10cSrcweir }
190cdf0e10cSrcweir }
191cdf0e10cSrcweir
192cdf0e10cSrcweir if( pUnknownItem )
193cdf0e10cSrcweir {
194cdf0e10cSrcweir rSet.Put( *pUnknownItem );
195cdf0e10cSrcweir delete pUnknownItem;
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir finished(rSet, rUnitConverter);
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir /** this method is called for every item that has the
202cdf0e10cSrcweir MID_SW_FLAG_SPECIAL_ITEM_IMPORT flag set */
203cdf0e10cSrcweir sal_Bool
handleSpecialItem(const SvXMLItemMapEntry &,SfxPoolItem &,SfxItemSet &,const OUString &,const SvXMLUnitConverter &,const SvXMLNamespaceMap &)204cdf0e10cSrcweir SvXMLImportItemMapper::handleSpecialItem( const SvXMLItemMapEntry& /*rEntry*/,
205cdf0e10cSrcweir SfxPoolItem& /*rItem*/,
206cdf0e10cSrcweir SfxItemSet& /*rSet*/,
207cdf0e10cSrcweir const OUString& /*rValue*/,
208cdf0e10cSrcweir const SvXMLUnitConverter& /*rUnitConverter*/,
209cdf0e10cSrcweir const SvXMLNamespaceMap& /*rNamespaceMap*/ )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir DBG_ERROR( "unsuported special item in xml import" );
212cdf0e10cSrcweir return sal_False;
213cdf0e10cSrcweir }
214cdf0e10cSrcweir
215cdf0e10cSrcweir /** this method is called for every item that has the
216cdf0e10cSrcweir MID_SW_FLAG_NO_ITEM_IMPORT flag set */
handleNoItem(const SvXMLItemMapEntry &,SfxItemSet &,const OUString &,const SvXMLUnitConverter &,const SvXMLNamespaceMap &)217cdf0e10cSrcweir sal_Bool SvXMLImportItemMapper::handleNoItem( const SvXMLItemMapEntry& /*rEntry*/,
218cdf0e10cSrcweir SfxItemSet& /*rSet*/,
219cdf0e10cSrcweir const OUString& /*rValue*/,
220cdf0e10cSrcweir const SvXMLUnitConverter& /*rUnitConverter*/,
221cdf0e10cSrcweir const SvXMLNamespaceMap& /*rNamespaceMap*/ )
222cdf0e10cSrcweir {
223cdf0e10cSrcweir DBG_ERROR( "unsuported no item in xml import" );
224cdf0e10cSrcweir return sal_False;
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
227cdf0e10cSrcweir void
finished(SfxItemSet &,SvXMLUnitConverter const &) const228cdf0e10cSrcweir SvXMLImportItemMapper::finished(SfxItemSet &, SvXMLUnitConverter const&) const
229cdf0e10cSrcweir {
230cdf0e10cSrcweir // nothing to do here
231cdf0e10cSrcweir }
232cdf0e10cSrcweir
233cdf0e10cSrcweir
234cdf0e10cSrcweir
235cdf0e10cSrcweir // put an XML-string value into an item
PutXMLValue(SfxPoolItem & rItem,const::rtl::OUString & rValue,sal_uInt16 nMemberId,const SvXMLUnitConverter & rUnitConverter)236cdf0e10cSrcweir sal_Bool SvXMLImportItemMapper::PutXMLValue(
237cdf0e10cSrcweir SfxPoolItem& rItem,
238cdf0e10cSrcweir const ::rtl::OUString& rValue,
239cdf0e10cSrcweir sal_uInt16 nMemberId,
240cdf0e10cSrcweir const SvXMLUnitConverter& rUnitConverter )
241cdf0e10cSrcweir {
242cdf0e10cSrcweir sal_Bool bOk = sal_False;
243cdf0e10cSrcweir
244cdf0e10cSrcweir switch (rItem.Which())
245cdf0e10cSrcweir {
246cdf0e10cSrcweir case RES_LR_SPACE:
247cdf0e10cSrcweir {
248cdf0e10cSrcweir SvxLRSpaceItem* pLRSpace = PTR_CAST(SvxLRSpaceItem, &rItem);
249cdf0e10cSrcweir DBG_ASSERT( pLRSpace != NULL, "Wrong Which-ID!" );
250cdf0e10cSrcweir
251cdf0e10cSrcweir switch( nMemberId )
252cdf0e10cSrcweir {
253cdf0e10cSrcweir case MID_L_MARGIN:
254cdf0e10cSrcweir case MID_R_MARGIN:
255cdf0e10cSrcweir {
256cdf0e10cSrcweir sal_Int32 nProp = 100;
257cdf0e10cSrcweir sal_Int32 nAbs = 0;
258cdf0e10cSrcweir
259cdf0e10cSrcweir if( rValue.indexOf( sal_Unicode('%') ) != -1 )
260cdf0e10cSrcweir bOk = rUnitConverter.convertPercent( nProp, rValue );
261cdf0e10cSrcweir else
262cdf0e10cSrcweir bOk = rUnitConverter.convertMeasure( nAbs, rValue );
263cdf0e10cSrcweir
264cdf0e10cSrcweir if( bOk )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir switch( nMemberId )
267cdf0e10cSrcweir {
268cdf0e10cSrcweir case MID_L_MARGIN:
269cdf0e10cSrcweir pLRSpace->SetTxtLeft( (sal_Int32)nAbs, (sal_uInt16)nProp );
270cdf0e10cSrcweir break;
271cdf0e10cSrcweir case MID_R_MARGIN:
272cdf0e10cSrcweir pLRSpace->SetRight( (sal_Int32)nAbs, (sal_uInt16)nProp );
273cdf0e10cSrcweir break;
274cdf0e10cSrcweir }
275cdf0e10cSrcweir }
276cdf0e10cSrcweir }
277cdf0e10cSrcweir break;
278cdf0e10cSrcweir case MID_FIRST_LINE_INDENT:
279cdf0e10cSrcweir {
280cdf0e10cSrcweir sal_Int32 nProp = 100;
281cdf0e10cSrcweir sal_Int32 nAbs = 0;
282cdf0e10cSrcweir
283cdf0e10cSrcweir if( rValue.indexOf( sal_Unicode('%') ) != -1 )
284cdf0e10cSrcweir bOk = rUnitConverter.convertPercent( nProp, rValue );
285cdf0e10cSrcweir else
286cdf0e10cSrcweir bOk = rUnitConverter.convertMeasure( nAbs, rValue,
287cdf0e10cSrcweir -0x7fff, 0x7fff );
288cdf0e10cSrcweir
289cdf0e10cSrcweir pLRSpace->SetTxtFirstLineOfst( (short)nAbs, (sal_uInt16)nProp );
290cdf0e10cSrcweir }
291cdf0e10cSrcweir
292cdf0e10cSrcweir case MID_FIRST_AUTO:
293cdf0e10cSrcweir {
294cdf0e10cSrcweir sal_Bool bAutoFirst;
295cdf0e10cSrcweir bOk = rUnitConverter.convertBool( bAutoFirst, rValue );
296cdf0e10cSrcweir if( bOk )
297cdf0e10cSrcweir pLRSpace->SetAutoFirst( bAutoFirst );
298cdf0e10cSrcweir }
299cdf0e10cSrcweir break;
300cdf0e10cSrcweir
301cdf0e10cSrcweir default:
302cdf0e10cSrcweir DBG_ERROR( "unknown member id!");
303cdf0e10cSrcweir }
304cdf0e10cSrcweir }
305cdf0e10cSrcweir break;
306cdf0e10cSrcweir
307cdf0e10cSrcweir case RES_UL_SPACE:
308cdf0e10cSrcweir {
309cdf0e10cSrcweir SvxULSpaceItem* pULSpace = PTR_CAST(SvxULSpaceItem, &rItem);
310cdf0e10cSrcweir DBG_ASSERT( pULSpace != NULL, "Wrong Which-ID!" );
311cdf0e10cSrcweir
312cdf0e10cSrcweir sal_Int32 nProp = 100;
313cdf0e10cSrcweir sal_Int32 nAbs = 0;
314cdf0e10cSrcweir
315cdf0e10cSrcweir if( rValue.indexOf( sal_Unicode('%') ) != -1 )
316cdf0e10cSrcweir bOk = rUnitConverter.convertPercent( nProp, rValue );
317cdf0e10cSrcweir else
318cdf0e10cSrcweir bOk = rUnitConverter.convertMeasure( nAbs, rValue );
319cdf0e10cSrcweir
320cdf0e10cSrcweir switch( nMemberId )
321cdf0e10cSrcweir {
322cdf0e10cSrcweir case MID_UP_MARGIN:
323cdf0e10cSrcweir pULSpace->SetUpper( (sal_uInt16)nAbs, (sal_uInt16)nProp );
324cdf0e10cSrcweir break;
325cdf0e10cSrcweir case MID_LO_MARGIN:
326cdf0e10cSrcweir pULSpace->SetLower( (sal_uInt16)nAbs, (sal_uInt16)nProp );
327cdf0e10cSrcweir break;
328cdf0e10cSrcweir default:
329cdf0e10cSrcweir DBG_ERROR("unknown MemberId");
330cdf0e10cSrcweir }
331cdf0e10cSrcweir }
332cdf0e10cSrcweir break;
333cdf0e10cSrcweir
334cdf0e10cSrcweir case RES_SHADOW:
335cdf0e10cSrcweir {
336cdf0e10cSrcweir SvxShadowItem* pShadow = PTR_CAST(SvxShadowItem, &rItem);
337cdf0e10cSrcweir DBG_ASSERT( pShadow != NULL, "Wrong Which-ID" );
338cdf0e10cSrcweir
339cdf0e10cSrcweir sal_Bool bColorFound = sal_False;
340cdf0e10cSrcweir sal_Bool bOffsetFound = sal_False;
341cdf0e10cSrcweir
342cdf0e10cSrcweir SvXMLTokenEnumerator aTokenEnum( rValue );
343cdf0e10cSrcweir
344cdf0e10cSrcweir Color aColor( 128,128, 128 );
345cdf0e10cSrcweir pShadow->SetLocation( SVX_SHADOW_BOTTOMRIGHT );
346cdf0e10cSrcweir
347cdf0e10cSrcweir OUString aToken;
348cdf0e10cSrcweir while( aTokenEnum.getNextToken( aToken ) )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir if( IsXMLToken( aToken, XML_NONE ) )
351cdf0e10cSrcweir {
352cdf0e10cSrcweir pShadow->SetLocation( SVX_SHADOW_NONE );
353cdf0e10cSrcweir bOk = sal_True;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir else if( !bColorFound && aToken.compareToAscii( "#", 1 ) == 0 )
356cdf0e10cSrcweir {
357cdf0e10cSrcweir bOk = rUnitConverter.convertColor( aColor, aToken );
358cdf0e10cSrcweir if( !bOk )
359cdf0e10cSrcweir return sal_False;
360cdf0e10cSrcweir
361cdf0e10cSrcweir bColorFound = sal_True;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir else if( !bOffsetFound )
364cdf0e10cSrcweir {
365cdf0e10cSrcweir sal_Int32 nX = 0, nY = 0;
366cdf0e10cSrcweir
367cdf0e10cSrcweir bOk = rUnitConverter.convertMeasure( nX, aToken );
368cdf0e10cSrcweir if( bOk && aTokenEnum.getNextToken( aToken ) )
369cdf0e10cSrcweir bOk = rUnitConverter.convertMeasure( nY, aToken );
370cdf0e10cSrcweir
371cdf0e10cSrcweir if( bOk )
372cdf0e10cSrcweir {
373cdf0e10cSrcweir if( nX < 0 )
374cdf0e10cSrcweir {
375cdf0e10cSrcweir if( nY < 0 )
376cdf0e10cSrcweir {
377cdf0e10cSrcweir pShadow->SetLocation( SVX_SHADOW_TOPLEFT );
378cdf0e10cSrcweir }
379cdf0e10cSrcweir else
380cdf0e10cSrcweir {
381cdf0e10cSrcweir pShadow->SetLocation( SVX_SHADOW_BOTTOMLEFT );
382cdf0e10cSrcweir }
383cdf0e10cSrcweir }
384cdf0e10cSrcweir else
385cdf0e10cSrcweir {
386cdf0e10cSrcweir if( nY < 0 )
387cdf0e10cSrcweir {
388cdf0e10cSrcweir pShadow->SetLocation( SVX_SHADOW_TOPRIGHT );
389cdf0e10cSrcweir }
390cdf0e10cSrcweir else
391cdf0e10cSrcweir {
392cdf0e10cSrcweir pShadow->SetLocation( SVX_SHADOW_BOTTOMRIGHT );
393cdf0e10cSrcweir }
394cdf0e10cSrcweir }
395cdf0e10cSrcweir
396cdf0e10cSrcweir if( nX < 0 ) nX *= -1;
397cdf0e10cSrcweir if( nY < 0 ) nY *= -1;
398cdf0e10cSrcweir
399cdf0e10cSrcweir pShadow->SetWidth( static_cast< sal_uInt16 >( (nX + nY) >> 1 ) );
400cdf0e10cSrcweir }
401cdf0e10cSrcweir }
402cdf0e10cSrcweir }
403cdf0e10cSrcweir
404cdf0e10cSrcweir if( bOk && ( bColorFound || bOffsetFound ) )
405cdf0e10cSrcweir {
406cdf0e10cSrcweir pShadow->SetColor( aColor );
407cdf0e10cSrcweir }
408cdf0e10cSrcweir else
409cdf0e10cSrcweir bOk = sal_False;
410cdf0e10cSrcweir }
411cdf0e10cSrcweir break;
412cdf0e10cSrcweir
413cdf0e10cSrcweir case RES_BOX:
414cdf0e10cSrcweir {
415cdf0e10cSrcweir SvxBoxItem* pBox = PTR_CAST(SvxBoxItem, &rItem);
416cdf0e10cSrcweir DBG_ASSERT( pBox != NULL, "Wrong WHich-ID" );
417cdf0e10cSrcweir
418cdf0e10cSrcweir /** copy SvxBorderLines */
419cdf0e10cSrcweir SvxBorderLine* pTop = pBox->GetTop() == NULL ?
420cdf0e10cSrcweir NULL : new SvxBorderLine( *pBox->GetTop() );
421cdf0e10cSrcweir SvxBorderLine* pBottom = pBox->GetBottom() == NULL ?
422cdf0e10cSrcweir NULL : new SvxBorderLine( *pBox->GetBottom() );
423cdf0e10cSrcweir SvxBorderLine* pLeft = pBox->GetLeft() == NULL ?
424cdf0e10cSrcweir NULL : new SvxBorderLine( *pBox->GetLeft() );
425cdf0e10cSrcweir SvxBorderLine* pRight = pBox->GetRight() == NULL ?
426cdf0e10cSrcweir NULL : new SvxBorderLine( *pBox->GetRight() );
427cdf0e10cSrcweir
428cdf0e10cSrcweir sal_Int32 nTemp;
429cdf0e10cSrcweir
430cdf0e10cSrcweir switch( nMemberId )
431cdf0e10cSrcweir {
432cdf0e10cSrcweir case ALL_BORDER_PADDING:
433cdf0e10cSrcweir case LEFT_BORDER_PADDING:
434cdf0e10cSrcweir case RIGHT_BORDER_PADDING:
435cdf0e10cSrcweir case TOP_BORDER_PADDING:
436cdf0e10cSrcweir case BOTTOM_BORDER_PADDING:
437cdf0e10cSrcweir if(!rUnitConverter.convertMeasure( nTemp, rValue, 0, 0xffff ))
438cdf0e10cSrcweir return sal_False;
439cdf0e10cSrcweir
440cdf0e10cSrcweir if( nMemberId == LEFT_BORDER_PADDING ||
441cdf0e10cSrcweir nMemberId == ALL_BORDER_PADDING )
442cdf0e10cSrcweir pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_LEFT );
443cdf0e10cSrcweir if( nMemberId == RIGHT_BORDER_PADDING ||
444cdf0e10cSrcweir nMemberId == ALL_BORDER_PADDING )
445cdf0e10cSrcweir pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_RIGHT );
446cdf0e10cSrcweir if( nMemberId == TOP_BORDER_PADDING ||
447cdf0e10cSrcweir nMemberId == ALL_BORDER_PADDING )
448cdf0e10cSrcweir pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_TOP );
449cdf0e10cSrcweir if( nMemberId == BOTTOM_BORDER_PADDING ||
450cdf0e10cSrcweir nMemberId == ALL_BORDER_PADDING )
451cdf0e10cSrcweir pBox->SetDistance( (sal_uInt16)nTemp, BOX_LINE_BOTTOM);
452cdf0e10cSrcweir break;
453cdf0e10cSrcweir
454cdf0e10cSrcweir case ALL_BORDER:
455cdf0e10cSrcweir case LEFT_BORDER:
456cdf0e10cSrcweir case RIGHT_BORDER:
457cdf0e10cSrcweir case TOP_BORDER:
458cdf0e10cSrcweir case BOTTOM_BORDER:
459cdf0e10cSrcweir {
460cdf0e10cSrcweir sal_Bool bHasStyle = sal_False;
461cdf0e10cSrcweir sal_Bool bHasWidth = sal_False;
462cdf0e10cSrcweir sal_Bool bHasColor = sal_False;
463cdf0e10cSrcweir
464cdf0e10cSrcweir sal_uInt16 nStyle = USHRT_MAX;
465cdf0e10cSrcweir sal_uInt16 nWidth = 0;
466cdf0e10cSrcweir sal_uInt16 nNamedWidth = USHRT_MAX;
467cdf0e10cSrcweir
468cdf0e10cSrcweir Color aColor( COL_BLACK );
469cdf0e10cSrcweir
470cdf0e10cSrcweir if( !lcl_frmitems_parseXMLBorder( rValue, rUnitConverter,
471cdf0e10cSrcweir bHasStyle, nStyle,
472cdf0e10cSrcweir bHasWidth, nWidth, nNamedWidth,
473cdf0e10cSrcweir bHasColor, aColor ) )
474cdf0e10cSrcweir return sal_False;
475cdf0e10cSrcweir
476cdf0e10cSrcweir if( TOP_BORDER == nMemberId || ALL_BORDER == nMemberId )
477cdf0e10cSrcweir lcl_frmitems_setXMLBorder( pTop,
478cdf0e10cSrcweir bHasStyle, nStyle,
479cdf0e10cSrcweir bHasWidth, nWidth, nNamedWidth,
480cdf0e10cSrcweir bHasColor, aColor );
481cdf0e10cSrcweir
482cdf0e10cSrcweir if( BOTTOM_BORDER == nMemberId || ALL_BORDER == nMemberId )
483cdf0e10cSrcweir lcl_frmitems_setXMLBorder( pBottom,
484cdf0e10cSrcweir bHasStyle, nStyle,
485cdf0e10cSrcweir bHasWidth, nWidth, nNamedWidth,
486cdf0e10cSrcweir bHasColor, aColor );
487cdf0e10cSrcweir
488cdf0e10cSrcweir if( LEFT_BORDER == nMemberId || ALL_BORDER == nMemberId )
489cdf0e10cSrcweir lcl_frmitems_setXMLBorder( pLeft,
490cdf0e10cSrcweir bHasStyle, nStyle,
491cdf0e10cSrcweir bHasWidth, nWidth, nNamedWidth,
492cdf0e10cSrcweir bHasColor, aColor );
493cdf0e10cSrcweir
494cdf0e10cSrcweir if( RIGHT_BORDER == nMemberId || ALL_BORDER == nMemberId )
495cdf0e10cSrcweir lcl_frmitems_setXMLBorder( pRight,
496cdf0e10cSrcweir bHasStyle, nStyle,
497cdf0e10cSrcweir bHasWidth, nWidth, nNamedWidth,
498cdf0e10cSrcweir bHasColor, aColor );
499cdf0e10cSrcweir }
500cdf0e10cSrcweir break;
501cdf0e10cSrcweir case ALL_BORDER_LINE_WIDTH:
502cdf0e10cSrcweir case LEFT_BORDER_LINE_WIDTH:
503cdf0e10cSrcweir case RIGHT_BORDER_LINE_WIDTH:
504cdf0e10cSrcweir case TOP_BORDER_LINE_WIDTH:
505cdf0e10cSrcweir case BOTTOM_BORDER_LINE_WIDTH:
506cdf0e10cSrcweir {
507cdf0e10cSrcweir SvXMLTokenEnumerator aTokenEnum( rValue );
508cdf0e10cSrcweir
509cdf0e10cSrcweir sal_Int32 nInWidth, nDistance, nOutWidth;
510cdf0e10cSrcweir
511cdf0e10cSrcweir OUString aToken;
512cdf0e10cSrcweir if( !aTokenEnum.getNextToken( aToken ) )
513cdf0e10cSrcweir return sal_False;
514cdf0e10cSrcweir
515cdf0e10cSrcweir if( !rUnitConverter.convertMeasure( nInWidth, aToken,
516cdf0e10cSrcweir DEF_LINE_WIDTH_0,
517cdf0e10cSrcweir DEF_LINE_WIDTH_4 ) )
518cdf0e10cSrcweir return sal_False;
519cdf0e10cSrcweir
520cdf0e10cSrcweir if( !aTokenEnum.getNextToken( aToken ) )
521cdf0e10cSrcweir return sal_False;
522cdf0e10cSrcweir
523cdf0e10cSrcweir if( !rUnitConverter.convertMeasure( nDistance, aToken,
524cdf0e10cSrcweir DEF_LINE_WIDTH_0,
525cdf0e10cSrcweir DEF_LINE_WIDTH_4 ) )
526cdf0e10cSrcweir return sal_False;
527cdf0e10cSrcweir
528cdf0e10cSrcweir if( !aTokenEnum.getNextToken( aToken ) )
529cdf0e10cSrcweir return sal_False;
530cdf0e10cSrcweir
531cdf0e10cSrcweir if( !rUnitConverter.convertMeasure( nOutWidth, aToken,
532cdf0e10cSrcweir DEF_LINE_WIDTH_0,
533cdf0e10cSrcweir DEF_LINE_WIDTH_4 ) )
534cdf0e10cSrcweir return sal_False;
535cdf0e10cSrcweir
536cdf0e10cSrcweir // #i61946: accept line style even it's not part of our "normal" set of line styles
537cdf0e10cSrcweir sal_uInt16 nWidth = 0;
538cdf0e10cSrcweir
539cdf0e10cSrcweir if( TOP_BORDER_LINE_WIDTH == nMemberId ||
540cdf0e10cSrcweir ALL_BORDER_LINE_WIDTH == nMemberId )
541cdf0e10cSrcweir lcl_frmitems_setXMLBorder( pTop, nWidth,
542cdf0e10cSrcweir static_cast< sal_uInt16 >( nOutWidth ),
543cdf0e10cSrcweir static_cast< sal_uInt16 >( nInWidth ),
544cdf0e10cSrcweir static_cast< sal_uInt16 >( nDistance ) );
545cdf0e10cSrcweir
546cdf0e10cSrcweir if( BOTTOM_BORDER_LINE_WIDTH == nMemberId ||
547cdf0e10cSrcweir ALL_BORDER_LINE_WIDTH == nMemberId )
548cdf0e10cSrcweir lcl_frmitems_setXMLBorder( pBottom, nWidth,
549cdf0e10cSrcweir static_cast< sal_uInt16 >( nOutWidth ),
550cdf0e10cSrcweir static_cast< sal_uInt16 >( nInWidth ),
551cdf0e10cSrcweir static_cast< sal_uInt16 >( nDistance ) );
552cdf0e10cSrcweir
553cdf0e10cSrcweir if( LEFT_BORDER_LINE_WIDTH == nMemberId ||
554cdf0e10cSrcweir ALL_BORDER_LINE_WIDTH == nMemberId )
555cdf0e10cSrcweir lcl_frmitems_setXMLBorder( pLeft, nWidth,
556cdf0e10cSrcweir static_cast< sal_uInt16 >( nOutWidth ),
557cdf0e10cSrcweir static_cast< sal_uInt16 >( nInWidth ),
558cdf0e10cSrcweir static_cast< sal_uInt16 >( nDistance ) );
559cdf0e10cSrcweir
560cdf0e10cSrcweir if( RIGHT_BORDER_LINE_WIDTH == nMemberId ||
561cdf0e10cSrcweir ALL_BORDER_LINE_WIDTH == nMemberId )
562cdf0e10cSrcweir lcl_frmitems_setXMLBorder( pRight, nWidth,
563cdf0e10cSrcweir static_cast< sal_uInt16 >( nOutWidth ),
564cdf0e10cSrcweir static_cast< sal_uInt16 >( nInWidth ),
565cdf0e10cSrcweir static_cast< sal_uInt16 >( nDistance ) );
566cdf0e10cSrcweir }
567cdf0e10cSrcweir break;
568cdf0e10cSrcweir }
569cdf0e10cSrcweir
570cdf0e10cSrcweir pBox->SetLine( pTop, BOX_LINE_TOP );
571cdf0e10cSrcweir pBox->SetLine( pBottom, BOX_LINE_BOTTOM );
572cdf0e10cSrcweir pBox->SetLine( pLeft, BOX_LINE_LEFT );
573cdf0e10cSrcweir pBox->SetLine( pRight, BOX_LINE_RIGHT );
574cdf0e10cSrcweir
575cdf0e10cSrcweir delete pTop;
576cdf0e10cSrcweir delete pBottom;
577cdf0e10cSrcweir delete pLeft;
578cdf0e10cSrcweir delete pRight;
579cdf0e10cSrcweir
580cdf0e10cSrcweir bOk = sal_True;
581cdf0e10cSrcweir }
582cdf0e10cSrcweir break;
583cdf0e10cSrcweir
584cdf0e10cSrcweir case RES_BREAK:
585cdf0e10cSrcweir {
586cdf0e10cSrcweir SvxFmtBreakItem* pFmtBreak = PTR_CAST(SvxFmtBreakItem, &rItem);
587cdf0e10cSrcweir DBG_ASSERT( pFmtBreak != NULL, "Wrong Which-ID" );
588cdf0e10cSrcweir
589cdf0e10cSrcweir sal_uInt16 eEnum;
590cdf0e10cSrcweir
591cdf0e10cSrcweir if( !rUnitConverter.convertEnum( eEnum, rValue, psXML_BreakType ) )
592cdf0e10cSrcweir return sal_False;
593cdf0e10cSrcweir
594cdf0e10cSrcweir if( eEnum == 0 )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir pFmtBreak->SetValue( SVX_BREAK_NONE );
597cdf0e10cSrcweir bOk = sal_True;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir else
600cdf0e10cSrcweir {
601cdf0e10cSrcweir switch( nMemberId )
602cdf0e10cSrcweir {
603cdf0e10cSrcweir case MID_BREAK_BEFORE:
604cdf0e10cSrcweir pFmtBreak->SetValue( static_cast< sal_uInt16 >((eEnum == 1) ?
605cdf0e10cSrcweir SVX_BREAK_COLUMN_BEFORE :
606cdf0e10cSrcweir SVX_BREAK_PAGE_BEFORE) );
607cdf0e10cSrcweir break;
608cdf0e10cSrcweir case MID_BREAK_AFTER:
609cdf0e10cSrcweir pFmtBreak->SetValue( static_cast< sal_uInt16 >((eEnum == 1) ?
610cdf0e10cSrcweir SVX_BREAK_COLUMN_AFTER :
611cdf0e10cSrcweir SVX_BREAK_PAGE_AFTER) );
612cdf0e10cSrcweir break;
613cdf0e10cSrcweir }
614cdf0e10cSrcweir bOk = sal_True;
615cdf0e10cSrcweir }
616cdf0e10cSrcweir }
617cdf0e10cSrcweir break;
618cdf0e10cSrcweir
619cdf0e10cSrcweir case RES_KEEP:
620cdf0e10cSrcweir {
621cdf0e10cSrcweir SvxFmtKeepItem* pFmtKeep = PTR_CAST(SvxFmtKeepItem, &rItem);
622cdf0e10cSrcweir DBG_ASSERT( pFmtKeep != NULL, "Wrong Which-ID" );
623cdf0e10cSrcweir
624cdf0e10cSrcweir if( IsXMLToken( rValue, XML_ALWAYS ) ||
625cdf0e10cSrcweir IsXMLToken( rValue, XML_TRUE ) )
626cdf0e10cSrcweir {
627cdf0e10cSrcweir pFmtKeep->SetValue( sal_True );
628cdf0e10cSrcweir bOk = sal_True;
629cdf0e10cSrcweir }
630cdf0e10cSrcweir else if( IsXMLToken( rValue, XML_AUTO ) ||
631cdf0e10cSrcweir IsXMLToken( rValue, XML_FALSE ) )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir pFmtKeep->SetValue( sal_False );
634cdf0e10cSrcweir bOk = sal_True;
635cdf0e10cSrcweir }
636cdf0e10cSrcweir }
637cdf0e10cSrcweir break;
638cdf0e10cSrcweir
639cdf0e10cSrcweir case RES_BACKGROUND:
640cdf0e10cSrcweir {
641cdf0e10cSrcweir SvxBrushItem* pBrush = PTR_CAST(SvxBrushItem, &rItem);
642cdf0e10cSrcweir DBG_ASSERT( pBrush != NULL, "Wrong Which-ID" );
643cdf0e10cSrcweir
644cdf0e10cSrcweir Color aTempColor;
645cdf0e10cSrcweir switch( nMemberId )
646cdf0e10cSrcweir {
647cdf0e10cSrcweir case MID_BACK_COLOR:
648cdf0e10cSrcweir if( IsXMLToken( rValue, XML_TRANSPARENT ) )
649cdf0e10cSrcweir {
650cdf0e10cSrcweir pBrush->GetColor().SetTransparency(0xff);
651cdf0e10cSrcweir bOk = sal_True;
652cdf0e10cSrcweir }
653cdf0e10cSrcweir else if( rUnitConverter.convertColor( aTempColor, rValue ) )
654cdf0e10cSrcweir {
655cdf0e10cSrcweir aTempColor.SetTransparency(0);
656cdf0e10cSrcweir pBrush->SetColor( aTempColor );
657cdf0e10cSrcweir bOk = sal_True;
658cdf0e10cSrcweir }
659cdf0e10cSrcweir break;
660cdf0e10cSrcweir
661cdf0e10cSrcweir case MID_GRAPHIC_LINK:
662cdf0e10cSrcweir {
663cdf0e10cSrcweir SvxGraphicPosition eOldGraphicPos = pBrush->GetGraphicPos();
664cdf0e10cSrcweir uno::Any aAny;
665cdf0e10cSrcweir aAny <<= rValue;
666cdf0e10cSrcweir pBrush->PutValue( aAny, MID_GRAPHIC_URL );
667cdf0e10cSrcweir if( GPOS_NONE == eOldGraphicPos &&
668cdf0e10cSrcweir GPOS_NONE != pBrush->GetGraphicPos() )
669cdf0e10cSrcweir pBrush->SetGraphicPos( GPOS_TILED );
670cdf0e10cSrcweir bOk = sal_True ;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir break;
673cdf0e10cSrcweir
674cdf0e10cSrcweir case MID_GRAPHIC_REPEAT:
675cdf0e10cSrcweir {
676cdf0e10cSrcweir SvxGraphicPosition eGraphicPos = pBrush->GetGraphicPos();
677cdf0e10cSrcweir sal_uInt16 nPos = GPOS_NONE;
678cdf0e10cSrcweir if( rUnitConverter.convertEnum( nPos, rValue,
679cdf0e10cSrcweir psXML_BrushRepeat ) )
680cdf0e10cSrcweir {
681cdf0e10cSrcweir if( GPOS_MM != nPos || GPOS_NONE == eGraphicPos ||
682cdf0e10cSrcweir GPOS_AREA == eGraphicPos || GPOS_TILED == eGraphicPos )
683cdf0e10cSrcweir pBrush->SetGraphicPos( (SvxGraphicPosition)nPos );
684cdf0e10cSrcweir bOk = sal_True;
685cdf0e10cSrcweir }
686cdf0e10cSrcweir }
687cdf0e10cSrcweir break;
688cdf0e10cSrcweir
689cdf0e10cSrcweir case MID_GRAPHIC_POSITION:
690cdf0e10cSrcweir {
691cdf0e10cSrcweir SvxGraphicPosition ePos = GPOS_NONE, eTmp;
692cdf0e10cSrcweir sal_uInt16 nTmp;
693cdf0e10cSrcweir SvXMLTokenEnumerator aTokenEnum( rValue );
694cdf0e10cSrcweir OUString aToken;
695cdf0e10cSrcweir sal_Bool bHori = sal_False, bVert = sal_False;
696cdf0e10cSrcweir bOk = sal_True;
697cdf0e10cSrcweir while( bOk && aTokenEnum.getNextToken( aToken ) )
698cdf0e10cSrcweir {
699cdf0e10cSrcweir if( bHori && bVert )
700cdf0e10cSrcweir {
701cdf0e10cSrcweir bOk = sal_False;
702cdf0e10cSrcweir }
703cdf0e10cSrcweir else if( -1 != aToken.indexOf( sal_Unicode('%') ) )
704cdf0e10cSrcweir {
705cdf0e10cSrcweir sal_Int32 nPrc = 50;
706cdf0e10cSrcweir if( rUnitConverter.convertPercent( nPrc, aToken ) )
707cdf0e10cSrcweir {
708cdf0e10cSrcweir if( !bHori )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir ePos = nPrc < 25 ? GPOS_LT :
711cdf0e10cSrcweir (nPrc < 75 ? GPOS_MM : GPOS_RB);
712cdf0e10cSrcweir bHori = sal_True;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir else
715cdf0e10cSrcweir {
716cdf0e10cSrcweir eTmp = nPrc < 25 ? GPOS_LT:
717cdf0e10cSrcweir (nPrc < 75 ? GPOS_LM : GPOS_LB);
718cdf0e10cSrcweir lcl_frmitems_MergeXMLVertPos( ePos, eTmp );
719cdf0e10cSrcweir bVert = sal_True;
720cdf0e10cSrcweir }
721cdf0e10cSrcweir }
722cdf0e10cSrcweir else
723cdf0e10cSrcweir {
724cdf0e10cSrcweir // wrong percentage
725cdf0e10cSrcweir bOk = sal_False;
726cdf0e10cSrcweir }
727cdf0e10cSrcweir }
728cdf0e10cSrcweir else if( IsXMLToken( aToken, XML_CENTER ) )
729cdf0e10cSrcweir {
730cdf0e10cSrcweir if( bHori )
731cdf0e10cSrcweir lcl_frmitems_MergeXMLVertPos( ePos, GPOS_MM );
732cdf0e10cSrcweir else if ( bVert )
733cdf0e10cSrcweir lcl_frmitems_MergeXMLHoriPos( ePos, GPOS_MM );
734cdf0e10cSrcweir else
735cdf0e10cSrcweir ePos = GPOS_MM;
736cdf0e10cSrcweir }
737cdf0e10cSrcweir else if( rUnitConverter.convertEnum( nTmp, aToken,
738cdf0e10cSrcweir psXML_BrushHoriPos ) )
739cdf0e10cSrcweir {
740cdf0e10cSrcweir if( bVert )
741cdf0e10cSrcweir lcl_frmitems_MergeXMLHoriPos(
742cdf0e10cSrcweir ePos, (SvxGraphicPosition)nTmp );
743cdf0e10cSrcweir else if( !bHori )
744cdf0e10cSrcweir ePos = (SvxGraphicPosition)nTmp;
745cdf0e10cSrcweir else
746cdf0e10cSrcweir bOk = sal_False;
747cdf0e10cSrcweir bHori = sal_True;
748cdf0e10cSrcweir }
749cdf0e10cSrcweir else if( rUnitConverter.convertEnum( nTmp, aToken,
750cdf0e10cSrcweir psXML_BrushVertPos ) )
751cdf0e10cSrcweir {
752cdf0e10cSrcweir if( bHori )
753cdf0e10cSrcweir lcl_frmitems_MergeXMLVertPos(
754cdf0e10cSrcweir ePos, (SvxGraphicPosition)nTmp );
755cdf0e10cSrcweir else if( !bVert )
756cdf0e10cSrcweir ePos = (SvxGraphicPosition)nTmp;
757cdf0e10cSrcweir else
758cdf0e10cSrcweir bOk = sal_False;
759cdf0e10cSrcweir bVert = sal_True;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir else
762cdf0e10cSrcweir {
763cdf0e10cSrcweir bOk = sal_False;
764cdf0e10cSrcweir }
765cdf0e10cSrcweir }
766cdf0e10cSrcweir
767cdf0e10cSrcweir bOk &= GPOS_NONE != ePos;
768cdf0e10cSrcweir if( bOk )
769cdf0e10cSrcweir pBrush->SetGraphicPos( ePos );
770cdf0e10cSrcweir }
771cdf0e10cSrcweir break;
772cdf0e10cSrcweir
773cdf0e10cSrcweir case MID_GRAPHIC_FILTER:
774cdf0e10cSrcweir pBrush->SetGraphicFilter( rValue.getStr() );
775cdf0e10cSrcweir bOk = sal_True;
776cdf0e10cSrcweir break;
777cdf0e10cSrcweir }
778cdf0e10cSrcweir }
779cdf0e10cSrcweir break;
780cdf0e10cSrcweir
781cdf0e10cSrcweir case RES_PAGEDESC:
782cdf0e10cSrcweir {
783cdf0e10cSrcweir SwFmtPageDesc* pPageDesc = PTR_CAST(SwFmtPageDesc, &rItem);
784cdf0e10cSrcweir DBG_ASSERT( pPageDesc != NULL, "Wrong Which-ID" );
785cdf0e10cSrcweir
786cdf0e10cSrcweir if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId )
787cdf0e10cSrcweir {
788cdf0e10cSrcweir sal_Int32 nVal;
789cdf0e10cSrcweir bOk = rUnitConverter.convertNumber( nVal, rValue, 0, USHRT_MAX );
790cdf0e10cSrcweir if( bOk )
791cdf0e10cSrcweir pPageDesc->SetNumOffset( (sal_uInt16)nVal );
792cdf0e10cSrcweir }
793cdf0e10cSrcweir }
794cdf0e10cSrcweir break;
795cdf0e10cSrcweir
796cdf0e10cSrcweir case RES_LAYOUT_SPLIT:
797cdf0e10cSrcweir case RES_ROW_SPLIT:
798cdf0e10cSrcweir {
799cdf0e10cSrcweir SfxBoolItem* pSplit = PTR_CAST(SfxBoolItem, &rItem);
800cdf0e10cSrcweir DBG_ASSERT( pSplit != NULL, "Wrong Which-ID" );
801cdf0e10cSrcweir
802cdf0e10cSrcweir if( IsXMLToken( rValue, XML_AUTO ) ||
803cdf0e10cSrcweir IsXMLToken( rValue, XML_TRUE ) )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir pSplit->SetValue( sal_True );
806cdf0e10cSrcweir bOk = sal_True;
807cdf0e10cSrcweir }
808cdf0e10cSrcweir else if( IsXMLToken( rValue, XML_ALWAYS ) ||
809cdf0e10cSrcweir IsXMLToken( rValue, XML_FALSE ) )
810cdf0e10cSrcweir {
811cdf0e10cSrcweir pSplit->SetValue( sal_False );
812cdf0e10cSrcweir bOk = sal_True;
813cdf0e10cSrcweir }
814cdf0e10cSrcweir }
815cdf0e10cSrcweir break;
816cdf0e10cSrcweir
817cdf0e10cSrcweir case RES_HORI_ORIENT:
818cdf0e10cSrcweir {
819cdf0e10cSrcweir SwFmtHoriOrient* pHoriOrient = PTR_CAST(SwFmtHoriOrient, &rItem);
820cdf0e10cSrcweir DBG_ASSERT( pHoriOrient != NULL, "Wrong Which-ID" );
821cdf0e10cSrcweir
822cdf0e10cSrcweir sal_uInt16 nValue;
823cdf0e10cSrcweir bOk = rUnitConverter.convertEnum( nValue, rValue,
824cdf0e10cSrcweir aXMLTableAlignMap );
825cdf0e10cSrcweir if( bOk )
826cdf0e10cSrcweir pHoriOrient->SetHoriOrient( nValue );
827cdf0e10cSrcweir }
828cdf0e10cSrcweir break;
829cdf0e10cSrcweir
830cdf0e10cSrcweir case RES_VERT_ORIENT:
831cdf0e10cSrcweir {
832cdf0e10cSrcweir SwFmtVertOrient* pVertOrient = PTR_CAST(SwFmtVertOrient, &rItem);
833cdf0e10cSrcweir DBG_ASSERT( pVertOrient != NULL, "Wrong Which-ID" );
834cdf0e10cSrcweir
835cdf0e10cSrcweir sal_uInt16 nValue;
836cdf0e10cSrcweir bOk = rUnitConverter.convertEnum( nValue, rValue,
837cdf0e10cSrcweir aXMLTableVAlignMap );
838cdf0e10cSrcweir if( bOk )
839cdf0e10cSrcweir pVertOrient->SetVertOrient( nValue );
840cdf0e10cSrcweir //#i8855# text::VertOrientation::NONE is stored as empty string and should be applied here
841cdf0e10cSrcweir else if(!rValue.getLength())
842cdf0e10cSrcweir {
843cdf0e10cSrcweir pVertOrient->SetVertOrient( text::VertOrientation::NONE );
844cdf0e10cSrcweir bOk = sal_True;
845cdf0e10cSrcweir }
846cdf0e10cSrcweir }
847cdf0e10cSrcweir break;
848cdf0e10cSrcweir
849cdf0e10cSrcweir case RES_FRM_SIZE:
850cdf0e10cSrcweir {
851cdf0e10cSrcweir SwFmtFrmSize* pFrmSize = PTR_CAST(SwFmtFrmSize, &rItem);
852cdf0e10cSrcweir DBG_ASSERT( pFrmSize != NULL, "Wrong Which-ID" );
853cdf0e10cSrcweir
854cdf0e10cSrcweir sal_Bool bSetHeight = sal_False;
855cdf0e10cSrcweir sal_Bool bSetWidth = sal_False;
856cdf0e10cSrcweir sal_Bool bSetSizeType = sal_False;
857cdf0e10cSrcweir SwFrmSize eSizeType = ATT_VAR_SIZE;
858cdf0e10cSrcweir sal_Int32 nMin = MINLAY;
859cdf0e10cSrcweir
860cdf0e10cSrcweir switch( nMemberId )
861cdf0e10cSrcweir {
862cdf0e10cSrcweir case MID_FRMSIZE_REL_WIDTH:
863cdf0e10cSrcweir {
864cdf0e10cSrcweir sal_Int32 nValue;
865cdf0e10cSrcweir bOk = rUnitConverter.convertPercent( nValue, rValue );
866cdf0e10cSrcweir if( bOk )
867cdf0e10cSrcweir {
868cdf0e10cSrcweir if( nValue < 1 )
869cdf0e10cSrcweir nValue = 1;
870cdf0e10cSrcweir else if( nValue > 100 )
871cdf0e10cSrcweir nValue = 100;
872cdf0e10cSrcweir
873cdf0e10cSrcweir pFrmSize->SetWidthPercent( (sal_Int8)nValue );
874cdf0e10cSrcweir }
875cdf0e10cSrcweir }
876cdf0e10cSrcweir break;
877cdf0e10cSrcweir case MID_FRMSIZE_WIDTH:
878cdf0e10cSrcweir bSetWidth = sal_True;
879cdf0e10cSrcweir break;
880cdf0e10cSrcweir case MID_FRMSIZE_MIN_HEIGHT:
881cdf0e10cSrcweir eSizeType = ATT_MIN_SIZE;
882cdf0e10cSrcweir bSetHeight = sal_True;
883cdf0e10cSrcweir nMin = 1;
884cdf0e10cSrcweir bSetSizeType = sal_True;
885cdf0e10cSrcweir break;
886cdf0e10cSrcweir case MID_FRMSIZE_FIX_HEIGHT:
887cdf0e10cSrcweir eSizeType = ATT_FIX_SIZE;
888cdf0e10cSrcweir bSetHeight = sal_True;
889cdf0e10cSrcweir nMin = 1;
890cdf0e10cSrcweir bSetSizeType = sal_True;
891cdf0e10cSrcweir break;
892cdf0e10cSrcweir case MID_FRMSIZE_COL_WIDTH:
893cdf0e10cSrcweir eSizeType = ATT_FIX_SIZE;
894cdf0e10cSrcweir bSetWidth = sal_True;
895cdf0e10cSrcweir bSetSizeType = sal_True;
896cdf0e10cSrcweir break;
897cdf0e10cSrcweir case MID_FRMSIZE_REL_COL_WIDTH:
898cdf0e10cSrcweir {
899cdf0e10cSrcweir sal_Int32 nPos = rValue.indexOf( (sal_Unicode)'*' );
900cdf0e10cSrcweir if( -1L != nPos )
901cdf0e10cSrcweir {
902cdf0e10cSrcweir OUString sNum( rValue.copy( 0L, nPos ) );
903cdf0e10cSrcweir sal_Int32 nValue = rValue.toInt32();
904cdf0e10cSrcweir if( nValue < MINLAY )
905cdf0e10cSrcweir nValue = MINLAY;
906cdf0e10cSrcweir else if( nValue > USHRT_MAX )
907cdf0e10cSrcweir nValue = USHRT_MAX;
908cdf0e10cSrcweir
909cdf0e10cSrcweir pFrmSize->SetWidth( (sal_uInt16)nValue );
910cdf0e10cSrcweir pFrmSize->SetHeightSizeType( ATT_VAR_SIZE );
911cdf0e10cSrcweir bOk = sal_True;
912cdf0e10cSrcweir }
913cdf0e10cSrcweir }
914cdf0e10cSrcweir break;
915cdf0e10cSrcweir }
916cdf0e10cSrcweir
917cdf0e10cSrcweir sal_Int32 nValue;
918cdf0e10cSrcweir if( bSetHeight || bSetWidth )
919cdf0e10cSrcweir {
920cdf0e10cSrcweir bOk = rUnitConverter.convertMeasure( nValue, rValue, nMin,
921cdf0e10cSrcweir USHRT_MAX );
922cdf0e10cSrcweir if( bOk )
923cdf0e10cSrcweir {
924cdf0e10cSrcweir if( bSetWidth )
925cdf0e10cSrcweir pFrmSize->SetWidth( (sal_uInt16)nValue );
926cdf0e10cSrcweir if( bSetHeight )
927cdf0e10cSrcweir pFrmSize->SetHeight( (sal_uInt16)nValue );
928cdf0e10cSrcweir if( bSetSizeType )
929cdf0e10cSrcweir pFrmSize->SetHeightSizeType( eSizeType );
930cdf0e10cSrcweir }
931cdf0e10cSrcweir }
932cdf0e10cSrcweir }
933cdf0e10cSrcweir break;
934cdf0e10cSrcweir
935cdf0e10cSrcweir case RES_FRAMEDIR:
936cdf0e10cSrcweir {
937cdf0e10cSrcweir const XMLPropertyHandler* pWritingModeHandler =
938cdf0e10cSrcweir XMLPropertyHandlerFactory::CreatePropertyHandler(
939cdf0e10cSrcweir XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT );
940cdf0e10cSrcweir if( pWritingModeHandler != NULL )
941cdf0e10cSrcweir {
942cdf0e10cSrcweir Any aAny;
943cdf0e10cSrcweir bOk = pWritingModeHandler->importXML( rValue, aAny,
944cdf0e10cSrcweir rUnitConverter );
945cdf0e10cSrcweir if( bOk )
946cdf0e10cSrcweir bOk = rItem.PutValue( aAny );
947*8996694bSHerbert Dürr
948*8996694bSHerbert Dürr delete pWritingModeHandler;
949cdf0e10cSrcweir }
950cdf0e10cSrcweir }
951cdf0e10cSrcweir break;
952cdf0e10cSrcweir
953cdf0e10cSrcweir case RES_COLLAPSING_BORDERS:
954cdf0e10cSrcweir {
955cdf0e10cSrcweir SfxBoolItem* pBorders = PTR_CAST(SfxBoolItem, &rItem);
956cdf0e10cSrcweir DBG_ASSERT( pBorders != NULL, "Wrong Which-ID" );
957cdf0e10cSrcweir
958cdf0e10cSrcweir if( IsXMLToken( rValue, XML_COLLAPSING ) )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir pBorders->SetValue( sal_True );
961cdf0e10cSrcweir bOk = sal_True;
962cdf0e10cSrcweir }
963cdf0e10cSrcweir else if( IsXMLToken( rValue, XML_SEPARATING ) )
964cdf0e10cSrcweir {
965cdf0e10cSrcweir pBorders->SetValue( sal_False );
966cdf0e10cSrcweir bOk = sal_True;
967cdf0e10cSrcweir }
968cdf0e10cSrcweir else
969cdf0e10cSrcweir bOk = sal_False;
970cdf0e10cSrcweir }
971cdf0e10cSrcweir break;
972cdf0e10cSrcweir
973cdf0e10cSrcweir default:
974cdf0e10cSrcweir DBG_ERROR("Item not implemented!");
975cdf0e10cSrcweir break;
976cdf0e10cSrcweir }
977cdf0e10cSrcweir
978cdf0e10cSrcweir return bOk;
979cdf0e10cSrcweir }
980cdf0e10cSrcweir
981cdf0e10cSrcweir
982