xref: /aoo42x/main/sw/source/ui/uno/unomod.cxx (revision a41e6500)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <swtypes.hxx>
29 #include <tools/debug.hxx>
30 #include <unomod.hxx>
31 #include <unomid.h>
32 #include <unoprnms.hxx>
33 #include <unomap.hxx>
34 #include <prtopt.hxx>
35 #include <tools/shl.hxx>
36 #include <swmodule.hxx>
37 #include <view.hxx>
38 #include <docsh.hxx>
39 #include <wrtsh.hxx>
40 #include <viewopt.hxx>
41 #include <vos/mutex.hxx>
42 #include <vcl/svapp.hxx>
43 #include <com/sun/star/text/NotePrintMode.hpp>
44 #include <doc.hxx>
45 #include <comphelper/TypeGeneration.hxx>
46 #include <com/sun/star/beans/PropertyAttribute.hpp>
47 #include <com/sun/star/view/DocumentZoomType.hpp>
48 #include <comphelper/ChainablePropertySetInfo.hxx>
49 #include <edtwin.hxx>
50 #include <rtl/ustrbuf.hxx>
51 #include <tools/urlobj.hxx>
52 
53 using namespace ::com::sun::star;
54 using namespace ::com::sun::star::uno;
55 using namespace ::com::sun::star::beans;
56 using namespace ::com::sun::star::lang;
57 using namespace ::comphelper;
58 using ::rtl::OUString;
59 using ::rtl::OUStringBuffer;
60 
61 enum SwViewSettingsPropertyHandles
62 {
63 	HANDLE_VIEWSET_ANNOTATIONS,
64 	HANDLE_VIEWSET_BREAKS,
65 	HANDLE_VIEWSET_DRAWINGS,
66 	HANDLE_VIEWSET_FIELD_COMMANDS,
67 	HANDLE_VIEWSET_FOOTNOTE_BACKGROUND,
68 	HANDLE_VIEWSET_GRAPHICS,
69 	HANDLE_VIEWSET_HIDDEN_CHARACTERS,
70 	HANDLE_VIEWSET_HIDDEN_PARAGRAPHS,
71 	HANDLE_VIEWSET_HIDDEN_TEXT,
72 	HANDLE_VIEWSET_HRULER,
73 	HANDLE_VIEWSET_HSCROLL,
74 	HANDLE_VIEWSET_INDEX_MARK_BACKGROUND,
75 	HANDLE_VIEWSET_NONPRINTING_CHARACTERS,
76 	HANDLE_VIEWSET_ONLINE_LAYOUT,
77 	HANDLE_VIEWSET_PARA_BREAKS,
78 	HANDLE_VIEWSET_PROTECTED_SPACES,
79 	HANDLE_VIEWSET_SOFT_HYPHENS,
80 	HANDLE_VIEWSET_SPACES,
81 	HANDLE_VIEWSET_TABLE_BOUNDARIES,
82 	HANDLE_VIEWSET_TABLES,
83 	HANDLE_VIEWSET_TABSTOPS,
84 	HANDLE_VIEWSET_TEXT_BOUNDARIES,
85 	HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND,
86 	HANDLE_VIEWSET_VRULER,
87 	HANDLE_VIEWSET_VSCROLL,
88 	HANDLE_VIEWSET_SMOOTH_SCROLLING,
89 	HANDLE_VIEWSET_SOLID_MARK_HANDLES,
90 	HANDLE_VIEWSET_ZOOM_TYPE,
91 	HANDLE_VIEWSET_ZOOM,
92     HANDLE_VIEWSET_SHOW_CONTENT_TIPS,
93     HANDLE_VIEWSET_HELP_URL,
94     HANDLE_VIEWSET_VRULER_RIGHT,
95     HANDLE_VIEWSET_SHOW_RULER,
96     HANDLE_VIEWSET_IS_RASTER_VISIBLE,
97     HANDLE_VIEWSET_IS_SNAP_TO_RASTER,
98     HANDLE_VIEWSET_RASTER_RESOLUTION_X,
99     HANDLE_VIEWSET_RASTER_RESOLUTION_Y,
100     HANDLE_VIEWSET_RASTER_SUBDIVISION_X,
101     HANDLE_VIEWSET_RASTER_SUBDIVISION_Y,
102     HANDLE_VIEWSET_HORI_RULER_METRIC,
103     HANDLE_VIEWSET_VERT_RULER_METRIC,
104     HANDLE_VIEWSET_SCROLLBAR_TIPS
105 };
106 enum SwPrintSettingsPropertyHandles
107 {
108 	HANDLE_PRINTSET_ANNOTATION_MODE,
109 	HANDLE_PRINTSET_BLACK_FONTS,
110 	HANDLE_PRINTSET_CONTROLS,
111 	HANDLE_PRINTSET_DRAWINGS,
112 	HANDLE_PRINTSET_GRAPHICS,
113 	HANDLE_PRINTSET_LEFT_PAGES,
114 	HANDLE_PRINTSET_PAGE_BACKGROUND,
115 	HANDLE_PRINTSET_PROSPECT,
116 	HANDLE_PRINTSET_REVERSED,
117 	HANDLE_PRINTSET_RIGHT_PAGES,
118 	HANDLE_PRINTSET_FAX_NAME,
119 	HANDLE_PRINTSET_PAPER_FROM_SETUP,
120 	HANDLE_PRINTSET_TABLES,
121     HANDLE_PRINTSET_SINGLE_JOBS,
122     HANDLE_PRINTSET_EMPTY_PAGES,
123     HANDLE_PRINTSET_PROSPECT_RTL,
124     HANDLE_PRINTSET_PLACEHOLDER,
125     HANDLE_PRINTSET_HIDDEN_TEXT
126 };
127 
lcl_createViewSettingsInfo()128 static ChainablePropertySetInfo * lcl_createViewSettingsInfo()
129 {
130 	static PropertyInfo aViewSettingsMap_Impl[] =
131 	{
132         { RTL_CONSTASCII_STRINGPARAM ( "HelpURL" ),             HANDLE_VIEWSET_HELP_URL             , CPPUTYPE_OUSTRING,    PROPERTY_NONE,  0},
133         { RTL_CONSTASCII_STRINGPARAM ( "HorizontalRulerMetric"),HANDLE_VIEWSET_HORI_RULER_METRIC   , CPPUTYPE_INT32, PROPERTY_NONE, 0},
134         { RTL_CONSTASCII_STRINGPARAM ( "IsRasterVisible"),      HANDLE_VIEWSET_IS_RASTER_VISIBLE,       CPPUTYPE_BOOLEAN,   PROPERTY_NONE, 0},
135         { RTL_CONSTASCII_STRINGPARAM ( "IsSnapToRaster"),       HANDLE_VIEWSET_IS_SNAP_TO_RASTER,       CPPUTYPE_BOOLEAN,   PROPERTY_NONE, 0},
136         { RTL_CONSTASCII_STRINGPARAM ( "IsVertRulerRightAligned"),HANDLE_VIEWSET_VRULER_RIGHT         , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
137         { RTL_CONSTASCII_STRINGPARAM ( "ShowContentTips" ),     HANDLE_VIEWSET_SHOW_CONTENT_TIPS      , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
138         { RTL_CONSTASCII_STRINGPARAM ( "RasterResolutionX"),    HANDLE_VIEWSET_RASTER_RESOLUTION_X,     CPPUTYPE_INT32,     PROPERTY_NONE, 0},
139         { RTL_CONSTASCII_STRINGPARAM ( "RasterResolutionY"),    HANDLE_VIEWSET_RASTER_RESOLUTION_Y,     CPPUTYPE_INT32,     PROPERTY_NONE, 0},
140         { RTL_CONSTASCII_STRINGPARAM ( "RasterSubdivisionX"),   HANDLE_VIEWSET_RASTER_SUBDIVISION_X,    CPPUTYPE_INT32,     PROPERTY_NONE, 0},
141         { RTL_CONSTASCII_STRINGPARAM ( "RasterSubdivisionY"),   HANDLE_VIEWSET_RASTER_SUBDIVISION_Y,    CPPUTYPE_INT32,     PROPERTY_NONE, 0},
142         { RTL_CONSTASCII_STRINGPARAM ( "ShowAnnotations" ),     HANDLE_VIEWSET_ANNOTATIONS          , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
143 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowBreaks"),			HANDLE_VIEWSET_BREAKS               , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
144 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowDrawings"),			HANDLE_VIEWSET_DRAWINGS             , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
145 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowFieldCommands"),	HANDLE_VIEWSET_FIELD_COMMANDS       , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
146 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowFootnoteBackground"),HANDLE_VIEWSET_FOOTNOTE_BACKGROUND , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
147 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowGraphics"),			HANDLE_VIEWSET_GRAPHICS             , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
148 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenCharacters"), HANDLE_VIEWSET_HIDDEN_CHARACTERS    , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
149 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenParagraphs"),	HANDLE_VIEWSET_HIDDEN_PARAGRAPHS    , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
150 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenText"),		HANDLE_VIEWSET_HIDDEN_TEXT          , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
151 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowHoriRuler"),		HANDLE_VIEWSET_HRULER 			  	, CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
152 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowHoriScrollBar"),	HANDLE_VIEWSET_HSCROLL			    , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
153 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowIndexMarkBackground"),HANDLE_VIEWSET_INDEX_MARK_BACKGROUND, CPPUTYPE_BOOLEAN,PROPERTY_NONE,	0},
154 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowNonprintingCharacters"),HANDLE_VIEWSET_NONPRINTING_CHARACTERS, CPPUTYPE_BOOLEAN,PROPERTY_NONE,	0},
155 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowOnlineLayout"),		HANDLE_VIEWSET_ONLINE_LAYOUT		, CPPUTYPE_BOOLEAN,	PropertyAttribute::MAYBEVOID,	0},
156 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowParaBreaks"),		HANDLE_VIEWSET_PARA_BREAKS          , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
157 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowProtectedSpaces"),	HANDLE_VIEWSET_PROTECTED_SPACES     , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
158         { RTL_CONSTASCII_STRINGPARAM ( "ShowRulers"),           HANDLE_VIEWSET_SHOW_RULER           , CPPUTYPE_BOOLEAN, PROPERTY_NONE,  0},
159         { RTL_CONSTASCII_STRINGPARAM ( "ShowScrollBarTips"),    HANDLE_VIEWSET_SCROLLBAR_TIPS       , CPPUTYPE_BOOLEAN, PROPERTY_NONE,  0},
160 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowSoftHyphens"),		HANDLE_VIEWSET_SOFT_HYPHENS         , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
161 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowSpaces"),			HANDLE_VIEWSET_SPACES               , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
162 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowTableBoundaries"),	HANDLE_VIEWSET_TABLE_BOUNDARIES     , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
163 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowTables"),			HANDLE_VIEWSET_TABLES               , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
164 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowTabstops"),			HANDLE_VIEWSET_TABSTOPS             , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
165 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowTextBoundaries"),	HANDLE_VIEWSET_TEXT_BOUNDARIES      , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
166 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowTextFieldBackground"),HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND, CPPUTYPE_BOOLEAN,PROPERTY_NONE,	0},
167 		{ RTL_CONSTASCII_STRINGPARAM ( "ShowVertRuler"),		HANDLE_VIEWSET_VRULER 				, CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
168         { RTL_CONSTASCII_STRINGPARAM ( "ShowVertScrollBar"),    HANDLE_VIEWSET_VSCROLL              , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
169 		{ RTL_CONSTASCII_STRINGPARAM ( "SmoothScrolling"),		HANDLE_VIEWSET_SMOOTH_SCROLLING     , CPPUTYPE_BOOLEAN,	PROPERTY_NONE,	0},
170 		{ RTL_CONSTASCII_STRINGPARAM ( "SolidMarkHandles"), 	HANDLE_VIEWSET_SOLID_MARK_HANDLES	, CPPUTYPE_BOOLEAN,	PROPERTY_NONE, 0},
171         { RTL_CONSTASCII_STRINGPARAM ( "VerticalRulerMetric"),  HANDLE_VIEWSET_VERT_RULER_METRIC   , CPPUTYPE_INT32, PROPERTY_NONE, 0},
172 		{ RTL_CONSTASCII_STRINGPARAM ( "ZoomType"), 			HANDLE_VIEWSET_ZOOM_TYPE			, CPPUTYPE_INT16,  	PROPERTY_NONE, 0},
173 		{ RTL_CONSTASCII_STRINGPARAM ( "ZoomValue"), 			HANDLE_VIEWSET_ZOOM				 	, CPPUTYPE_INT16, 	PROPERTY_NONE, 0},
174         { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
175 	};
176 	return new ChainablePropertySetInfo ( aViewSettingsMap_Impl );
177 }
lcl_createPrintSettingsInfo()178 static ChainablePropertySetInfo * lcl_createPrintSettingsInfo()
179 {
180 	static PropertyInfo aPrintSettingsMap_Impl[] =
181 	{
182 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintAnnotationMode" ), HANDLE_PRINTSET_ANNOTATION_MODE	, CPPUTYPE_INT16,   PROPERTY_NONE,	0},
183 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintBlackFonts" ), 	 HANDLE_PRINTSET_BLACK_FONTS		, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
184 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintControls" ), 		 HANDLE_PRINTSET_CONTROLS			, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
185 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintDrawings" ), 		 HANDLE_PRINTSET_DRAWINGS			, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
186 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintGraphics" ), 		 HANDLE_PRINTSET_GRAPHICS			, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
187         { RTL_CONSTASCII_STRINGPARAM ( "PrintHiddenText"),       HANDLE_PRINTSET_HIDDEN_TEXT        , CPPUTYPE_BOOLEAN, PROPERTY_NONE,  0},
188 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintLeftPages" ), 		 HANDLE_PRINTSET_LEFT_PAGES			, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
189 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintPageBackground" ),  HANDLE_PRINTSET_PAGE_BACKGROUND	, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
190 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintProspect" ), 		 HANDLE_PRINTSET_PROSPECT			, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
191         { RTL_CONSTASCII_STRINGPARAM ( "PrintProspectRTL" ),     HANDLE_PRINTSET_PROSPECT_RTL       , CPPUTYPE_BOOLEAN, PROPERTY_NONE,  0},
192 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintReversed" ), 		 HANDLE_PRINTSET_REVERSED   		, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
193 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintRightPages" ), 	 HANDLE_PRINTSET_RIGHT_PAGES		, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
194 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintFaxName" ), 		 HANDLE_PRINTSET_FAX_NAME			, CPPUTYPE_OUSTRING, PROPERTY_NONE,	0},
195 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintPaperFromSetup" ),  HANDLE_PRINTSET_PAPER_FROM_SETUP	, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
196 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintTables" ), 		 HANDLE_PRINTSET_TABLES				, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
197         { RTL_CONSTASCII_STRINGPARAM ( "PrintTextPlaceholder"),  HANDLE_PRINTSET_PLACEHOLDER        , CPPUTYPE_BOOLEAN, PROPERTY_NONE,  0},
198 		{ RTL_CONSTASCII_STRINGPARAM ( "PrintSingleJobs" ), 	 HANDLE_PRINTSET_SINGLE_JOBS		, CPPUTYPE_BOOLEAN, PROPERTY_NONE,	0},
199         { RTL_CONSTASCII_STRINGPARAM ( "PrintEmptyPages" ),      HANDLE_PRINTSET_EMPTY_PAGES        , CPPUTYPE_BOOLEAN, PROPERTY_NONE,  0},
200         { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
201 	};
202 	return new ChainablePropertySetInfo ( aPrintSettingsMap_Impl );
203 }
204 
205 /******************************************************************
206  * SwXModule
207  ******************************************************************/
208 /* -----------------30.03.99 15:10-------------------
209  *
210  * --------------------------------------------------*/
SwXModule_createInstance(const Reference<XMultiServiceFactory> &)211 Reference< uno::XInterface > SAL_CALL SwXModule_createInstance(
212     const Reference< XMultiServiceFactory > & /*rSMgr*/) throw( Exception )
213 {
214 	static Reference< uno::XInterface >  xModule = (cppu::OWeakObject*)new SwXModule();;
215 	return xModule;
216 }
217 /* -----------------------------17.04.01 13:11--------------------------------
218 
219  ---------------------------------------------------------------------------*/
SwXModule_getSupportedServiceNames()220 Sequence< OUString > SAL_CALL SwXModule_getSupportedServiceNames() throw()
221 {
222     OUString sService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GlobalSettings"));
223     const Sequence< OUString > aSeq( &sService, 1 );
224 	return aSeq;
225 }
226 /* -----------------------------17.04.01 13:11--------------------------------
227 
228  ---------------------------------------------------------------------------*/
SwXModule_getImplementationName()229 OUString SAL_CALL SwXModule_getImplementationName() throw()
230 {
231     return OUString( RTL_CONSTASCII_USTRINGPARAM("SwXModule" ) );
232 }
233 /*-- 17.12.98 12:19:01---------------------------------------------------
234 
235   -----------------------------------------------------------------------*/
SwXModule()236 SwXModule::SwXModule() :
237 	pxViewSettings(0),
238 	pxPrintSettings(0)
239 {
240 }
241 /*-- 17.12.98 12:19:02---------------------------------------------------
242 
243   -----------------------------------------------------------------------*/
~SwXModule()244 SwXModule::~SwXModule()
245 {
246 	delete pxViewSettings;
247 	delete pxPrintSettings;
248 }
249 /*-- 17.12.98 12:19:03---------------------------------------------------
250 
251   -----------------------------------------------------------------------*/
getViewSettings(void)252 Reference< XPropertySet >  SwXModule::getViewSettings(void) throw( uno::RuntimeException )
253 {
254 	::vos::OGuard aGuard(Application::GetSolarMutex());
255 	if(!pxViewSettings)
256 	{
257 		((SwXModule*)this)->pxViewSettings = new Reference< XPropertySet > ;
258 		DBG_ERROR("Web oder Text?");
259 		*pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, 0 ) );
260 	}
261 	return *pxViewSettings;
262 }
263 /*-- 17.12.98 12:19:03---------------------------------------------------
264 
265   -----------------------------------------------------------------------*/
getPrintSettings(void)266 Reference< XPropertySet >  SwXModule::getPrintSettings(void) throw( uno::RuntimeException )
267 {
268 	::vos::OGuard aGuard(Application::GetSolarMutex());
269 	if(!pxPrintSettings)
270 	{
271 		((SwXModule*)this)->pxPrintSettings = new Reference< XPropertySet > ;
272 		DBG_ERROR("Web oder Text?");
273 		*pxPrintSettings = static_cast < HelperBaseNoState * > ( new SwXPrintSettings ( PRINT_SETTINGS_MODULE ) );
274 	}
275 	return *pxPrintSettings;
276 }
277 /* -----------------------------06.04.00 10:59--------------------------------
278 
279  ---------------------------------------------------------------------------*/
getImplementationName(void)280 OUString SwXModule::getImplementationName(void) throw( RuntimeException )
281 {
282     return SwXModule_getImplementationName();
283 }
284 /* -----------------------------06.04.00 10:59--------------------------------
285 
286  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)287 sal_Bool SwXModule::supportsService(const OUString& rServiceName) throw( RuntimeException )
288 {
289     const Sequence< OUString > aNames = SwXModule_getSupportedServiceNames();
290     for(sal_Int32 nService = 0; nService < aNames.getLength(); nService++)
291     {
292         if(aNames.getConstArray()[nService] == rServiceName)
293             return sal_True;
294     }
295     return sal_False;
296 }
297 /* -----------------------------06.04.00 10:59--------------------------------
298 
299  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)300 Sequence< OUString > SwXModule::getSupportedServiceNames(void) throw( RuntimeException )
301 {
302     return SwXModule_getSupportedServiceNames();
303 }
304 
305 /******************************************************************
306  * SwXPrintSettings
307  ******************************************************************/
308 /*-- 17.12.98 12:54:04---------------------------------------------------
309 
310   -----------------------------------------------------------------------*/
SwXPrintSettings(SwXPrintSettingsType eType,SwDoc * pDoc)311 SwXPrintSettings::SwXPrintSettings(SwXPrintSettingsType eType, SwDoc* pDoc)
312 : ChainableHelperNoState ( lcl_createPrintSettingsInfo (), &Application::GetSolarMutex() )
313 , meType(eType)
314 , mpPrtOpt ( NULL )
315 , mpDoc ( pDoc )
316 {
317 }
318 /*-- 17.12.98 12:54:05---------------------------------------------------
319 
320   -----------------------------------------------------------------------*/
~SwXPrintSettings()321 SwXPrintSettings::~SwXPrintSettings()
322 	throw()
323 {
324 }
325 
_preSetValues()326 void SwXPrintSettings::_preSetValues ()
327 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
328 {
329 	switch (meType)
330 	{
331 		case PRINT_SETTINGS_MODULE:
332 			mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
333 		break;
334 		case PRINT_SETTINGS_WEB:
335 			mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
336 		break;
337 		case PRINT_SETTINGS_DOCUMENT:
338 		{
339 			if (!mpDoc)
340 				throw IllegalArgumentException ();
341             mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData());
342 		}
343 		break;
344 	}
345 }
346 
_setSingleValue(const comphelper::PropertyInfo & rInfo,const uno::Any & rValue)347 void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
348 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
349 {
350 	sal_Bool bVal;
351 	if ( rInfo.mnHandle != HANDLE_PRINTSET_ANNOTATION_MODE &&
352 		 rInfo.mnHandle != HANDLE_PRINTSET_FAX_NAME )
353 		bVal = *(sal_Bool*)rValue.getValue();
354 
355 	switch( rInfo.mnHandle )
356 	{
357 		case HANDLE_PRINTSET_LEFT_PAGES:
358 		{
359 			bVal = *(sal_Bool*)rValue.getValue();
360 			mpPrtOpt->SetPrintLeftPage(bVal);
361 		}
362 		break;
363 		case HANDLE_PRINTSET_RIGHT_PAGES:
364 		{
365 			bVal = *(sal_Bool*)rValue.getValue();
366 			mpPrtOpt->SetPrintRightPage(bVal);
367 		}
368 		break;
369 		case HANDLE_PRINTSET_REVERSED:
370 		{
371 			bVal = *(sal_Bool*)rValue.getValue();
372 			mpPrtOpt->SetPrintReverse(bVal);
373 		}
374 		break;
375 		case HANDLE_PRINTSET_PROSPECT:
376 		{
377 			bVal = *(sal_Bool*)rValue.getValue();
378 			mpPrtOpt->SetPrintProspect(bVal);
379 		}
380 		break;
381 		case HANDLE_PRINTSET_GRAPHICS:
382 		{
383 			bVal = *(sal_Bool*)rValue.getValue();
384 			mpPrtOpt->SetPrintGraphic(bVal);
385 		}
386 		break;
387 		case HANDLE_PRINTSET_TABLES:
388 		{
389 			bVal = *(sal_Bool*)rValue.getValue();
390 			mpPrtOpt->SetPrintTable(bVal);
391 		}
392 		break;
393 		case HANDLE_PRINTSET_DRAWINGS:
394 		{
395 			bVal = *(sal_Bool*)rValue.getValue();
396 			mpPrtOpt->SetPrintDraw(bVal);
397 		}
398 		break;
399 		case HANDLE_PRINTSET_CONTROLS:
400 		{
401 			bVal = *(sal_Bool*)rValue.getValue();
402 			mpPrtOpt->SetPrintControl(bVal);
403 		}
404 		break;
405 		case HANDLE_PRINTSET_PAGE_BACKGROUND:
406 		{
407 			bVal = *(sal_Bool*)rValue.getValue();
408 			mpPrtOpt->SetPrintPageBackground(bVal);
409 		}
410 		break;
411 		case HANDLE_PRINTSET_BLACK_FONTS:
412 		{
413 			bVal = *(sal_Bool*)rValue.getValue();
414 			mpPrtOpt->SetPrintBlackFont(bVal);
415 		}
416 		break;
417 		case HANDLE_PRINTSET_SINGLE_JOBS:
418 		{
419 			bVal = *(sal_Bool*)rValue.getValue();
420 			mpPrtOpt->SetPrintSingleJobs(bVal);
421 		}
422 		break;
423 		case HANDLE_PRINTSET_PAPER_FROM_SETUP:
424 		{
425 			bVal = *(sal_Bool*)rValue.getValue();
426 			mpPrtOpt->SetPaperFromSetup(bVal);
427 		}
428 		break;
429 		case HANDLE_PRINTSET_ANNOTATION_MODE:
430 		{
431 			sal_Int16 nVal = 0;
432 			rValue >>= nVal;
433 			if(nVal <= text::NotePrintMode_PAGE_END)
434 				mpPrtOpt->SetPrintPostIts(nVal);
435 			else
436 				throw lang::IllegalArgumentException();
437 		}
438 		break;
439         case HANDLE_PRINTSET_EMPTY_PAGES:
440         {
441             bVal = *(sal_Bool*)rValue.getValue();
442             mpPrtOpt->SetPrintEmptyPages(bVal);
443         }
444         break;
445 		case HANDLE_PRINTSET_FAX_NAME:
446 		{
447 			OUString sString;
448 			if ( rValue >>= sString)
449 				mpPrtOpt->SetFaxName(sString);
450 			else
451 				throw lang::IllegalArgumentException();
452 		}
453 		break;
454         case HANDLE_PRINTSET_PROSPECT_RTL:
455         {
456             bVal = *(sal_Bool*)rValue.getValue();
457             mpPrtOpt->SetPrintProspect_RTL(bVal);
458         }
459         break;
460         case HANDLE_PRINTSET_PLACEHOLDER:
461         {
462             bVal = *(sal_Bool*)rValue.getValue();
463             mpPrtOpt->SetPrintTextPlaceholder(bVal);
464         }
465         break;
466         case HANDLE_PRINTSET_HIDDEN_TEXT:
467         {
468             bVal = *(sal_Bool*)rValue.getValue();
469             mpPrtOpt->SetPrintHiddenText(bVal);
470         }
471         break;
472 		default:
473 			throw UnknownPropertyException();
474 	}
475 }
_postSetValues()476 void SwXPrintSettings::_postSetValues ()
477 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
478 {
479 	mpPrtOpt = NULL;
480 }
481 
_preGetValues()482 void SwXPrintSettings::_preGetValues ()
483 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
484 {
485 	switch (meType)
486 	{
487 		case PRINT_SETTINGS_MODULE:
488 			mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
489 		break;
490 		case PRINT_SETTINGS_WEB:
491 			mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
492 		break;
493 		case PRINT_SETTINGS_DOCUMENT:
494 		{
495 			if (!mpDoc)
496 				throw IllegalArgumentException ();
497             mpPrtOpt = const_cast< SwPrintData * >(&mpDoc->getPrintData());
498 		}
499 		break;
500 	}
501 }
_getSingleValue(const comphelper::PropertyInfo & rInfo,uno::Any & rValue)502 void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
503 	throw(UnknownPropertyException, WrappedTargetException )
504 {
505 	switch( rInfo.mnHandle )
506 	{
507 		case HANDLE_PRINTSET_LEFT_PAGES:
508             rValue <<= mpPrtOpt->IsPrintLeftPage();
509 		break;
510 		case HANDLE_PRINTSET_RIGHT_PAGES:
511             rValue <<= mpPrtOpt->IsPrintRightPage();
512 		break;
513 		case HANDLE_PRINTSET_REVERSED:
514             rValue <<= mpPrtOpt->IsPrintReverse();
515 		break;
516 		case HANDLE_PRINTSET_PROSPECT:
517             rValue <<= mpPrtOpt->IsPrintProspect();
518 		break;
519 		case HANDLE_PRINTSET_GRAPHICS:
520             rValue <<= mpPrtOpt->IsPrintGraphic();
521 		break;
522 		case HANDLE_PRINTSET_TABLES:
523             rValue <<= mpPrtOpt->IsPrintTable();
524 		break;
525 		case HANDLE_PRINTSET_DRAWINGS:
526             rValue <<= mpPrtOpt->IsPrintDraw();
527 		break;
528 		case HANDLE_PRINTSET_CONTROLS:
529             rValue <<= mpPrtOpt->IsPrintControl();
530 		break;
531 		case HANDLE_PRINTSET_PAGE_BACKGROUND:
532             rValue <<= mpPrtOpt->IsPrintPageBackground();
533 		break;
534 		case HANDLE_PRINTSET_BLACK_FONTS:
535             rValue <<= mpPrtOpt->IsPrintBlackFont();
536 		break;
537 		case HANDLE_PRINTSET_SINGLE_JOBS:
538             rValue <<= mpPrtOpt->IsPrintSingleJobs();
539 		break;
540         case HANDLE_PRINTSET_EMPTY_PAGES:
541             rValue <<= mpPrtOpt->IsPrintEmptyPages();
542         break;
543         case HANDLE_PRINTSET_PAPER_FROM_SETUP:
544             rValue <<= mpPrtOpt->IsPaperFromSetup();
545 		break;
546 		case HANDLE_PRINTSET_ANNOTATION_MODE:
547 		{
548 			rValue <<= static_cast < sal_Int16 > ( mpPrtOpt->GetPrintPostIts() );
549 		}
550 		break;
551 		case HANDLE_PRINTSET_FAX_NAME :
552 		{
553 			rValue <<= mpPrtOpt->GetFaxName();
554 		}
555 		break;
556         case HANDLE_PRINTSET_PROSPECT_RTL:
557         {
558             rValue <<= mpPrtOpt->IsPrintProspectRTL();
559         }
560         break;
561         case HANDLE_PRINTSET_PLACEHOLDER:
562         {
563             rValue <<= mpPrtOpt->IsPrintTextPlaceholder();
564         }
565         break;
566         case HANDLE_PRINTSET_HIDDEN_TEXT:
567         {
568             rValue <<= mpPrtOpt->IsPrintHiddenText();
569         }
570         break;
571 		default:
572 			throw UnknownPropertyException();
573 	}
574 }
_postGetValues()575 void SwXPrintSettings::_postGetValues ()
576 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
577 {
578 	mpPrtOpt = NULL;
579 }
580 /* -----------------------------06.04.00 11:02--------------------------------
581 
582  ---------------------------------------------------------------------------*/
getImplementationName(void)583 OUString SwXPrintSettings::getImplementationName(void) throw( RuntimeException )
584 {
585 	return C2U("SwXPrintSettings");
586 }
587 /* -----------------------------06.04.00 11:02--------------------------------
588 
589  ---------------------------------------------------------------------------*/
supportsService(const OUString & rServiceName)590 sal_Bool SwXPrintSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
591 {
592 	return C2U("com.sun.star.text.PrintSettings") == rServiceName;
593 }
594 /* -----------------------------06.04.00 11:02--------------------------------
595 
596  ---------------------------------------------------------------------------*/
getSupportedServiceNames(void)597 Sequence< OUString > SwXPrintSettings::getSupportedServiceNames(void) throw( RuntimeException )
598 {
599 	Sequence< OUString > aRet(1);
600 	OUString* pArray = aRet.getArray();
601 	pArray[0] = C2U("com.sun.star.text.PrintSettings");
602 	return aRet;
603 }
604 
605 
606 /******************************************************************
607  *
608  ******************************************************************/
609 /*-- 18.12.98 11:01:10---------------------------------------------------
610 
611   -----------------------------------------------------------------------*/
SwXViewSettings(sal_Bool bWebView,SwView * pVw)612 SwXViewSettings::SwXViewSettings(sal_Bool bWebView, SwView*	pVw)
613 : ChainableHelperNoState( lcl_createViewSettingsInfo (), &Application::GetSolarMutex() )
614 , pView(pVw)
615 , mpViewOption ( NULL )
616 , mpConstViewOption ( NULL )
617 , bObjectValid(sal_True)
618 , bWeb(bWebView)
619 , eHRulerUnit( FUNIT_CM )
620 , mbApplyHRulerMetric( sal_False )
621 , eVRulerUnit( FUNIT_CM )
622 , mbApplyVRulerMetric( sal_False )
623 {
624 	// This property only exists if we have a view (ie, not at the module )
625 	if ( !pView )
626 		mpInfo->remove ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "HelpURL" ) ) );
627 
628 }
629 /*-- 18.12.98 11:01:10---------------------------------------------------
630 
631   -----------------------------------------------------------------------*/
~SwXViewSettings()632 SwXViewSettings::~SwXViewSettings()
633 	throw()
634 {
635 
636 }
_preSetValues()637 void SwXViewSettings::_preSetValues ()
638 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
639 {
640 	const SwViewOption* pVOpt = 0;
641 	if(pView)
642 	{
643 		if(!IsValid())
644 			return;
645 		pVOpt = pView->GetWrtShell().GetViewOptions();
646 	}
647 	else
648 		pVOpt = SW_MOD()->GetViewOption(bWeb);
649 
650 	mpViewOption = new SwViewOption (*pVOpt);
651 	mbApplyZoom = sal_False;
652 	if(pView)
653 		mpViewOption->SetStarOneSetting(sal_True);
654 }
_setSingleValue(const comphelper::PropertyInfo & rInfo,const uno::Any & rValue)655 void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
656 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
657 {
658 	sal_Bool bVal = HANDLE_VIEWSET_ZOOM != rInfo.mnHandle ?
659 		*(sal_Bool*)rValue.getValue() : sal_False;
660 	// the API flag should not be set to the application's view settings
661 	switch( rInfo.mnHandle )
662 	{
663         case  HANDLE_VIEWSET_SHOW_RULER            :   mpViewOption->SetViewAnyRuler(bVal); break;
664         case  HANDLE_VIEWSET_HRULER                :   mpViewOption->SetViewHRuler(bVal);   break;
665         case  HANDLE_VIEWSET_VRULER                :   mpViewOption->SetViewVRuler(bVal);break;
666         case  HANDLE_VIEWSET_VRULER_RIGHT          :   mpViewOption->SetVRulerRight(bVal);break;
667 		case  HANDLE_VIEWSET_HSCROLL			   :   mpViewOption->SetViewHScrollBar(bVal);break;
668 		case  HANDLE_VIEWSET_VSCROLL			   :   mpViewOption->SetViewVScrollBar(bVal);break;
669 		case  HANDLE_VIEWSET_GRAPHICS              :   mpViewOption->SetGraphic(bVal);break;
670 		case  HANDLE_VIEWSET_TABLES                :   mpViewOption->SetTable(bVal);	break;
671 		case  HANDLE_VIEWSET_DRAWINGS              :   mpViewOption->SetDraw(bVal);	break;
672 		case  HANDLE_VIEWSET_FIELD_COMMANDS        :   mpViewOption->SetFldName(bVal);	break;
673 		case  HANDLE_VIEWSET_ANNOTATIONS           :   mpViewOption->SetPostIts(bVal);	break;
674         case  HANDLE_VIEWSET_INDEX_MARK_BACKGROUND :   mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True);  break;
675         case  HANDLE_VIEWSET_NONPRINTING_CHARACTERS:   mpViewOption->SetViewMetaChars( bVal ); break;
676         case  HANDLE_VIEWSET_FOOTNOTE_BACKGROUND   :   mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break;
677         case  HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND :   mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True);    break;
678 		case  HANDLE_VIEWSET_PARA_BREAKS           :   mpViewOption->SetParagraph(bVal);	break;
679 		case  HANDLE_VIEWSET_SOFT_HYPHENS          :   mpViewOption->SetSoftHyph(bVal);	break;
680 		case  HANDLE_VIEWSET_SPACES                :   mpViewOption->SetBlank(bVal);	break;
681 		case  HANDLE_VIEWSET_PROTECTED_SPACES      :   mpViewOption->SetHardBlank(bVal);	break;
682 		case  HANDLE_VIEWSET_TABSTOPS              :   mpViewOption->SetTab(bVal);	break;
683 		case  HANDLE_VIEWSET_BREAKS                :   mpViewOption->SetLineBreak(bVal); break;
684         case  HANDLE_VIEWSET_HIDDEN_TEXT           :   mpViewOption->SetShowHiddenField(bVal);  break;
685 		case  HANDLE_VIEWSET_HIDDEN_CHARACTERS     :   mpViewOption->SetShowHiddenChar(bVal); break;
686 		case  HANDLE_VIEWSET_HIDDEN_PARAGRAPHS     :   mpViewOption->SetShowHiddenPara(bVal);	break;
687         case  HANDLE_VIEWSET_TABLE_BOUNDARIES      :   mpViewOption->SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bVal, sal_True);    break;
688         case  HANDLE_VIEWSET_TEXT_BOUNDARIES       :   mpViewOption->SetDocBoundaries(bVal);    break;
689 		case  HANDLE_VIEWSET_SMOOTH_SCROLLING      :   mpViewOption->SetSmoothScroll(bVal);	break;
690 		case  HANDLE_VIEWSET_SOLID_MARK_HANDLES    :   mpViewOption->SetSolidMarkHdl(bVal);	break;
691         case  HANDLE_VIEWSET_SHOW_CONTENT_TIPS     :   mpViewOption->SetShowContentTips(bVal); break;
692         case  HANDLE_VIEWSET_IS_RASTER_VISIBLE     : mpViewOption->SetGridVisible(bVal); break;
693         case  HANDLE_VIEWSET_IS_SNAP_TO_RASTER     : mpViewOption->SetSnap(bVal); break;
694         case  HANDLE_VIEWSET_SCROLLBAR_TIPS        : mpViewOption->SetShowScrollBarTips(bVal); break;
695         case  HANDLE_VIEWSET_RASTER_RESOLUTION_X   :
696         {
697             sal_Int32 nTmp = 0;
698             if(!(rValue >>= nTmp)  ||  nTmp < 10)
699                 throw IllegalArgumentException();
700             Size aSize( mpViewOption->GetSnapSize() );
701             aSize.Width() = MM100_TO_TWIP( nTmp );
702             mpViewOption->SetSnapSize( aSize );
703         }
704         break;
705         case  HANDLE_VIEWSET_RASTER_RESOLUTION_Y   :
706         {
707             sal_Int32 nTmp = 0;
708             if(!(rValue >>= nTmp)  ||  nTmp < 10)
709                 throw IllegalArgumentException();
710             Size aSize( mpViewOption->GetSnapSize() );
711             aSize.Height() = MM100_TO_TWIP( nTmp );
712             mpViewOption->SetSnapSize( aSize );
713         }
714         break;
715         case  HANDLE_VIEWSET_RASTER_SUBDIVISION_X  :
716         {
717             sal_Int32 nTmp = 0;
718             if(!(rValue >>= nTmp)  ||  !(0 <= nTmp  &&  nTmp < 100))
719                 throw IllegalArgumentException();
720             mpViewOption->SetDivisionX( (short) nTmp );
721         }
722         break;
723         case  HANDLE_VIEWSET_RASTER_SUBDIVISION_Y  :
724         {
725             sal_Int32 nTmp = 0;
726             if(!(rValue >>= nTmp)  ||  !(0 <= nTmp  &&  nTmp < 100))
727                 throw IllegalArgumentException();
728             mpViewOption->SetDivisionY( (short) nTmp );
729         }
730         break;
731         case  HANDLE_VIEWSET_ZOOM                   :
732 		{
733             sal_Int16 nZoom = 0;
734             if(!(rValue >>= nZoom) || nZoom > 1000 || nZoom < 5)
735 				throw lang::IllegalArgumentException();
736 			mpViewOption->SetZoom((sal_uInt16)nZoom);
737 			mbApplyZoom = sal_True;
738 		}
739 		break;
740 		case HANDLE_VIEWSET_ZOOM_TYPE:
741 		{
742             sal_Int16 nZoom = 0;
743             if(!(rValue >>= nZoom))
744                 throw IllegalArgumentException();
745 			SvxZoomType eZoom = (SvxZoomType)USHRT_MAX;
746             switch (nZoom)
747             {
748                 case view::DocumentZoomType::OPTIMAL:
749                     eZoom = SVX_ZOOM_OPTIMAL;
750                 break;
751                 case view::DocumentZoomType::PAGE_WIDTH:
752                     eZoom = SVX_ZOOM_PAGEWIDTH;
753                 break;
754                 case view::DocumentZoomType::ENTIRE_PAGE:
755                     eZoom = SVX_ZOOM_WHOLEPAGE;
756                 break;
757                 case view::DocumentZoomType::BY_VALUE:
758                     eZoom = SVX_ZOOM_PERCENT;
759                 break;
760                 case view::DocumentZoomType::PAGE_WIDTH_EXACT:
761                     eZoom = SVX_ZOOM_PAGEWIDTH_NOBORDER;
762                 break;
763                 default:
764                     throw IllegalArgumentException(
765                         ::rtl::OUString::createFromAscii(
766                             "SwXViewSettings: invalid zoom type"), 0, 0);
767                 break;
768             }
769 			if(eZoom < USHRT_MAX)
770 			{
771 				mpViewOption->SetZoomType( eZoom );
772 				mbApplyZoom = sal_True;
773 			}
774 		}
775 		break;
776 		case HANDLE_VIEWSET_ONLINE_LAYOUT :
777 		{
778             if( pView && !bVal != !pView->GetWrtShell().GetViewOptions()->getBrowseMode() )
779             {
780 				SwViewOption aOpt( *pView->GetWrtShell().GetViewOptions() );
781 				aOpt.setBrowseMode( bVal );
782 				pView->GetWrtShell().ApplyViewOptions( aOpt );
783 				pView->RecheckBrowseMode();
784 
785 				// must be set in mpViewOption as this will overwrite settings in _post!
786 				mpViewOption->setBrowseMode( bVal );
787 
788 				// disable multiple layout
789 				pView->GetDocShell()->ToggleBrowserMode(bVal, pView );
790             }
791 		}
792 		break;
793 		case HANDLE_VIEWSET_HELP_URL :
794 		{
795 			if ( pView )
796 			{
797 				OUString sHelpURL;
798 				if ( ! ( rValue >>= sHelpURL ) )
799 					throw IllegalArgumentException();
800 
801                 INetURLObject aHID( sHelpURL );
802                 if ( aHID.GetProtocol() == INET_PROT_HID )
803 	          	    pView->GetEditWin().SetHelpId( rtl::OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 ) );
804                 else
805 					throw IllegalArgumentException ();
806 			}
807 			else
808 				throw UnknownPropertyException();
809 		}
810 		break;
811         case HANDLE_VIEWSET_HORI_RULER_METRIC:
812         case HANDLE_VIEWSET_VERT_RULER_METRIC:
813         {
814             sal_Int32 nUnit = -1;
815             if( rValue >>= nUnit )
816             switch( nUnit )
817             {
818                 case FUNIT_MM:
819                 case FUNIT_CM:
820                 case FUNIT_POINT:
821                 case FUNIT_PICA:
822                 case FUNIT_INCH:
823                 if( rInfo.mnHandle == HANDLE_VIEWSET_HORI_RULER_METRIC )
824                 {
825                     eHRulerUnit = nUnit;
826                     mbApplyHRulerMetric = sal_True;
827                 }
828                 else
829                 {
830                     eVRulerUnit = nUnit;
831                     mbApplyVRulerMetric = sal_True;
832                 }
833                 break;
834                 default:
835                     throw IllegalArgumentException();
836             }
837         }
838         break;
839 		default:
840 			throw UnknownPropertyException();
841 	}
842 }
843 
_postSetValues()844 void SwXViewSettings::_postSetValues ()
845 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
846 {
847     if( pView )
848     {
849         if(mbApplyZoom )
850             pView->SetZoom( (SvxZoomType)mpViewOption->GetZoomType(),
851                             mpViewOption->GetZoom(), sal_True );
852         if(mbApplyHRulerMetric)
853             pView->ChangeTabMetric((FieldUnit)eHRulerUnit);
854         if(mbApplyVRulerMetric)
855             pView->ChangeVLinealMetric((FieldUnit)eVRulerUnit);
856 
857     }
858     else
859     {
860         if(mbApplyHRulerMetric)
861             SW_MOD()->ApplyRulerMetric( (FieldUnit)eHRulerUnit, sal_True, bWeb );
862         if(mbApplyVRulerMetric)
863             SW_MOD()->ApplyRulerMetric( (FieldUnit)eVRulerUnit, sal_False, bWeb );
864     }
865 
866 
867     SW_MOD()->ApplyUsrPref( *mpViewOption, pView, pView ? VIEWOPT_DEST_VIEW_ONLY
868 								  				: bWeb ? VIEWOPT_DEST_WEB
869 								  		 			   : VIEWOPT_DEST_TEXT );
870 
871 
872 	delete mpViewOption;
873 	mpViewOption = NULL;
874 }
875 
_preGetValues()876 void SwXViewSettings::_preGetValues ()
877 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
878 {
879 	if(pView)
880 	{
881 		if(!IsValid())
882 			return;
883 		mpConstViewOption = pView->GetWrtShell().GetViewOptions();
884 	}
885 	else
886 		mpConstViewOption = SW_MOD()->GetViewOption(bWeb);
887 }
_getSingleValue(const comphelper::PropertyInfo & rInfo,uno::Any & rValue)888 void SwXViewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
889 	throw(UnknownPropertyException, WrappedTargetException )
890 {
891 	sal_Bool bBool = sal_True;
892 	sal_Bool bBoolVal;
893 	switch( rInfo.mnHandle )
894 	{
895         case  HANDLE_VIEWSET_SHOW_RULER:                bBoolVal = mpConstViewOption->IsViewAnyRuler();   break;
896         case  HANDLE_VIEWSET_HRULER :                   bBoolVal = mpConstViewOption->IsViewHRuler(sal_True);   break;
897         case  HANDLE_VIEWSET_VRULER :                   bBoolVal = mpConstViewOption->IsViewVRuler(sal_True);break;
898         case  HANDLE_VIEWSET_VRULER_RIGHT          :   bBoolVal = mpConstViewOption->IsVRulerRight();break;
899         case  HANDLE_VIEWSET_HSCROLL:                   bBoolVal = mpConstViewOption->IsViewHScrollBar();break;
900 		case  HANDLE_VIEWSET_VSCROLL: 					bBoolVal = mpConstViewOption->IsViewVScrollBar();break;
901 		case  HANDLE_VIEWSET_GRAPHICS              :	bBoolVal = mpConstViewOption->IsGraphic();break;
902 		case  HANDLE_VIEWSET_TABLES                :   bBoolVal = mpConstViewOption->IsTable();	break;
903 		case  HANDLE_VIEWSET_DRAWINGS              :   bBoolVal = mpConstViewOption->IsDraw();	break;
904 		case  HANDLE_VIEWSET_FIELD_COMMANDS        :   bBoolVal = mpConstViewOption->IsFldName();	break;
905 		case  HANDLE_VIEWSET_ANNOTATIONS           :   bBoolVal = mpConstViewOption->IsPostIts();	break;
906         case  HANDLE_VIEWSET_INDEX_MARK_BACKGROUND :   bBoolVal = SwViewOption::IsFieldShadings();   break;
907         case  HANDLE_VIEWSET_NONPRINTING_CHARACTERS:   bBoolVal = mpConstViewOption->IsViewMetaChars(); break;
908         case  HANDLE_VIEWSET_FOOTNOTE_BACKGROUND   :   bBoolVal = SwViewOption::IsFieldShadings();  break;
909         case  HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND :   bBoolVal = SwViewOption::IsFieldShadings(); break;
910 		case  HANDLE_VIEWSET_PARA_BREAKS           :   bBoolVal = mpConstViewOption->IsParagraph(sal_True);	break;
911 		case  HANDLE_VIEWSET_SOFT_HYPHENS          :   bBoolVal = mpConstViewOption->IsSoftHyph();	break;
912 		case  HANDLE_VIEWSET_SPACES                :   bBoolVal = mpConstViewOption->IsBlank(sal_True);	break;
913 		case  HANDLE_VIEWSET_PROTECTED_SPACES      :   bBoolVal = mpConstViewOption->IsHardBlank();	break;
914 		case  HANDLE_VIEWSET_TABSTOPS              :   bBoolVal = mpConstViewOption->IsTab(sal_True);	break;
915 		case  HANDLE_VIEWSET_BREAKS                :   bBoolVal = mpConstViewOption->IsLineBreak(sal_True); break;
916         case  HANDLE_VIEWSET_HIDDEN_TEXT           :   bBoolVal = mpConstViewOption->IsShowHiddenField();   break;
917 		case  HANDLE_VIEWSET_HIDDEN_CHARACTERS     :   bBoolVal = mpConstViewOption->IsShowHiddenChar(sal_True); break;
918 		case  HANDLE_VIEWSET_HIDDEN_PARAGRAPHS     :   bBoolVal = mpConstViewOption->IsShowHiddenPara();	break;
919         case  HANDLE_VIEWSET_TABLE_BOUNDARIES      :   bBoolVal = SwViewOption::IsTableBoundaries(); break;
920         case  HANDLE_VIEWSET_TEXT_BOUNDARIES       :   bBoolVal = SwViewOption::IsDocBoundaries(); break;
921 		case  HANDLE_VIEWSET_SMOOTH_SCROLLING      :   bBoolVal = mpConstViewOption->IsSmoothScroll();	break;
922 		case  HANDLE_VIEWSET_SOLID_MARK_HANDLES    :   bBoolVal = mpConstViewOption->IsSolidMarkHdl();	break;
923         case  HANDLE_VIEWSET_SHOW_CONTENT_TIPS     :   bBoolVal = mpConstViewOption->IsShowContentTips(); break;
924         case  HANDLE_VIEWSET_IS_RASTER_VISIBLE     : bBoolVal = mpConstViewOption->IsGridVisible(); break;
925         case  HANDLE_VIEWSET_IS_SNAP_TO_RASTER     : bBoolVal = mpConstViewOption->IsSnap(); break;
926         case  HANDLE_VIEWSET_SCROLLBAR_TIPS        : bBoolVal = mpConstViewOption->IsShowScrollBarTips(); break;
927         case  HANDLE_VIEWSET_RASTER_RESOLUTION_X   :
928             bBool = sal_False;
929             rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Width());
930         break;
931         case  HANDLE_VIEWSET_RASTER_RESOLUTION_Y   :
932             bBool = sal_False;
933             rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Height());
934         break;
935         case  HANDLE_VIEWSET_RASTER_SUBDIVISION_X  :
936             bBool = sal_False;
937             rValue <<= (sal_Int32) mpConstViewOption->GetDivisionX();
938         break;
939         case  HANDLE_VIEWSET_RASTER_SUBDIVISION_Y  :
940             bBool = sal_False;
941             rValue <<= (sal_Int32) mpConstViewOption->GetDivisionY();
942         break;
943         case  HANDLE_VIEWSET_ZOOM                   :
944 				bBool = sal_False;
945 				rValue <<= (sal_Int16)mpConstViewOption->GetZoom();
946 		break;
947 		case HANDLE_VIEWSET_ZOOM_TYPE:
948 		{
949 			bBool = sal_False;
950             sal_Int16 nRet(0);
951             switch (mpConstViewOption->GetZoomType())
952             {
953                 case SVX_ZOOM_OPTIMAL:
954                     nRet = view::DocumentZoomType::OPTIMAL;
955                 break;
956                 case SVX_ZOOM_PAGEWIDTH:
957                     nRet = view::DocumentZoomType::PAGE_WIDTH;
958                 break;
959                 case SVX_ZOOM_WHOLEPAGE:
960                     nRet = view::DocumentZoomType::ENTIRE_PAGE;
961                 break;
962                 case SVX_ZOOM_PERCENT:
963                     nRet = view::DocumentZoomType::BY_VALUE;
964                 break;
965                 case SVX_ZOOM_PAGEWIDTH_NOBORDER:
966                     nRet = view::DocumentZoomType::PAGE_WIDTH_EXACT;
967                 break;
968                 default:
969                     OSL_ENSURE(false, "SwXViewSettings: invalid zoom type");
970                 break;
971             }
972             rValue <<= nRet;
973         }
974 		break;
975 		case HANDLE_VIEWSET_ONLINE_LAYOUT:
976 			if(pView)
977                 bBoolVal = pView->GetWrtShell().GetViewOptions()->getBrowseMode();
978 		break;
979 		case HANDLE_VIEWSET_HELP_URL :
980 		{
981 			if ( pView )
982 			{
983 				bBool = sal_False;
984 				OUStringBuffer sHelpURL;
985 				sHelpURL.appendAscii ( INET_HID_SCHEME );
986 				SwEditWin &rEditWin = pView->GetEditWin();
987 				sHelpURL.append( rtl::OStringToOUString( rEditWin.GetHelpId(), RTL_TEXTENCODING_UTF8 ) );
988 				rValue <<= sHelpURL.makeStringAndClear();
989 			}
990 			else
991 				throw UnknownPropertyException();
992 		}
993 		break;
994         case HANDLE_VIEWSET_HORI_RULER_METRIC:
995         {
996             if ( pView )
997             {
998                 FieldUnit eUnit;
999                 pView->GetHLinealMetric( eUnit );
1000                 rValue <<= (sal_Int32)eUnit;
1001             }
1002             else
1003             {
1004                 const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
1005                 rValue <<= (sal_Int32)pUsrPref->GetHScrollMetric();
1006             }
1007             bBool = sal_False;
1008         }
1009         break;
1010         case HANDLE_VIEWSET_VERT_RULER_METRIC:
1011         {
1012             if ( pView )
1013             {
1014                 FieldUnit eUnit;
1015                 pView->GetVLinealMetric( eUnit );
1016                 rValue <<= (sal_Int32)eUnit;
1017             }
1018             else
1019             {
1020                 const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
1021                 rValue <<= (sal_Int32)pUsrPref->GetVScrollMetric();
1022             }
1023             bBool = sal_False;
1024         }
1025         break;
1026 		default: DBG_ERROR("Diese Id gibt's nicht!");
1027 	}
1028 	if( bBool )
1029 		rValue.setValue(&bBoolVal, ::getBooleanCppuType());
1030 }
_postGetValues()1031 void SwXViewSettings::_postGetValues ()
1032 	throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
1033 {
1034 	mpConstViewOption = NULL;
1035 }
1036 
getImplementationName(void)1037 OUString SwXViewSettings::getImplementationName(void) throw( RuntimeException )
1038 {
1039 	return C2U("SwXViewSettings");
1040 }
1041 
supportsService(const OUString & rServiceName)1042 sal_Bool SwXViewSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
1043 {
1044 	return C2U("com.sun.star.text.ViewSettings") == rServiceName;
1045 }
1046 
getSupportedServiceNames(void)1047 Sequence< OUString > SwXViewSettings::getSupportedServiceNames(void) throw( RuntimeException )
1048 {
1049 	Sequence< OUString > aRet(1);
1050 	OUString* pArray = aRet.getArray();
1051 	pArray[0] = C2U("com.sun.star.text.ViewSettings");
1052 	return aRet;
1053 }
1054 
1055