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 $
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>
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>
55 #include "charfmt.hxx"
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
),
78 nReadFmt( USHRT_MAX
),
81 bWholeWord( sal_False
)
87 SwFmtDrop::SwFmtDrop( const SwFmtDrop
&rCpy
)
88 : SfxPoolItem( RES_PARATR_DROP
),
89 SwClient( rCpy
.pRegisteredIn
),
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
)
111 pRegisteredIn
->Remove( this );
114 nReadFmt
= USHRT_MAX
;
119 void SwFmtDrop::Modify( SfxPoolItem
*, SfxPoolItem
* )
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 ??
135 pLast
->Modify( this, this );
136 if( !pDefinedIn
->GetDepends() ) // Baum schon Weg ??
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));
180 case MID_DROPCAP_WHOLE_WORD
:
181 rVal
.setValue(&bWholeWord
, ::getBooleanCppuType());
183 case MID_DROPCAP_CHAR_STYLE_NAME
:
187 sName
= SwStyleNameMapper::GetProgName(
188 GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT
);
196 sal_Bool
SwFmtDrop::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
198 switch(nMemberId
&~CONVERT_TWIPS
)
200 case MID_DROPCAP_LINES
:
204 if(nTemp
>=1 && nTemp
< 0x7f)
205 nLines
= (BYTE
)nTemp
;
208 case MID_DROPCAP_COUNT
:
212 if(nTemp
>=1 && nTemp
< 0x7f)
213 nChars
= (BYTE
)nTemp
;
216 case MID_DROPCAP_DISTANCE
:
220 nDistance
= (sal_Int16
) MM100_TO_TWIP((sal_Int32
)nVal
);
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
);
235 //exception( wrong_type)
240 case MID_DROPCAP_WHOLE_WORD
:
241 bWholeWord
= *(sal_Bool
*)rVal
.getValue();
243 case MID_DROPCAP_CHAR_STYLE_NAME
:
244 DBG_ERROR("char format cannot be set in PutValue()!");
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();
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
);
279 /* -----------------------------27.06.00 11:05--------------------------------
281 ---------------------------------------------------------------------------*/
282 BOOL
SwNumRuleItem::PutValue( const uno::Any
& rVal
, BYTE
)
286 SetValue(SwStyleNameMapper::GetUIName(uName
, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE
));
289 /* -----------------19.05.2003 10:44-----------------
291 --------------------------------------------------*/
292 SfxPoolItem
* SwParaConnectBorderItem::Clone( SfxItemPool
* ) const
294 return new SwParaConnectBorderItem( *this );