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 : #include "hintids.hxx"
21 : #include <swtypes.hxx>
22 : #include "unomid.h"
23 : #include <com/sun/star/style/LineSpacingMode.hpp>
24 : #include <com/sun/star/style/ParagraphAdjust.hpp>
25 : #include <com/sun/star/style/DropCapFormat.hpp>
26 : #include <com/sun/star/style/LineSpacing.hpp>
27 : #include <com/sun/star/text/RelOrientation.hpp>
28 : #include <com/sun/star/text/VertOrientation.hpp>
29 : #include <com/sun/star/text/HorizontalAdjust.hpp>
30 : #include <com/sun/star/text/DocumentStatistic.hpp>
31 : #include <com/sun/star/text/HoriOrientation.hpp>
32 : #include <com/sun/star/text/HoriOrientationFormat.hpp>
33 : #include <com/sun/star/text/NotePrintMode.hpp>
34 : #include <com/sun/star/text/SizeType.hpp>
35 : #include <com/sun/star/text/VertOrientationFormat.hpp>
36 : #include <com/sun/star/text/WrapTextMode.hpp>
37 : #include <unostyle.hxx>
38 : #include <SwStyleNameMapper.hxx>
39 : #include "paratr.hxx"
40 : #include "charfmt.hxx"
41 : #include "cmdid.h"
42 :
43 : using namespace ::com::sun::star;
44 :
45 15711 : TYPEINIT2_AUTOFACTORY( SwFmtDrop, SfxPoolItem, SwClient);
46 26013 : TYPEINIT1_AUTOFACTORY( SwRegisterItem, SfxBoolItem);
47 229469 : TYPEINIT1_AUTOFACTORY( SwNumRuleItem, SfxStringItem);
48 15405 : TYPEINIT1_AUTOFACTORY( SwParaConnectBorderItem, SfxBoolItem);
49 :
50 5135 : SwFmtDrop::SwFmtDrop()
51 : : SfxPoolItem( RES_PARATR_DROP ),
52 : SwClient( 0 ),
53 : pDefinedIn( 0 ),
54 : nDistance( 0 ),
55 : nReadFmt( USHRT_MAX ),
56 : nLines( 0 ),
57 : nChars( 0 ),
58 5135 : bWholeWord( false )
59 : {
60 5135 : }
61 :
62 150090 : SwFmtDrop::SwFmtDrop( const SwFmtDrop &rCpy )
63 : : SfxPoolItem( RES_PARATR_DROP ),
64 : SwClient( rCpy.GetRegisteredInNonConst() ),
65 : pDefinedIn( 0 ),
66 150090 : nDistance( rCpy.GetDistance() ),
67 : nReadFmt( rCpy.nReadFmt ),
68 150090 : nLines( rCpy.GetLines() ),
69 150090 : nChars( rCpy.GetChars() ),
70 600360 : bWholeWord( rCpy.GetWholeWord() )
71 : {
72 150090 : }
73 :
74 305405 : SwFmtDrop::~SwFmtDrop()
75 : {
76 305405 : }
77 :
78 12 : void SwFmtDrop::SetCharFmt( SwCharFmt *pNew )
79 : {
80 : // Rewire
81 12 : if ( GetRegisteredIn() )
82 0 : GetRegisteredInNonConst()->Remove( this );
83 12 : if(pNew)
84 12 : pNew->Add( this );
85 12 : nReadFmt = USHRT_MAX;
86 12 : }
87 :
88 24 : void SwFmtDrop::Modify( const SfxPoolItem*, const SfxPoolItem * )
89 : {
90 24 : if( pDefinedIn )
91 : {
92 12 : if( !pDefinedIn->ISA( SwFmt ))
93 12 : pDefinedIn->ModifyNotification( this, this );
94 0 : else if( pDefinedIn->GetDepends() &&
95 0 : !pDefinedIn->IsModifyLocked() )
96 : {
97 : // Notify those who are dependent on the format on our own.
98 : // The format itself wouldn't pass on the notify as it does not get past the check.
99 0 : pDefinedIn->ModifyBroadcast( this, this );
100 : }
101 : }
102 24 : }
103 :
104 8 : bool SwFmtDrop::GetInfo( SfxPoolItem& ) const
105 : {
106 8 : return true; // Continue
107 : }
108 :
109 76 : bool SwFmtDrop::operator==( const SfxPoolItem& rAttr ) const
110 : {
111 : assert(SfxPoolItem::operator==(rAttr));
112 152 : return ( nLines == ((SwFmtDrop&)rAttr).GetLines() &&
113 152 : nChars == ((SwFmtDrop&)rAttr).GetChars() &&
114 152 : nDistance == ((SwFmtDrop&)rAttr).GetDistance() &&
115 152 : bWholeWord == ((SwFmtDrop&)rAttr).GetWholeWord() &&
116 198 : GetCharFmt() == ((SwFmtDrop&)rAttr).GetCharFmt() &&
117 122 : pDefinedIn == ((SwFmtDrop&)rAttr).pDefinedIn );
118 : }
119 :
120 150078 : SfxPoolItem* SwFmtDrop::Clone( SfxItemPool* ) const
121 : {
122 150078 : return new SwFmtDrop( *this );
123 : }
124 :
125 74 : bool SwFmtDrop::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
126 : {
127 74 : switch(nMemberId&~CONVERT_TWIPS)
128 : {
129 0 : case MID_DROPCAP_LINES : rVal <<= (sal_Int16)nLines; break;
130 0 : case MID_DROPCAP_COUNT : rVal <<= (sal_Int16)nChars; break;
131 0 : case MID_DROPCAP_DISTANCE : rVal <<= (sal_Int16) convertTwipToMm100(nDistance); break;
132 : case MID_DROPCAP_FORMAT:
133 : {
134 22 : style::DropCapFormat aDrop;
135 22 : aDrop.Lines = nLines ;
136 22 : aDrop.Count = nChars ;
137 22 : aDrop.Distance = convertTwipToMm100(nDistance);
138 22 : rVal.setValue(&aDrop, ::cppu::UnoType<style::DropCapFormat>::get());
139 : }
140 22 : break;
141 : case MID_DROPCAP_WHOLE_WORD:
142 22 : rVal.setValue(&bWholeWord, ::getBooleanCppuType());
143 22 : break;
144 : case MID_DROPCAP_CHAR_STYLE_NAME :
145 : {
146 30 : OUString sName;
147 30 : if(GetCharFmt())
148 : sName = SwStyleNameMapper::GetProgName(
149 16 : GetCharFmt()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_CHRFMT );
150 30 : rVal <<= sName;
151 : }
152 30 : break;
153 : }
154 74 : return true;
155 : }
156 :
157 28 : bool SwFmtDrop::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
158 : {
159 28 : switch(nMemberId&~CONVERT_TWIPS)
160 : {
161 : case MID_DROPCAP_LINES :
162 : {
163 0 : sal_Int8 nTemp = 0;
164 0 : rVal >>= nTemp;
165 0 : if(nTemp >=1 && nTemp < 0x7f)
166 0 : nLines = (sal_uInt8)nTemp;
167 : }
168 0 : break;
169 : case MID_DROPCAP_COUNT :
170 : {
171 0 : sal_Int16 nTemp = 0;
172 0 : rVal >>= nTemp;
173 0 : if(nTemp >=1 && nTemp < 0x7f)
174 0 : nChars = (sal_uInt8)nTemp;
175 : }
176 0 : break;
177 : case MID_DROPCAP_DISTANCE :
178 : {
179 0 : sal_Int16 nVal = 0;
180 0 : if ( rVal >>= nVal )
181 0 : nDistance = (sal_Int16) convertMm100ToTwip((sal_Int32)nVal);
182 : else
183 0 : return false;
184 0 : break;
185 : }
186 : case MID_DROPCAP_FORMAT:
187 : {
188 14 : if(rVal.getValueType() == ::cppu::UnoType<style::DropCapFormat>::get())
189 : {
190 14 : const style::DropCapFormat* pDrop = (const style::DropCapFormat*)rVal.getValue();
191 14 : nLines = pDrop->Lines;
192 14 : nChars = pDrop->Count;
193 14 : nDistance = convertMm100ToTwip(pDrop->Distance);
194 : }
195 : else {
196 : }
197 : }
198 14 : break;
199 : case MID_DROPCAP_WHOLE_WORD:
200 14 : bWholeWord = *(sal_Bool*)rVal.getValue();
201 14 : break;
202 : case MID_DROPCAP_CHAR_STYLE_NAME :
203 : OSL_FAIL("char format cannot be set in PutValue()!");
204 0 : break;
205 : }
206 28 : return true;
207 : }
208 :
209 55944 : SfxPoolItem* SwRegisterItem::Clone( SfxItemPool * ) const
210 : {
211 55944 : return new SwRegisterItem( *this );
212 : }
213 :
214 3634 : SfxPoolItem* SwNumRuleItem::Clone( SfxItemPool * ) const
215 : {
216 3634 : return new SwNumRuleItem( *this );
217 : }
218 35498 : bool SwNumRuleItem::operator==( const SfxPoolItem& rAttr ) const
219 : {
220 : assert(SfxPoolItem::operator==(rAttr));
221 :
222 35498 : return GetValue() == ((SwNumRuleItem&)rAttr).GetValue();
223 : }
224 :
225 502 : bool SwNumRuleItem::QueryValue( uno::Any& rVal, sal_uInt8 ) const
226 : {
227 502 : OUString sRet = SwStyleNameMapper::GetProgName(GetValue(), nsSwGetPoolIdFromName::GET_POOLID_NUMRULE );
228 502 : rVal <<= sRet;
229 502 : return true;
230 : }
231 :
232 642 : bool SwNumRuleItem::PutValue( const uno::Any& rVal, sal_uInt8 )
233 : {
234 642 : OUString uName;
235 642 : rVal >>= uName;
236 642 : SetValue(SwStyleNameMapper::GetUIName(uName, nsSwGetPoolIdFromName::GET_POOLID_NUMRULE));
237 642 : return true;
238 : }
239 :
240 8 : SfxPoolItem* SwParaConnectBorderItem::Clone( SfxItemPool * ) const
241 : {
242 8 : return new SwParaConnectBorderItem( *this );
243 270 : }
244 :
245 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|