Files
loongoffice/scaddins/source/datefunc/datefunc.cxx
Pedro Giffuni 820a29950b Many spelling fixes: directories r* - z*.
Attempt to clean up most but certainly not all the spelling
mistakes that found home in OpenOffice through decades. We
could probably blame the international nature of the code but
it is somewhat shameful that this wasn't done before.

(cherry picked from commit 28206a7cb43aff5adb10f8235ad1680c3941ee3e)

Conflicts:
	include/osl/file.hxx
	include/osl/pipe_decl.hxx
	include/osl/socket.h
	include/osl/socket_decl.hxx
	include/sal/main.h
	include/svx/dbaexchange.hxx
	include/svx/dlgctrl.hxx
	include/svx/msdffdef.hxx
	include/svx/sdr/contact/objectcontactofpageview.hxx
	include/svx/svdpntv.hxx
	include/ucbhelper/content.hxx
	include/ucbhelper/interceptedinteraction.hxx
	include/ucbhelper/resultsethelper.hxx
	include/unotools/sharedunocomponent.hxx
	include/unotools/viewoptions.hxx
	include/vcl/pdfwriter.hxx
	include/xmloff/txtparae.hxx
	include/xmloff/uniref.hxx
	rhino/rhino1_7R3.patch
	rsc/inc/rscrsc.hxx
	sal/inc/osl/conditn.h
	sal/inc/osl/security.h
	sal/inc/osl/semaphor.h
	sal/inc/osl/semaphor.hxx
	sal/inc/rtl/string.hxx
	sal/inc/rtl/tres.h
	sal/inc/systools/win32/StrConvert.h
	sal/osl/os2/file_path_helper.h
	sal/osl/os2/file_path_helper.hxx
	sal/osl/os2/file_url.cxx
	sal/osl/os2/file_url.h
	sal/osl/os2/makefile.mk
	sal/osl/os2/pipe.cxx
	sal/osl/os2/process.c
	sal/osl/os2/profile.c
	sal/osl/os2/socket.c
	sal/osl/os2/system.h
	sal/osl/unx/asm/interlck_sparc.s
	sal/osl/unx/file_url.cxx
	sal/osl/unx/signal.c
	sal/osl/unx/system.h
	sal/osl/w32/MAKEFILE.MK
	sal/osl/w32/interlck.c
	sal/osl/w32/module.cxx
	sal/osl/w32/security.c
	sal/qa/buildall.pl
	sal/qa/osl/file/osl_File.cxx
	sal/qa/osl/module/osl_Module_Const.h
	sal/qa/osl/mutex/osl_Mutex.cxx
	sal/qa/osl/pipe/osl_Pipe.cxx
	sal/qa/osl/process/osl_Thread.cxx
	sal/qa/osl/socket/osl_StreamSocket.cxx
	sal/qa/osl/socket/sockethelper.cxx
	sal/qa/rtl_strings/rtl_OUString.cxx
	sal/rtl/source/unload.cxx
	sal/systools/win32/kill/kill.cxx
	sal/systools/win32/uwinapi/MoveFileExA.cpp
	sal/test/bootstrap.pl
	sal/typesconfig/typesconfig.c
	sal/workben/tgetpwnam.cxx
	sax/inc/sax/parser/saxparser.hxx
	sc/addin/datefunc/dfa.cl
	sc/addin/datefunc/dfa.src
	sc/addin/rot13/rot13.cl
	sc/addin/rot13/rot13.src
	sc/inc/attarray.hxx
	sc/inc/chgtrack.hxx
	sc/inc/column.hxx
	sc/inc/compressedarray.hxx
	sc/inc/document.hxx
	sc/inc/table.hxx
	sc/source/core/data/column.cxx
	sc/source/core/data/dptablecache.cxx
	sc/source/core/data/dptabres.cxx
	sc/source/core/data/dptabsrc.cxx
	sc/source/core/data/global.cxx
	sc/source/core/tool/chgtrack.cxx
	sc/source/core/tool/compiler.cxx
	sc/source/filter/excel/xestyle.cxx
	sc/source/filter/excel/xichart.cxx
	sc/source/filter/inc/fapihelper.hxx
	sc/source/filter/inc/xistyle.hxx
	sc/source/filter/xml/xmlsubti.cxx
	sc/source/ui/Accessibility/AccessibleCell.cxx
	sc/source/ui/Accessibility/AccessibleContextBase.cxx
	sc/source/ui/Accessibility/AccessibleDataPilotControl.cxx
	sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
	sc/source/ui/Accessibility/AccessibleEditObject.cxx
	sc/source/ui/Accessibility/AccessiblePreviewCell.cxx
	sc/source/ui/app/inputwin.cxx
	sc/source/ui/docshell/docfunc.cxx
	sc/source/ui/drawfunc/fupoor.cxx
	sc/source/ui/miscdlgs/linkarea.cxx
	sc/source/ui/unoobj/chart2uno.cxx
	sc/source/ui/unoobj/nameuno.cxx
	sc/source/ui/vba/vbacharacters.hxx
	sc/source/ui/vba/vbarange.cxx
	sc/source/ui/vba/vbawindow.cxx
	scaddins/source/analysis/analysishelper.cxx
	scaddins/source/analysis/analysishelper.hxx
	scaddins/source/datefunc/datefunc.cxx
	scripting/examples/python/Capitalise.py
	scripting/source/pyprov/officehelper.py
	sd/source/filter/eppt/eppt.cxx
	sd/source/filter/eppt/epptso.cxx
	sd/source/ui/dlg/prltempl.cxx
	sd/source/ui/dlg/tpoption.cxx
	sd/source/ui/func/fuediglu.cxx
	sd/source/ui/func/fupoor.cxx
	sd/source/ui/func/fusel.cxx
	sd/source/ui/func/smarttag.cxx
	sd/source/ui/inc/OutlinerIteratorImpl.hxx
	sd/source/ui/inc/SlideViewShell.hxx
	sd/source/ui/inc/fuediglu.hxx
	sd/source/ui/inc/fusel.hxx
	sd/source/ui/slideshow/slideshowimpl.cxx
	sd/source/ui/slidesorter/cache/SlsQueueProcessorThread.hxx
	sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx
	sd/source/ui/slidesorter/controller/SlsSelectionCommand.hxx
	sd/source/ui/slidesorter/inc/controller/SlsAnimationFunction.hxx
	sd/source/ui/slidesorter/view/SlsButtonBar.cxx
	sd/source/ui/view/Outliner.cxx
	sd/source/ui/view/drviewsh.cxx
	sd/source/ui/view/frmview.cxx
	sdext/source/presenter/PresenterFrameworkObserver.hxx
	sdext/source/presenter/PresenterSlideShowView.cxx
	setup_native/scripts/deregister_extensions
	setup_native/scripts/register_extensions
	setup_native/source/opensolaris/bundledextensions/README
	setup_native/source/opensolaris/bundledextensions/svc-ooo_bundled_extensions
	setup_native/source/win32/customactions/patch/swappatchfiles.cxx
	setup_native/source/win32/customactions/reg4msdoc/registrar.cxx
	setup_native/source/win32/customactions/reg4msdoc/userregistrar.cxx
	sfx2/inc/sfx2/sfxbasemodel.hxx
	sfx2/qa/complex/sfx2/DocumentProperties.java
	sfx2/source/appl/appopen.cxx
	sfx2/source/appl/appquit.cxx
	sfx2/source/appl/appserv.cxx
	sfx2/source/bastyp/sfxhtml.cxx
	sfx2/source/dialog/dockwin.cxx
	sfx2/source/doc/docfile.cxx
	sfx2/source/doc/docvor.cxx
	sfx2/source/doc/graphhelp.cxx
	sfx2/source/doc/objcont.cxx
	sfx2/source/doc/objserv.cxx
	sfx2/source/doc/objstor.cxx
	sfx2/source/doc/objuno.cxx
	sfx2/source/doc/objxtor.cxx
	sfx2/source/doc/printhelper.cxx
	sfx2/source/doc/sfxbasemodel.cxx
	sfx2/source/notify/eventsupplier.cxx
	sfx2/source/view/frmload.cxx
	sfx2/source/view/sfxbasecontroller.cxx
	shell/qa/zip/ziptest.cxx
	shell/source/backends/wininetbe/wininetbackend.cxx
	shell/source/win32/shlxthandler/util/utilities.cxx
	solenv/bin/build.pl
	solenv/bin/build_release.pl
	solenv/bin/cws.pl
	solenv/bin/download_external_dependencies.pl
	solenv/bin/make_download.pl
	solenv/bin/make_installer.pl
	solenv/bin/modules/Cws.pm
	solenv/bin/modules/ExtensionsLst.pm
	solenv/bin/modules/installer/control.pm
	solenv/bin/modules/installer/downloadsigner.pm
	solenv/bin/modules/installer/javainstaller.pm
	solenv/bin/modules/installer/packagepool.pm
	solenv/bin/modules/installer/patch/InstallationSet.pm
	solenv/bin/modules/installer/scriptitems.pm
	solenv/bin/modules/installer/windows/feature.pm
	solenv/bin/modules/installer/windows/msiglobal.pm
	solenv/bin/modules/installer/windows/sign.pm
	solenv/bin/modules/installer/worker.pm
	solenv/bin/modules/installer/xpdinstaller.pm
	solenv/bin/modules/osarch.pm
	solenv/bin/modules/packager/work.pm
	solenv/bin/modules/pre2par/parameter.pm
	solenv/bin/patch_tool.pl
	solenv/bin/transform_description.pl
	solenv/doc/gbuild/doxygen.cfg
	solenv/gbuild/LinkTarget.mk
	solenv/gbuild/gbuild.mk
	solenv/inc/os2gcci.mk
	solenv/inc/settings.mk
	solenv/inc/startup/Readme
	solenv/inc/target.mk
	solenv/inc/tg_compv.mk
	solenv/inc/tg_javav.mk
	solenv/inc/unitools.mk
	solenv/inc/unxbsdi.mk
	solenv/inc/unxbsdi2.mk
	solenv/inc/unxbsds.mk
	solenv/inc/unxfbsd.mk
	solenv/inc/unxlng.mk
	sot/source/sdstor/stg.cxx
	sot/source/sdstor/stgelem.cxx
	sot/source/sdstor/ucbstorage.cxx
	starmath/inc/toolbox.hxx
	starmath/source/mathmlexport.cxx
	starmath/source/node.cxx
	starmath/source/toolbox.cxx
	starmath/source/view.cxx
	stoc/source/bootstrap/bootstrap.xml
	stoc/source/corereflection/criface.cxx
	stoc/source/invocation/invocation.cxx
	stoc/source/security/access_controller.cxx
	stoc/source/servicemanager/servicemanager.cxx
	stoc/source/tdmanager/tdmgr.cxx
	stoc/test/javavm/testjavavm.cxx
	stoc/test/testconv.cxx
	stoc/test/testcorefl.cxx
	stoc/test/testintrosp.cxx
	svl/inc/svl/inettype.hxx
	svl/inc/svl/urihelper.hxx
	svl/qa/complex/ConfigItems/helper/HistoryOptTest.cxx
	svl/qa/complex/ConfigItems/helper/HistoryOptTest.hxx
	svl/source/config/itemholder2.hxx
	svl/source/items/itemset.cxx
	svl/source/numbers/zforlist.cxx
	svl/source/numbers/zformat.cxx
	svl/source/numbers/zforscan.cxx
	svtools/bmpmaker/bmp.cxx
	svtools/inc/svtools/helpagentwindow.hxx
	svtools/inc/svtools/menuoptions.hxx
	svtools/inc/svtools/miscopt.hxx
	svtools/inc/svtools/optionsdrawinglayer.hxx
	svtools/inc/svtools/stringtransfer.hxx
	svtools/inc/svtools/svlbitm.hxx
	svtools/inc/svtools/svtdata.hxx
	svtools/inc/svtools/valueset.hxx
	svtools/source/brwbox/editbrowsebox.cxx
	svtools/source/config/itemholder2.hxx
	svtools/source/contnr/contentenumeration.hxx
	svx/inc/svx/fmsrcimp.hxx
	svx/inc/svx/svdobj.hxx
	svx/inc/svx/xtable.hxx
	svx/source/accessibility/DGColorNameLookUp.cxx
	svx/source/accessibility/svxrectctaccessiblecontext.cxx
	svx/source/dialog/pfiledlg.cxx
	svx/source/fmcomp/fmgridcl.cxx
	svx/source/fmcomp/fmgridif.cxx
	svx/source/fmcomp/gridctrl.cxx
	svx/source/form/filtnav.cxx
	svx/source/form/fmPropBrw.cxx
	svx/source/form/fmshimp.cxx
	svx/source/form/fmsrcimp.cxx
	svx/source/gallery2/galtheme.cxx
	svx/source/inc/docrecovery.hxx
	svx/source/sdr/event/eventhandler.cxx
	svx/source/svdraw/svdedtv2.cxx
	svx/source/svdraw/svdedxv.cxx
	svx/source/svdraw/svdhdl.cxx
	svx/source/svdraw/svdobj.cxx
	svx/source/svdraw/svdograf.cxx
	svx/source/svdraw/svdoole2.cxx
	svx/source/svdraw/svdotxtr.cxx
	svx/source/svdraw/svdundo.cxx
	svx/source/svdraw/svdxcgv.cxx
	svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.cxx
	sw/inc/SwNumberTree.hxx
	sw/inc/ndnotxt.hxx
	sw/source/core/access/acccell.cxx
	sw/source/core/access/acccell.hxx
	sw/source/core/access/accframebase.cxx
	sw/source/core/access/accframebase.hxx
	sw/source/core/access/accmap.cxx
	sw/source/core/access/accpage.cxx
	sw/source/core/access/accpage.hxx
	sw/source/core/access/accpara.cxx
	sw/source/core/access/accpara.hxx
	sw/source/core/bastyp/swrect.cxx
	sw/source/core/crsr/findtxt.cxx
	sw/source/core/doc/docdde.cxx
	sw/source/core/doc/notxtfrm.cxx
	sw/source/core/docnode/section.cxx
	sw/source/core/draw/dcontact.cxx
	sw/source/core/edit/edlingu.cxx
	sw/source/core/inc/anchoredobjectposition.hxx
	sw/source/core/layout/paintfrm.cxx
	sw/source/core/layout/tabfrm.cxx
	sw/source/core/layout/trvlfrm.cxx
	sw/source/core/ole/ndole.cxx
	sw/source/core/text/atrstck.cxx
	sw/source/core/text/inftxt.cxx
	sw/source/core/text/itratr.cxx
	sw/source/core/text/itrform2.cxx
	sw/source/core/text/itrform2.hxx
	sw/source/core/text/porfld.cxx
	sw/source/core/text/txtfly.cxx
	sw/source/core/txtnode/thints.cxx
	sw/source/core/txtnode/txtedt.cxx
	sw/source/core/uibase/dochdl/swdtflvr.cxx
	sw/source/core/uibase/docvw/PostItMgr.cxx
	sw/source/core/uibase/docvw/SidebarWin.cxx
	sw/source/core/uibase/docvw/edtwin.cxx
	sw/source/core/uibase/envelp/labimg.cxx
	sw/source/core/uibase/uiview/pview.cxx
	sw/source/core/uibase/uno/unomailmerge.cxx
	sw/source/core/undo/unattr.cxx
	sw/source/core/undo/untbl.cxx
	sw/source/core/unocore/unochart.cxx
	sw/source/core/view/vdraw.cxx
	sw/source/core/view/vnew.cxx
	sw/source/filter/basflt/fltini.cxx
	sw/source/filter/html/wrthtml.cxx
	sw/source/filter/inc/wwstyles.hxx
	sw/source/filter/rtf/rtffly.cxx
	sw/source/filter/rtf/swparrtf.cxx
	sw/source/filter/ww8/docxattributeoutput.cxx
	sw/source/filter/ww8/dump/msvbasic.cxx
	sw/source/filter/ww8/dump/ww8scan.cxx
	sw/source/filter/ww8/dump/ww8scan.hxx
	sw/source/filter/ww8/dump/ww8struc.hxx
	sw/source/filter/ww8/wrtww8.cxx
	sw/source/filter/ww8/ww8graf.cxx
	sw/source/filter/ww8/ww8par.cxx
	sw/source/filter/ww8/ww8par2.cxx
	sw/source/filter/ww8/ww8par2.hxx
	sw/source/filter/ww8/ww8par3.cxx
	sw/source/filter/ww8/ww8par6.cxx
	sw/source/filter/ww8/ww8scan.cxx
	sw/source/filter/ww8/ww8scan.hxx
	sw/source/ui/dbui/dbinsdlg.cxx
	sw/source/ui/inc/tablemgr.hxx
	sw/source/ui/inc/uitool.hxx
	sw/source/ui/lingu/olmenu.cxx
	sw/source/ui/uiview/viewport.cxx
	sysui/desktop/productversion.mk
	sysui/desktop/slackware/makefile.mk
	testgraphical/source/CallExternals.pm
	testgraphical/source/fill_documents_loop.pl
	testgraphical/ui/java/ConvwatchGUIProject/src/IniFile.java
	toolkit/doc/layout/notes.txt
	toolkit/doc/layout/oldnotes.txt
	toolkit/source/awt/vclxtabcontrol.cxx
	toolkit/src2xml/source/srcparser.py
	toolkit/workben/layout/editor.cxx
	tools/inc/tools/simplerm.hxx
	tools/inc/tools/solar.h
	tools/source/communi/geninfo.cxx
	tools/source/fsys/dirent.cxx
	tools/source/fsys/filecopy.cxx
	tools/source/fsys/os2.cxx
	tools/source/inet/inetmime.cxx
	tools/source/rc/resmgr.cxx
	ucb/source/core/ucbcmds.cxx
	ucb/source/ucp/file/filglob.cxx
	ucb/source/ucp/odma/odma_content.cxx
	ucb/source/ucp/tdoc/ucptdoc.xml
	ucb/source/ucp/webdav/makefile.mk
	ucbhelper/inc/ucbhelper/simplecertificatevalidationrequest.hxx
	ucbhelper/source/client/content.cxx
	ucbhelper/source/client/interceptedinteraction.cxx
	udkapi/com/sun/star/beans/XPropertiesChangeListener.idl
	udkapi/com/sun/star/io/ObjectOutputStream.idl
	udkapi/com/sun/star/io/XMarkableStream.idl
	udkapi/com/sun/star/io/XTextOutputStream.idl
	udkapi/com/sun/star/reflection/CoreReflection.idl
	udkapi/com/sun/star/reflection/XTypeDescriptionEnumerationAccess.idl
	udkapi/com/sun/star/test/XSimpleTest.idl
	unodevtools/source/skeletonmaker/skeletoncommon.cxx
	unodevtools/source/skeletonmaker/skeletoncommon.hxx
	unotools/inc/unotools/cacheoptions.hxx
	unotools/inc/unotools/cmdoptions.hxx
	unotools/inc/unotools/dynamicmenuoptions.hxx
	unotools/inc/unotools/extendedsecurityoptions.hxx
	unotools/inc/unotools/fontoptions.hxx
	unotools/inc/unotools/historyoptions.hxx
	unotools/inc/unotools/idhelper.hxx
	unotools/inc/unotools/internaloptions.hxx
	unotools/inc/unotools/localisationoptions.hxx
	unotools/inc/unotools/moduleoptions.hxx
	unotools/inc/unotools/printwarningoptions.hxx
	unotools/inc/unotools/securityoptions.hxx
	unotools/inc/unotools/startoptions.hxx
	unotools/inc/unotools/workingsetoptions.hxx
	unotools/source/config/cmdoptions.cxx
	unotools/source/config/compatibility.cxx
	unotools/source/config/configitem.cxx
	unotools/source/config/configmgr.cxx
	unotools/source/config/dynamicmenuoptions.cxx
	unotools/source/config/fontcfg.cxx
	unotools/source/config/itemholder1.hxx
	unotools/source/config/moduleoptions.cxx
	unotools/source/config/pathoptions.cxx
	unotools/source/config/viewoptions.cxx
	unotools/source/misc/sharedunocomponent.cxx
	uui/source/fltdlg.cxx
	uui/source/iahndl-filter.cxx
	vbahelper/inc/vbahelper/collectionbase.hxx
	vbahelper/source/msforms/vbacontrol.cxx
	vbahelper/source/vbahelper/collectionbase.cxx
	vcl/aqua/source/gdi/atsfonts.cxx
	vcl/inc/aqua/salmathutils.hxx
	vcl/inc/graphite_cache.hxx
	vcl/inc/jobset.h
	vcl/inc/os2/salgdi.h
	vcl/inc/osx/saldata.hxx
	vcl/inc/salgdi.hxx
	vcl/inc/salwtype.hxx
	vcl/inc/unx/wmadaptor.hxx
	vcl/inc/vcl/print.hxx
	vcl/inc/vcl/strhelper.hxx
	vcl/os2/source/app/salinst.cxx
	vcl/os2/source/app/saltimer.cxx
	vcl/os2/source/gdi/salgdi2.cxx
	vcl/osx/salframeview.mm
	vcl/osx/salprn.cxx
	vcl/qa/cppunit/dndtest.cxx
	vcl/source/app/dbggui.cxx
	vcl/source/control/ilstbox.cxx
	vcl/source/gdi/cvtsvm.cxx
	vcl/source/gdi/gdimtf.cxx
	vcl/source/gdi/outdev4.cxx
	vcl/source/gdi/outdev6.cxx
	vcl/source/gdi/pdfwriter_impl.cxx
	vcl/source/gdi/pdfwriter_impl2.cxx
	vcl/source/gdi/print.cxx
	vcl/source/gdi/print2.cxx
	vcl/source/glyphs/gcach_layout.cxx
	vcl/source/glyphs/glyphcache.cxx
	vcl/source/glyphs/graphite_layout.cxx
	vcl/source/window/printdlg.cxx
	vcl/source/window/tabdlg.cxx
	vcl/source/window/window.cxx
	vcl/source/window/winproc.cxx
	vcl/unx/generic/app/saldisp.cxx
	vcl/unx/generic/dtrans/X11_selection.hxx
	vcl/unx/gtk/app/gtkdata.cxx
	vcl/win/source/gdi/salgdi2.cxx
	vcl/win/source/gdi/salgdi3.cxx
	vcl/win/source/window/salframe.cxx
	vos/inc/vos/pipe.hxx
	vos/inc/vos/process.hxx
	vos/inc/vos/signal.hxx
	vos/inc/vos/socket.hxx
	vos/inc/vos/thread.hxx
	vos/source/pipe.cxx
	vos/source/socket.cxx
	wizards/com/sun/star/wizards/agenda/AgendaTemplate.java
	wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java
	wizards/com/sun/star/wizards/agenda/TopicsControl.java
	wizards/com/sun/star/wizards/web/FTPDialog.java
	wizards/com/sun/star/wizards/web/ImageListDialog.java
	wizards/com/sun/star/wizards/web/Process.java
	wizards/com/sun/star/wizards/web/ProcessStatusRenderer.java
	wizards/com/sun/star/wizards/web/TOCPreview.java
	wizards/com/sun/star/wizards/web/WWD_Startup.java
	wizards/com/sun/star/wizards/web/data/TypeDetection.java
	wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.java
	writerfilter/inc/doctok/WW8Document.hxx
	writerfilter/source/dmapper/DomainMapper.cxx
	writerfilter/source/dmapper/NumberingManager.cxx
	writerfilter/source/dmapper/PropertyMap.cxx
	writerfilter/source/dmapper/StyleSheetTable.cxx
	writerfilter/source/doctok/WW8StructBase.hxx
	writerfilter/source/doctok/resources.xmi
	writerfilter/source/ooxml/README.efforts
	xmerge/source/activesync/XMergeFilter.cpp
	xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java
	xmerge/source/palmtests/qa/comparator/pdbcomparison.java
	xmerge/source/palmtests/qa/test_spec/convertor_test_spec.html
	xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java
	xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java
	xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java
	xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java
	xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java
	xmerge/workben/jstyle.pl
	xmlhelp/source/cxxhelp/provider/databases.hxx
	xmlhelp/source/cxxhelp/provider/provider.cxx
	xmlhelp/source/treeview/tvread.cxx
	xmloff/inc/txtfldi.hxx
	xmloff/inc/xmloff/xmlmultiimagehelper.hxx
	xmloff/inc/xmloff/xmluconv.hxx
	xmloff/source/core/xmlexp.cxx
	xmloff/source/draw/shapeexport2.cxx
	xmloff/source/draw/shapeexport3.cxx
	xmloff/source/meta/xmlversion.cxx
	xmloff/source/style/impastp4.cxx
	xmloff/source/style/xmlaustp.cxx
	xmloff/source/text/XMLSectionExport.cxx
	xmloff/source/text/txtflde.cxx
	xmloff/source/text/txtimp.cxx
	xmloff/source/text/txtparae.cxx
	xmloff/source/text/txtparai.cxx
	xmloff/source/text/txtvfldi.cxx
	xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx

Change-Id: Ie072e7c3a60c5dae16a67ac36d1f372c5065c99c
2014-05-01 08:59:14 +01:00

864 lines
25 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "datefunc.hxx"
#include "datefunc.hrc"
#include <com/sun/star/util/Date.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
#include <tools/rcid.h>
#include <tools/resmgr.hxx>
using namespace ::com::sun::star;
using namespace ::rtl;
#define ADDIN_SERVICE "com.sun.star.sheet.AddIn"
#define MY_SERVICE "com.sun.star.sheet.addin.DateFunctions"
#define MY_IMPLNAME "com.sun.star.sheet.addin.DateFunctionsImpl"
#define STR_FROM_ANSI( s ) OUString( s, strlen( s ), RTL_TEXTENCODING_MS_1252 )
const sal_uInt32 ScaList::nStartSize = 16;
const sal_uInt32 ScaList::nIncrSize = 16;
ScaList::ScaList() :
pData( new void*[ nStartSize ] ),
nSize( nStartSize ),
nCount( 0 ),
nCurr( 0 )
{
}
ScaList::~ScaList()
{
delete[] pData;
}
void ScaList::_Grow()
{
nSize += nIncrSize;
void** pNewData = new void*[ nSize ];
memcpy( pNewData, pData, nCount * sizeof( void* ) );
delete[] pData;
pData = pNewData;
}
ScaStringList::~ScaStringList()
{
for( OUString* pStr = First(); pStr; pStr = Next() )
delete pStr;
}
ScaResId::ScaResId( sal_uInt16 nId, ResMgr& rResMgr ) :
ResId( nId, rResMgr )
{
}
#define UNIQUE false // function name does not exist in Calc
#define STDPAR false // all parameters are described
#define INTPAR true // first parameter is internal
#define FUNCDATA( FuncName, ParamCount, Category, Double, IntPar ) \
{ "get" #FuncName, DATE_FUNCNAME_##FuncName, DATE_FUNCDESC_##FuncName, DATE_DEFFUNCNAME_##FuncName, ParamCount, Category, Double, IntPar }
const ScaFuncDataBase pFuncDataArr[] =
{
FUNCDATA( DiffWeeks, 3, ScaCat_DateTime, UNIQUE, INTPAR ),
FUNCDATA( DiffMonths, 3, ScaCat_DateTime, UNIQUE, INTPAR ),
FUNCDATA( DiffYears, 3, ScaCat_DateTime, UNIQUE, INTPAR ),
FUNCDATA( IsLeapYear, 1, ScaCat_DateTime, UNIQUE, INTPAR ),
FUNCDATA( DaysInMonth, 1, ScaCat_DateTime, UNIQUE, INTPAR ),
FUNCDATA( DaysInYear, 1, ScaCat_DateTime, UNIQUE, INTPAR ),
FUNCDATA( WeeksInYear, 1, ScaCat_DateTime, UNIQUE, INTPAR ),
FUNCDATA( Rot13, 1, ScaCat_Text, UNIQUE, STDPAR )
};
#undef FUNCDATA
ScaFuncData::ScaFuncData( const ScaFuncDataBase& rBaseData, ResMgr& rResMgr ) :
aIntName( OUString::createFromAscii( rBaseData.pIntName ) ),
nUINameID( rBaseData.nUINameID ),
nDescrID( rBaseData.nDescrID ),
nCompListID( rBaseData.nCompListID ),
nParamCount( rBaseData.nParamCount ),
eCat( rBaseData.eCat ),
bDouble( rBaseData.bDouble ),
bWithOpt( rBaseData.bWithOpt )
{
ScaResStringArrLoader aArrLoader( RID_DATE_DEFFUNCTION_NAMES, nCompListID, rResMgr );
const ResStringArray& rArr = aArrLoader.GetStringArray();
for( sal_uInt16 nIndex = 0; nIndex < rArr.Count(); nIndex++ )
aCompList.Append( rArr.GetString( nIndex ) );
}
ScaFuncData::~ScaFuncData()
{
}
sal_uInt16 ScaFuncData::GetStrIndex( sal_uInt16 nParam ) const
{
if( !bWithOpt )
nParam++;
return (nParam > nParamCount) ? (nParamCount * 2) : (nParam * 2);
}
ScaFuncDataList::ScaFuncDataList( ResMgr& rResMgr ) :
nLast( 0xFFFFFFFF )
{
for( sal_uInt16 nIndex = 0; nIndex < SAL_N_ELEMENTS(pFuncDataArr); nIndex++ )
Append( new ScaFuncData( pFuncDataArr[ nIndex ], rResMgr ) );
}
ScaFuncDataList::~ScaFuncDataList()
{
for( ScaFuncData* pFData = First(); pFData; pFData = Next() )
delete pFData;
}
const ScaFuncData* ScaFuncDataList::Get( const OUString& rProgrammaticName ) const
{
if( aLastName == rProgrammaticName )
return Get( nLast );
for( sal_uInt32 nIndex = 0; nIndex < Count(); nIndex++ )
{
const ScaFuncData* pCurr = Get( nIndex );
if( pCurr->Is( rProgrammaticName ) )
{
const_cast< ScaFuncDataList* >( this )->aLastName = rProgrammaticName;
const_cast< ScaFuncDataList* >( this )->nLast = nIndex;
return pCurr;
}
}
return NULL;
}
ScaFuncRes::ScaFuncRes( ResId& rResId, ResMgr& rResMgr, sal_uInt16 nIndex, OUString& rRet ) :
Resource( rResId )
{
rRet = ScaResId(nIndex, rResMgr).toString();
FreeResource();
}
// entry points for service registration / instantiation
uno::Reference< uno::XInterface > SAL_CALL ScaDateAddIn_CreateInstance(
const uno::Reference< lang::XMultiServiceFactory >& )
{
static uno::Reference< uno::XInterface > xInst = (cppu::OWeakObject*) new ScaDateAddIn();
return xInst;
}
extern "C" {
SAL_DLLPUBLIC_EXPORT void * SAL_CALL date_component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
{
void* pRet = 0;
if ( pServiceManager &&
OUString::createFromAscii( pImplName ) == ScaDateAddIn::getImplementationName_Static() )
{
uno::Reference< lang::XSingleServiceFactory > xFactory( cppu::createOneInstanceFactory(
reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
ScaDateAddIn::getImplementationName_Static(),
ScaDateAddIn_CreateInstance,
ScaDateAddIn::getSupportedServiceNames_Static() ) );
if (xFactory.is())
{
xFactory->acquire();
pRet = xFactory.get();
}
}
return pRet;
}
} // extern C
// "normal" service implementation
ScaDateAddIn::ScaDateAddIn() :
pDefLocales( NULL ),
pResMgr( NULL ),
pFuncDataList( NULL )
{
}
ScaDateAddIn::~ScaDateAddIn()
{
if( pFuncDataList )
delete pFuncDataList;
if( pDefLocales )
delete[] pDefLocales;
// pResMgr already deleted (_all_ resource managers are deleted _before_ this dtor is called)
}
static const sal_Char* pLang[] = { "de", "en" };
static const sal_Char* pCoun[] = { "DE", "US" };
static const sal_uInt32 nNumOfLoc = SAL_N_ELEMENTS( pLang );
void ScaDateAddIn::InitDefLocales()
{
pDefLocales = new lang::Locale[ nNumOfLoc ];
for( sal_uInt32 nIndex = 0; nIndex < nNumOfLoc; nIndex++ )
{
pDefLocales[ nIndex ].Language = OUString::createFromAscii( pLang[ nIndex ] );
pDefLocales[ nIndex ].Country = OUString::createFromAscii( pCoun[ nIndex ] );
}
}
const lang::Locale& ScaDateAddIn::GetLocale( sal_uInt32 nIndex )
{
if( !pDefLocales )
InitDefLocales();
return (nIndex < sizeof( pLang )) ? pDefLocales[ nIndex ] : aFuncLoc;
}
ResMgr& ScaDateAddIn::GetResMgr() throw( uno::RuntimeException )
{
if( !pResMgr )
{
InitData(); // try to get resource manager
if( !pResMgr )
throw uno::RuntimeException();
}
return *pResMgr;
}
void ScaDateAddIn::InitData()
{
if( pResMgr )
delete pResMgr;
OString aModName( "date" );
pResMgr = ResMgr::CreateResMgr( aModName.getStr(), LanguageTag( aFuncLoc) );
if( pFuncDataList )
delete pFuncDataList;
pFuncDataList = pResMgr ? new ScaFuncDataList( *pResMgr ) : NULL;
if( pDefLocales )
{
delete pDefLocales;
pDefLocales = NULL;
}
}
OUString ScaDateAddIn::GetDisplFuncStr( sal_uInt16 nResId ) throw( uno::RuntimeException )
{
return ScaResStringLoader( RID_DATE_FUNCTION_NAMES, nResId, GetResMgr() ).GetString();
}
OUString ScaDateAddIn::GetFuncDescrStr( sal_uInt16 nResId, sal_uInt16 nStrIndex ) throw( uno::RuntimeException )
{
OUString aRet;
ScaResPublisher aResPubl( ScaResId( RID_DATE_FUNCTION_DESCRIPTIONS, GetResMgr() ) );
ScaResId aResId( nResId, GetResMgr() );
aResId.SetRT( RSC_RESOURCE );
if( aResPubl.IsAvailableRes( aResId ) )
ScaFuncRes aSubRes( aResId, GetResMgr(), nStrIndex, aRet );
aResPubl.FreeResource();
return aRet;
}
OUString ScaDateAddIn::getImplementationName_Static()
{
return OUString( MY_IMPLNAME );
}
uno::Sequence< OUString > ScaDateAddIn::getSupportedServiceNames_Static()
{
uno::Sequence< OUString > aRet( 2 );
OUString* pArray = aRet.getArray();
pArray[0] = OUString( ADDIN_SERVICE );
pArray[1] = OUString( MY_SERVICE );
return aRet;
}
// XServiceName
OUString SAL_CALL ScaDateAddIn::getServiceName() throw( uno::RuntimeException, std::exception )
{
// name of specific AddIn service
return OUString( MY_SERVICE );
}
// XServiceInfo
OUString SAL_CALL ScaDateAddIn::getImplementationName() throw( uno::RuntimeException, std::exception )
{
return getImplementationName_Static();
}
sal_Bool SAL_CALL ScaDateAddIn::supportsService( const OUString& aServiceName ) throw( uno::RuntimeException, std::exception )
{
return cppu::supportsService(this, aServiceName);
}
uno::Sequence< OUString > SAL_CALL ScaDateAddIn::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
{
return getSupportedServiceNames_Static();
}
// XLocalizable
void SAL_CALL ScaDateAddIn::setLocale( const lang::Locale& eLocale ) throw( uno::RuntimeException, std::exception )
{
aFuncLoc = eLocale;
InitData(); // change of locale invalidates resources!
}
lang::Locale SAL_CALL ScaDateAddIn::getLocale() throw( uno::RuntimeException, std::exception )
{
return aFuncLoc;
}
OUString SAL_CALL ScaDateAddIn::getProgrammaticFuntionName( const OUString& ) throw( uno::RuntimeException, std::exception )
{
// not used by calc
// (but should be implemented for other uses of the AddIn service)
return OUString();
}
OUString SAL_CALL ScaDateAddIn::getDisplayFunctionName( const OUString& aProgrammaticName ) throw( uno::RuntimeException, std::exception )
{
OUString aRet;
const ScaFuncData* pFData = pFuncDataList->Get( aProgrammaticName );
if( pFData )
{
aRet = GetDisplFuncStr( pFData->GetUINameID() );
if( pFData->IsDouble() )
aRet += STR_FROM_ANSI( "_ADD" );
}
else
{
aRet = STR_FROM_ANSI( "UNKNOWNFUNC_" );
aRet += aProgrammaticName;
}
return aRet;
}
OUString SAL_CALL ScaDateAddIn::getFunctionDescription( const OUString& aProgrammaticName ) throw( uno::RuntimeException, std::exception )
{
OUString aRet;
const ScaFuncData* pFData = pFuncDataList->Get( aProgrammaticName );
if( pFData )
aRet = GetFuncDescrStr( pFData->GetDescrID(), 1 );
return aRet;
}
OUString SAL_CALL ScaDateAddIn::getDisplayArgumentName(
const OUString& aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException, std::exception )
{
OUString aRet;
const ScaFuncData* pFData = pFuncDataList->Get( aProgrammaticName );
if( pFData && (nArgument <= 0xFFFF) )
{
sal_uInt16 nStr = pFData->GetStrIndex( static_cast< sal_uInt16 >( nArgument ) );
if( nStr )
aRet = GetFuncDescrStr( pFData->GetDescrID(), nStr );
else
aRet = STR_FROM_ANSI( "internal" );
}
return aRet;
}
OUString SAL_CALL ScaDateAddIn::getArgumentDescription(
const OUString& aProgrammaticName, sal_Int32 nArgument ) throw( uno::RuntimeException, std::exception )
{
OUString aRet;
const ScaFuncData* pFData = pFuncDataList->Get( aProgrammaticName );
if( pFData && (nArgument <= 0xFFFF) )
{
sal_uInt16 nStr = pFData->GetStrIndex( static_cast< sal_uInt16 >( nArgument ) );
if( nStr )
aRet = GetFuncDescrStr( pFData->GetDescrID(), nStr + 1 );
else
aRet = STR_FROM_ANSI( "for internal use only" );
}
return aRet;
}
OUString SAL_CALL ScaDateAddIn::getProgrammaticCategoryName(
const OUString& aProgrammaticName ) throw( uno::RuntimeException, std::exception )
{
OUString aRet;
const ScaFuncData* pFData = pFuncDataList->Get( aProgrammaticName );
if( pFData )
{
switch( pFData->GetCategory() )
{
case ScaCat_DateTime: aRet = STR_FROM_ANSI( "Date&Time" ); break;
case ScaCat_Text: aRet = STR_FROM_ANSI( "Text" ); break;
case ScaCat_Finance: aRet = STR_FROM_ANSI( "Financial" ); break;
case ScaCat_Inf: aRet = STR_FROM_ANSI( "Information" ); break;
case ScaCat_Math: aRet = STR_FROM_ANSI( "Mathematical" ); break;
case ScaCat_Tech: aRet = STR_FROM_ANSI( "Technical" ); break;
default: // to prevent compiler warnings
break;
}
}
if( aRet.isEmpty() )
aRet = STR_FROM_ANSI( "Add-In" );
return aRet;
}
OUString SAL_CALL ScaDateAddIn::getDisplayCategoryName(
const OUString& aProgrammaticName ) throw( uno::RuntimeException, std::exception )
{
return getProgrammaticCategoryName( aProgrammaticName );
}
// XCompatibilityNames
uno::Sequence< sheet::LocalizedName > SAL_CALL ScaDateAddIn::getCompatibilityNames(
const OUString& aProgrammaticName ) throw( uno::RuntimeException, std::exception )
{
const ScaFuncData* pFData = pFuncDataList->Get( aProgrammaticName );
if( !pFData )
return uno::Sequence< sheet::LocalizedName >( 0 );
const ScaStringList& rStrList = pFData->GetCompNameList();
sal_uInt32 nCount = rStrList.Count();
uno::Sequence< sheet::LocalizedName > aRet( nCount );
sheet::LocalizedName* pArray = aRet.getArray();
for( sal_uInt32 nIndex = 0; nIndex < nCount; nIndex++ )
pArray[ nIndex ] = sheet::LocalizedName( GetLocale( nIndex ), *rStrList.Get( nIndex ) );
return aRet;
}
namespace {
// auxiliary functions
bool IsLeapYear( sal_uInt16 nYear )
{
return ((((nYear % 4) == 0) && ((nYear % 100) != 0)) || ((nYear % 400) == 0));
}
sal_uInt16 DaysInMonth( sal_uInt16 nMonth, sal_uInt16 nYear )
{
static const sal_uInt16 aDaysInMonth[12] = { 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31 };
if ( nMonth != 2 )
return aDaysInMonth[nMonth-1];
else
{
if ( IsLeapYear(nYear) )
return aDaysInMonth[nMonth-1] + 1;
else
return aDaysInMonth[nMonth-1];
}
}
/**
* Convert a date to a count of days starting from 01/01/0001
*
* The internal representation of a Date used in this Addin
* is the number of days between 01/01/0001 and the date
* this function converts a Day , Month, Year representation
* to this internal Date value.
*/
sal_Int32 DateToDays( sal_uInt16 nDay, sal_uInt16 nMonth, sal_uInt16 nYear )
{
sal_Int32 nDays = ((sal_Int32)nYear-1) * 365;
nDays += ((nYear-1) / 4) - ((nYear-1) / 100) + ((nYear-1) / 400);
for( sal_uInt16 i = 1; i < nMonth; i++ )
nDays += DaysInMonth(i,nYear);
nDays += nDay;
return nDays;
}
/**
* Convert a count of days starting from 01/01/0001 to a date
*
* The internal representation of a Date used in this Addin
* is the number of days between 01/01/0001 and the date
* this function converts this internal Date value
* to a Day , Month, Year representation of a Date.
*/
void DaysToDate( sal_Int32 nDays,
sal_uInt16& rDay, sal_uInt16& rMonth, sal_uInt16& rYear )
throw( lang::IllegalArgumentException )
{
if( nDays < 0 )
throw lang::IllegalArgumentException();
sal_Int32 nTempDays;
sal_Int32 i = 0;
bool bCalc;
do
{
nTempDays = nDays;
rYear = (sal_uInt16)((nTempDays / 365) - i);
nTempDays -= ((sal_Int32) rYear -1) * 365;
nTempDays -= (( rYear -1) / 4) - (( rYear -1) / 100) + ((rYear -1) / 400);
bCalc = false;
if ( nTempDays < 1 )
{
i++;
bCalc = true;
}
else
{
if ( nTempDays > 365 )
{
if ( (nTempDays != 366) || !IsLeapYear( rYear ) )
{
i--;
bCalc = true;
}
}
}
}
while ( bCalc );
rMonth = 1;
while ( (sal_Int32)nTempDays > DaysInMonth( rMonth, rYear ) )
{
nTempDays -= DaysInMonth( rMonth, rYear );
rMonth++;
}
rDay = (sal_uInt16)nTempDays;
}
/**
* Get the null date used by the spreadsheet document
*
* The internal representation of a Date used in this Addin
* is the number of days between 01/01/0001 and the date
* this function returns this internal Date value for the document null date
*
*/
sal_Int32 GetNullDate( const uno::Reference< beans::XPropertySet >& xOptions )
throw( uno::RuntimeException )
{
if (xOptions.is())
{
try
{
uno::Any aAny = xOptions->getPropertyValue(
OUString( "NullDate" ) );
util::Date aDate;
if ( aAny >>= aDate )
return DateToDays( aDate.Day, aDate.Month, aDate.Year );
}
catch (uno::Exception&)
{
}
}
// no null date available -> no calculations possible
throw uno::RuntimeException();
}
}
// XDateFunctions
/**
* Get week difference between 2 dates
*
* new Weeks(date1,date2,mode) function for StarCalc
*
* Two modes of operation are provided.
* The first is just a simple division by 7 calculation.
*
* The second calculates the diffence by week of year.
*
* The International Standard IS-8601 has decreed that Monday
* shall be the first day of the week.
*
* A week that lies partly in one year and partly in annother
* is assigned a number in the year in which most of its days lie.
*
* That means that week 1 of any year is the week that contains the 4. January
*
* The internal representation of a Date used in the Addin is the number of days based on 01/01/0001
*
* A WeekDay can be then calculated by subtracting 1 and calculating the rest of
* a division by 7, which gives a 0 - 6 value for Monday - Sunday
*
* Using the 4. January rule explained above the formula
*
* nWeek1= ( nDays1 - nJan4 + ( (nJan4-1) % 7 ) ) / 7 + 1;
*
* calculates a number between 0-53 for each day which is in the same year as nJan4
* where 0 means that this week belonged to the year before.
*
* If a day in the same or another year is used in this formula this calculates
* an calendar week offset from a given 4. January
*
* nWeek2 = ( nDays2 - nJan4 + ( (nJan4-1) % 7 ) ) / 7 + 1;
*
* The 4.January of first Date Argument can thus be used to calculate
* the week difference by calendar weeks which is then nWeek = nWeek2 - nWeek1
*
* which can be optimized to
*
* nWeek = ( (nDays2-nJan4+((nJan4-1)%7))/7 ) - ( (nDays1-nJan4+((nJan4-1)%7))/7 )
*
* Note: All calculations are operating on the long integer data type
* % is the modulo operator in C which calculates the rest of an Integer division
*
*
* mode 0 is the interval between the dates in month, that is days / 7
*
* mode 1 is the difference by week of year
*
*/
sal_Int32 SAL_CALL ScaDateAddIn::getDiffWeeks(
const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nStartDate, sal_Int32 nEndDate,
sal_Int32 nMode ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
{
sal_Int32 nNullDate = GetNullDate( xOptions );
sal_Int32 nDays1 = nStartDate + nNullDate;
sal_Int32 nDays2 = nEndDate + nNullDate;
sal_Int32 nRet;
if ( nMode == 1 )
{
sal_uInt16 nDay,nMonth,nYear;
DaysToDate( nDays1, nDay, nMonth, nYear );
sal_Int32 nJan4 = DateToDays( 4, 1, nYear );
nRet = ( (nDays2-nJan4+((nJan4-1)%7))/7 ) - ( (nDays1-nJan4+((nJan4-1)%7))/7 );
}
else
{
nRet = (nDays2 - nDays1) / 7;
}
return nRet;
}
/**
* Get month difference between 2 dates
* =Month(start, end, mode) Function for StarCalc
*
* two modes are provided
*
* mode 0 is the interval between the dates in month
*
* mode 1 is the difference in calendar month
*/
sal_Int32 SAL_CALL ScaDateAddIn::getDiffMonths(
const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nStartDate, sal_Int32 nEndDate,
sal_Int32 nMode ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
{
sal_Int32 nNullDate = GetNullDate( xOptions );
sal_Int32 nDays1 = nStartDate + nNullDate;
sal_Int32 nDays2 = nEndDate + nNullDate;
sal_uInt16 nDay1,nMonth1,nYear1;
sal_uInt16 nDay2,nMonth2,nYear2;
DaysToDate(nDays1,nDay1,nMonth1,nYear1);
DaysToDate(nDays2,nDay2,nMonth2,nYear2);
sal_Int32 nRet = nMonth2 - nMonth1 + (nYear2 - nYear1) * 12;
if ( nMode == 1 || nDays1 == nDays2 ) return nRet;
if ( nDays1 < nDays2 )
{
if ( nDay1 > nDay2 )
{
nRet -= 1;
}
}
else
{
if ( nDay1 < nDay2 )
{
nRet += 1;
}
}
return nRet;
}
/**
* Get Year difference between 2 dates
*
* two modes are provided
*
* mode 0 is the interval between the dates in years
*
* mode 1 is the difference in calendar years
*/
sal_Int32 SAL_CALL ScaDateAddIn::getDiffYears(
const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nStartDate, sal_Int32 nEndDate,
sal_Int32 nMode ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
{
if ( nMode != 1 )
return getDiffMonths( xOptions, nStartDate, nEndDate, nMode ) / 12;
sal_Int32 nNullDate = GetNullDate( xOptions );
sal_Int32 nDays1 = nStartDate + nNullDate;
sal_Int32 nDays2 = nEndDate + nNullDate;
sal_uInt16 nDay1,nMonth1,nYear1;
sal_uInt16 nDay2,nMonth2,nYear2;
DaysToDate(nDays1,nDay1,nMonth1,nYear1);
DaysToDate(nDays2,nDay2,nMonth2,nYear2);
return nYear2 - nYear1;
}
/**
* Check if a Date is in a leap year in the Gregorian calendar
*/
sal_Int32 SAL_CALL ScaDateAddIn::getIsLeapYear(
const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
{
sal_Int32 nNullDate = GetNullDate( xOptions );
sal_Int32 nDays = nDate + nNullDate;
sal_uInt16 nDay, nMonth, nYear;
DaysToDate(nDays,nDay,nMonth,nYear);
return (sal_Int32)IsLeapYear(nYear);
}
/**
* Get the Number of Days in the month for a date
*/
sal_Int32 SAL_CALL ScaDateAddIn::getDaysInMonth(
const uno::Reference<beans::XPropertySet>& xOptions,
sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
{
sal_Int32 nNullDate = GetNullDate( xOptions );
sal_Int32 nDays = nDate + nNullDate;
sal_uInt16 nDay, nMonth, nYear;
DaysToDate(nDays,nDay,nMonth,nYear);
return DaysInMonth( nMonth, nYear );
}
/**
* Get number of days in the year of a date specified
*/
sal_Int32 SAL_CALL ScaDateAddIn::getDaysInYear(
const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
{
sal_Int32 nNullDate = GetNullDate( xOptions );
sal_Int32 nDays = nDate + nNullDate;
sal_uInt16 nDay, nMonth, nYear;
DaysToDate(nDays,nDay,nMonth,nYear);
return ( IsLeapYear(nYear) ? 366 : 365 );
}
/**
* Get number of weeks in the year for a date
*
* Most years have 52 weeks, but years that start on a Thursday
* and leep years that start on a Wednesday have 53 weeks
*
* The International Standard IS-8601 has decreed that Monday
* shall be the first day of the week.
*
* A WeekDay can be calculated by subtracting 1 and calculating the rest of
* a division by 7 from the internal date represention
* which gives a 0 - 6 value for Monday - Sunday
*
* @see #IsLeapYear #WeekNumber
*/
sal_Int32 SAL_CALL ScaDateAddIn::getWeeksInYear(
const uno::Reference< beans::XPropertySet >& xOptions,
sal_Int32 nDate ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
{
sal_Int32 nNullDate = GetNullDate( xOptions );
sal_Int32 nDays = nDate + nNullDate;
sal_uInt16 nDay, nMonth, nYear;
DaysToDate(nDays,nDay,nMonth,nYear);
sal_Int32 nJan1WeekDay = ( DateToDays(1,1,nYear) - 1) % 7;
sal_Int32 nRet;
if ( nJan1WeekDay == 3 ) /* Thursday */
nRet = 53;
else if ( nJan1WeekDay == 2 ) /* Wednesday */
nRet = ( IsLeapYear(nYear) ? 53 : 52 );
else
nRet = 52;
return nRet;
}
/**
* Encrypt or decrypt a string using ROT13 algorithm
*
* This function rotates each character by 13 in the alphabet.
* Only the characters 'a' ... 'z' and 'A' ... 'Z' are modified.
*/
OUString SAL_CALL ScaDateAddIn::getRot13( const OUString& aSrcString ) throw( uno::RuntimeException, lang::IllegalArgumentException, std::exception )
{
OUStringBuffer aBuffer( aSrcString );
for( sal_Int32 nIndex = 0; nIndex < aBuffer.getLength(); nIndex++ )
{
sal_Unicode cChar = aBuffer[nIndex];
if( ((cChar >= 'a') && (cChar <= 'z') && ((cChar += 13) > 'z')) ||
((cChar >= 'A') && (cChar <= 'Z') && ((cChar += 13) > 'Z')) )
cChar -= 26;
aBuffer[nIndex] = cChar;
}
return aBuffer.makeStringAndClear();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */