Update ooo320-m1
[ooovba.git] / sw / source / core / para / paratr.cxx
blobfd03467c01b4fdbab578e89bfc0bfda63a5b424f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: paratr.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
34 #include "hintids.hxx"
35 #include <swtypes.hxx>
36 #include "unomid.h"
37 #include <com/sun/star/style/LineSpacingMode.hpp>
38 #include <com/sun/star/style/ParagraphAdjust.hpp>
39 #include <com/sun/star/style/DropCapFormat.hpp>
40 #include <com/sun/star/style/LineSpacing.hpp>
41 #include <com/sun/star/text/RelOrientation.hpp>
42 #include <com/sun/star/text/VertOrientation.hpp>
43 #include <com/sun/star/text/HorizontalAdjust.hpp>
44 #include <com/sun/star/text/DocumentStatistic.hpp>
45 #include <com/sun/star/text/HoriOrientation.hpp>
46 #include <com/sun/star/text/HoriOrientationFormat.hpp>
47 #include <com/sun/star/text/NotePrintMode.hpp>
48 #include <com/sun/star/text/SizeType.hpp>
49 #include <com/sun/star/text/VertOrientationFormat.hpp>
50 #include <com/sun/star/text/WrapTextMode.hpp>
51 #include <unostyle.hxx>
52 #include <SwStyleNameMapper.hxx>
53 #include "errhdl.hxx"
54 #include "paratr.hxx"
55 #include "charfmt.hxx"
56 #include "cmdid.h"
58 using namespace ::com::sun::star;
60 TYPEINIT2_AUTOFACTORY( SwFmtDrop, SfxPoolItem, SwClient);
61 TYPEINIT1_AUTOFACTORY( SwRegisterItem, SfxBoolItem);
62 TYPEINIT1_AUTOFACTORY( SwNumRuleItem, SfxStringItem);
63 TYPEINIT1_AUTOFACTORY( SwParaConnectBorderItem, SfxBoolItem);
65 /*************************************************************************
66 |* Beschreibung Methoden von SwFmtDrop
67 |* Ersterstellung MS 19.02.91
68 |* Letzte Aenderung JP 08.08.94
69 *************************************************************************/
73 SwFmtDrop::SwFmtDrop()
74 : SfxPoolItem( RES_PARATR_DROP ),
75 SwClient( 0 ),
76 pDefinedIn( 0 ),
77 nDistance( 0 ),
78 nReadFmt( USHRT_MAX ),
79 nLines( 0 ),
80 nChars( 0 ),
81 bWholeWord( sal_False )
87 SwFmtDrop::SwFmtDrop( const SwFmtDrop &rCpy )
88 : SfxPoolItem( RES_PARATR_DROP ),
89 SwClient( rCpy.pRegisteredIn ),
90 pDefinedIn( 0 ),
91 nDistance( rCpy.GetDistance() ),
92 nReadFmt( rCpy.nReadFmt ),
93 nLines( rCpy.GetLines() ),
94 nChars( rCpy.GetChars() ),
95 bWholeWord( rCpy.GetWholeWord() )
101 SwFmtDrop::~SwFmtDrop()
107 void SwFmtDrop::SetCharFmt( SwCharFmt *pNew )
109 //Ummelden
110 if ( pRegisteredIn )
111 pRegisteredIn->Remove( this );
112 if(pNew)
113 pNew->Add( this );
114 nReadFmt = USHRT_MAX;
119 void SwFmtDrop::Modify( SfxPoolItem *, SfxPoolItem * )
121 if( pDefinedIn )
123 if( !pDefinedIn->ISA( SwFmt ))
124 pDefinedIn->Modify( this, this );
125 else if( pDefinedIn->GetDepends() &&
126 !pDefinedIn->IsModifyLocked() )
128 // selbst den Abhaengigen vom Format bescheid sagen. Das
129 // Format selbst wuerde es nicht weitergeben, weil es ueber
130 // die Abpruefung nicht hinauskommt.
131 SwClientIter aIter( *pDefinedIn );
132 SwClient * pLast = aIter.GoStart();
133 if( pLast ) // konnte zum Anfang gesprungen werden ??
134 do {
135 pLast->Modify( this, this );
136 if( !pDefinedIn->GetDepends() ) // Baum schon Weg ??
137 break;
138 } while( 0 != ( pLast = aIter++ ));
143 sal_Bool SwFmtDrop::GetInfo( SfxPoolItem& ) const
145 return sal_True; // weiter
148 int SwFmtDrop::operator==( const SfxPoolItem& rAttr ) const
150 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
151 return ( nLines == ((SwFmtDrop&)rAttr).GetLines() &&
152 nChars == ((SwFmtDrop&)rAttr).GetChars() &&
153 nDistance == ((SwFmtDrop&)rAttr).GetDistance() &&
154 bWholeWord == ((SwFmtDrop&)rAttr).GetWholeWord() &&
155 GetCharFmt() == ((SwFmtDrop&)rAttr).GetCharFmt() &&
156 pDefinedIn == ((SwFmtDrop&)rAttr).pDefinedIn );
159 SfxPoolItem* SwFmtDrop::Clone( SfxItemPool* ) const
161 return new SwFmtDrop( *this );
164 sal_Bool SwFmtDrop::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
166 switch(nMemberId&~CONVERT_TWIPS)
168 case MID_DROPCAP_LINES : rVal <<= (sal_Int16)nLines; break;
169 case MID_DROPCAP_COUNT : rVal <<= (sal_Int16)nChars; break;
170 case MID_DROPCAP_DISTANCE : rVal <<= (sal_Int16) TWIP_TO_MM100_UNSIGNED(nDistance); break;
171 case MID_DROPCAP_FORMAT:
173 style::DropCapFormat aDrop;
174 aDrop.Lines = nLines ;
175 aDrop.Count = nChars ;
176 aDrop.Distance = TWIP_TO_MM100_UNSIGNED(nDistance);
177 rVal.setValue(&aDrop, ::getCppuType((const style::DropCapFormat*)0));
179 break;
180 case MID_DROPCAP_WHOLE_WORD:
181 rVal.setValue(&bWholeWord, ::getBooleanCppuType());
182 break;
183 case MID_DROPCAP_CHAR_STYLE_NAME :
185 rtl::OUString sName;
186 if(GetCharFmt())
187 sName = SwStyleNameMapper::GetProgName(
188 GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
189 rVal <<= sName;
191 break;
193 return sal_True;
196 sal_Bool SwFmtDrop::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
198 switch(nMemberId&~CONVERT_TWIPS)
200 case MID_DROPCAP_LINES :
202 sal_Int8 nTemp = 0;
203 rVal >>= nTemp;
204 if(nTemp >=1 && nTemp < 0x7f)
205 nLines = (BYTE)nTemp;
207 break;
208 case MID_DROPCAP_COUNT :
210 sal_Int16 nTemp = 0;
211 rVal >>= nTemp;
212 if(nTemp >=1 && nTemp < 0x7f)
213 nChars = (BYTE)nTemp;
215 break;
216 case MID_DROPCAP_DISTANCE :
218 sal_Int16 nVal = 0;
219 if ( rVal >>= nVal )
220 nDistance = (sal_Int16) MM100_TO_TWIP((sal_Int32)nVal);
221 else
222 return sal_False;
223 break;
225 case MID_DROPCAP_FORMAT:
227 if(rVal.getValueType() == ::getCppuType((const style::DropCapFormat*)0))
229 const style::DropCapFormat* pDrop = (const style::DropCapFormat*)rVal.getValue();
230 nLines = pDrop->Lines;
231 nChars = pDrop->Count;
232 nDistance = MM100_TO_TWIP(pDrop->Distance);
234 else {
235 //exception( wrong_type)
239 break;
240 case MID_DROPCAP_WHOLE_WORD:
241 bWholeWord = *(sal_Bool*)rVal.getValue();
242 break;
243 case MID_DROPCAP_CHAR_STYLE_NAME :
244 DBG_ERROR("char format cannot be set in PutValue()!");
245 break;
247 return sal_True;
250 // class SwRegisterItem -------------------------------------------------
253 SfxPoolItem* SwRegisterItem::Clone( SfxItemPool * ) const
255 return new SwRegisterItem( *this );
258 // class SwNumRuleItem -------------------------------------------------
259 SfxPoolItem* SwNumRuleItem::Clone( SfxItemPool * ) const
261 return new SwNumRuleItem( *this );
263 int SwNumRuleItem::operator==( const SfxPoolItem& rAttr ) const
265 ASSERT( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
266 // --> OD 2008-03-04 #refactorlists# - removed <pDefinedIn>
267 return GetValue() == ((SwNumRuleItem&)rAttr).GetValue();
268 // <--
270 /* -----------------------------27.06.00 11:05--------------------------------
272 ---------------------------------------------------------------------------*/
273 BOOL SwNumRuleItem::QueryValue( uno::Any& rVal, BYTE ) const
275 rtl::OUString sRet = SwStyleNameMapper::GetProgName(GetValue(), nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
276 rVal <<= sRet;
277 return TRUE;
279 /* -----------------------------27.06.00 11:05--------------------------------
281 ---------------------------------------------------------------------------*/
282 BOOL SwNumRuleItem::PutValue( const uno::Any& rVal, BYTE )
284 rtl::OUString uName;
285 rVal >>= uName;
286 SetValue(SwStyleNameMapper::GetUIName(uName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE));
287 return TRUE;
289 /* -----------------19.05.2003 10:44-----------------
291 --------------------------------------------------*/
292 SfxPoolItem* SwParaConnectBorderItem::Clone( SfxItemPool * ) const
294 return new SwParaConnectBorderItem( *this );