Better, Faster, Freer

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: i386 ]
Version: HEAD ]

001 /*************************************************************************
002  *
003  *  OpenOffice.org - a multi-platform office productivity suite
004  *
005  *  $RCSfile: SwXPrintPreviewSettings.cxx,v $
006  *
007  *  $Revision: 1.8 $
008  *
009  *  last change: $Author: hr $ $Date: 2007/09/27 12:40:36 $
010  *
011  *  The Contents of this file are made available subject to
012  *  the terms of GNU Lesser General Public License Version 2.1.
013  *
014  *
015  *    GNU Lesser General Public License Version 2.1
016  *    =============================================
017  *    Copyright 2005 by Sun Microsystems, Inc.
018  *    901 San Antonio Road, Palo Alto, CA 94303, USA
019  *
020  *    This library is free software; you can redistribute it and/or
021  *    modify it under the terms of the GNU Lesser General Public
022  *    License version 2.1, as published by the Free Software Foundation.
023  *
024  *    This library is distributed in the hope that it will be useful,
025  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
026  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
027  *    Lesser General Public License for more details.
028  *
029  *    You should have received a copy of the GNU Lesser General Public
030  *    License along with this library; if not, write to the Free Software
031  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
032  *    MA  02111-1307  USA
033  *
034  ************************************************************************/
035 
036 // MARKER(update_precomp.py): autogen include statement, do not remove
037 #include "precompiled_sw.hxx"
038 #ifndef _SW_XPRINTPREVIEWSETTINGS_HXX_
039 #include <SwXPrintPreviewSettings.hxx>
040 #endif
041 #ifndef _COMPHELPER_CHAINABLEPROPERTYSETINFO_HXX_
042 #include <comphelper/ChainablePropertySetInfo.hxx>
043 #endif
044 #ifndef _PVPRTDAT_HXX
045 #include <pvprtdat.hxx>
046 #endif
047 #ifndef _SWTYPES_HXX
048 #include <swtypes.hxx>
049 #endif
050 #ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_
051 #include <com/sun/star/beans/PropertyAttribute.hpp>
052 #endif
053 #ifndef _COM_SUN_STAR_BEANS_PropertyAttribute_HPP_
054 #include <com/sun/star/beans/PropertyAttribute.hpp>
055 #endif
056 #ifndef _DOC_HXX
057 #include <doc.hxx>
058 #endif
059 #ifndef _SV_SVAPP_HXX
060 #include <vcl/svapp.hxx>
061 #endif
062 using namespace ::com::sun::star;
063 using namespace ::com::sun::star::uno;
064 using namespace ::com::sun::star::beans;
065 using namespace ::com::sun::star::lang;
066 using namespace ::comphelper;
067 using namespace ::rtl;
068 
069 enum SwPrintSettingsPropertyHandles
070 {
071         HANDLE_PRINTSET_PREVIEW_LEFT_MARGIN,
072         HANDLE_PRINTSET_PREVIEW_RIGHT_MARGIN,
073         HANDLE_PRINTSET_PREVIEW_TOP_MARGIN,
074         HANDLE_PRINTSET_PREVIEW_BOTTOM_MARGIN,
075         HANDLE_PRINTSET_PREVIEW_HORIZONTAL_SPACING,
076         HANDLE_PRINTSET_PREVIEW_VERTICAL_SPACING,
077         HANDLE_PRINTSET_PREVIEW_NUM_ROWS,
078         HANDLE_PRINTSET_PREVIEW_NUM_COLUMNS,
079         HANDLE_PRINTSET_PREVIEW_LANDSCAPE
080 };
081 
082 static ChainablePropertySetInfo * lcl_createPrintPreviewSettingsInfo()
083 {
084         static PropertyInfo aPrintPreviewSettingsMap_Impl[] =
085         {
086                 { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintLeftMargin" ),      HANDLE_PRINTSET_PREVIEW_LEFT_MARGIN,    CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
087                 { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintRightMargin" ),     HANDLE_PRINTSET_PREVIEW_RIGHT_MARGIN,   CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
088                 { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintTopMargin" ),       HANDLE_PRINTSET_PREVIEW_TOP_MARGIN,             CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
089                 { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintBottomMargin" ),HANDLE_PRINTSET_PREVIEW_BOTTOM_MARGIN,      CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
090                 { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintHorizontalSpacing" ),HANDLE_PRINTSET_PREVIEW_HORIZONTAL_SPACING,    CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
091                 { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintVerticalSpacing" ), HANDLE_PRINTSET_PREVIEW_VERTICAL_SPACING,       CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
092                 { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintNumRows" ), HANDLE_PRINTSET_PREVIEW_NUM_ROWS,                       CPPUTYPE_INT8, PropertyAttribute::MAYBEVOID, 0 },
093                 { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintNumColumns" ),      HANDLE_PRINTSET_PREVIEW_NUM_COLUMNS,    CPPUTYPE_INT8, PropertyAttribute::MAYBEVOID, 0 },
094                 { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintLandscape" ),       HANDLE_PRINTSET_PREVIEW_LANDSCAPE,              CPPUTYPE_BOOLEAN, PropertyAttribute::MAYBEVOID, 0 },
095                 { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
096         };
097         return new ChainablePropertySetInfo ( aPrintPreviewSettingsMap_Impl );
098 }
099 SwXPrintPreviewSettings::SwXPrintPreviewSettings( SwDoc *pDoc)
100 : ChainablePropertySet ( lcl_createPrintPreviewSettingsInfo (), &Application::GetSolarMutex() )
101 , mbPreviewDataChanged( sal_False )
102 , mpDoc( pDoc)
103 {
104 }
105 /*-- 17.12.98 12:54:05---------------------------------------------------
106 
107   -----------------------------------------------------------------------*/
108 SwXPrintPreviewSettings::~SwXPrintPreviewSettings()
109         throw()
110 {
111 }
112 
113 Any SAL_CALL SwXPrintPreviewSettings::queryInterface( const Type& rType )
114         throw(RuntimeException)
115 {
116                 return ::cppu::queryInterface ( rType                                                                           ,
117                                                                                 // OWeakObject interfaces
118                                         dynamic_cast< XInterface* >( dynamic_cast< OWeakObject* >(this) )  ,
119                                         dynamic_cast< XWeak* >( this )   ,
120                                                                                 // my own interfaces
121                                         dynamic_cast< XServiceInfo* >( this )   ,
122                                         dynamic_cast< XPropertySet* >( this )   ,
123                                         dynamic_cast< XMultiPropertySet* >( this ) );
124 }
125 void SwXPrintPreviewSettings::acquire ()
126         throw ()
127 {
128         OWeakObject::acquire();
129 }
130 void SwXPrintPreviewSettings::release ()
131         throw ()
132 {
133         OWeakObject::release();
134 }
135 
136 void SwXPrintPreviewSettings::_preSetValues ()
137         throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
138 {
139         if ( mpDoc )
140         {
141                 const SwPagePreViewPrtData *pConstPrtData = mpDoc->GetPreViewPrtData();
142                 mpPreViewData = new SwPagePreViewPrtData;
143                 if ( pConstPrtData )
144                 {
145                         mpPreViewData->SetLeftSpace     ( pConstPrtData->GetLeftSpace() );
146                         mpPreViewData->SetRightSpace    ( pConstPrtData->GetRightSpace() );
147                         mpPreViewData->SetTopSpace              ( pConstPrtData->GetTopSpace() );
148                         mpPreViewData->SetBottomSpace   ( pConstPrtData->GetBottomSpace() );
149                         mpPreViewData->SetHorzSpace     ( pConstPrtData->GetHorzSpace() );
150                         mpPreViewData->SetVertSpace     ( pConstPrtData->GetVertSpace() );
151                         mpPreViewData->SetRow                   ( pConstPrtData->GetRow() );
152                         mpPreViewData->SetCol                   ( pConstPrtData->GetCol() );
153                         mpPreViewData->SetLandscape     ( pConstPrtData->GetLandscape() );
154                 }
155         }
156 }
157 
158 void SwXPrintPreviewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
159         throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
160 {
161         switch( rInfo.mnHandle )
162         {
163                 case HANDLE_PRINTSET_PREVIEW_LEFT_MARGIN:
164                 {
165                         sal_Int32 nVal;
166                         rValue >>= nVal;
167                         nVal = MM100_TO_TWIP( nVal );
168                         if ( nVal != static_cast < sal_Int32 > (mpPreViewData->GetLeftSpace() ) )
169                         {
170                                 mbPreviewDataChanged = sal_True;
171                                 mpPreViewData->SetLeftSpace( nVal );
172                         }
173                 }
174                 break;
175                 case HANDLE_PRINTSET_PREVIEW_RIGHT_MARGIN:
176                 {
177                         sal_Int32 nVal;
178                         rValue >>= nVal;
179                         nVal = MM100_TO_TWIP( nVal );
180                         if ( nVal != static_cast < sal_Int32 > (mpPreViewData->GetRightSpace() ) )
181                         {
182                                 mbPreviewDataChanged = sal_True;
183                                 mpPreViewData->SetRightSpace( nVal );
184                         }
185                 }
186                 break;
187                 case HANDLE_PRINTSET_PREVIEW_TOP_MARGIN:
188                 {
189                         sal_Int32 nVal;
190                         rValue >>= nVal;
191                         nVal = MM100_TO_TWIP( nVal );
192                         if ( nVal != static_cast < sal_Int32 > ( mpPreViewData->GetTopSpace() ) )
193                         {
194                                 mbPreviewDataChanged = sal_True;
195                                 mpPreViewData->SetTopSpace( nVal );
196                         }
197                 }
198                 break;
199                 case HANDLE_PRINTSET_PREVIEW_BOTTOM_MARGIN:
200                 {
201                         sal_Int32 nVal;
202                         rValue >>= nVal;
203                         nVal = MM100_TO_TWIP( nVal );
204                         if ( nVal != static_cast < sal_Int32 > ( mpPreViewData->GetBottomSpace() ) )
205                         {
206                                 mbPreviewDataChanged = sal_True;
207                                 mpPreViewData->SetBottomSpace( nVal );
208                         }
209                 }
210                 break;
211                 case HANDLE_PRINTSET_PREVIEW_HORIZONTAL_SPACING:
212                 {
213                         sal_Int32 nVal;
214                         rValue >>= nVal;
215                         nVal = MM100_TO_TWIP( nVal );
216                         if ( nVal != static_cast < sal_Int32 > ( mpPreViewData->GetHorzSpace() ) )
217                         {
218                                 mbPreviewDataChanged = sal_True;
219                                 mpPreViewData->SetHorzSpace( nVal );
220                         }
221                 }
222                 break;
223                 case HANDLE_PRINTSET_PREVIEW_VERTICAL_SPACING:
224                 {
225                         sal_Int32 nVal;
226                         rValue >>= nVal;
227                         nVal = MM100_TO_TWIP( nVal );
228                         if ( nVal != static_cast < sal_Int32 > ( mpPreViewData->GetVertSpace() ) )
229                         {
230                                 mbPreviewDataChanged = sal_True;
231                                 mpPreViewData->SetVertSpace( nVal );
232                         }
233                 }
234                 break;
235                 case HANDLE_PRINTSET_PREVIEW_NUM_ROWS:
236                 {
237                         sal_Int8 nVal;
238                         rValue >>= nVal;
239                         if ( nVal != mpPreViewData->GetRow() )
240                         {
241                                 mbPreviewDataChanged = sal_True;
242                                 mpPreViewData->SetRow( nVal );
243                         }
244                 }
245                 break;
246                 case HANDLE_PRINTSET_PREVIEW_NUM_COLUMNS:
247                 {
248                         sal_Int8 nVal;
249                         rValue >>= nVal;
250                         if ( nVal != mpPreViewData->GetCol() )
251                         {
252                                 mbPreviewDataChanged = sal_True;
253                                 mpPreViewData->SetCol( nVal );
254                         }
255                 }
256                 break;
257                 case HANDLE_PRINTSET_PREVIEW_LANDSCAPE:
258                 {
259                         sal_Bool bVal = *(sal_Bool*)rValue.getValue();
260                         if ( bVal != mpPreViewData->GetLandscape() )
261                         {
262                                 mbPreviewDataChanged = sal_True;
263                                 mpPreViewData->SetLandscape ( bVal );
264                         }
265                 }
266                 break;
267                 default:
268                         throw UnknownPropertyException();
269         }
270 }
271 void SwXPrintPreviewSettings::_postSetValues ()
272         throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
273 {
274         if ( mbPreviewDataChanged )
275         {
276                 mpDoc->SetPreViewPrtData ( mpPreViewData );
277                 mbPreviewDataChanged = sal_False;
278         }
279         delete mpPreViewData;
280         mpPreViewData = NULL;
281 }
282 
283 void SwXPrintPreviewSettings::_preGetValues ()
284         throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
285 {
286         if (mpDoc)
287                 mpConstPreViewData = mpDoc->GetPreViewPrtData();
288 }
289 void SwXPrintPreviewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
290         throw(UnknownPropertyException, WrappedTargetException )
291 {
292         sal_Bool bBool = TRUE;
293         sal_Bool bBoolVal;
294         switch( rInfo.mnHandle )
295         {
296                 case HANDLE_PRINTSET_PREVIEW_LEFT_MARGIN:
297                 {
298                         bBool = FALSE;
299                         if ( mpConstPreViewData )
300                                 rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetLeftSpace() ) );
301                 }
302                 break;
303                 case HANDLE_PRINTSET_PREVIEW_RIGHT_MARGIN:
304                 {
305                         bBool = FALSE;
306                         if ( mpConstPreViewData )
307                                 rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetRightSpace() ) );
308                 }
309                 break;
310                 case HANDLE_PRINTSET_PREVIEW_TOP_MARGIN:
311                 {
312                         bBool = FALSE;
313                         if ( mpConstPreViewData )
314                                 rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetTopSpace() ) );
315                 }
316                 break;
317                 case HANDLE_PRINTSET_PREVIEW_BOTTOM_MARGIN:
318                 {
319                         bBool = FALSE;
320                         if ( mpConstPreViewData )
321                                 rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetBottomSpace() ) );
322                 }
323                 break;
324                 case HANDLE_PRINTSET_PREVIEW_HORIZONTAL_SPACING:
325                 {
326                         bBool = FALSE;
327                         if ( mpConstPreViewData )
328                                 rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetHorzSpace() ) );
329                 }
330                 break;
331                 case HANDLE_PRINTSET_PREVIEW_VERTICAL_SPACING:
332                 {
333                         bBool = FALSE;
334                         if ( mpConstPreViewData )
335                                 rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetVertSpace() ) );
336                 }
337                 break;
338                 case HANDLE_PRINTSET_PREVIEW_NUM_ROWS:
339                 {
340                         bBool = FALSE;
341                         if ( mpConstPreViewData )
342                                 rValue <<= static_cast < sal_Int8 > ( mpConstPreViewData->GetRow() );
343                 }
344                 break;
345                 case HANDLE_PRINTSET_PREVIEW_NUM_COLUMNS:
346                 {
347                         bBool = FALSE;
348                         if ( mpConstPreViewData )
349                                 rValue <<= static_cast < sal_Int8 > ( mpConstPreViewData->GetCol() );
350                 }
351                 break;
352                 case HANDLE_PRINTSET_PREVIEW_LANDSCAPE:
353                 {
354                         if (mpConstPreViewData)
355                                 bBoolVal = mpConstPreViewData->GetLandscape();
356                         else
357                                 bBool = FALSE;
358                 }
359                 break;
360                 default:
361                         throw UnknownPropertyException();
362         }
363         if(bBool)
364                 rValue.setValue(&bBoolVal, ::getBooleanCppuType());
365 }
366 void SwXPrintPreviewSettings::_postGetValues ()
367         throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
368 {
369         mpConstPreViewData = NULL;
370 }
371 /* -----------------------------06.04.00 11:02--------------------------------
372 
373  ---------------------------------------------------------------------------*/
374 OUString SwXPrintPreviewSettings::getImplementationName(void) throw( RuntimeException )
375 {
376         return OUString( RTL_CONSTASCII_USTRINGPARAM ( "SwXPrintPreviewSettings" ) );
377 }
378 /* -----------------------------06.04.00 11:02--------------------------------
379 
380  ---------------------------------------------------------------------------*/
381 sal_Bool SwXPrintPreviewSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
382 {
383         return rServiceName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.text.PrintPreviewSettings") );
384 }
385 /* -----------------------------06.04.00 11:02--------------------------------
386 
387  ---------------------------------------------------------------------------*/
388 Sequence< OUString > SwXPrintPreviewSettings::getSupportedServiceNames(void) throw( RuntimeException )
389 {
390         Sequence< OUString > aRet(1);
391         OUString* pArray = aRet.getArray();
392         pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.PrintPreviewSettings" ) );
393         return aRet;
394 }
395 

source navigation ] diff markup ] identifier search ] general search ]

This page was automatically generated by the LXR engine.
The LXR team
Valid HTML 4.01!