Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "hintids.hxx"
22 : #include <swtypes.hxx>
23 : #include "unomid.h"
24 : #include <com/sun/star/style/LineSpacingMode.hpp>
25 : #include <com/sun/star/style/ParagraphAdjust.hpp>
26 : #include <com/sun/star/style/DropCapFormat.hpp>
27 : #include <com/sun/star/style/LineSpacing.hpp>
28 : #include <com/sun/star/text/RelOrientation.hpp>
29 : #include <com/sun/star/text/VertOrientation.hpp>
30 : #include <com/sun/star/text/HorizontalAdjust.hpp>
31 : #include <com/sun/star/text/DocumentStatistic.hpp>
32 : #include <com/sun/star/text/HoriOrientation.hpp>
33 : #include <com/sun/star/text/HoriOrientationFormat.hpp>
34 : #include <com/sun/star/text/NotePrintMode.hpp>
35 : #include <com/sun/star/text/SizeType.hpp>
36 : #include <com/sun/star/text/VertOrientationFormat.hpp>
37 : #include <com/sun/star/text/WrapTextMode.hpp>
38 : #include <unostyle.hxx>
39 : #include <SwStyleNameMapper.hxx>
40 : #include "paratr.hxx"
41 : #include "charfmt.hxx"
42 : #include "cmdid.h"
43 :
44 : using namespace ::com::sun::star;
45 :
46 346 : TYPEINIT2_AUTOFACTORY( SwFmtDrop, SfxPoolItem, SwClient);
47 757 : TYPEINIT1_AUTOFACTORY( SwRegisterItem, SfxBoolItem);
48 14496 : TYPEINIT1_AUTOFACTORY( SwNumRuleItem, SfxStringItem);
49 336 : TYPEINIT1_AUTOFACTORY( SwParaConnectBorderItem, SfxBoolItem);
50 :
51 : /*************************************************************************
52 : |* Beschreibung Methoden von SwFmtDrop
53 : *************************************************************************/
54 :
55 :
56 :
57 112 : SwFmtDrop::SwFmtDrop()
58 : : SfxPoolItem( RES_PARATR_DROP ),
59 : SwClient( 0 ),
60 : pDefinedIn( 0 ),
61 : nDistance( 0 ),
62 : nReadFmt( USHRT_MAX ),
63 : nLines( 0 ),
64 : nChars( 0 ),
65 112 : bWholeWord( sal_False )
66 : {
67 112 : }
68 :
69 :
70 :
71 2680 : SwFmtDrop::SwFmtDrop( const SwFmtDrop &rCpy )
72 : : SfxPoolItem( RES_PARATR_DROP ),
73 : SwClient( rCpy.GetRegisteredInNonConst() ),
74 : pDefinedIn( 0 ),
75 2680 : nDistance( rCpy.GetDistance() ),
76 : nReadFmt( rCpy.nReadFmt ),
77 2680 : nLines( rCpy.GetLines() ),
78 2680 : nChars( rCpy.GetChars() ),
79 10720 : bWholeWord( rCpy.GetWholeWord() )
80 : {
81 2680 : }
82 :
83 :
84 :
85 5482 : SwFmtDrop::~SwFmtDrop()
86 : {
87 5482 : }
88 :
89 :
90 :
91 0 : void SwFmtDrop::SetCharFmt( SwCharFmt *pNew )
92 : {
93 : //Ummelden
94 0 : if ( GetRegisteredIn() )
95 0 : GetRegisteredInNonConst()->Remove( this );
96 0 : if(pNew)
97 0 : pNew->Add( this );
98 0 : nReadFmt = USHRT_MAX;
99 0 : }
100 :
101 :
102 :
103 0 : void SwFmtDrop::Modify( const SfxPoolItem*, const SfxPoolItem * )
104 : {
105 0 : if( pDefinedIn )
106 : {
107 0 : if( !pDefinedIn->ISA( SwFmt ))
108 0 : pDefinedIn->ModifyNotification( this, this );
109 0 : else if( pDefinedIn->GetDepends() &&
110 0 : !pDefinedIn->IsModifyLocked() )
111 : {
112 : // selbst den Abhaengigen vom Format bescheid sagen. Das
113 : // Format selbst wuerde es nicht weitergeben, weil es ueber
114 : // die Abpruefung nicht hinauskommt.
115 0 : pDefinedIn->ModifyBroadcast( this, this );
116 : }
117 : }
118 0 : }
119 :
120 0 : bool SwFmtDrop::GetInfo( SfxPoolItem& ) const
121 : {
122 0 : return true; // weiter
123 : }
124 :
125 0 : int SwFmtDrop::operator==( const SfxPoolItem& rAttr ) const
126 : {
127 : OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
128 0 : return ( nLines == ((SwFmtDrop&)rAttr).GetLines() &&
129 0 : nChars == ((SwFmtDrop&)rAttr).GetChars() &&
130 0 : nDistance == ((SwFmtDrop&)rAttr).GetDistance() &&
131 0 : bWholeWord == ((SwFmtDrop&)rAttr).GetWholeWord() &&
132 0 : GetCharFmt() == ((SwFmtDrop&)rAttr).GetCharFmt() &&
133 0 : pDefinedIn == ((SwFmtDrop&)rAttr).pDefinedIn );
134 : }
135 :
136 2680 : SfxPoolItem* SwFmtDrop::Clone( SfxItemPool* ) const
137 : {
138 2680 : return new SwFmtDrop( *this );
139 : }
140 :
141 0 : bool SwFmtDrop::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
142 : {
143 0 : switch(nMemberId&~CONVERT_TWIPS)
144 : {
145 0 : case MID_DROPCAP_LINES : rVal <<= (sal_Int16)nLines; break;
146 0 : case MID_DROPCAP_COUNT : rVal <<= (sal_Int16)nChars; break;
147 0 : case MID_DROPCAP_DISTANCE : rVal <<= (sal_Int16) TWIP_TO_MM100_UNSIGNED(nDistance); break;
148 : case MID_DROPCAP_FORMAT:
149 : {
150 0 : style::DropCapFormat aDrop;
151 0 : aDrop.Lines = nLines ;
152 0 : aDrop.Count = nChars ;
153 0 : aDrop.Distance = TWIP_TO_MM100_UNSIGNED(nDistance);
154 0 : rVal.setValue(&aDrop, ::getCppuType((const style::DropCapFormat*)0));
155 : }
156 0 : break;
157 : case MID_DROPCAP_WHOLE_WORD:
158 0 : rVal.setValue(&bWholeWord, ::getBooleanCppuType());
159 0 : break;
160 : case MID_DROPCAP_CHAR_STYLE_NAME :
161 : {
162 0 : rtl::OUString sName;
163 0 : if(GetCharFmt())
164 : sName = SwStyleNameMapper::GetProgName(
165 0 : GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
166 0 : rVal <<= sName;
167 : }
168 0 : break;
169 : }
170 0 : return true;
171 : }
172 :
173 0 : bool SwFmtDrop::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
174 : {
175 0 : switch(nMemberId&~CONVERT_TWIPS)
176 : {
177 : case MID_DROPCAP_LINES :
178 : {
179 0 : sal_Int8 nTemp = 0;
180 0 : rVal >>= nTemp;
181 0 : if(nTemp >=1 && nTemp < 0x7f)
182 0 : nLines = (sal_uInt8)nTemp;
183 : }
184 0 : break;
185 : case MID_DROPCAP_COUNT :
186 : {
187 0 : sal_Int16 nTemp = 0;
188 0 : rVal >>= nTemp;
189 0 : if(nTemp >=1 && nTemp < 0x7f)
190 0 : nChars = (sal_uInt8)nTemp;
191 : }
192 0 : break;
193 : case MID_DROPCAP_DISTANCE :
194 : {
195 0 : sal_Int16 nVal = 0;
196 0 : if ( rVal >>= nVal )
197 0 : nDistance = (sal_Int16) MM100_TO_TWIP((sal_Int32)nVal);
198 : else
199 0 : return false;
200 : break;
201 : }
202 : case MID_DROPCAP_FORMAT:
203 : {
204 0 : if(rVal.getValueType() == ::getCppuType((const style::DropCapFormat*)0))
205 : {
206 0 : const style::DropCapFormat* pDrop = (const style::DropCapFormat*)rVal.getValue();
207 0 : nLines = pDrop->Lines;
208 0 : nChars = pDrop->Count;
209 0 : nDistance = MM100_TO_TWIP(pDrop->Distance);
210 : }
211 : else {
212 : }
213 : }
214 0 : break;
215 : case MID_DROPCAP_WHOLE_WORD:
216 0 : bWholeWord = *(sal_Bool*)rVal.getValue();
217 0 : break;
218 : case MID_DROPCAP_CHAR_STYLE_NAME :
219 : OSL_FAIL("char format cannot be set in PutValue()!");
220 0 : break;
221 : }
222 0 : return true;
223 : }
224 :
225 : // class SwRegisterItem -------------------------------------------------
226 :
227 :
228 1962 : SfxPoolItem* SwRegisterItem::Clone( SfxItemPool * ) const
229 : {
230 1962 : return new SwRegisterItem( *this );
231 : }
232 :
233 : // class SwNumRuleItem -------------------------------------------------
234 371 : SfxPoolItem* SwNumRuleItem::Clone( SfxItemPool * ) const
235 : {
236 371 : return new SwNumRuleItem( *this );
237 : }
238 3450 : int SwNumRuleItem::operator==( const SfxPoolItem& rAttr ) const
239 : {
240 : OSL_ENSURE( SfxPoolItem::operator==( rAttr ), "keine gleichen Attribute" );
241 :
242 3450 : return GetValue() == ((SwNumRuleItem&)rAttr).GetValue();
243 : }
244 :
245 21 : bool SwNumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
246 : {
247 21 : rtl::OUString sRet = SwStyleNameMapper::GetProgName(GetValue(), nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
248 21 : rVal <<= sRet;
249 21 : return true;
250 : }
251 :
252 20 : bool SwNumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 )
253 : {
254 20 : rtl::OUString uName;
255 20 : rVal >>= uName;
256 20 : SetValue(SwStyleNameMapper::GetUIName(uName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE));
257 20 : return true;
258 : }
259 :
260 0 : SfxPoolItem* SwParaConnectBorderItem::Clone( SfxItemPool * ) const
261 : {
262 0 : return new SwParaConnectBorderItem( *this );
263 : }
264 :
265 :
266 :
267 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|