summaryrefslogtreecommitdiff
path: root/sw/source/ui/uno
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/ui/uno')
-rw-r--r--sw/source/ui/uno/RefreshListenerContainer.cxx61
-rw-r--r--sw/source/ui/uno/SwXDocumentSettings.cxx1096
-rw-r--r--sw/source/ui/uno/SwXDocumentSettings.hxx108
-rw-r--r--sw/source/ui/uno/SwXFilterOptions.cxx192
-rw-r--r--sw/source/ui/uno/SwXPrintPreviewSettings.cxx371
-rw-r--r--sw/source/ui/uno/SwXPrintPreviewSettings.hxx90
-rw-r--r--sw/source/ui/uno/detreg.cxx111
-rw-r--r--sw/source/ui/uno/dlelstnr.cxx189
-rw-r--r--sw/source/ui/uno/makefile.mk82
-rw-r--r--sw/source/ui/uno/swdet2.cxx124
-rw-r--r--sw/source/ui/uno/swdetect.cxx487
-rw-r--r--sw/source/ui/uno/swdetect.hxx98
-rw-r--r--sw/source/ui/uno/unoatxt.cxx1148
-rw-r--r--sw/source/ui/uno/unodefaults.cxx65
-rw-r--r--sw/source/ui/uno/unodefaults.hxx50
-rw-r--r--sw/source/ui/uno/unodispatch.cxx405
-rw-r--r--sw/source/ui/uno/unodoc.cxx130
-rw-r--r--sw/source/ui/uno/unofreg.cxx479
-rw-r--r--sw/source/ui/uno/unomailmerge.cxx1253
-rw-r--r--sw/source/ui/uno/unomod.cxx1026
-rw-r--r--sw/source/ui/uno/unomodule.cxx174
-rw-r--r--sw/source/ui/uno/unomodule.hxx101
-rw-r--r--sw/source/ui/uno/unotxdoc.cxx3893
-rw-r--r--sw/source/ui/uno/unotxvw.cxx2023
24 files changed, 13756 insertions, 0 deletions
diff --git a/sw/source/ui/uno/RefreshListenerContainer.cxx b/sw/source/ui/uno/RefreshListenerContainer.cxx
new file mode 100644
index 000000000000..fe595b76ed63
--- /dev/null
+++ b/sw/source/ui/uno/RefreshListenerContainer.cxx
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <RefreshListenerContainer.hxx>
+#include <com/sun/star/lang/EventObject.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/util/XRefreshListener.hpp>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::util;
+
+SwRefreshListenerContainer::SwRefreshListenerContainer( uno::XInterface* pxParent2 )
+: SwEventListenerContainer ( pxParent2 )
+{
+}
+
+void SwRefreshListenerContainer::Refreshed ()
+{
+ if(!pListenerArr)
+ return;
+
+ lang::EventObject aObj(pxParent);
+ for(sal_uInt16 i = 0, nEnd = pListenerArr->Count(); i < nEnd ; i++)
+ {
+ Reference < XRefreshListener > xRefreshListener = Reference < XRefreshListener > ( *pListenerArr->GetObject(i), UNO_QUERY );
+ xRefreshListener->refreshed(aObj);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx
new file mode 100644
index 000000000000..4b1740ec9105
--- /dev/null
+++ b/sw/source/ui/uno/SwXDocumentSettings.cxx
@@ -0,0 +1,1096 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include <osl/mutex.hxx>
+#include <sfx2/sfxbasecontroller.hxx>
+#include <SwXDocumentSettings.hxx>
+#include <SwXPrintPreviewSettings.hxx>
+#include <comphelper/MasterPropertySetInfo.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
+#include <com/sun/star/document/PrinterIndependentLayout.hpp>
+#include <doc.hxx>
+#include <docsh.hxx>
+#include <fldupde.hxx>
+#include <linkenum.hxx>
+#include <sfx2/printer.hxx>
+#include <editsh.hxx>
+#include <drawdoc.hxx>
+#include <svl/zforlist.hxx>
+#include <unotxdoc.hxx>
+#include <cmdid.h>
+#include <svx/zoomitem.hxx>
+#include <unomod.hxx>
+#include <vcl/svapp.hxx>
+
+#include "swmodule.hxx"
+#include "cfgitems.hxx"
+#include "prtopt.hxx"
+
+
+#include "swmodule.hxx"
+#include "cfgitems.hxx"
+#include "prtopt.hxx"
+
+using rtl::OUString;
+
+using namespace comphelper;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::i18n;
+
+enum SwDocumentSettingsPropertyHandles
+{
+ HANDLE_FORBIDDEN_CHARS,
+ HANDLE_LINK_UPDATE_MODE,
+ HANDLE_FIELD_AUTO_UPDATE,
+ HANDLE_CHART_AUTO_UPDATE,
+ HANDLE_ADD_PARA_TABLE_SPACING,
+ HANDLE_ADD_PARA_TABLE_SPACING_AT_START,
+ HANDLE_ALIGN_TAB_STOP_POSITION,
+ HANDLE_PRINTER_NAME,
+ HANDLE_PRINTER_SETUP,
+ HANDLE_IS_KERN_ASIAN_PUNCTUATION,
+ HANDLE_CHARACTER_COMPRESSION_TYPE,
+ HANDLE_APPLY_USER_DATA,
+ HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS,
+ HANDLE_CURRENT_DATABASE_DATA_SOURCE,
+ HANDLE_CURRENT_DATABASE_COMMAND,
+ HANDLE_CURRENT_DATABASE_COMMAND_TYPE,
+ HANDLE_SAVE_VERSION_ON_CLOSE,
+ HANDLE_IS_GRID_VISIBLE,
+ HANDLE_IS_SNAP_TO_GRID,
+ HANDLE_IS_SYNCHRONISE_AXES,
+ HANDLE_HORIZONTAL_GRID_RESOLUTION,
+ HANDLE_HORIZONTAL_GRID_SUBDIVISION,
+ HANDLE_VERTICAL_GRID_RESOLUTION,
+ HANDLE_VERTICAL_GRID_SUBDIVISION,
+ HANDLE_UPDATE_FROM_TEMPLATE,
+ HANDLE_PRINTER_INDEPENDENT_LAYOUT,
+ HANDLE_IS_LABEL_DOC,
+ HANDLE_IS_ADD_FLY_OFFSET,
+ HANDLE_IS_ADD_EXTERNAL_LEADING,
+ HANDLE_OLD_NUMBERING, // #111955#
+ HANDLE_OUTLINELEVEL_YIELDS_NUMBERING,
+ /* Stampit It disable the print cancel button of the shown progress dialog. */
+ HANDLE_ALLOW_PRINTJOB_CANCEL,
+ HANDLE_USE_FORMER_LINE_SPACING,
+ HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS,
+ HANDLE_USE_FORMER_OBJECT_POSITIONING,
+ HANDLE_USE_FORMER_TEXT_WRAPPING,
+ HANDLE_CHANGES_PASSWORD,
+ HANDLE_CONSIDER_WRAP_ON_OBJPOS,
+ HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING,
+ HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK,
+ HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT,
+ HANDLE_TABLE_ROW_KEEP,
+ HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION,
+ HANDLE_LOAD_READONLY,
+ HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE,
+ HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES,
+ HANDLE_UNIX_FORCE_ZERO_EXT_LEADING,
+ HANDLE_USE_OLD_PRINTER_METRICS,
+ HANDLE_PROTECT_FORM,
+ HANDLE_TABS_RELATIVE_TO_INDENT,
+ // --> OD 2008-06-05 #i89181#
+ HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST,
+ // <--
+ HANDLE_MODIFYPASSWORDINFO,
+ HANDLE_INVERT_BORDER_SPACING,
+ HANDLE_COLLAPSE_EMPTY_CELL_PARA
+};
+
+MasterPropertySetInfo * lcl_createSettingsInfo()
+{
+ static PropertyInfo aWriterSettingsInfoMap[] =
+ {
+ { RTL_CONSTASCII_STRINGPARAM("ForbiddenCharacters"), HANDLE_FORBIDDEN_CHARS, CPPUTYPE_REFFORBCHARS, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("LinkUpdateMode"), HANDLE_LINK_UPDATE_MODE, CPPUTYPE_INT16, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("FieldAutoUpdate"), HANDLE_FIELD_AUTO_UPDATE, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ChartAutoUpdate"), HANDLE_CHART_AUTO_UPDATE, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("AddParaTableSpacing"), HANDLE_ADD_PARA_TABLE_SPACING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("AddParaTableSpacingAtStart"), HANDLE_ADD_PARA_TABLE_SPACING_AT_START, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("AlignTabStopPosition"), HANDLE_ALIGN_TAB_STOP_POSITION, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("PrinterName"), HANDLE_PRINTER_NAME, CPPUTYPE_OUSTRING, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("PrinterSetup"), HANDLE_PRINTER_SETUP, CPPUTYPE_SEQINT8, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("IsKernAsianPunctuation"), HANDLE_IS_KERN_ASIAN_PUNCTUATION, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("CharacterCompressionType"), HANDLE_CHARACTER_COMPRESSION_TYPE, CPPUTYPE_INT16, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ApplyUserData"), HANDLE_APPLY_USER_DATA, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("SaveGlobalDocumentLinks"), HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("CurrentDatabaseDataSource"), HANDLE_CURRENT_DATABASE_DATA_SOURCE, CPPUTYPE_OUSTRING, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("CurrentDatabaseCommand"), HANDLE_CURRENT_DATABASE_COMMAND, CPPUTYPE_OUSTRING, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("CurrentDatabaseCommandType"), HANDLE_CURRENT_DATABASE_COMMAND_TYPE, CPPUTYPE_INT32, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("SaveVersionOnClose"), HANDLE_SAVE_VERSION_ON_CLOSE, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("UpdateFromTemplate"), HANDLE_UPDATE_FROM_TEMPLATE, CPPUTYPE_BOOLEAN, 0, 0},
+
+ { RTL_CONSTASCII_STRINGPARAM("PrinterIndependentLayout"), HANDLE_PRINTER_INDEPENDENT_LAYOUT, CPPUTYPE_INT16, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("IsLabelDocument"), HANDLE_IS_LABEL_DOC, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("AddFrameOffsets"), HANDLE_IS_ADD_FLY_OFFSET, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("AddExternalLeading"), HANDLE_IS_ADD_EXTERNAL_LEADING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("UseOldNumbering"), HANDLE_OLD_NUMBERING, CPPUTYPE_BOOLEAN, 0, 0}, // #111955#
+ { RTL_CONSTASCII_STRINGPARAM("OutlineLevelYieldsNumbering"), HANDLE_OUTLINELEVEL_YIELDS_NUMBERING, CPPUTYPE_BOOLEAN, 0, 0},
+ /* Stampit It disable the print cancel button of the shown progress dialog. */
+ { RTL_CONSTASCII_STRINGPARAM("AllowPrintJobCancel"), HANDLE_ALLOW_PRINTJOB_CANCEL, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("UseFormerLineSpacing"), HANDLE_USE_FORMER_LINE_SPACING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("AddParaSpacingToTableCells"), HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("UseFormerObjectPositioning"), HANDLE_USE_FORMER_OBJECT_POSITIONING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("UseFormerTextWrapping"), HANDLE_USE_FORMER_TEXT_WRAPPING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("RedlineProtectionKey"), HANDLE_CHANGES_PASSWORD, CPPUTYPE_SEQINT8, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ConsiderTextWrapOnObjPos"), HANDLE_CONSIDER_WRAP_ON_OBJPOS, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("IgnoreFirstLineIndentInNumbering"), HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("DoNotJustifyLinesWithManualBreak"), HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("DoNotResetParaAttrsForNumFont"), HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("TableRowKeep"), HANDLE_TABLE_ROW_KEEP, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("IgnoreTabsAndBlanksForLineCalculation"), HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("LoadReadonly"), HANDLE_LOAD_READONLY, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("DoNotCaptureDrawObjsOnPage"), HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ClipAsCharacterAnchoredWriterFlyFrames"), HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("UnxForceZeroExtLeading"), HANDLE_UNIX_FORCE_ZERO_EXT_LEADING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("UseOldPrinterMetrics"), HANDLE_USE_OLD_PRINTER_METRICS, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("TabsRelativeToIndent"), HANDLE_TABS_RELATIVE_TO_INDENT, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ProtectForm"), HANDLE_PROTECT_FORM, CPPUTYPE_BOOLEAN, 0, 0},
+ // --> OD 2008-06-05 #i89181#
+ { RTL_CONSTASCII_STRINGPARAM("TabAtLeftIndentForParagraphsInList"), HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ModifyPasswordInfo"), HANDLE_MODIFYPASSWORDINFO, CPPUTYPE_PROPERTYVALUE, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, CPPUTYPE_BOOLEAN, 0, 0},
+/*
+ * As OS said, we don't have a view when we need to set this, so I have to
+ * find another solution before adding them to this property set - MTG
+ { RTL_CONSTASCII_STRINGPARAM("IsGridVisible"), HANDLE_IS_GRID_VISIBLE, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("IsSnapToGrid"), HANDLE_IS_SNAP_TO_GRID, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("IsSynchroniseAxes"), HANDLE_IS_SYNCHRONISE_AXES, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("HorizontalGridResolution"), HANDLE_HORIZONTAL_GRID_RESOLUTION, CPPUTYPE_INT32, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("HorizontalGridSubdivision"), HANDLE_HORIZONTAL_GRID_SUBDIVISION, CPPUTYPE_INT16, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("VerticalGridResolution"), HANDLE_VERTICAL_GRID_RESOLUTION, CPPUTYPE_INT32, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("VerticalGridSubdivision"), HANDLE_VERTICAL_GRID_SUBDIVISION, CPPUTYPE_INT16, 0, 0},
+
+ { RTL_CONSTASCII_STRINGPARAM("ShowParagraphEnd"), HANDLE_SHOW_PARAGRAPH_END, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowOptionalHyphens"), HANDLE_SHOW_OPTIONAL_HYPHENS, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowSpaces"), HANDLE_SHOW_SPACES, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowTabs"), HANDLE_SHOW_TABS, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowBreaks"), HANDLE_SHOW_BREAKS, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowHiddenText"), HANDLE_SHOW_HIDDEN_TEXT, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowHiddenParagraphs"), HANDLE_SHOW_HIDDEN_PARAGRAPHS, CPPUTYPE_BOOLEAN, 0, 0},
+
+ { RTL_CONSTASCII_STRINGPARAM("ShowTextLimitGuide"), HANDLE_SHOW_TEXT_LIMIT_GUIDE, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowTableLimitGuide"), HANDLE_SHOW_TABLE_LIMIT_GUIDE, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowSectionLimitGuide"), HANDLE_SHOW_SECTION_LIMIT_GUIDE, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowGuidesWhileMoving"), HANDLE_SHOW_GUIDES_WHILE_MOVING, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowSimpleHandles"), HANDLE_SHOW_SIMPLE_HANDLES, CPPUTYPE_BOOLEAN, 0, 0},
+ { RTL_CONSTASCII_STRINGPARAM("ShowLargeHandles"), HANDLE_SHOW_LARGE_HANDLES, CPPUTYPE_BOOLEAN, 0, 0},
+*/
+ { NULL, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
+ };
+ return new MasterPropertySetInfo ( aWriterSettingsInfoMap );
+}
+
+SwXDocumentSettings::SwXDocumentSettings ( SwXTextDocument * pModel )
+: MasterPropertySet ( lcl_createSettingsInfo (),
+ &Application::GetSolarMutex () )
+, mxModel ( pModel )
+, mpModel ( pModel )
+, mpDocSh ( NULL )
+, mpDoc ( NULL )
+, mpPrinter( NULL )
+{
+ registerSlave ( new SwXPrintSettings ( PRINT_SETTINGS_DOCUMENT, mpModel->GetDocShell()->GetDoc() ) );
+ registerSlave ( new SwXPrintPreviewSettings ( mpModel->GetDocShell()->GetDoc() ) );
+}
+
+SwXDocumentSettings::~SwXDocumentSettings()
+ throw()
+{
+}
+
+Any SAL_CALL SwXDocumentSettings::queryInterface( const Type& rType )
+ throw(RuntimeException)
+{
+ return ::cppu::queryInterface ( rType,
+ // OWeakObject interfaces
+ dynamic_cast< XInterface* > ( dynamic_cast< OWeakObject* >(this) ),
+ dynamic_cast< XWeak* > ( this ),
+ // my own interfaces
+ dynamic_cast< XPropertySet* > ( this ),
+ dynamic_cast< XPropertyState* > ( this ),
+ dynamic_cast< XMultiPropertySet* > ( this ),
+ dynamic_cast< XServiceInfo* > ( this ),
+ dynamic_cast< XTypeProvider* > ( this ) );
+}
+void SwXDocumentSettings::acquire ()
+ throw ()
+{
+ OWeakObject::acquire();
+}
+void SwXDocumentSettings::release ()
+ throw ()
+{
+ OWeakObject::release();
+}
+
+uno::Sequence< uno::Type > SAL_CALL SwXDocumentSettings::getTypes( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ uno::Sequence< uno::Type > aBaseTypes( 5 );
+ uno::Type* pBaseTypes = aBaseTypes.getArray();
+
+ // from MasterPropertySet
+ pBaseTypes[0] = ::getCppuType((Reference< XPropertySet >*)0);
+ pBaseTypes[1] = ::getCppuType((Reference< XPropertyState >*)0);
+ pBaseTypes[2] = ::getCppuType((Reference< XMultiPropertySet >*)0);
+ //
+ pBaseTypes[3] = ::getCppuType((Reference< XServiceInfo >*)0);
+ pBaseTypes[4] = ::getCppuType((Reference< XTypeProvider >*)0);
+
+ return aBaseTypes;
+}
+
+uno::Sequence< sal_Int8 > SAL_CALL SwXDocumentSettings::getImplementationId( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static Sequence< sal_Int8 > aId( 16 );
+ static sal_Bool bInit = sal_False;
+ if(!bInit)
+ {
+ rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
+ bInit = sal_True;
+ }
+ return aId;
+}
+
+void SwXDocumentSettings::_preSetValues ()
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ mpDocSh = mpModel->GetDocShell();
+ mpDoc = mpDocSh->GetDoc();
+
+ if( NULL == mpDoc || NULL == mpDocSh )
+ throw UnknownPropertyException();
+}
+
+
+void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ if (rInfo.mnAttributes & PropertyAttribute::READONLY)
+ throw PropertyVetoException ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + C2U(rInfo.mpName), static_cast < cppu::OWeakObject * > ( 0 ) );
+
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_FORBIDDEN_CHARS:
+ break;
+ case HANDLE_LINK_UPDATE_MODE:
+ {
+ sal_Int16 nMode = 0;
+ rValue >>= nMode;
+ switch (nMode)
+ {
+ case NEVER:
+ case MANUAL:
+ case AUTOMATIC:
+ case GLOBALSETTING:
+ break;
+ default:
+ throw IllegalArgumentException();
+ }
+ mpDoc->setLinkUpdateMode(nMode);
+ }
+ break;
+ case HANDLE_FIELD_AUTO_UPDATE:
+ {
+ sal_Bool bUpdateField = *(sal_Bool*)rValue.getValue();
+ SwFldUpdateFlags nFlag = mpDoc->getFieldUpdateFlags(true);
+ mpDoc->setFieldUpdateFlags( bUpdateField ?
+ nFlag == AUTOUPD_FIELD_AND_CHARTS ?
+ AUTOUPD_FIELD_AND_CHARTS :
+ AUTOUPD_FIELD_ONLY :
+ AUTOUPD_OFF );
+ }
+ break;
+ case HANDLE_CHART_AUTO_UPDATE:
+ {
+ sal_Bool bUpdateChart = *(sal_Bool*)rValue.getValue();
+ SwFldUpdateFlags nFlag = mpDoc->getFieldUpdateFlags(true);
+ mpDoc->setFieldUpdateFlags( (nFlag == AUTOUPD_FIELD_ONLY || nFlag == AUTOUPD_FIELD_AND_CHARTS ) ?
+ bUpdateChart ?
+ AUTOUPD_FIELD_AND_CHARTS :
+ AUTOUPD_FIELD_ONLY :
+ AUTOUPD_OFF );
+ }
+ break;
+ case HANDLE_ADD_PARA_TABLE_SPACING:
+ {
+ sal_Bool bParaSpace = sal_False;
+ rValue >>= bParaSpace;
+ mpDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX, bParaSpace );
+ }
+ break;
+ case HANDLE_ADD_PARA_TABLE_SPACING_AT_START:
+ {
+ sal_Bool bParaSpacePage = sal_False;
+ rValue >>= bParaSpacePage;
+ mpDoc->set(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES, bParaSpacePage );
+ }
+ break;
+ case HANDLE_ALIGN_TAB_STOP_POSITION:
+ {
+ sal_Bool bAlignTab = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TAB_COMPAT, bAlignTab);
+ }
+ break;
+ case HANDLE_PRINTER_NAME:
+ {
+ //the printer must be created
+ OUString sPrinterName;
+ if( rValue >>= sPrinterName )
+ {
+ if( !mpPrinter && sPrinterName.getLength() > 0 && mpDocSh->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
+ {
+ SfxPrinter* pPrinter = mpDoc->getPrinter( true );
+ if ( OUString ( pPrinter->GetName()) != sPrinterName )
+ {
+ SfxPrinter *pNewPrinter = new SfxPrinter ( pPrinter->GetOptions().Clone(), sPrinterName );
+ if( pNewPrinter->IsKnown() )
+ {
+ // set printer only once; in _postSetValues
+ mpPrinter = pNewPrinter;
+ }
+ else
+ {
+ delete pNewPrinter;
+ }
+ }
+ }
+ }
+ else
+ throw IllegalArgumentException();
+ }
+ break;
+ case HANDLE_PRINTER_SETUP:
+ {
+ Sequence < sal_Int8 > aSequence;
+ if ( rValue >>= aSequence )
+ {
+ sal_uInt32 nSize = aSequence.getLength();
+ if( nSize > 0 )
+ {
+ SvMemoryStream aStream (aSequence.getArray(), nSize,
+ STREAM_READ );
+ aStream.Seek ( STREAM_SEEK_TO_BEGIN );
+ static sal_uInt16 __READONLY_DATA nRange[] =
+ {
+ FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
+ SID_HTML_MODE, SID_HTML_MODE,
+ SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
+ SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
+ 0
+ };
+ SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange );
+ SfxPrinter *pPrinter = SfxPrinter::Create ( aStream, pItemSet );
+
+ // set printer only once; in _postSetValues
+ delete mpPrinter;
+ mpPrinter = pPrinter;
+ }
+ }
+ else
+ throw IllegalArgumentException();
+ }
+ break;
+ case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
+ {
+ sal_Bool bIsKern = *(sal_Bool*)(rValue).getValue();
+ mpDoc->set(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION, bIsKern);
+ SwEditShell* pEditSh = mpDoc->GetEditShell();
+ if(pEditSh)
+ pEditSh->ChgHyphenation();
+ }
+ break;
+ case HANDLE_CHARACTER_COMPRESSION_TYPE:
+ {
+ sal_Int16 nMode = 0;
+ rValue >>= nMode;
+ switch (nMode)
+ {
+ case CHARCOMPRESS_NONE:
+ case CHARCOMPRESS_PUNCTUATION:
+ case CHARCOMPRESS_PUNCTUATION_KANA:
+ break;
+ default:
+ throw IllegalArgumentException();
+ }
+ mpDoc->setCharacterCompressionType(static_cast < SwCharCompressType > (nMode) );
+ }
+ break;
+ case HANDLE_APPLY_USER_DATA:
+ {
+ mpDocSh->SetUseUserData( *(sal_Bool*)rValue.getValue() );
+ }
+ break;
+ case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS:
+ {
+ sal_Bool bSaveGlobal = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS, bSaveGlobal );
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_DATA_SOURCE:
+ {
+ SwDBData aData = mpDoc->GetDBData();
+ if ( rValue >>= aData.sDataSource )
+ mpDoc->ChgDBData( aData );
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_COMMAND:
+ {
+ SwDBData aData = mpDoc->GetDBData();
+ if ( rValue >>= aData.sCommand )
+ mpDoc->ChgDBData( aData );
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_COMMAND_TYPE:
+ {
+ SwDBData aData = mpDoc->GetDBData();
+ if ( rValue >>= aData.nCommandType )
+ mpDoc->ChgDBData( aData );
+ }
+ break;
+ case HANDLE_SAVE_VERSION_ON_CLOSE:
+ {
+ mpDocSh->SetSaveVersionOnClose( *(sal_Bool*)rValue.getValue() );
+ }
+ break;
+ case HANDLE_UPDATE_FROM_TEMPLATE:
+ {
+ mpDocSh->SetQueryLoadTemplate( *(sal_Bool*)rValue.getValue() );
+ }
+ break;
+ case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
+ {
+ sal_Int16 nTmp = 0;
+ rValue >>= nTmp;
+
+ bool bUseVirDev = true;
+ bool bHiResVirDev = true;
+ if( nTmp == document::PrinterIndependentLayout::DISABLED )
+ bUseVirDev = false;
+ else if ( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
+ bHiResVirDev = false;
+ else if ( nTmp != document::PrinterIndependentLayout::HIGH_RESOLUTION )
+ throw IllegalArgumentException();
+
+ mpDoc->setReferenceDeviceType( bUseVirDev, bHiResVirDev );
+ }
+ break;
+ case HANDLE_IS_LABEL_DOC :
+ {
+ sal_Bool bSet = sal_False;
+ if(!(rValue >>= bSet))
+ throw IllegalArgumentException();
+ mpDoc->set(IDocumentSettingAccess::LABEL_DOCUMENT, bSet);
+ }
+ break;
+ case HANDLE_IS_ADD_FLY_OFFSET:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::ADD_FLY_OFFSETS, bTmp);
+ }
+ break;
+ case HANDLE_IS_ADD_EXTERNAL_LEADING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::ADD_EXT_LEADING, bTmp);
+ }
+ break;
+ case HANDLE_OLD_NUMBERING: // #111955#
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::OLD_NUMBERING, bTmp);
+ }
+ case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE, bTmp);
+ }
+ break;
+ case HANDLE_ALLOW_PRINTJOB_CANCEL:
+ {
+ sal_Bool bState = sal_False;
+ if (!(rValue >>= bState))
+ throw IllegalArgumentException();
+ mpDocSh->Stamp_SetPrintCancelState(bState);
+ }
+ break;
+ case HANDLE_USE_FORMER_LINE_SPACING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::OLD_LINE_SPACING, bTmp);
+ }
+ break;
+ case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS, bTmp);
+ }
+ break;
+ case HANDLE_USE_FORMER_OBJECT_POSITIONING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::USE_FORMER_OBJECT_POS, bTmp);
+ }
+ break;
+ case HANDLE_USE_FORMER_TEXT_WRAPPING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING, bTmp);
+ }
+ break;
+ case HANDLE_CHANGES_PASSWORD:
+ {
+ Sequence <sal_Int8> aNew;
+ if(rValue >>= aNew)
+ {
+ mpDoc->SetRedlinePassword(aNew);
+ if(aNew.getLength())
+ {
+ sal_uInt16 eMode = mpDoc->GetRedlineMode();
+ eMode = eMode|nsRedlineMode_t::REDLINE_ON;
+ mpDoc->SetRedlineMode((RedlineMode_t)( eMode ));
+ }
+ }
+ }
+ break;
+ case HANDLE_CONSIDER_WRAP_ON_OBJPOS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION, bTmp );
+ }
+ break;
+ case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, bTmp);
+ }
+ break;
+ case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, bTmp);
+ }
+ break;
+ case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, bTmp);
+ }
+ break;
+ case HANDLE_TABLE_ROW_KEEP:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TABLE_ROW_KEEP, bTmp);
+ }
+ break;
+ case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, bTmp);
+ }
+ break;
+ case HANDLE_LOAD_READONLY:
+ {
+ mpDocSh->SetLoadReadonly( *(sal_Bool*)rValue.getValue() );
+ }
+ break;
+ case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, bTmp);
+ }
+ break;
+ case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME, bTmp);
+ }
+ break;
+ case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING, bTmp);
+ }
+ break;
+ case HANDLE_USE_OLD_PRINTER_METRICS:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::USE_OLD_PRINTER_METRICS, bTmp);
+ }
+ break;
+ case HANDLE_TABS_RELATIVE_TO_INDENT:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT, bTmp);
+ }
+ break;
+ case HANDLE_PROTECT_FORM:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::PROTECT_FORM, bTmp);
+ }
+ break;
+ // --> OD 2008-06-05 #i89181#
+ case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, bTmp);
+ }
+ break;
+ // <--
+ case HANDLE_MODIFYPASSWORDINFO:
+ {
+ uno::Sequence< beans::PropertyValue > aInfo;
+ if ( !( rValue >>= aInfo ) )
+ throw lang::IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Value of type Sequence<PropertyValue> expected!" ) ),
+ uno::Reference< uno::XInterface >(),
+ 2 );
+
+ if ( !mpDocSh->SetModifyPasswordInfo( aInfo ) )
+ throw beans::PropertyVetoException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The hash is not allowed to be changed now!" ) ),
+ uno::Reference< uno::XInterface >() );
+ }
+ break;
+ case HANDLE_INVERT_BORDER_SPACING:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::INVERT_BORDER_SPACING, bTmp);
+ }
+ break;
+ case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
+ {
+ sal_Bool bTmp = *(sal_Bool*)rValue.getValue();
+ mpDoc->set(IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA, bTmp);
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXDocumentSettings::_postSetValues ()
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ // set printer only once, namely here!
+ if( mpPrinter != NULL )
+ {
+ // #i86352# the printer is also used as container for options by sfx
+ // when setting a printer it should have decent default options
+ SfxItemSet aOptions( mpPrinter->GetOptions() );
+ SwPrintData aPrtData;
+ if( mpDoc->getPrintData() )
+ aPrtData = *mpDoc->getPrintData();
+ else
+ aPrtData = *SW_MOD()->GetPrtOptions(false);
+ SwAddPrinterItem aAddPrinterItem (FN_PARAM_ADDPRINTER, aPrtData);
+ aOptions.Put(aAddPrinterItem);
+ mpPrinter->SetOptions( aOptions );
+
+ mpDoc->setPrinter( mpPrinter, true, true );
+ }
+
+ mpPrinter = 0;
+ mpDocSh = 0;
+ mpDoc = 0;
+}
+
+void SwXDocumentSettings::_preGetValues ()
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ mpDocSh = mpModel->GetDocShell();
+ mpDoc = mpDocSh->GetDoc();
+ if( NULL == mpDoc || NULL == mpDocSh )
+ throw UnknownPropertyException();
+}
+
+void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException )
+{
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_FORBIDDEN_CHARS:
+ {
+ Reference<XForbiddenCharacters> xRet(*mpModel->GetPropertyHelper(), UNO_QUERY);
+ rValue <<= xRet;
+ }
+ break;
+ case HANDLE_LINK_UPDATE_MODE:
+ {
+ rValue <<= static_cast < sal_Int16 > ( mpDoc->getLinkUpdateMode(true) );
+ }
+ break;
+ case HANDLE_FIELD_AUTO_UPDATE:
+ {
+ SwFldUpdateFlags nFlags = mpDoc->getFieldUpdateFlags(true);
+ BOOL bFieldUpd = (nFlags == AUTOUPD_FIELD_ONLY || nFlags == AUTOUPD_FIELD_AND_CHARTS );
+ rValue.setValue(&bFieldUpd, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_CHART_AUTO_UPDATE:
+ {
+ SwFldUpdateFlags nFlags = mpDoc->getFieldUpdateFlags(true);
+ BOOL bChartUpd = nFlags == AUTOUPD_FIELD_AND_CHARTS;
+ rValue.setValue(&bChartUpd, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_ADD_PARA_TABLE_SPACING:
+ {
+ sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX);
+ rValue.setValue(&bParaSpace, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_ADD_PARA_TABLE_SPACING_AT_START:
+ {
+ sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES);
+ rValue.setValue(&bParaSpace, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_ALIGN_TAB_STOP_POSITION:
+ {
+ sal_Bool bAlignTab = mpDoc->get(IDocumentSettingAccess::TAB_COMPAT);
+ rValue.setValue(&bAlignTab, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_PRINTER_NAME:
+ {
+ SfxPrinter *pPrinter = mpDoc->getPrinter( sal_False );
+ rValue <<= pPrinter ? OUString ( pPrinter->GetName()) : OUString();
+ }
+ break;
+ case HANDLE_PRINTER_SETUP:
+ {
+ SfxPrinter *pPrinter = mpDocSh->GetDoc()->getPrinter( sal_False );
+ if (pPrinter)
+ {
+ SvMemoryStream aStream;
+ pPrinter->Store( aStream );
+ aStream.Seek ( STREAM_SEEK_TO_END );
+ sal_uInt32 nSize = aStream.Tell();
+ aStream.Seek ( STREAM_SEEK_TO_BEGIN );
+ Sequence < sal_Int8 > aSequence( nSize );
+ aStream.Read ( aSequence.getArray(), nSize );
+ rValue <<= aSequence;
+ }
+ else
+ {
+ Sequence < sal_Int8 > aSequence ( 0 );
+ rValue <<= aSequence;
+ }
+ }
+ break;
+ case HANDLE_IS_KERN_ASIAN_PUNCTUATION:
+ {
+ //sal_Bool bParaSpace = mpDoc->IsKernAsianPunctuation();
+ sal_Bool bParaSpace = mpDoc->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION);
+ rValue.setValue(&bParaSpace, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_APPLY_USER_DATA:
+ {
+ rValue <<= mpDocSh->IsUseUserData();
+ }
+ break;
+ case HANDLE_CHARACTER_COMPRESSION_TYPE:
+ {
+ rValue <<= static_cast < sal_Int16 > (mpDoc->getCharacterCompressionType());
+ }
+ break;
+ case HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS:
+ {
+ sal_Bool bSaveGlobal = mpDoc->get(IDocumentSettingAccess::GLOBAL_DOCUMENT_SAVE_LINKS);
+ rValue.setValue(&bSaveGlobal, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_DATA_SOURCE:
+ {
+ const SwDBData& rData = mpDoc->GetDBDesc();
+ rValue <<= rData.sDataSource;
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_COMMAND:
+ {
+ const SwDBData& rData = mpDoc->GetDBDesc();
+ rValue <<= rData.sCommand;
+ }
+ break;
+ case HANDLE_CURRENT_DATABASE_COMMAND_TYPE:
+ {
+ const SwDBData& rData = mpDoc->GetDBDesc();
+ rValue <<= rData.nCommandType;
+ }
+ break;
+ case HANDLE_SAVE_VERSION_ON_CLOSE:
+ {
+ rValue <<= mpDocSh->IsSaveVersionOnClose();
+ }
+ break;
+ case HANDLE_UPDATE_FROM_TEMPLATE:
+ {
+ rValue <<= mpDocSh->IsQueryLoadTemplate();
+ }
+ break;
+ case HANDLE_PRINTER_INDEPENDENT_LAYOUT:
+ {
+ // returns short (see css.document.PrinterIndependentLayout)
+ sal_Int16 nVirDevType = mpDoc->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ?
+ ( mpDoc->get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE) ?
+ document::PrinterIndependentLayout::HIGH_RESOLUTION :
+ document::PrinterIndependentLayout::LOW_RESOLUTION ) :
+ document::PrinterIndependentLayout::DISABLED;
+ rValue <<= nVirDevType;
+ }
+ break;
+ case HANDLE_IS_LABEL_DOC:
+ {
+ sal_Bool bLabel = mpDoc->get(IDocumentSettingAccess::LABEL_DOCUMENT);
+ rValue <<= bLabel;
+ }
+ break;
+ case HANDLE_IS_ADD_FLY_OFFSET:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_FLY_OFFSETS);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_IS_ADD_EXTERNAL_LEADING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_EXT_LEADING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_OLD_NUMBERING: // #111955#
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OLD_NUMBERING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_OUTLINELEVEL_YIELDS_NUMBERING: // #111955#
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OUTLINE_LEVEL_YIELDS_OUTLINE_RULE);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_ALLOW_PRINTJOB_CANCEL:
+ {
+ sal_Bool bPrintCancelState = mpDocSh->Stamp_GetPrintCancelState();
+ rValue.setValue(&bPrintCancelState, ::getBooleanCppuType());
+ }
+ break;
+ case HANDLE_USE_FORMER_LINE_SPACING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::OLD_LINE_SPACING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_USE_FORMER_OBJECT_POSITIONING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_USE_FORMER_TEXT_WRAPPING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_CHANGES_PASSWORD:
+ {
+ rValue <<= mpDoc->GetRedlinePassword();
+ }
+ break;
+ case HANDLE_CONSIDER_WRAP_ON_OBJPOS:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::IGNORE_FIRST_LINE_INDENT_IN_NUMBERING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_TABLE_ROW_KEEP :
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TABLE_ROW_KEEP);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_LOAD_READONLY:
+ {
+ rValue <<= mpDocSh->IsLoadReadonly();
+ }
+ break;
+ case HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_UNIX_FORCE_ZERO_EXT_LEADING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_USE_OLD_PRINTER_METRICS:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::USE_OLD_PRINTER_METRICS);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_TABS_RELATIVE_TO_INDENT:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_PROTECT_FORM:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::PROTECT_FORM);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ // --> OD 2008-06-05 #i89181#
+ case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ // <--
+ case HANDLE_MODIFYPASSWORDINFO:
+ {
+ rValue <<= mpDocSh->GetModifyPasswordInfo();
+ }
+ break;
+ case HANDLE_INVERT_BORDER_SPACING:
+ {
+ sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::INVERT_BORDER_SPACING);
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ case HANDLE_COLLAPSE_EMPTY_CELL_PARA:
+ {
+ sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::COLLAPSE_EMPTY_CELL_PARA );
+ rValue.setValue( &bTmp, ::getBooleanCppuType() );
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXDocumentSettings::_postGetValues ()
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException )
+{
+ mpDocSh = 0;
+ mpDoc = 0;
+}
+
+// XServiceInfo
+OUString SAL_CALL SwXDocumentSettings::getImplementationName( )
+ throw(RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Writer.DocumentSettings"));
+}
+
+sal_Bool SAL_CALL SwXDocumentSettings::supportsService( const OUString& ServiceName )
+ throw(RuntimeException)
+{
+ const Sequence< OUString > aSeq( getSupportedServiceNames() );
+ sal_Int32 nCount = aSeq.getLength();
+ const OUString* pServices = aSeq.getConstArray();
+ while( nCount-- )
+ {
+ if( *pServices++ == ServiceName )
+ return sal_True;
+ }
+ return sal_True;
+}
+
+Sequence< OUString > SAL_CALL SwXDocumentSettings::getSupportedServiceNames( )
+ throw(RuntimeException)
+{
+ Sequence< OUString > aSeq( 4 );
+ aSeq[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.document.Settings") );
+ aSeq[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.DocumentSettings") );
+ aSeq[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.PrintSettings") );
+ aSeq[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.PrintPreviewSettings") );
+ return aSeq;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/SwXDocumentSettings.hxx b/sw/source/ui/uno/SwXDocumentSettings.hxx
new file mode 100644
index 000000000000..48ca75ba97d2
--- /dev/null
+++ b/sw/source/ui/uno/SwXDocumentSettings.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SW_XDOCUMENT_SETTINGS_HXX
+#define _SW_XDOCUMENT_SETTINGS_HXX
+
+#ifdef PRECOMPILED
+#include "ui_pch.hxx"
+#endif
+
+#include <comphelper/MasterPropertySet.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/implbase5.hxx>
+
+
+class SwXTextDocument;
+class SwDocShell;
+class SwDoc;
+class SfxPrinter;
+
+class SwXDocumentSettings :
+ public comphelper::MasterPropertySet,
+ public com::sun::star::lang::XServiceInfo,
+ public com::sun::star::lang::XTypeProvider,
+ public cppu::OWeakObject
+{
+protected:
+ com::sun::star::uno::Reference< com::sun::star::text::XTextDocument > mxModel;
+ SwXTextDocument* mpModel;
+ SwDocShell* mpDocSh;
+ SwDoc* mpDoc;
+
+ /** the printer should be set only once; since there are several
+ * printer-related properties, remember the last printer and set it in
+ * _postSetValues */
+ SfxPrinter* mpPrinter;
+
+ virtual void _preSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const ::com::sun::star::uno::Any &rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void _preGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, ::com::sun::star::uno::Any & rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+protected:
+ virtual ~SwXDocumentSettings()
+ throw();
+public:
+ SwXDocumentSettings( SwXTextDocument* pModel );
+
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( )
+ throw ();
+ virtual void SAL_CALL release( )
+ throw ();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw(com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw(com::sun::star::uno::RuntimeException);
+ virtual com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw(com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException);
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/SwXFilterOptions.cxx b/sw/source/ui/uno/SwXFilterOptions.cxx
new file mode 100644
index 000000000000..03e5e753d60c
--- /dev/null
+++ b/sw/source/ui/uno/SwXFilterOptions.cxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include <SwXFilterOptions.hxx>
+#include <shellio.hxx>
+#include <swdll.hxx>
+#include <unoprnms.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotxdoc.hxx>
+
+#include "swabstdlg.hxx"
+#include "dialog.hrc"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::ui::dialogs;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::lang;
+
+#define SWFILTEROPTIONSOBJ_SERVICE RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ui.dialogs.FilterOptionsDialog")
+#define SWFILTEROPTIONSOBJ_IMPLNAME RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Writer.FilterOptionsDialog")
+#define FILTER_OPTIONS_NAME RTL_CONSTASCII_USTRINGPARAM("FilterOptions")
+
+SwXFilterOptions::SwXFilterOptions() :
+ bExport( sal_False )
+{
+}
+
+SwXFilterOptions::~SwXFilterOptions()
+{
+}
+
+::rtl::OUString SwXFilterOptions::getImplementationName_Static()
+{
+ return ::rtl::OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
+}
+
+uno::Sequence< ::rtl::OUString> SwXFilterOptions::getSupportedServiceNames_Static()
+{
+ ::rtl::OUString sService(SWFILTEROPTIONSOBJ_SERVICE);
+ return uno::Sequence< ::rtl::OUString> (&sService, 1);
+}
+
+uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues() throw (uno::RuntimeException)
+{
+ uno::Sequence<beans::PropertyValue> aRet(1);
+ beans::PropertyValue* pArray = aRet.getArray();
+
+ pArray[0].Name = rtl::OUString( FILTER_OPTIONS_NAME );
+ pArray[0].Value <<= sFilterOptions;
+
+ return aRet;
+}
+
+void SwXFilterOptions::setPropertyValues( const uno::Sequence<beans::PropertyValue >& aProps )
+ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
+ IllegalArgumentException, WrappedTargetException, uno::RuntimeException)
+{
+ const beans::PropertyValue* pPropArray = aProps.getConstArray();
+ long nPropCount = aProps.getLength();
+ for (long i = 0; i < nPropCount; i++)
+ {
+ const beans::PropertyValue& rProp = pPropArray[i];
+ ::rtl::OUString aPropName = rProp.Name;
+
+ if ( aPropName.equalsAscii( SW_PROP_NAME_STR(UNO_NAME_FILTER_NAME) ) )
+ rProp.Value >>= sFilterName;
+ else if ( aPropName == ::rtl::OUString(FILTER_OPTIONS_NAME) )
+ rProp.Value >>= sFilterOptions;
+ else if ( aPropName.equalsAscii( "InputStream" ) )
+ rProp.Value >>= xInputStream;
+ }
+}
+
+void SwXFilterOptions::setTitle( const ::rtl::OUString& /*rTitle*/ )
+ throw (uno::RuntimeException)
+{
+}
+
+sal_Int16 SwXFilterOptions::execute() throw (uno::RuntimeException)
+{
+ sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
+
+ SvStream* pInStream = NULL;
+ if ( xInputStream.is() )
+ pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
+
+ uno::Reference< XUnoTunnel > xTunnel(xModel, uno::UNO_QUERY);
+ SwDocShell* pDocShell = 0;
+ if(xTunnel.is())
+ {
+ SwXTextDocument* pXDoc = reinterpret_cast< SwXTextDocument * >(
+ sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextDocument::getUnoTunnelId())));
+ pDocShell = pXDoc ? pXDoc->GetDocShell() : 0;
+ }
+ if(pDocShell)
+ {
+
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
+
+ AbstractSwAsciiFilterDlg* pAsciiDlg = pFact->CreateSwAsciiFilterDlg( NULL, *pDocShell,pInStream, DLG_ASCII_FILTER );
+ OSL_ENSURE(pAsciiDlg, "Dialogdiet fail!");
+ if(RET_OK == pAsciiDlg->Execute())
+ {
+ SwAsciiOptions aOptions;
+ pAsciiDlg->FillOptions( aOptions );
+ String sTmp;
+ aOptions.WriteUserData(sTmp);
+ sFilterOptions = sTmp;
+ nRet = ui::dialogs::ExecutableDialogResults::OK;
+ }
+ delete pAsciiDlg;
+ }
+
+ if( pInStream )
+ delete pInStream;
+
+ return nRet;
+}
+
+void SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc )
+ throw (IllegalArgumentException, uno::RuntimeException)
+{
+ bExport = sal_False;
+ xModel = xDoc;
+}
+
+void SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc )
+ throw (IllegalArgumentException,uno::RuntimeException)
+{
+ bExport = sal_True;
+ xModel = xDoc;
+}
+
+::rtl::OUString SwXFilterOptions::getImplementationName() throw(uno::RuntimeException)
+{
+ return ::rtl::OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
+}
+
+sal_Bool SwXFilterOptions::supportsService( const ::rtl::OUString& rServiceName )
+ throw(uno::RuntimeException)
+{
+ return rServiceName == ::rtl::OUString(SWFILTEROPTIONSOBJ_SERVICE);
+}
+
+uno::Sequence< ::rtl::OUString > SwXFilterOptions::getSupportedServiceNames()
+ throw(uno::RuntimeException)
+{
+ return SwXFilterOptions::getSupportedServiceNames_Static();
+}
+
+uno::Reference<uno::XInterface> SAL_CALL SwXFilterOptions_createInstance(
+ const uno::Reference<lang::XMultiServiceFactory>& )
+{
+ SolarMutexGuard aGuard;
+ SwDLL::Init();
+ return (::cppu::OWeakObject*) new SwXFilterOptions;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/SwXPrintPreviewSettings.cxx b/sw/source/ui/uno/SwXPrintPreviewSettings.cxx
new file mode 100644
index 000000000000..63950a5e0816
--- /dev/null
+++ b/sw/source/ui/uno/SwXPrintPreviewSettings.cxx
@@ -0,0 +1,371 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include <SwXPrintPreviewSettings.hxx>
+#include <comphelper/ChainablePropertySetInfo.hxx>
+#include <pvprtdat.hxx>
+#include <swtypes.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <doc.hxx>
+#include <vcl/svapp.hxx>
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::comphelper;
+using ::rtl::OUString;
+
+enum SwPrintSettingsPropertyHandles
+{
+ HANDLE_PRINTSET_PREVIEW_LEFT_MARGIN,
+ HANDLE_PRINTSET_PREVIEW_RIGHT_MARGIN,
+ HANDLE_PRINTSET_PREVIEW_TOP_MARGIN,
+ HANDLE_PRINTSET_PREVIEW_BOTTOM_MARGIN,
+ HANDLE_PRINTSET_PREVIEW_HORIZONTAL_SPACING,
+ HANDLE_PRINTSET_PREVIEW_VERTICAL_SPACING,
+ HANDLE_PRINTSET_PREVIEW_NUM_ROWS,
+ HANDLE_PRINTSET_PREVIEW_NUM_COLUMNS,
+ HANDLE_PRINTSET_PREVIEW_LANDSCAPE
+};
+
+static ChainablePropertySetInfo * lcl_createPrintPreviewSettingsInfo()
+{
+ static PropertyInfo aPrintPreviewSettingsMap_Impl[] =
+ {
+ { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintLeftMargin" ), HANDLE_PRINTSET_PREVIEW_LEFT_MARGIN, CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
+ { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintRightMargin" ), HANDLE_PRINTSET_PREVIEW_RIGHT_MARGIN, CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
+ { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintTopMargin" ), HANDLE_PRINTSET_PREVIEW_TOP_MARGIN, CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
+ { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintBottomMargin" ),HANDLE_PRINTSET_PREVIEW_BOTTOM_MARGIN, CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
+ { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintHorizontalSpacing" ),HANDLE_PRINTSET_PREVIEW_HORIZONTAL_SPACING, CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
+ { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintVerticalSpacing" ), HANDLE_PRINTSET_PREVIEW_VERTICAL_SPACING, CPPUTYPE_INT32, PropertyAttribute::MAYBEVOID, 0 },
+ { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintNumRows" ), HANDLE_PRINTSET_PREVIEW_NUM_ROWS, CPPUTYPE_INT8, PropertyAttribute::MAYBEVOID, 0 },
+ { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintNumColumns" ), HANDLE_PRINTSET_PREVIEW_NUM_COLUMNS, CPPUTYPE_INT8, PropertyAttribute::MAYBEVOID, 0 },
+ { RTL_CONSTASCII_STRINGPARAM ( "PreviewPrintLandscape" ), HANDLE_PRINTSET_PREVIEW_LANDSCAPE, CPPUTYPE_BOOLEAN, PropertyAttribute::MAYBEVOID, 0 },
+ { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
+ };
+ return new ChainablePropertySetInfo ( aPrintPreviewSettingsMap_Impl );
+}
+
+SwXPrintPreviewSettings::SwXPrintPreviewSettings( SwDoc *pDoc)
+: ChainablePropertySet ( lcl_createPrintPreviewSettingsInfo (), &Application::GetSolarMutex() )
+, mbPreviewDataChanged( sal_False )
+, mpDoc( pDoc)
+{
+}
+
+SwXPrintPreviewSettings::~SwXPrintPreviewSettings()
+ throw()
+{
+}
+
+Any SAL_CALL SwXPrintPreviewSettings::queryInterface( const Type& rType )
+ throw(RuntimeException)
+{
+ return ::cppu::queryInterface ( rType ,
+ // OWeakObject interfaces
+ dynamic_cast< XInterface* >( dynamic_cast< OWeakObject* >(this) ) ,
+ dynamic_cast< XWeak* >( this ) ,
+ // my own interfaces
+ dynamic_cast< XServiceInfo* >( this ) ,
+ dynamic_cast< XPropertySet* >( this ) ,
+ dynamic_cast< XMultiPropertySet* >( this ) );
+}
+
+void SwXPrintPreviewSettings::acquire ()
+ throw ()
+{
+ OWeakObject::acquire();
+}
+
+void SwXPrintPreviewSettings::release ()
+ throw ()
+{
+ OWeakObject::release();
+}
+
+void SwXPrintPreviewSettings::_preSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ if ( mpDoc )
+ {
+ const SwPagePreViewPrtData *pConstPrtData = mpDoc->GetPreViewPrtData();
+ mpPreViewData = new SwPagePreViewPrtData;
+ if ( pConstPrtData )
+ {
+ mpPreViewData->SetLeftSpace ( pConstPrtData->GetLeftSpace() );
+ mpPreViewData->SetRightSpace ( pConstPrtData->GetRightSpace() );
+ mpPreViewData->SetTopSpace ( pConstPrtData->GetTopSpace() );
+ mpPreViewData->SetBottomSpace ( pConstPrtData->GetBottomSpace() );
+ mpPreViewData->SetHorzSpace ( pConstPrtData->GetHorzSpace() );
+ mpPreViewData->SetVertSpace ( pConstPrtData->GetVertSpace() );
+ mpPreViewData->SetRow ( pConstPrtData->GetRow() );
+ mpPreViewData->SetCol ( pConstPrtData->GetCol() );
+ mpPreViewData->SetLandscape ( pConstPrtData->GetLandscape() );
+ }
+ }
+}
+
+void SwXPrintPreviewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_PRINTSET_PREVIEW_LEFT_MARGIN:
+ {
+ sal_Int32 nVal = 0;
+ rValue >>= nVal;
+ nVal = MM100_TO_TWIP( nVal );
+ if ( nVal != static_cast < sal_Int32 > (mpPreViewData->GetLeftSpace() ) )
+ {
+ mbPreviewDataChanged = sal_True;
+ mpPreViewData->SetLeftSpace( nVal );
+ }
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_RIGHT_MARGIN:
+ {
+ sal_Int32 nVal = 0;
+ rValue >>= nVal;
+ nVal = MM100_TO_TWIP( nVal );
+ if ( nVal != static_cast < sal_Int32 > (mpPreViewData->GetRightSpace() ) )
+ {
+ mbPreviewDataChanged = sal_True;
+ mpPreViewData->SetRightSpace( nVal );
+ }
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_TOP_MARGIN:
+ {
+ sal_Int32 nVal = 0;
+ rValue >>= nVal;
+ nVal = MM100_TO_TWIP( nVal );
+ if ( nVal != static_cast < sal_Int32 > ( mpPreViewData->GetTopSpace() ) )
+ {
+ mbPreviewDataChanged = sal_True;
+ mpPreViewData->SetTopSpace( nVal );
+ }
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_BOTTOM_MARGIN:
+ {
+ sal_Int32 nVal = 0;
+ rValue >>= nVal;
+ nVal = MM100_TO_TWIP( nVal );
+ if ( nVal != static_cast < sal_Int32 > ( mpPreViewData->GetBottomSpace() ) )
+ {
+ mbPreviewDataChanged = sal_True;
+ mpPreViewData->SetBottomSpace( nVal );
+ }
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_HORIZONTAL_SPACING:
+ {
+ sal_Int32 nVal = 0;
+ rValue >>= nVal;
+ nVal = MM100_TO_TWIP( nVal );
+ if ( nVal != static_cast < sal_Int32 > ( mpPreViewData->GetHorzSpace() ) )
+ {
+ mbPreviewDataChanged = sal_True;
+ mpPreViewData->SetHorzSpace( nVal );
+ }
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_VERTICAL_SPACING:
+ {
+ sal_Int32 nVal = 0;
+ rValue >>= nVal;
+ nVal = MM100_TO_TWIP( nVal );
+ if ( nVal != static_cast < sal_Int32 > ( mpPreViewData->GetVertSpace() ) )
+ {
+ mbPreviewDataChanged = sal_True;
+ mpPreViewData->SetVertSpace( nVal );
+ }
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_NUM_ROWS:
+ {
+ sal_Int8 nVal = 0;
+ rValue >>= nVal;
+ if ( nVal != mpPreViewData->GetRow() )
+ {
+ mbPreviewDataChanged = sal_True;
+ mpPreViewData->SetRow( nVal );
+ }
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_NUM_COLUMNS:
+ {
+ sal_Int8 nVal = 0;
+ rValue >>= nVal;
+ if ( nVal != mpPreViewData->GetCol() )
+ {
+ mbPreviewDataChanged = sal_True;
+ mpPreViewData->SetCol( nVal );
+ }
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_LANDSCAPE:
+ {
+ sal_Bool bVal = *(sal_Bool*)rValue.getValue();
+ if ( bVal != mpPreViewData->GetLandscape() )
+ {
+ mbPreviewDataChanged = sal_True;
+ mpPreViewData->SetLandscape ( bVal );
+ }
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXPrintPreviewSettings::_postSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ if ( mbPreviewDataChanged )
+ {
+ mpDoc->SetPreViewPrtData ( mpPreViewData );
+ mbPreviewDataChanged = sal_False;
+ }
+ delete mpPreViewData;
+ mpPreViewData = NULL;
+}
+
+void SwXPrintPreviewSettings::_preGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ if (mpDoc)
+ mpConstPreViewData = mpDoc->GetPreViewPrtData();
+}
+
+void SwXPrintPreviewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
+ throw(UnknownPropertyException, WrappedTargetException )
+{
+ sal_Bool bBool = TRUE;
+ sal_Bool bBoolVal;
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_PRINTSET_PREVIEW_LEFT_MARGIN:
+ {
+ bBool = FALSE;
+ if ( mpConstPreViewData )
+ rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetLeftSpace() ) );
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_RIGHT_MARGIN:
+ {
+ bBool = FALSE;
+ if ( mpConstPreViewData )
+ rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetRightSpace() ) );
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_TOP_MARGIN:
+ {
+ bBool = FALSE;
+ if ( mpConstPreViewData )
+ rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetTopSpace() ) );
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_BOTTOM_MARGIN:
+ {
+ bBool = FALSE;
+ if ( mpConstPreViewData )
+ rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetBottomSpace() ) );
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_HORIZONTAL_SPACING:
+ {
+ bBool = FALSE;
+ if ( mpConstPreViewData )
+ rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetHorzSpace() ) );
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_VERTICAL_SPACING:
+ {
+ bBool = FALSE;
+ if ( mpConstPreViewData )
+ rValue <<= static_cast < sal_Int32 > ( TWIP_TO_MM100_UNSIGNED( mpConstPreViewData->GetVertSpace() ) );
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_NUM_ROWS:
+ {
+ bBool = FALSE;
+ if ( mpConstPreViewData )
+ rValue <<= static_cast < sal_Int8 > ( mpConstPreViewData->GetRow() );
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_NUM_COLUMNS:
+ {
+ bBool = FALSE;
+ if ( mpConstPreViewData )
+ rValue <<= static_cast < sal_Int8 > ( mpConstPreViewData->GetCol() );
+ }
+ break;
+ case HANDLE_PRINTSET_PREVIEW_LANDSCAPE:
+ {
+ if (mpConstPreViewData)
+ bBoolVal = mpConstPreViewData->GetLandscape();
+ else
+ bBool = FALSE;
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+ if(bBool)
+ rValue.setValue(&bBoolVal, ::getBooleanCppuType());
+}
+
+void SwXPrintPreviewSettings::_postGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ mpConstPreViewData = NULL;
+}
+
+OUString SwXPrintPreviewSettings::getImplementationName(void) throw( RuntimeException )
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM ( "SwXPrintPreviewSettings" ) );
+}
+
+sal_Bool SwXPrintPreviewSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
+{
+ return rServiceName.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.text.PrintPreviewSettings") );
+}
+
+Sequence< OUString > SwXPrintPreviewSettings::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.PrintPreviewSettings" ) );
+ return aRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/SwXPrintPreviewSettings.hxx b/sw/source/ui/uno/SwXPrintPreviewSettings.hxx
new file mode 100644
index 000000000000..518f250a5f3f
--- /dev/null
+++ b/sw/source/ui/uno/SwXPrintPreviewSettings.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SW_XPRINTPREVIEWSETTINGS_HXX_
+#define _SW_XPRINTPREVIEWSETTINGS_HXX_
+
+#ifdef PRECOMPILED
+#include "ui_pch.hxx"
+#endif
+#include <comphelper/ChainablePropertySet.hxx>
+#include <com/sun/star/text/XTextDocument.hpp>
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+class SwDoc;
+class SwPagePreViewPrtData;
+
+class SwXPrintPreviewSettings :public comphelper::ChainablePropertySet,
+ public cppu::OWeakObject,
+ public com::sun::star::lang::XServiceInfo
+{
+ friend class SwXDocumentSettings;
+protected:
+ sal_Bool mbPreviewDataChanged;
+ SwDoc* mpDoc;
+ SwPagePreViewPrtData *mpPreViewData;
+ const SwPagePreViewPrtData *mpConstPreViewData;
+
+ virtual void _preSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _setSingleValue( const comphelper::PropertyInfo & rInfo, const ::com::sun::star::uno::Any &rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postSetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+
+ virtual void _preGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _getSingleValue( const comphelper::PropertyInfo & rInfo, ::com::sun::star::uno::Any & rValue )
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException );
+ virtual void _postGetValues ()
+ throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException );
+ virtual ~SwXPrintPreviewSettings()
+ throw();
+public:
+ SwXPrintPreviewSettings(SwDoc *pDoc);
+
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( )
+ throw ();
+ virtual void SAL_CALL release( )
+ throw ();
+
+ //XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName(void)
+ throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
+ throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
+ throw( ::com::sun::star::uno::RuntimeException );
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/detreg.cxx b/sw/source/ui/uno/detreg.cxx
new file mode 100644
index 000000000000..e6c55d11e2f4
--- /dev/null
+++ b/sw/source/ui/uno/detreg.cxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include "swdetect.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+
+extern "C" {
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char** ppEnvironmentTypeName,
+ uno_Environment** /*ppEnvironment*/ )
+{
+ *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey )
+{
+ Reference< ::registry::XRegistryKey >
+ xKey( reinterpret_cast< ::registry::XRegistryKey* >( pRegistryKey ) ) ;
+
+ OUString aDelimiter( RTL_CONSTASCII_USTRINGPARAM("/") );
+ OUString aUnoServices( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") );
+
+ // Eigentliche Implementierung und ihre Services registrieren
+ sal_Int32 i;
+ Reference< ::registry::XRegistryKey > xNewKey;
+
+ xNewKey = xKey->createKey( aDelimiter + SwFilterDetect::impl_getStaticImplementationName() +
+ aUnoServices );
+
+ Sequence< OUString > aServices = SwFilterDetect::impl_getStaticSupportedServiceNames();
+ for(i = 0; i < aServices.getLength(); i++ )
+ xNewKey->createKey( aServices.getConstArray()[i] );
+
+ return sal_True;
+}
+
+SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/ )
+{
+ // Set default return value for this operation - if it failed.
+ void* pReturn = NULL ;
+
+ if (
+ ( pImplementationName != NULL ) &&
+ ( pServiceManager != NULL )
+ )
+ {
+ // Define variables which are used in following macros.
+ Reference< XSingleServiceFactory > xFactory ;
+ Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
+
+ if( SwFilterDetect::impl_getStaticImplementationName().equalsAscii( pImplementationName ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xServiceManager,
+ SwFilterDetect::impl_getStaticImplementationName(),
+ SwFilterDetect::impl_createInstance,
+ SwFilterDetect::impl_getStaticSupportedServiceNames() );
+ }
+
+ // Factory is valid - service was found.
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pReturn = xFactory.get();
+ }
+ }
+
+ // Return with result of this operation.
+ return pReturn ;
+}
+} // extern "C"
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/dlelstnr.cxx b/sw/source/ui/uno/dlelstnr.cxx
new file mode 100644
index 000000000000..254d2e61b32e
--- /dev/null
+++ b/sw/source/ui/uno/dlelstnr.cxx
@@ -0,0 +1,189 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp>
+#include <com/sun/star/linguistic2/XDictionaryList.hpp>
+#include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
+#include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
+#include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
+#include <com/sun/star/linguistic2/LinguServiceEventFlags.hpp>
+
+#include <unotools/lingucfg.hxx>
+
+#include <com/sun/star/uno/Reference.h>
+#include <comphelper/processfactory.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <tools/shl.hxx>
+#include "dlelstnr.hxx"
+#include <swmodule.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+
+using ::rtl::OUString;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::linguistic2;
+using namespace ::com::sun::star::linguistic2::LinguServiceEventFlags;
+
+#define A2OU(x) OUString::createFromAscii(x)
+
+SwLinguServiceEventListener::SwLinguServiceEventListener()
+{
+ Reference< XMultiServiceFactory > xMgr( comphelper::getProcessServiceFactory() );
+ if (xMgr.is())
+ {
+ try
+ {
+ OUString aSvcName( A2OU( "com.sun.star.frame.Desktop" ) );
+ xDesktop = Reference< frame::XDesktop >(
+ xMgr->createInstance( aSvcName ), UNO_QUERY );
+ if (xDesktop.is())
+ xDesktop->addTerminateListener( this );
+
+ aSvcName = A2OU( "com.sun.star.linguistic2.LinguServiceManager" );
+ xLngSvcMgr = Reference< XLinguServiceManager >( xMgr->createInstance( aSvcName ), UNO_QUERY );
+ if (xLngSvcMgr.is())
+ xLngSvcMgr->addLinguServiceManagerListener( (XLinguServiceEventListener *) this );
+
+ if (SvtLinguConfig().HasGrammarChecker())
+ {
+ aSvcName = A2OU( "com.sun.star.linguistic2.ProofreadingIterator" );
+ xGCIterator = Reference< XProofreadingIterator >( xMgr->createInstance( aSvcName ), UNO_QUERY );
+ Reference< XLinguServiceEventBroadcaster > xBC( xGCIterator, UNO_QUERY );
+ if (xBC.is())
+ xBC->addLinguServiceEventListener( (XLinguServiceEventListener *) this );
+ }
+ }
+ catch (uno::Exception &)
+ {
+ OSL_ENSURE(0, "exception caught in SwLinguServiceEventListener c-tor" );
+ }
+ }
+}
+
+SwLinguServiceEventListener::~SwLinguServiceEventListener()
+{
+}
+
+void SwLinguServiceEventListener::processDictionaryListEvent(
+ const DictionaryListEvent& rDicListEvent)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ sal_Int16 nEvt = rDicListEvent.nCondensedEvent;
+
+ sal_Int16 nSpellWrongFlags =
+ DictionaryListEventFlags::ADD_POS_ENTRY |
+ DictionaryListEventFlags::DEL_NEG_ENTRY |
+ DictionaryListEventFlags::ACTIVATE_POS_DIC |
+ DictionaryListEventFlags::DEACTIVATE_NEG_DIC;
+ sal_Bool bIsSpellWrong = 0 != (nEvt & nSpellWrongFlags);
+ sal_Int16 nSpellAllFlags =
+ DictionaryListEventFlags::ADD_NEG_ENTRY |
+ DictionaryListEventFlags::DEL_POS_ENTRY |
+ DictionaryListEventFlags::ACTIVATE_NEG_DIC |
+ DictionaryListEventFlags::DEACTIVATE_POS_DIC;
+ sal_Bool bIsSpellAll = 0 != (nEvt & nSpellAllFlags);
+
+ if (bIsSpellWrong || bIsSpellAll)
+ SW_MOD()->CheckSpellChanges( sal_False, bIsSpellWrong, bIsSpellAll, sal_False );
+}
+
+void SAL_CALL SwLinguServiceEventListener::processLinguServiceEvent(
+ const LinguServiceEvent& rLngSvcEvent )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ sal_Bool bIsSpellWrong = 0 != (rLngSvcEvent.nEvent & SPELL_WRONG_WORDS_AGAIN);
+ sal_Bool bIsSpellAll = 0 != (rLngSvcEvent.nEvent & SPELL_CORRECT_WORDS_AGAIN);
+ if (0 != (rLngSvcEvent.nEvent & PROOFREAD_AGAIN))
+ bIsSpellWrong = bIsSpellAll = sal_True; // have all spelling and grammar checked...
+ if (bIsSpellWrong || bIsSpellAll)
+ {
+ SW_MOD()->CheckSpellChanges( sal_False, bIsSpellWrong, bIsSpellAll, sal_False );
+ }
+ if (rLngSvcEvent.nEvent & HYPHENATE_AGAIN)
+ {
+ SwView *pSwView = SW_MOD()->GetFirstView();
+
+ //!! since this function may be called within the ctor of
+ //!! SwView (during formatting) where the WrtShell is not yet
+ //!! created, we have to check for the WrtShellPtr to see
+ //!! if it is already availbale
+ while (pSwView && pSwView->GetWrtShellPtr())
+ {
+ pSwView->GetWrtShell().ChgHyphenation();
+ pSwView = SW_MOD()->GetNextView( pSwView );
+ }
+ }
+}
+
+void SAL_CALL SwLinguServiceEventListener::disposing(
+ const EventObject& rEventObj )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if (xLngSvcMgr.is() && rEventObj.Source == xLngSvcMgr)
+ xLngSvcMgr = 0;
+ if (xLngSvcMgr.is() && rEventObj.Source == xGCIterator)
+ xGCIterator = 0;
+}
+
+void SAL_CALL SwLinguServiceEventListener::queryTermination(
+ const EventObject& /*rEventObj*/ )
+ throw(TerminationVetoException, RuntimeException)
+{
+ //SolarMutexGuard aGuard;
+}
+
+void SAL_CALL SwLinguServiceEventListener::notifyTermination(
+ const EventObject& rEventObj )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if (xDesktop.is() && rEventObj.Source == xDesktop)
+ {
+ if (xLngSvcMgr.is())
+ xLngSvcMgr = 0;
+ if (xGCIterator.is())
+ xGCIterator = 0;
+ xDesktop = NULL;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/makefile.mk b/sw/source/ui/uno/makefile.mk
new file mode 100644
index 000000000000..0023fd52f55c
--- /dev/null
+++ b/sw/source/ui/uno/makefile.mk
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=sw
+TARGET=unoidl
+ENABLE_EXCEPTIONS=TRUE
+LIBTARGET=no
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/inc$/swpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/inc$/sw.mk
+
+.IF "$(DVO_XFORMS)" != ""
+CDEFS+=-DDVO_XFORMS
+.ENDIF
+
+# --- Files --------------------------------------------------------
+
+SLO1FILES = \
+ $(SLO)$/unodefaults.obj\
+ $(SLO)$/unodispatch.obj\
+ $(SLO)$/unotxdoc.obj\
+ $(SLO)$/unoatxt.obj \
+ $(SLO)$/unomailmerge.obj \
+ $(SLO)$/unomod.obj \
+ $(SLO)$/unotxvw.obj \
+ $(SLO)$/dlelstnr.obj \
+ $(SLO)$/unofreg.obj \
+ $(SLO)$/SwXDocumentSettings.obj \
+ $(SLO)$/SwXPrintPreviewSettings.obj \
+ $(SLO)$/SwXFilterOptions.obj\
+ $(SLO)$/RefreshListenerContainer.obj \
+ $(SLO)$/unomodule.obj \
+ $(SLO)$/unodoc.obj
+
+SLO2FILES = \
+ $(SLO)$/swdetect.obj \
+ $(SLO)$/swdet2.obj \
+ $(SLO)$/detreg.obj
+
+SLOFILES = \
+ $(SLO1FILES) \
+ $(SLO2FILES)
+
+LIB1TARGET = \
+ $(SLB)$/$(TARGET).lib
+
+LIB1OBJFILES = \
+ $(SLO1FILES)
+
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sw/source/ui/uno/swdet2.cxx b/sw/source/ui/uno/swdet2.cxx
new file mode 100644
index 000000000000..1956fe8b75c9
--- /dev/null
+++ b/sw/source/ui/uno/swdet2.cxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#define _SWLIB_CXX
+#include <sfx2/docfac.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/app.hxx>
+#include <svtools/sfxecode.hxx>
+#include <vcl/msgbox.hxx>
+#include <svtools/parhtml.hxx>
+#include <sot/clsids.hxx>
+#include <iodetect.hxx>
+
+#include <swdetect.hxx>
+
+#include <app.hrc>
+#include <web.hrc>
+#include <globdoc.hrc>
+
+#include <unotools/moduleoptions.hxx>
+
+#include <unomid.h>
+
+bool IsDocShellRegistered()
+{
+ return SvtModuleOptions().IsWriter();
+}
+
+//-------------------------------------------------------------------------
+
+ULONG SwFilterDetect::DetectFilter( SfxMedium& rMedium, const SfxFilter** ppFilter )
+{
+ ULONG nRet = ERRCODE_NONE;
+ if( *ppFilter )
+ {
+ // verify the given filter
+ String aPrefFlt = (*ppFilter)->GetUserData();
+
+ // detection for TextFilter needs an additional checking
+ BOOL bDetected = SwIoSystem::IsFileFilter( rMedium, aPrefFlt );
+ return bDetected ? nRet : ERRCODE_ABORT;
+ }
+
+ // mba: without preselection there is no PrefFlt
+ String aPrefFlt;
+ const SfxFilter* pTmp = SwIoSystem::GetFileFilter( rMedium.GetPhysicalName(), aPrefFlt, &rMedium );
+ if( !pTmp )
+ return ERRCODE_ABORT;
+ /*
+ else if( *ppFilter && (*ppFilter)->GetUserData().EqualsAscii( "W4W", 0, 3 )
+ && pTmp->GetUserData().EqualsAscii( FILTER_TEXT, 0, 4 ) )
+ {
+ // Bug 95262 - if the user (or short detect) select a
+ // Word 4 Word filter, but the autodect of mastersoft
+ // can't detect it, we normally return the ascii filter
+ // But the user may have a change to use the W4W filter,
+ // so the SFX must show now a dialog with the 2 filters
+ nRet = ERRCODE_SFX_CONSULTUSER;
+ *ppFilter = pTmp;
+ } */
+
+ // sollte der voreingestellte Filter ASCII sein und wir haben
+ // ASCII erkannt, dann ist das ein gultiger Filter, ansonsten ist das
+ // ein Fehler und wir wollen die Filterbox sehen
+ /*
+ else if( pTmp->GetUserData().EqualsAscii( FILTER_TEXT ) )
+ {
+ // Bug 28974: "Text" erkannt, aber "Text Dos" "Text ..." eingestellt
+ // -> keine FilterBox, sondern den eingestellten Filter benutzen
+ if( *ppFilter && (*ppFilter)->GetUserData().EqualsAscii( FILTER_TEXT, 0, 4 ) )
+ ;
+ else
+// if( !*ppFilter || COMPARE_EQUAL != pTmp->GetUserData().Compare((*ppFilter)->GetUserData(), 4 ))
+ {
+// nRet = ERRCODE_ABORT;
+ *ppFilter = pTmp;
+ }
+ } */
+ else
+ {
+ //Bug 41417: JP 09.07.97: HTML documents should be loaded by WebWriter
+ SfxFilterContainer aFilterContainer( String::CreateFromAscii("swriter/web") );
+ if( pTmp->GetUserData() != C2S(sHTML) ||
+ String::CreateFromAscii( "com.sun.star.text.WebDocument" ) ==
+ String( pTmp->GetServiceName() ) ||
+ 0 == ( (*ppFilter) = SwIoSystem::GetFilterOfFormat( C2S(sHTML),
+ &aFilterContainer ) ) )
+ *ppFilter = pTmp;
+ }
+
+ return nRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/swdetect.cxx b/sw/source/ui/uno/swdetect.cxx
new file mode 100644
index 000000000000..ab62a5d422db
--- /dev/null
+++ b/sw/source/ui/uno/swdetect.cxx
@@ -0,0 +1,487 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include "swdetect.hxx"
+
+#include <framework/interaction.hxx>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
+#include <com/sun/star/ucb/CommandAbortedException.hpp>
+#include <com/sun/star/ucb/InteractiveAppException.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/packages/zip/ZipIOException.hpp>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <ucbhelper/simpleinteractionrequest.hxx>
+#include <rtl/ustring.h>
+#include <rtl/logfile.hxx>
+#include <svl/itemset.hxx>
+#include <vcl/window.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+#include <tools/urlobj.hxx>
+#include <osl/mutex.hxx>
+#include <svtools/sfxecode.hxx>
+#include <svtools/ehdl.hxx>
+#include <sot/storinfo.hxx>
+#include <vcl/svapp.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/request.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/fcontnr.hxx>
+#include <sfx2/brokenpackageint.hxx>
+#include <svtools/FilterConfigItem.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <com/sun/star/util/XArchiver.hpp>
+#include <comphelper/ihwrapnofilter.hxx>
+
+#include <swdll.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ucb;
+using ::rtl::OUString;
+
+SwFilterDetect::SwFilterDetect( const REFERENCE < lang::XMultiServiceFactory >& /*xFactory*/ )
+{
+}
+
+SwFilterDetect::~SwFilterDetect()
+{
+}
+
+::rtl::OUString SAL_CALL SwFilterDetect::detect( uno::Sequence< beans::PropertyValue >& lDescriptor ) throw( uno::RuntimeException )
+{
+ REFERENCE< XInputStream > xStream;
+ REFERENCE< XContent > xContent;
+ REFERENCE< XInteractionHandler > xInteraction;
+ String aURL;
+ ::rtl::OUString sTemp;
+ String aTypeName; // a name describing the type (from MediaDescriptor, usually from flat detection)
+ String aPreselectedFilterName; // a name describing the filter to use (from MediaDescriptor, usually from UI action)
+
+ ::rtl::OUString aDocumentTitle; // interesting only if set in this method
+
+ // opening as template is done when a parameter tells to do so and a template filter can be detected
+ // (otherwise no valid filter would be found) or if the detected filter is a template filter and
+ // there is no parameter that forbids to open as template
+ sal_Bool bOpenAsTemplate = sal_False;
+ sal_Bool bWasReadOnly = sal_False, bReadOnly = sal_False;
+
+ sal_Bool bRepairPackage = sal_False;
+ sal_Bool bRepairAllowed = sal_False;
+
+ // now some parameters that can already be in the array, but may be overwritten or new inserted here
+ // remember their indices in the case new values must be added to the array
+ sal_Int32 nPropertyCount = lDescriptor.getLength();
+ sal_Int32 nIndexOfFilterName = -1;
+ sal_Int32 nIndexOfInputStream = -1;
+ sal_Int32 nIndexOfContent = -1;
+ sal_Int32 nIndexOfReadOnlyFlag = -1;
+ sal_Int32 nIndexOfTemplateFlag = -1;
+ sal_Int32 nIndexOfDocumentTitle = -1;
+ sal_Int32 nIndexOfInteractionHandler = -1;
+
+ for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
+ {
+ // extract properties
+ if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("URL")) )
+ {
+ lDescriptor[nProperty].Value >>= sTemp;
+ aURL = sTemp;
+ }
+ else if( !aURL.Len() && lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("FileName")) )
+ {
+ lDescriptor[nProperty].Value >>= sTemp;
+ aURL = sTemp;
+ }
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("TypeName")) )
+ {
+ lDescriptor[nProperty].Value >>= sTemp;
+ aTypeName = sTemp;
+ }
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("FilterName")) )
+ {
+ lDescriptor[nProperty].Value >>= sTemp;
+ aPreselectedFilterName = sTemp;
+
+ // if the preselected filter name is not correct, it must be erased after detection
+ // remember index of property to get access to it later
+ nIndexOfFilterName = nProperty;
+ }
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream")) )
+ nIndexOfInputStream = nProperty;
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly")) )
+ nIndexOfReadOnlyFlag = nProperty;
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("UCBContent")) )
+ nIndexOfContent = nProperty;
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate")) )
+ {
+ lDescriptor[nProperty].Value >>= bOpenAsTemplate;
+ nIndexOfTemplateFlag = nProperty;
+ }
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("InteractionHandler")) )
+ {
+ lDescriptor[nProperty].Value >>= xInteraction;
+ nIndexOfInteractionHandler = nProperty;
+ }
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("RepairPackage")) )
+ lDescriptor[nProperty].Value >>= bRepairPackage;
+ else if( lDescriptor[nProperty].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentTitle")) )
+ nIndexOfDocumentTitle = nProperty;
+ }
+
+ // can't check the type for external filters, so set the "dont" flag accordingly
+ SolarMutexGuard aGuard;
+ //SfxFilterFlags nMust = SFX_FILTER_IMPORT, nDont = SFX_FILTER_NOTINSTALLED;
+
+ SfxApplication* pApp = SFX_APP();
+ SfxAllItemSet *pSet = new SfxAllItemSet( pApp->GetPool() );
+ TransformParameters( SID_OPENDOC, lDescriptor, *pSet );
+ SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, SID_DOC_READONLY, FALSE );
+
+ bWasReadOnly = pItem && pItem->GetValue();
+
+ const SfxFilter* pFilter = 0;
+ String aPrefix = String::CreateFromAscii( "private:factory/" );
+ if( aURL.Match( aPrefix ) == aPrefix.Len() )
+ {
+ if( SvtModuleOptions().IsWriter() )
+ {
+ String aPattern( aPrefix );
+ aPattern += String::CreateFromAscii("swriter");
+ if ( aURL.Match( aPattern ) >= aPattern.Len() )
+ //pFilter = SfxFilter::GetDefaultFilterFromFactory( aURL );
+ return aTypeName;
+ }
+ }
+ else
+ {
+ // ctor of SfxMedium uses owner transition of ItemSet
+ SfxMedium aMedium( aURL, bWasReadOnly ? STREAM_STD_READ : STREAM_STD_READWRITE, FALSE, NULL, pSet );
+ aMedium.UseInteractionHandler( TRUE );
+ if ( aMedium.GetErrorCode() == ERRCODE_NONE )
+ {
+ // remember input stream and content and put them into the descriptor later
+ // should be done here since later the medium can switch to a version
+ xStream = aMedium.GetInputStream();
+ xContent = aMedium.GetContent();
+ bReadOnly = aMedium.IsReadOnly();
+
+ BOOL bIsStorage = aMedium.IsStorage();
+ if ( bIsStorage )
+ {
+ uno::Reference< embed::XStorage > xStorage = aMedium.GetStorage( sal_False );
+ if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE )
+ {
+ // error during storage creation means _here_ that the medium
+ // is broken, but we can not handle it in medium since impossibility
+ // to create a storage does not _always_ means that the medium is broken
+ aMedium.SetError( aMedium.GetLastStorageCreationState(), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ if ( xInteraction.is() )
+ {
+ OUString empty;
+ try
+ {
+ InteractiveAppException xException( empty,
+ REFERENCE< XInterface >(),
+ InteractionClassification_ERROR,
+ aMedium.GetError() );
+
+ REFERENCE< XInteractionRequest > xRequest(
+ new ucbhelper::SimpleInteractionRequest( makeAny( xException ),
+ ucbhelper::CONTINUATION_APPROVE ) );
+ xInteraction->handle( xRequest );
+ }
+ catch ( Exception & ) {};
+ }
+ }
+ else
+ {
+ OSL_ENSURE( xStorage.is(), "At this point storage must exist!" );
+
+ try
+ {
+ const SfxFilter* pPreFilter = aPreselectedFilterName.Len() ?
+ SfxFilterMatcher().GetFilter4FilterName( aPreselectedFilterName ) : aTypeName.Len() ?
+ SfxFilterMatcher(String::CreateFromAscii("swriter")).GetFilter4EA( aTypeName ) : 0;
+ if (!pPreFilter)
+ pPreFilter = SfxFilterMatcher(String::CreateFromAscii("sweb")).GetFilter4EA( aTypeName );
+ String aFilterName;
+ if ( pPreFilter )
+ {
+ aFilterName = pPreFilter->GetName();
+ aTypeName = pPreFilter->GetTypeName();
+ }
+
+ aTypeName = SfxFilter::GetTypeFromStorage( xStorage, pPreFilter ? pPreFilter->IsOwnTemplateFormat() : FALSE, &aFilterName );
+ }
+ catch( lang::WrappedTargetException& aWrap )
+ {
+ packages::zip::ZipIOException aZipException;
+
+ // repairing is done only if this type is requested from outside
+ // we don't do any type detection on broken packages (f.e. because it might be impossible), so any requested
+ // type will be accepted if the user allows to repair the file
+ if ( ( aWrap.TargetException >>= aZipException ) && ( aTypeName.Len() || aPreselectedFilterName.Len() ) )
+ {
+ if ( xInteraction.is() )
+ {
+ // the package is a broken one
+ aDocumentTitle = aMedium.GetURLObject().getName(
+ INetURLObject::LAST_SEGMENT,
+ true,
+ INetURLObject::DECODE_WITH_CHARSET );
+
+ if ( !bRepairPackage )
+ {
+ // ask the user whether he wants to try to repair
+ RequestPackageReparation* pRequest = new RequestPackageReparation( aDocumentTitle );
+ uno::Reference< task::XInteractionRequest > xRequest ( pRequest );
+ xInteraction->handle( xRequest );
+ bRepairAllowed = pRequest->isApproved();
+ }
+
+ if ( !bRepairAllowed )
+ {
+ // repair either not allowed or not successful
+ NotifyBrokenPackage* pNotifyRequest = new NotifyBrokenPackage( aDocumentTitle );
+ uno::Reference< task::XInteractionRequest > xRequest ( pNotifyRequest );
+ xInteraction->handle( xRequest );
+
+ rtl::Reference< ::comphelper::OIHWrapNoFilterDialog > xHandler = new ::comphelper::OIHWrapNoFilterDialog( xInteraction );
+ if ( nIndexOfInteractionHandler != -1 )
+ lDescriptor[nIndexOfInteractionHandler].Value <<= uno::Reference< XInteractionHandler >( static_cast< task::XInteractionHandler* >( xHandler.get() ) );
+
+ aMedium.SetError( ERRCODE_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+ }
+ }
+ else
+ // no interaction, error handling as usual
+ aMedium.SetError( ERRCODE_IO_BROKENPACKAGE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) );
+
+ if ( !bRepairAllowed )
+ {
+ aTypeName.Erase();
+ aPreselectedFilterName.Erase();
+ }
+ }
+ }
+ catch( uno::RuntimeException& )
+ {
+ throw;
+ }
+ catch( uno::Exception& )
+ {
+ aTypeName.Erase();
+ aPreselectedFilterName.Erase();
+ }
+ }
+ }
+ else
+ {
+ aMedium.GetInStream();
+ if ( aMedium.GetErrorCode() == ERRCODE_NONE )
+ {
+ if ( aPreselectedFilterName.Len() )
+ pFilter = SfxFilter::GetFilterByName( aPreselectedFilterName );
+ else
+ pFilter = SfxFilterMatcher().GetFilter4EA( aTypeName );
+
+ BOOL bTestWriter = !pFilter || pFilter->GetServiceName().EqualsAscii("com.sun.star.text.TextDocument") ||
+ pFilter->GetServiceName().EqualsAscii("com.sun.star.text.WebDocument");
+ BOOL bTestGlobal = !pFilter || pFilter->GetServiceName().EqualsAscii("com.sun.star.text.GlobalDocument");
+
+ const SfxFilter* pOrigFilter = NULL;
+ if ( !bTestWriter && !bTestGlobal && pFilter )
+ {
+ // cross filter; now this should be a type detection only, not a filter detection
+ // we can simulate it by preserving the preselected filter if the type matches
+ // example: HTML filter for Calc
+ pOrigFilter = pFilter;
+ pFilter = SfxFilterMatcher().GetFilter4EA( pFilter->GetTypeName() );
+ bTestWriter = TRUE;
+ }
+
+ ULONG nErr = ERRCODE_NONE;
+ if ( pFilter || bTestWriter )
+ nErr = DetectFilter( aMedium, &pFilter );
+ if ( nErr != ERRCODE_NONE )
+ pFilter = NULL;
+ else if ( pOrigFilter && pFilter && pFilter->GetTypeName() == pOrigFilter->GetTypeName() )
+ // cross filter, see above
+ pFilter = pOrigFilter;
+ }
+
+ if ( pFilter )
+ aTypeName = pFilter->GetTypeName();
+ else
+ aTypeName.Erase();
+ }
+ }
+ }
+
+ if ( nIndexOfInputStream == -1 && xStream.is() )
+ {
+ // if input stream wasn't part of the descriptor, now it should be, otherwise the content would be opend twice
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream"));
+ lDescriptor[nPropertyCount].Value <<= xStream;
+ nPropertyCount++;
+ }
+
+ if ( nIndexOfContent == -1 && xContent.is() )
+ {
+ // if input stream wasn't part of the descriptor, now it should be, otherwise the content would be opend twice
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UCBContent"));
+ lDescriptor[nPropertyCount].Value <<= xContent;
+ nPropertyCount++;
+ }
+
+ if ( bReadOnly != bWasReadOnly )
+ {
+ if ( nIndexOfReadOnlyFlag == -1 )
+ {
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ReadOnly"));
+ lDescriptor[nPropertyCount].Value <<= bReadOnly;
+ nPropertyCount++;
+ }
+ else
+ lDescriptor[nIndexOfReadOnlyFlag].Value <<= bReadOnly;
+ }
+
+ if ( !bRepairPackage && bRepairAllowed )
+ {
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RepairPackage"));
+ lDescriptor[nPropertyCount].Value <<= bRepairAllowed;
+ nPropertyCount++;
+ bOpenAsTemplate = sal_True;
+ // TODO/LATER: set progress bar that should be used
+ }
+
+ if ( bOpenAsTemplate )
+ {
+ if ( nIndexOfTemplateFlag == -1 )
+ {
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AsTemplate"));
+ lDescriptor[nPropertyCount].Value <<= bOpenAsTemplate;
+ nPropertyCount++;
+ }
+ else
+ lDescriptor[nIndexOfTemplateFlag].Value <<= bOpenAsTemplate;
+ }
+
+ if ( aDocumentTitle.getLength() )
+ {
+ // the title was set here
+ if ( nIndexOfDocumentTitle == -1 )
+ {
+ lDescriptor.realloc( nPropertyCount + 1 );
+ lDescriptor[nPropertyCount].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentTitle"));
+ lDescriptor[nPropertyCount].Value <<= aDocumentTitle;
+ nPropertyCount++;
+ }
+ else
+ lDescriptor[nIndexOfDocumentTitle].Value <<= aDocumentTitle;
+ }
+
+
+ return aTypeName;
+}
+
+SFX_IMPL_SINGLEFACTORY( SwFilterDetect )
+
+/* XServiceInfo */
+UNOOUSTRING SAL_CALL SwFilterDetect::getImplementationName() throw( UNORUNTIMEEXCEPTION )
+{
+ return impl_getStaticImplementationName();
+}
+ \
+/* XServiceInfo */
+sal_Bool SAL_CALL SwFilterDetect::supportsService( const UNOOUSTRING& sServiceName ) throw( UNORUNTIMEEXCEPTION )
+{
+ UNOSEQUENCE< UNOOUSTRING > seqServiceNames = getSupportedServiceNames();
+ const UNOOUSTRING* pArray = seqServiceNames.getConstArray();
+ for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
+ {
+ if ( pArray[nCounter] == sServiceName )
+ {
+ return sal_True ;
+ }
+ }
+ return sal_False ;
+}
+
+/* XServiceInfo */
+UNOSEQUENCE< UNOOUSTRING > SAL_CALL SwFilterDetect::getSupportedServiceNames() throw( UNORUNTIMEEXCEPTION )
+{
+ return impl_getStaticSupportedServiceNames();
+}
+
+/* Helper for XServiceInfo */
+UNOSEQUENCE< UNOOUSTRING > SwFilterDetect::impl_getStaticSupportedServiceNames()
+{
+ UNOMUTEXGUARD aGuard( UNOMUTEX::getGlobalMutex() );
+ UNOSEQUENCE< UNOOUSTRING > seqServiceNames( 3 );
+ seqServiceNames.getArray() [0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ExtendedTypeDetection" ));
+ seqServiceNames.getArray() [1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.FormatDetector" ));
+ seqServiceNames.getArray() [2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.text.W4WFormatDetector" ));
+ return seqServiceNames ;
+}
+
+/* Helper for XServiceInfo */
+UNOOUSTRING SwFilterDetect::impl_getStaticImplementationName()
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.writer.FormatDetector" ));
+}
+
+/* Helper for registry */
+UNOREFERENCE< UNOXINTERFACE > SAL_CALL SwFilterDetect::impl_createInstance( const UNOREFERENCE< UNOXMULTISERVICEFACTORY >& xServiceManager ) throw( UNOEXCEPTION )
+{
+ return UNOREFERENCE< UNOXINTERFACE >( *new SwFilterDetect( xServiceManager ) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/swdetect.hxx b/sw/source/ui/uno/swdetect.hxx
new file mode 100644
index 000000000000..5d6d3234530a
--- /dev/null
+++ b/sw/source/ui/uno/swdetect.hxx
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SW_TYPEDETECT_HXX
+#define _SW_TYPEDETECT_HXX
+
+#include <rtl/ustring.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include <cppuhelper/implbase2.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <cppuhelper/factory.hxx>
+#include <tools/link.hxx>
+#include <tools/string.hxx>
+
+class SfxMedium;
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace uno
+ {
+ class Any;
+ }
+ namespace lang
+ {
+ class XMultiServiceFactory;
+ }
+ namespace frame
+ {
+ class XFrame;
+ }
+ namespace beans
+ {
+ struct PropertyValue;
+ }
+ }
+ }
+}
+
+#include <sfx2/sfxuno.hxx>
+class SfxMedium;
+class SfxFilter;
+
+#define REFERENCE ::com::sun::star::uno::Reference
+#define SEQUENCE ::com::sun::star::uno::Sequence
+#define RUNTIME_EXCEPTION ::com::sun::star::uno::RuntimeException
+
+class SwFilterDetect : public ::cppu::WeakImplHelper2< ::com::sun::star::document::XExtendedFilterDetection, ::com::sun::star::lang::XServiceInfo >
+{
+ static ULONG DetectFilter( SfxMedium& rMedium, const SfxFilter** ppFilter );
+ static ULONG GlobDetectFilter( SfxMedium& rMedium, const SfxFilter** ppFilter );
+public:
+ SwFilterDetect( const REFERENCE < ::com::sun::star::lang::XMultiServiceFactory >& xFactory );
+ virtual ~SwFilterDetect();
+
+ SFX_DECL_XSERVICEINFO
+
+ //----------------------------------------------------------------------------------
+ // XExtendedFilterDetect
+ //----------------------------------------------------------------------------------
+ virtual ::rtl::OUString SAL_CALL detect( SEQUENCE< ::com::sun::star::beans::PropertyValue >& lDescriptor ) throw( RUNTIME_EXCEPTION );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx
new file mode 100644
index 000000000000..c05d258f6374
--- /dev/null
+++ b/sw/source/ui/uno/unoatxt.cxx
@@ -0,0 +1,1148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#define _SVSTDARR_STRINGS
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <osl/mutex.hxx>
+#include <osl/diagnose.h>
+#include <vcl/svapp.hxx>
+#include <svl/svstdarr.hxx>
+#include <svtools/unoevent.hxx>
+#include <svl/urihelper.hxx>
+#include <sfx2/event.hxx>
+#include <swtypes.hxx>
+#include <glosdoc.hxx>
+#include <shellio.hxx>
+#include <initui.hxx>
+#include <gloslst.hxx>
+#include <unoatxt.hxx>
+#include <unomap.hxx>
+#include <unomid.h>
+#include <unotextbodyhf.hxx>
+#include <unotextrange.hxx>
+#include <TextCursorHelper.hxx>
+#include <swevent.hxx>
+#include <doc.hxx>
+#include <unocrsr.hxx>
+#include <IMark.hxx>
+#include <unoprnms.hxx>
+#include <docsh.hxx>
+#include <swunodef.hxx>
+#include <swmodule.hxx>
+#include <svl/smplhint.hxx>
+#include <svl/macitem.hxx>
+
+#include <editeng/acorrcfg.hxx>
+
+#include <memory>
+
+
+SV_IMPL_REF ( SwDocShell )
+using namespace ::com::sun::star;
+using ::rtl::OUString;
+
+uno::Reference< uno::XInterface > SAL_CALL SwXAutoTextContainer_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception )
+{
+ //the module may not be loaded
+ SolarMutexGuard aGuard;
+ SwDLL::Init();
+ static uno::Reference< uno::XInterface > xAText = (cppu::OWeakObject*)new SwXAutoTextContainer();;
+ return xAText;
+}
+
+uno::Sequence< OUString > SAL_CALL SwXAutoTextContainer_getSupportedServiceNames() throw()
+{
+ OUString sService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.AutoTextContainer"));
+ const uno::Sequence< OUString > aSeq( &sService, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SwXAutoTextContainer_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SwXAutoTextContainer" ) );
+}
+
+SwXAutoTextContainer::SwXAutoTextContainer()
+{
+ pGlossaries = ::GetGlossaries();
+
+}
+
+SwXAutoTextContainer::~SwXAutoTextContainer()
+{
+
+}
+
+sal_Int32 SwXAutoTextContainer::getCount(void) throw( uno::RuntimeException )
+{
+ return pGlossaries->GetGroupCnt();
+}
+
+uno::Any SwXAutoTextContainer::getByIndex(sal_Int32 nIndex)
+ throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+ sal_uInt16 nCount = pGlossaries->GetGroupCnt();
+ if ( 0 <= nIndex && nIndex < nCount )
+ aRet = getByName(pGlossaries->GetGroupName( static_cast< USHORT >(nIndex) ));
+ else
+ throw lang::IndexOutOfBoundsException();
+ return aRet;
+}
+
+uno::Type SwXAutoTextContainer::getElementType(void) throw( uno::RuntimeException )
+{
+ return ::getCppuType((const uno::Reference<text::XAutoTextGroup>*)0);
+
+}
+
+sal_Bool SwXAutoTextContainer::hasElements(void) throw( uno::RuntimeException )
+{
+ //zumindest Standard sollte es immer geben!
+ return sal_True;
+}
+
+uno::Any SwXAutoTextContainer::getByName(const OUString& GroupName)
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ uno::Reference< text::XAutoTextGroup > xGroup;
+ if ( pGlossaries && hasByName( GroupName ) ) // group name already known?
+ // TRUE = create group if not already available
+ xGroup = pGlossaries->GetAutoTextGroup( GroupName, TRUE );
+
+ if ( !xGroup.is() )
+ throw container::NoSuchElementException();
+
+ return makeAny( xGroup );
+}
+
+uno::Sequence< OUString > SwXAutoTextContainer::getElementNames(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_uInt16 nCount = pGlossaries->GetGroupCnt();
+
+ uno::Sequence< OUString > aGroupNames(nCount);
+ OUString *pArr = aGroupNames.getArray();
+
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ // Die Namen werden ohne Pfad-Extension weitergegeben
+ String sGroupName(pGlossaries->GetGroupName(i));
+ pArr[i] = sGroupName.GetToken(0, GLOS_DELIM);
+ }
+ return aGroupNames;
+}
+/*-- 21.12.98 12:42:19---------------------------------------------------
+ findet Gruppennamen mit und ohne Pfadindex
+ -----------------------------------------------------------------------*/
+sal_Bool SwXAutoTextContainer::hasByName(const OUString& Name)
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ String sGroupName( pGlossaries->GetCompleteGroupName( Name ) );
+ if(sGroupName.Len())
+ return sal_True;
+ return sal_False;
+}
+
+uno::Reference< text::XAutoTextGroup > SwXAutoTextContainer::insertNewByName(
+ const OUString& aGroupName)
+ throw( lang::IllegalArgumentException, container::ElementExistException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(hasByName(aGroupName))
+ throw container::ElementExistException();
+ //check for non-ASCII characters
+ if(!aGroupName.getLength())
+ {
+ lang::IllegalArgumentException aIllegal;
+ aIllegal.Message = C2U("group name must not be empty");
+ throw aIllegal;
+ }
+ for(sal_Int32 nPos = 0; nPos < aGroupName.getLength(); nPos++)
+ {
+ sal_Unicode cChar = aGroupName[nPos];
+ if( ((cChar >= 'A') && (cChar <= 'Z')) ||
+ ((cChar >= 'a') && (cChar <= 'z')) ||
+ ((cChar >= '0') && (cChar <= '9')) ||
+ (cChar == '_') ||
+ (cChar == 0x20) ||
+ (cChar == GLOS_DELIM) )
+ {
+ continue;
+ }
+ lang::IllegalArgumentException aIllegal;
+ aIllegal.Message = C2U("group name must contain a-z, A-z, '_', ' ' only");
+ throw aIllegal;
+ }
+ String sGroup(aGroupName);
+ if(STRING_NOTFOUND == sGroup.Search(GLOS_DELIM))
+ {
+ sGroup += GLOS_DELIM;
+ sGroup += UniString::CreateFromInt32(0);
+ }
+ pGlossaries->NewGroupDoc(sGroup, sGroup.GetToken(0, GLOS_DELIM));
+
+ uno::Reference< text::XAutoTextGroup > xGroup = pGlossaries->GetAutoTextGroup( sGroup, true );
+ OSL_ENSURE( xGroup.is(), "SwXAutoTextContainer::insertNewByName: no UNO object created? How this?" );
+ // we just inserted the group into the glossaries, so why doesn't it exist?
+
+ return xGroup;
+}
+
+void SwXAutoTextContainer::removeByName(const OUString& aGroupName)
+ throw( container::NoSuchElementException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ //zunaechst den Namen mit Pfad-Extension finden
+ String sGroupName = pGlossaries->GetCompleteGroupName( aGroupName );
+ if(!sGroupName.Len())
+ throw container::NoSuchElementException();
+ pGlossaries->DelGroupDoc(sGroupName);
+}
+
+OUString SwXAutoTextContainer::getImplementationName(void) throw( uno::RuntimeException )
+{
+ return SwXAutoTextContainer_getImplementationName();
+}
+
+BOOL SwXAutoTextContainer::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
+{
+ const uno::Sequence< OUString > aNames = SwXAutoTextContainer_getSupportedServiceNames();
+ for(sal_Int32 nService = 0; nService < aNames.getLength(); nService++)
+ {
+ if(aNames.getConstArray()[nService] == rServiceName)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+uno::Sequence< OUString > SwXAutoTextContainer::getSupportedServiceNames(void) throw( uno::RuntimeException )
+{
+ return SwXAutoTextContainer_getSupportedServiceNames();
+}
+
+const uno::Sequence< sal_Int8 > & SwXAutoTextGroup::getUnoTunnelId()
+{
+ static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
+ return aSeq;
+}
+
+sal_Int64 SAL_CALL SwXAutoTextGroup::getSomething( const uno::Sequence< sal_Int8 >& rId )
+ throw(uno::RuntimeException)
+{
+ if( rId.getLength() == 16
+ && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ return 0;
+}
+
+SwXAutoTextGroup::SwXAutoTextGroup(const OUString& rName,
+ SwGlossaries* pGlos) :
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_AUTO_TEXT_GROUP)),
+ pGlossaries(pGlos),
+ sName(rName),
+ m_sGroupName(rName)
+{
+ OSL_ENSURE( -1 != rName.indexOf( GLOS_DELIM ),
+ "SwXAutoTextGroup::SwXAutoTextGroup: to be constructed with a complete name only!" );
+}
+
+SwXAutoTextGroup::~SwXAutoTextGroup()
+{
+}
+
+uno::Sequence< OUString > SwXAutoTextGroup::getTitles(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_uInt16 nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+
+ uno::Sequence< OUString > aEntryTitles(nCount);
+ OUString *pArr = aEntryTitles.getArray();
+
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
+ pArr[i] = pGlosGroup->GetLongName(i);
+ delete pGlosGroup;
+ return aEntryTitles;
+}
+
+void SwXAutoTextGroup::renameByName(const OUString& aElementName,
+ const OUString& aNewElementName, const OUString& aNewElementTitle)
+ throw( lang::IllegalArgumentException, container::ElementExistException, io::IOException,
+ uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ // throw exception only if the programmatic name is to be changed into an existing name
+ if(aNewElementName != aElementName && hasByName(aNewElementName))
+ throw container::ElementExistException();
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ {
+ sal_uInt16 nIdx = pGlosGroup->GetIndex( aElementName);
+ if(USHRT_MAX == nIdx)
+ throw lang::IllegalArgumentException();
+ String aNewShort( aNewElementName);
+ String aNewName( aNewElementTitle);
+ sal_uInt16 nOldLongIdx = pGlosGroup->GetLongIndex( aNewShort );
+ sal_uInt16 nOldIdx = pGlosGroup->GetIndex( aNewName );
+
+ if( nIdx != USHRT_MAX &&
+ (nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&&
+ (nOldIdx == USHRT_MAX || nOldIdx == nIdx ))
+ {
+ pGlosGroup->Rename( nIdx, &aNewShort, &aNewName );
+ if(pGlosGroup->GetError() != 0)
+ throw io::IOException();
+ }
+ delete pGlosGroup;
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+sal_Bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextRange* pxRange)
+{
+ OSL_ENSURE( pInsDoc, "no InsDoc");
+
+ SwNodes& rNds = pInsDoc->GetNodes();
+
+ SwNodeIndex aIdx( rNds.GetEndOfContent(), -1 );
+ SwCntntNode * pNd = aIdx.GetNode().GetCntntNode();
+ SwPosition aPos( aIdx, SwIndex( pNd, pNd->Len() ));
+
+ bool bRet = false;
+ pInsDoc->LockExpFlds();
+ {
+ SwDoc *const pDoc((pxCursor) ? pxCursor->GetDoc() : pxRange->GetDoc());
+ SwPaM aPam(pDoc->GetNodes());
+ SwPaM * pPam(0);
+ if(pxCursor)
+ {
+ pPam = pxCursor->GetPaM();
+ }
+ else
+ {
+ if (pxRange->GetPositions(aPam))
+ {
+ pPam = & aPam;
+ }
+ }
+ if (!pPam) { return false; }
+ bRet = pDoc->CopyRange( *pPam, aPos, false ) || bRet;
+ }
+
+ pInsDoc->UnlockExpFlds();
+ if( !pInsDoc->IsExpFldsLocked() )
+ pInsDoc->UpdateExpFlds(NULL, true);
+
+ return bRet;
+}
+
+uno::Reference< text::XAutoTextEntry > SwXAutoTextGroup::insertNewByName(const OUString& aName,
+ const OUString& aTitle, const uno::Reference< text::XTextRange > & xTextRange)
+ throw( container::ElementExistException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(hasByName(aName))
+ throw container::ElementExistException();
+ if(!xTextRange.is())
+ throw uno::RuntimeException();
+
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ String sShortName(aName);
+ String sLongName(aTitle);
+ if(pGlosGroup && !pGlosGroup->GetError())
+ {
+ /*if( pGlosGroup->IsOld() && pGlosGroup->ConvertToNew())
+ {
+ throw uno::RuntimeException();
+ } */
+ uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
+ SwXTextRange* pxRange = 0;
+ OTextCursorHelper* pxCursor = 0;
+ if(xRangeTunnel.is())
+ {
+ pxRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething(
+ SwXTextRange::getUnoTunnelId()));
+ pxCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId()));
+ }
+
+ String sOnlyTxt;
+ String* pOnlyTxt = 0;
+ sal_Bool bNoAttr = !pxCursor && !pxRange;
+ if(bNoAttr)
+ {
+ sOnlyTxt = UniString(xTextRange->getString());
+ pOnlyTxt = &sOnlyTxt;
+ }
+
+ const SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
+
+ SwDoc* pGDoc = pGlosGroup->GetDoc();
+
+ // Bis es eine Option dafuer gibt, base util::URL loeschen
+ if(pCfg->IsSaveRelFile())
+ {
+ INetURLObject aTemp(pGlosGroup->GetFileName());
+ pGlosGroup->SetBaseURL( aTemp.GetMainURL(INetURLObject::NO_DECODE));
+ }
+ else
+ pGlosGroup->SetBaseURL( aEmptyStr );
+
+ sal_uInt16 nRet;
+ if( pOnlyTxt )
+ nRet = pGlosGroup->PutText( sShortName, sLongName, *pOnlyTxt );
+ else
+ {
+ pGlosGroup->ClearDoc();
+ if( pGlosGroup->BeginPutDoc( sShortName, sLongName ) )
+ {
+ pGDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_DELETE_REDLINES );
+ lcl_CopySelToDoc( pGDoc, pxCursor, pxRange );
+ pGDoc->SetRedlineMode_intern((RedlineMode_t)( 0 ));
+ nRet = pGlosGroup->PutDoc();
+ }
+ else
+ nRet = (sal_uInt16) -1;
+ }
+
+ if(nRet == (sal_uInt16) -1 )
+ {
+ throw uno::RuntimeException();
+ }
+ pGlossaries->PutGroupDoc( pGlosGroup );
+ }
+
+ uno::Reference< text::XAutoTextEntry > xEntry = pGlossaries->GetAutoTextEntry( m_sGroupName, sName, sShortName, true );
+ OSL_ENSURE( xEntry.is(), "SwXAutoTextGroup::insertNewByName: no UNO object created? How this?" );
+ // we just inserted the entry into the group, so why doesn't it exist?
+
+ return xEntry;
+}
+
+void SwXAutoTextGroup::removeByName(const OUString& aEntryName) throw( container::NoSuchElementException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ {
+ sal_uInt16 nIdx = pGlosGroup->GetIndex(aEntryName);
+ if ( nIdx != USHRT_MAX )
+ pGlosGroup->Delete(nIdx);
+ delete pGlosGroup;
+ }
+ else
+ throw container::NoSuchElementException();
+}
+
+OUString SwXAutoTextGroup::getName(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ return sName;
+}
+
+void SwXAutoTextGroup::setName(const OUString& rName) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if( !pGlossaries )
+ throw uno::RuntimeException();
+
+ sal_Int32 nNewDelimPos = rName.lastIndexOf( GLOS_DELIM );
+ sal_Int32 nOldDelimPos = sName.lastIndexOf( GLOS_DELIM );
+
+ OUString aNewSuffix;
+ if (nNewDelimPos > -1)
+ aNewSuffix = rName.copy( nNewDelimPos + 1 );
+ OUString aOldSuffix;
+ if (nOldDelimPos > -1)
+ aOldSuffix = sName.copy( nOldDelimPos + 1 );
+
+ sal_Int32 nNewNumeric = aNewSuffix.toInt32();
+ sal_Int32 nOldNumeric = aOldSuffix.toInt32();
+
+ OUString aNewPrefix( (nNewDelimPos > 1) ? rName.copy( 0, nNewDelimPos ) : rName );
+ OUString aOldPrefix( (nOldDelimPos > 1) ? sName.copy( 0, nOldDelimPos ) : sName );
+
+ if ( sName == rName ||
+ ( nNewNumeric == nOldNumeric && aNewPrefix == aOldPrefix ) )
+ return;
+ String sNewGroup(rName);
+ if(STRING_NOTFOUND == sNewGroup.Search(GLOS_DELIM))
+ {
+ sNewGroup += GLOS_DELIM;
+ sNewGroup += UniString::CreateFromInt32(0);
+ }
+
+ //the name must be saved, the group may be invalidated while in RenameGroupDoc()
+ SwGlossaries* pTempGlossaries = pGlossaries;
+
+ String sPreserveTitle( pGlossaries->GetGroupTitle( sName ) );
+ if ( !pGlossaries->RenameGroupDoc( sName, sNewGroup, sPreserveTitle ) )
+ throw uno::RuntimeException();
+ else
+ {
+ sName = rName;
+ m_sGroupName = sNewGroup;
+ pGlossaries = pTempGlossaries;
+ }
+}
+
+sal_Int32 SwXAutoTextGroup::getCount(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ int nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+ delete pGlosGroup;
+ return nCount;
+}
+
+uno::Any SwXAutoTextGroup::getByIndex(sal_Int32 nIndex)
+ throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Any aRet;
+ sal_uInt16 nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+ if(0 <= nIndex && nIndex < nCount)
+ aRet = getByName(pGlosGroup->GetShortName((sal_uInt16) nIndex));
+ else
+ throw lang::IndexOutOfBoundsException();
+ delete pGlosGroup;
+ return aRet;
+}
+
+uno::Type SwXAutoTextGroup::getElementType(void) throw( uno::RuntimeException )
+{
+ return ::getCppuType((uno::Reference<text::XAutoTextEntry>*)0);
+
+}
+
+sal_Bool SwXAutoTextGroup::hasElements(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ sal_uInt16 nCount = 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+ delete pGlosGroup;
+ return nCount > 0;
+
+}
+
+uno::Any SwXAutoTextGroup::getByName(const OUString& _rName)
+ throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XAutoTextEntry > xEntry = pGlossaries->GetAutoTextEntry( m_sGroupName, sName, _rName, true );
+ OSL_ENSURE( xEntry.is(), "SwXAutoTextGroup::getByName: GetAutoTextEntry is fractious!" );
+ // we told it to create the object, so why didn't it?
+ return makeAny( xEntry );
+}
+
+uno::Sequence< OUString > SwXAutoTextGroup::getElementNames(void)
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_uInt16 nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+
+ uno::Sequence< OUString > aEntryNames(nCount);
+ OUString *pArr = aEntryNames.getArray();
+
+ for ( sal_uInt16 i = 0; i < nCount; i++ )
+ pArr[i] = pGlosGroup->GetShortName(i);
+ delete pGlosGroup;
+ return aEntryNames;
+}
+
+sal_Bool SwXAutoTextGroup::hasByName(const OUString& rName)
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ sal_uInt16 nCount = 0;
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(pGlosGroup && !pGlosGroup->GetError())
+ nCount = pGlosGroup->GetCount();
+ else
+ throw uno::RuntimeException();
+
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ {
+ String sCompare(pGlosGroup->GetShortName(i));
+ if(COMPARE_EQUAL == sCompare.CompareIgnoreCaseToAscii(String(rName)))
+ {
+ bRet = sal_True;
+ break;
+ }
+ }
+ delete pGlosGroup;
+ return bRet;
+}
+
+uno::Reference< beans::XPropertySetInfo > SwXAutoTextGroup::getPropertySetInfo(void)
+ throw( uno::RuntimeException )
+{
+ static uno::Reference< beans::XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
+ return xRet;
+}
+
+void SwXAutoTextGroup::setPropertyValue(
+ const OUString& rPropertyName, const uno::Any& aValue)
+ throw( beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName );
+
+ if(!pEntry)
+ throw beans::UnknownPropertyException();
+
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(!pGlosGroup || pGlosGroup->GetError())
+ throw uno::RuntimeException();
+ switch(pEntry->nWID)
+ {
+ case WID_GROUP_TITLE:
+ {
+ OUString sNewTitle;
+ aValue >>= sNewTitle;
+ if(!sNewTitle.getLength())
+ throw lang::IllegalArgumentException();
+ sal_Bool bChanged = !sNewTitle.equals(pGlosGroup->GetName());
+ pGlosGroup->SetName(sNewTitle);
+ if(bChanged && HasGlossaryList())
+ GetGlossaryList()->ClearGroups();
+ }
+ break;
+ }
+ delete pGlosGroup;
+}
+
+uno::Any SwXAutoTextGroup::getPropertyValue(const OUString& rPropertyName)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
+
+ if(!pEntry)
+ throw beans::UnknownPropertyException();
+ SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0;
+ if(!pGlosGroup || pGlosGroup->GetError())
+ throw uno::RuntimeException();
+
+ uno::Any aAny;
+ switch(pEntry->nWID)
+ {
+ case WID_GROUP_PATH:
+ aAny <<= OUString(pGlosGroup->GetFileName());
+ break;
+ case WID_GROUP_TITLE:
+ aAny <<= OUString(pGlosGroup->GetName());
+ break;
+ }
+ delete pGlosGroup;
+ return aAny;
+}
+
+void SwXAutoTextGroup::addPropertyChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+}
+
+void SwXAutoTextGroup::removePropertyChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+}
+
+void SwXAutoTextGroup::addVetoableChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+}
+
+void SwXAutoTextGroup::removeVetoableChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+}
+
+void SwXAutoTextGroup::Invalidate()
+{
+ pGlossaries = 0;
+ sName = aEmptyStr;
+ m_sGroupName = aEmptyStr;
+}
+
+OUString SwXAutoTextGroup::getImplementationName(void) throw( uno::RuntimeException )
+{
+ return C2U("SwXAutoTextGroup");
+}
+
+BOOL SwXAutoTextGroup::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
+{
+ return C2U("com.sun.star.text.AutoTextGroup") == rServiceName;
+}
+
+uno::Sequence< OUString > SwXAutoTextGroup::getSupportedServiceNames(void) throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = C2U("com.sun.star.text.AutoTextGroup");
+ return aRet;
+}
+
+const uno::Sequence< sal_Int8 > & SwXAutoTextEntry::getUnoTunnelId()
+{
+ static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
+ return aSeq;
+}
+
+sal_Int64 SAL_CALL SwXAutoTextEntry::getSomething( const uno::Sequence< sal_Int8 >& rId )
+ throw(uno::RuntimeException)
+{
+ if( rId.getLength() == 16
+ && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ return 0;
+}
+
+SwXAutoTextEntry::SwXAutoTextEntry(SwGlossaries* pGlss, const String& rGroupName,
+ const String& rEntryName) :
+ pGlossaries(pGlss),
+ sGroupName(rGroupName),
+ sEntryName(rEntryName),
+ pBodyText ( NULL )
+{
+}
+
+SwXAutoTextEntry::~SwXAutoTextEntry()
+{
+ {
+ SolarMutexGuard aGuard;
+
+ // ensure that any pending modifications are written
+ implFlushDocument( true );
+
+ //! Bug #96559
+ // DocShell must be cleared before mutex is lost.
+ // Needs to be done explicitly since xDocSh is a class member.
+ // Thus, an own block here, guarded by the SolarMutex
+ }
+}
+
+void SwXAutoTextEntry::implFlushDocument( bool _bCloseDoc )
+{
+ if ( xDocSh.Is() )
+ {
+ if ( xDocSh->GetDoc()->IsModified () )
+ xDocSh->Save();
+
+ if ( _bCloseDoc )
+ {
+ // stop listening at the document
+ EndListening( *&xDocSh );
+
+ xDocSh->DoClose();
+ xDocSh.Clear();
+ }
+ }
+}
+
+void SwXAutoTextEntry::Notify( SfxBroadcaster& _rBC, const SfxHint& _rHint )
+{
+ if ( &_rBC == &xDocSh )
+ { // it's our document
+ if ( _rHint.ISA( SfxSimpleHint ) )
+ {
+ if ( SFX_HINT_DEINITIALIZING == static_cast< const SfxSimpleHint& >( _rHint ).GetId() )
+ {
+ // our document is dying (possibly because we're shuting down, and the document was notified
+ // earlier than we are?)
+ // stop listening at the docu
+ EndListening( *&xDocSh );
+ // and release our reference
+ xDocSh.Clear();
+ }
+ }
+ else if(_rHint.ISA(SfxEventHint))
+ {
+ if(SFX_EVENT_PREPARECLOSEDOC == static_cast< const SfxEventHint& >( _rHint ).GetEventId())
+ {
+ implFlushDocument( sal_False );
+ xBodyText = 0;
+ xDocSh.Clear();
+ }
+ }
+ }
+}
+
+void SwXAutoTextEntry::GetBodyText ()
+{
+ SolarMutexGuard aGuard;
+
+ xDocSh = pGlossaries->EditGroupDoc ( sGroupName, sEntryName, FALSE );
+ OSL_ENSURE( xDocSh.Is(), "SwXAutoTextEntry::GetBodyText: unexpected: no doc returned by EditGroupDoc!" );
+
+ // start listening at the document
+ StartListening( *&xDocSh );
+
+ pBodyText = new SwXBodyText ( xDocSh->GetDoc() );
+ xBodyText = uno::Reference < lang::XServiceInfo > ( *pBodyText, uno::UNO_QUERY);
+}
+
+uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursor(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->createTextCursor();
+}
+
+uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursorByRange(
+ const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->createTextCursorByRange ( aTextPosition );
+}
+
+void SwXAutoTextEntry::insertString(const uno::Reference< text::XTextRange > & xRange, const OUString& aString, sal_Bool bAbsorb) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->insertString ( xRange, aString, bAbsorb );
+}
+
+void SwXAutoTextEntry::insertControlCharacter(const uno::Reference< text::XTextRange > & xRange,
+ sal_Int16 nControlCharacter, sal_Bool bAbsorb)
+ throw( lang::IllegalArgumentException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->insertControlCharacter ( xRange, nControlCharacter, bAbsorb );
+}
+
+void SwXAutoTextEntry::insertTextContent(
+ const uno::Reference< text::XTextRange > & xRange,
+ const uno::Reference< text::XTextContent > & xContent, sal_Bool bAbsorb)
+ throw( lang::IllegalArgumentException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->insertTextContent ( xRange, xContent, bAbsorb );
+}
+
+void SwXAutoTextEntry::removeTextContent(
+ const uno::Reference< text::XTextContent > & xContent)
+ throw( container::NoSuchElementException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->removeTextContent ( xContent );
+}
+
+uno::Reference< text::XText > SwXAutoTextEntry::getText(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XText > xRet = (text::XText*)this;
+ return xRet;
+}
+
+uno::Reference< text::XTextRange > SwXAutoTextEntry::getStart(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->getStart();
+}
+
+uno::Reference< text::XTextRange > SwXAutoTextEntry::getEnd(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->getEnd();
+}
+
+OUString SwXAutoTextEntry::getString(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ return pBodyText->getString();
+}
+
+void SwXAutoTextEntry::setString(const OUString& aString) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ EnsureBodyText();
+ pBodyText->setString( aString );
+}
+
+void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextRange)throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ // ensure that any pending modifications are written
+ // reason is that we're holding the _copy_ of the auto text, while the real auto text
+ // is stored somewhere. And below, we're not working with our copy, but only tell the target
+ // TextRange to work with the stored version.
+ // #96380# - 2003-03-03 - fs@openoffice.org
+ implFlushDocument( false );
+ // TODO: think about if we should pass "true" here
+ // The difference would be that when the next modification is made to this instance here, then
+ // we would be forced to open the document again, instead of working on our current copy.
+ // This means that we would reflect any changes which were done to the AutoText by foreign instances
+ // in the meantime
+
+ uno::Reference<lang::XUnoTunnel> xTunnel( xTextRange, uno::UNO_QUERY);
+ SwXTextRange* pRange = 0;
+ OTextCursorHelper* pCursor = 0;
+ SwXText *pText = 0;
+
+ if(xTunnel.is())
+ {
+ pRange = reinterpret_cast < SwXTextRange* >
+ ( xTunnel->getSomething( SwXTextRange::getUnoTunnelId() ) );
+ pCursor = reinterpret_cast < OTextCursorHelper*>
+ ( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ) );
+ pText = reinterpret_cast < SwXText* >
+ ( xTunnel->getSomething( SwXText::getUnoTunnelId() ) );
+ }
+
+ SwDoc* pDoc = 0;
+ if (pRange)
+ pDoc = pRange->GetDoc();
+ else if ( pCursor )
+ pDoc = pCursor->GetDoc();
+ else if ( pText && pText->GetDoc() )
+ {
+ xTunnel = uno::Reference < lang::XUnoTunnel > (pText->getStart(), uno::UNO_QUERY);
+ if (xTunnel.is())
+ {
+ pCursor = reinterpret_cast < OTextCursorHelper* >
+ ( xTunnel->getSomething( OTextCursorHelper::getUnoTunnelId() ) );
+ if (pCursor)
+ pDoc = pText->GetDoc();
+ }
+ }
+
+ if(!pDoc)
+ throw uno::RuntimeException();
+
+ SwPaM InsertPaM(pDoc->GetNodes());
+ if (pRange)
+ {
+ if (!pRange->GetPositions(InsertPaM))
+ {
+ throw uno::RuntimeException();
+ }
+ }
+ else
+ {
+ InsertPaM = *pCursor->GetPaM();
+ }
+
+ ::std::auto_ptr<SwTextBlocks> pBlock(pGlossaries->GetGroupDoc(sGroupName));
+ const bool bResult = pBlock.get() && !pBlock->GetError()
+ && pDoc->InsertGlossary( *pBlock, sEntryName, InsertPaM);
+
+ if(!bResult)
+ throw uno::RuntimeException();
+}
+
+OUString SwXAutoTextEntry::getImplementationName(void) throw( uno::RuntimeException )
+{
+ return C2U("SwXAutoTextEntry");
+}
+
+BOOL SwXAutoTextEntry::supportsService(const OUString& rServiceName) throw( uno::RuntimeException )
+{
+ return C2U("com.sun.star.text.AutoTextEntry") == rServiceName;
+}
+
+uno::Sequence< OUString > SwXAutoTextEntry::getSupportedServiceNames(void) throw( uno::RuntimeException )
+{
+ uno::Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = C2U("com.sun.star.text.AutoTextEntry");
+ return aRet;
+}
+
+uno::Reference< container::XNameReplace > SwXAutoTextEntry::getEvents()
+ throw( uno::RuntimeException )
+{
+ return new SwAutoTextEventDescriptor( *this );
+}
+
+const struct SvEventDescription aAutotextEvents[] =
+{
+ { SW_EVENT_START_INS_GLOSSARY, "OnInsertStart" },
+ { SW_EVENT_END_INS_GLOSSARY, "OnInsertDone" },
+ { 0, NULL }
+};
+
+SwAutoTextEventDescriptor::SwAutoTextEventDescriptor(
+ SwXAutoTextEntry& rAutoText ) :
+ SvBaseEventDescriptor(aAutotextEvents),
+ sSwAutoTextEventDescriptor(RTL_CONSTASCII_USTRINGPARAM(
+ "SwAutoTextEventDescriptor")),
+ rAutoTextEntry(rAutoText)
+{
+}
+
+SwAutoTextEventDescriptor::~SwAutoTextEventDescriptor()
+{
+}
+
+OUString SwAutoTextEventDescriptor::getImplementationName()
+ throw( uno::RuntimeException )
+{
+ return sSwAutoTextEventDescriptor;
+}
+
+void SwAutoTextEventDescriptor::replaceByName(
+ const USHORT nEvent,
+ const SvxMacro& rMacro)
+ throw(
+ lang::IllegalArgumentException,
+ container::NoSuchElementException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( NULL != rAutoTextEntry.GetGlossaries(),
+ "Strangely enough, the AutoText vanished!" );
+ OSL_ENSURE( (nEvent == SW_EVENT_END_INS_GLOSSARY) ||
+ (nEvent == SW_EVENT_START_INS_GLOSSARY) ,
+ "Unknown event ID" );
+
+ const SwGlossaries* pGlossaries = rAutoTextEntry.GetGlossaries();
+ SwTextBlocks* pBlocks =
+ pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() );
+ OSL_ENSURE( NULL != pBlocks,
+ "can't get autotext group; SwAutoTextEntry has illegal name?");
+
+ if( pBlocks && !pBlocks->GetError())
+ {
+ USHORT nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() );
+ if( nIndex != USHRT_MAX )
+ {
+ SvxMacroTableDtor aMacroTable;
+ if( pBlocks->GetMacroTable( nIndex, aMacroTable ) )
+ {
+ SvxMacro* pNewMacro = new SvxMacro(rMacro);
+ aMacroTable.Replace( nEvent, pNewMacro );
+ pBlocks->SetMacroTable( nIndex, aMacroTable );
+ }
+ }
+
+ delete pBlocks;
+ }
+ // else: ignore
+}
+
+void SwAutoTextEventDescriptor::getByName(
+ SvxMacro& rMacro,
+ const USHORT nEvent )
+ throw(
+ container::NoSuchElementException,
+ lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ OSL_ENSURE( NULL != rAutoTextEntry.GetGlossaries(), "no AutoText" );
+ OSL_ENSURE( (nEvent == SW_EVENT_END_INS_GLOSSARY) ||
+ (nEvent == SW_EVENT_START_INS_GLOSSARY) ,
+ "Unknown event ID" );
+
+ const SwGlossaries* pGlossaries = rAutoTextEntry.GetGlossaries();
+ SwTextBlocks* pBlocks =
+ pGlossaries->GetGroupDoc( rAutoTextEntry.GetGroupName() );
+ OSL_ENSURE( NULL != pBlocks,
+ "can't get autotext group; SwAutoTextEntry has illegal name?");
+
+ // return empty macro, unless macro is found
+ OUString sEmptyStr;
+ SvxMacro aEmptyMacro(sEmptyStr, sEmptyStr);
+ rMacro = aEmptyMacro;
+
+ if ( pBlocks && !pBlocks->GetError())
+ {
+ USHORT nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() );
+ if( nIndex != USHRT_MAX )
+ {
+ SvxMacroTableDtor aMacroTable;
+ if( pBlocks->GetMacroTable( nIndex, aMacroTable ) )
+ {
+ SvxMacro *pMacro = aMacroTable.Get( nEvent );
+ if( pMacro )
+ rMacro = *pMacro;
+ }
+ }
+
+ delete pBlocks;
+ }
+}
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unodefaults.cxx b/sw/source/ui/uno/unodefaults.cxx
new file mode 100644
index 000000000000..32bb7e7c37f8
--- /dev/null
+++ b/sw/source/ui/uno/unodefaults.cxx
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <unodefaults.hxx>
+#include <svx/svdmodel.hxx>
+#include <svx/unoprov.hxx>
+#include <doc.hxx>
+
+SwSvxUnoDrawPool::SwSvxUnoDrawPool( SwDoc* pDoc ) throw() :
+ SvxUnoDrawPool(pDoc->GetDrawModel(), SVXUNO_SERVICEID_COM_SUN_STAR_DRAWING_DEFAULTS_WRITER),
+ m_pDoc(pDoc)
+{
+}
+
+SwSvxUnoDrawPool::~SwSvxUnoDrawPool() throw()
+{
+}
+
+SfxItemPool* SwSvxUnoDrawPool::getModelPool( sal_Bool /*bReadOnly*/ ) throw()
+{
+ if(m_pDoc)
+ {
+
+ // DVO, OD 01.10.2003 #i18732# - return item pool of writer document;
+ // it contains draw model item pool as secondary pool.
+ //SdrModel* pModel = m_pDoc->MakeDrawModel();
+ //return &pModel->GetItemPool();
+ // --> OD 2005-08-08 #i52858# - method name changed
+ m_pDoc->GetOrCreateDrawModel();
+ // <--
+ return &(m_pDoc->GetAttrPool());
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unodefaults.hxx b/sw/source/ui/uno/unodefaults.hxx
new file mode 100644
index 000000000000..48ffa96f74f2
--- /dev/null
+++ b/sw/source/ui/uno/unodefaults.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _UNODEFAULTS_HXX
+#define _UNODEFAULTS_HXX
+
+#include <svx/unopool.hxx>
+
+class SwDoc;
+
+class SwSvxUnoDrawPool : public SvxUnoDrawPool
+{
+ SwDoc* m_pDoc;
+public:
+ SwSvxUnoDrawPool( SwDoc* pDoc ) throw();
+ virtual ~SwSvxUnoDrawPool() throw();
+
+ virtual SfxItemPool* getModelPool( sal_Bool bReadOnly ) throw();
+
+ void Invalidate() {m_pDoc = 0;}
+};
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unodispatch.cxx b/sw/source/ui/uno/unodispatch.cxx
new file mode 100644
index 000000000000..7f4037680ec2
--- /dev/null
+++ b/sw/source/ui/uno/unodispatch.cxx
@@ -0,0 +1,405 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include <vcl/svapp.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+
+#include <unodispatch.hxx>
+#include <unobaseclass.hxx>
+#include <view.hxx>
+#include <cmdid.h>
+#include "wrtsh.hxx"
+#include "dbmgr.hxx"
+
+
+using namespace ::com::sun::star;
+using namespace rtl;
+
+const char* cURLStart = ".uno:DataSourceBrowser/";
+const char* cURLFormLetter = ".uno:DataSourceBrowser/FormLetter";
+const char* cURLInsertContent = ".uno:DataSourceBrowser/InsertContent";//data into fields
+const char* cURLInsertColumns = ".uno:DataSourceBrowser/InsertColumns";//data into text
+const char* cURLDocumentDataSource = ".uno:DataSourceBrowser/DocumentDataSource";//current data source of the document
+const sal_Char* cInternalDBChangeNotification = ".uno::Writer/DataSourceChanged";
+
+SwXDispatchProviderInterceptor::SwXDispatchProviderInterceptor(SwView& rVw) :
+ m_pView(&rVw)
+{
+ uno::Reference< frame::XFrame> xUnoFrame = m_pView->GetViewFrame()->GetFrame().GetFrameInterface();
+ m_xIntercepted = uno::Reference< frame::XDispatchProviderInterception>(xUnoFrame, uno::UNO_QUERY);
+ if(m_xIntercepted.is())
+ {
+ m_refCount++;
+ m_xIntercepted->registerDispatchProviderInterceptor((frame::XDispatchProviderInterceptor*)this);
+ // this should make us the top-level dispatch-provider for the component, via a call to our
+ // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill
+ uno::Reference< lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY);
+ if (xInterceptedComponent.is())
+ xInterceptedComponent->addEventListener((lang::XEventListener*)this);
+ m_refCount--;
+ }
+}
+
+SwXDispatchProviderInterceptor::~SwXDispatchProviderInterceptor()
+{
+}
+
+uno::Reference< frame::XDispatch > SwXDispatchProviderInterceptor::queryDispatch(
+ const util::URL& aURL, const OUString& aTargetFrameName, sal_Int32 nSearchFlags )
+ throw(uno::RuntimeException)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ uno::Reference< frame::XDispatch> xResult;
+ // create some dispatch ...
+ if(m_pView && !aURL.Complete.compareToAscii(cURLStart, 23))
+ {
+ if(!aURL.Complete.compareToAscii(cURLFormLetter) ||
+ !aURL.Complete.compareToAscii(cURLInsertContent) ||
+ !aURL.Complete.compareToAscii(cURLInsertColumns)||
+ !aURL.Complete.compareToAscii(cURLDocumentDataSource))
+ {
+ if(!m_xDispatch.is())
+ m_xDispatch = new SwXDispatch(*m_pView);
+ xResult = m_xDispatch;
+ }
+ }
+
+ // ask our slave provider
+ if (!xResult.is() && m_xSlaveDispatcher.is())
+ xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags);
+
+ return xResult;
+}
+
+uno::Sequence< uno::Reference< frame::XDispatch > > SwXDispatchProviderInterceptor::queryDispatches(
+ const uno::Sequence< frame::DispatchDescriptor >& aDescripts ) throw(uno::RuntimeException)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ uno::Sequence< uno::Reference< frame::XDispatch> > aReturn(aDescripts.getLength());
+ uno::Reference< frame::XDispatch>* pReturn = aReturn.getArray();
+ const frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray();
+ for (sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts)
+ {
+ *pReturn = queryDispatch(pDescripts->FeatureURL,
+ pDescripts->FrameName, pDescripts->SearchFlags);
+ }
+ return aReturn;
+}
+
+uno::Reference< frame::XDispatchProvider > SwXDispatchProviderInterceptor::getSlaveDispatchProvider( )
+ throw(uno::RuntimeException)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ return m_xSlaveDispatcher;
+}
+
+void SwXDispatchProviderInterceptor::setSlaveDispatchProvider(
+ const uno::Reference< frame::XDispatchProvider >& xNewDispatchProvider ) throw(uno::RuntimeException)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ m_xSlaveDispatcher = xNewDispatchProvider;
+}
+
+uno::Reference< frame::XDispatchProvider > SwXDispatchProviderInterceptor::getMasterDispatchProvider( )
+ throw(uno::RuntimeException)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ return m_xMasterDispatcher;
+}
+
+void SwXDispatchProviderInterceptor::setMasterDispatchProvider(
+ const uno::Reference< frame::XDispatchProvider >& xNewSupplier ) throw(uno::RuntimeException)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ m_xMasterDispatcher = xNewSupplier;
+}
+
+void SwXDispatchProviderInterceptor::disposing( const lang::EventObject& )
+ throw(uno::RuntimeException)
+{
+ DispatchMutexLock_Impl aLock(*this);
+ if (m_xIntercepted.is())
+ {
+ m_xIntercepted->releaseDispatchProviderInterceptor((frame::XDispatchProviderInterceptor*)this);
+ uno::Reference< lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY);
+ if (xInterceptedComponent.is())
+ xInterceptedComponent->removeEventListener((lang::XEventListener*)this);
+ m_xDispatch = 0;
+ }
+ m_xIntercepted = NULL;
+}
+
+const uno::Sequence< sal_Int8 > & SwXDispatchProviderInterceptor::getUnoTunnelId()
+{
+ static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
+ return aSeq;
+}
+
+sal_Int64 SwXDispatchProviderInterceptor::getSomething(
+ const uno::Sequence< sal_Int8 >& aIdentifier )
+ throw(uno::RuntimeException)
+{
+ if( aIdentifier.getLength() == 16
+ && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ aIdentifier.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ return 0;
+}
+
+void SwXDispatchProviderInterceptor::Invalidate()
+{
+ DispatchMutexLock_Impl aLock(*this);
+ if (m_xIntercepted.is())
+ {
+ m_xIntercepted->releaseDispatchProviderInterceptor((frame::XDispatchProviderInterceptor*)this);
+ uno::Reference< lang::XComponent> xInterceptedComponent(m_xIntercepted, uno::UNO_QUERY);
+ if (xInterceptedComponent.is())
+ xInterceptedComponent->removeEventListener((lang::XEventListener*)this);
+ m_xDispatch = 0;
+ }
+ m_xIntercepted = NULL;
+ m_pView = 0;
+}
+
+SwXDispatch::SwXDispatch(SwView& rVw) :
+ m_pView(&rVw),
+ m_bOldEnable(sal_False),
+ m_bListenerAdded(sal_False)
+{
+}
+
+SwXDispatch::~SwXDispatch()
+{
+ if(m_bListenerAdded && m_pView)
+ {
+ uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject();
+ uno::Reference<view::XSelectionChangeListener> xThis = this;
+ xSupplier->removeSelectionChangeListener(xThis);
+ }
+}
+
+void SwXDispatch::dispatch(
+ const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs ) throw(uno::RuntimeException)
+{
+ if(!m_pView)
+ throw uno::RuntimeException();
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr();
+ if(!aURL.Complete.compareToAscii(cURLInsertContent))
+ {
+ ::svx::ODataAccessDescriptor aDescriptor(aArgs);
+ SwMergeDescriptor aMergeDesc( DBMGR_MERGE, rSh, aDescriptor );
+ pNewDBMgr->MergeNew(aMergeDesc);
+ }
+ else if(!aURL.Complete.compareToAscii(cURLInsertColumns))
+ {
+ pNewDBMgr->InsertText(rSh, aArgs);
+ }
+ else if(!aURL.Complete.compareToAscii(cURLFormLetter))
+ {
+ SfxUsrAnyItem aDBProperties(FN_PARAM_DATABASE_PROPERTIES, uno::makeAny(aArgs));
+ m_pView->GetViewFrame()->GetDispatcher()->Execute(
+ FN_MAILMERGE_WIZARD,
+ SFX_CALLMODE_ASYNCHRON,
+ &aDBProperties, 0L);
+// pNewDBMgr->ExecuteFormLetter(rSh, aArgs);
+ }
+ else if(!aURL.Complete.compareToAscii(cURLDocumentDataSource))
+ {
+ OSL_ENSURE(sal_False, "SwXDispatch::dispatch: this URL is not to be dispatched!");
+ }
+ else if(!aURL.Complete.compareToAscii(cInternalDBChangeNotification))
+ {
+ frame::FeatureStateEvent aEvent;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Source = *(cppu::OWeakObject*)this;
+
+ const SwDBData& rData = m_pView->GetWrtShell().GetDBDesc();
+ ::svx::ODataAccessDescriptor aDescriptor;
+ aDescriptor.setDataSource(rData.sDataSource);
+ aDescriptor[::svx::daCommand] <<= rData.sCommand;
+ aDescriptor[::svx::daCommandType] <<= rData.nCommandType;
+
+ aEvent.State <<= aDescriptor.createPropertyValueSequence();
+ aEvent.IsEnabled = rData.sDataSource.getLength() > 0;
+
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter)
+ {
+ StatusStruct_Impl aStatus = *aListIter;
+ if(!aStatus.aURL.Complete.compareToAscii(cURLDocumentDataSource))
+ {
+ aEvent.FeatureURL = aStatus.aURL;
+ aStatus.xListener->statusChanged( aEvent );
+ }
+ }
+ }
+ else
+ throw uno::RuntimeException();
+
+}
+
+void SwXDispatch::addStatusListener(
+ const uno::Reference< frame::XStatusListener >& xControl, const util::URL& aURL ) throw(uno::RuntimeException)
+{
+ if(!m_pView)
+ throw uno::RuntimeException();
+ ShellModes eMode = m_pView->GetShellMode();
+ sal_Bool bEnable = SHELL_MODE_TEXT == eMode ||
+ SHELL_MODE_LIST_TEXT == eMode ||
+ SHELL_MODE_TABLE_TEXT == eMode ||
+ SHELL_MODE_TABLE_LIST_TEXT == eMode;
+
+ m_bOldEnable = bEnable;
+ frame::FeatureStateEvent aEvent;
+ aEvent.IsEnabled = bEnable;
+ aEvent.Source = *(cppu::OWeakObject*)this;
+ aEvent.FeatureURL = aURL;
+
+ // one of the URLs requires a special state ....
+ if (!aURL.Complete.compareToAscii(cURLDocumentDataSource))
+ {
+ const SwDBData& rData = m_pView->GetWrtShell().GetDBDesc();
+
+ ::svx::ODataAccessDescriptor aDescriptor;
+ aDescriptor.setDataSource(rData.sDataSource);
+ aDescriptor[::svx::daCommand] <<= rData.sCommand;
+ aDescriptor[::svx::daCommandType] <<= rData.nCommandType;
+
+ aEvent.State <<= aDescriptor.createPropertyValueSequence();
+ aEvent.IsEnabled = rData.sDataSource.getLength() > 0;
+ }
+
+
+ xControl->statusChanged( aEvent );
+
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ StatusStruct_Impl aStatus;
+ aStatus.xListener = xControl;
+ aStatus.aURL = aURL;
+ m_aListenerList.insert(aListIter, aStatus);
+
+ if(!m_bListenerAdded)
+ {
+ uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject();
+ uno::Reference<view::XSelectionChangeListener> xThis = this;
+ xSupplier->addSelectionChangeListener(xThis);
+ m_bListenerAdded = sal_True;
+ }
+}
+
+void SwXDispatch::removeStatusListener(
+ const uno::Reference< frame::XStatusListener >& xControl, const util::URL& ) throw(uno::RuntimeException)
+{
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter)
+ {
+ StatusStruct_Impl aStatus = *aListIter;
+ if(aStatus.xListener.get() == xControl.get())
+ {
+ m_aListenerList.erase(aListIter);
+ break;
+ }
+ }
+ if(m_aListenerList.empty() && m_pView)
+ {
+ uno::Reference<view::XSelectionSupplier> xSupplier = m_pView->GetUNOObject();
+ uno::Reference<view::XSelectionChangeListener> xThis = this;
+ xSupplier->removeSelectionChangeListener(xThis);
+ m_bListenerAdded = sal_False;
+ }
+}
+
+void SwXDispatch::selectionChanged( const lang::EventObject& ) throw(uno::RuntimeException)
+{
+ ShellModes eMode = m_pView->GetShellMode();
+ sal_Bool bEnable = SHELL_MODE_TEXT == eMode ||
+ SHELL_MODE_LIST_TEXT == eMode ||
+ SHELL_MODE_TABLE_TEXT == eMode ||
+ SHELL_MODE_TABLE_LIST_TEXT == eMode;
+ if(bEnable != m_bOldEnable)
+ {
+ m_bOldEnable = bEnable;
+ frame::FeatureStateEvent aEvent;
+ aEvent.IsEnabled = bEnable;
+ aEvent.Source = *(cppu::OWeakObject*)this;
+
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter)
+ {
+ StatusStruct_Impl aStatus = *aListIter;
+ aEvent.FeatureURL = aStatus.aURL;
+ if (0 != aStatus.aURL.Complete.compareToAscii(cURLDocumentDataSource))
+ // the document's data source does not depend on the selection, so it's state does not change here
+ aStatus.xListener->statusChanged( aEvent );
+ }
+ }
+}
+
+void SwXDispatch::disposing( const lang::EventObject& rSource ) throw(uno::RuntimeException)
+{
+ uno::Reference<view::XSelectionSupplier> xSupplier(rSource.Source, uno::UNO_QUERY);
+ uno::Reference<view::XSelectionChangeListener> xThis = this;
+ xSupplier->removeSelectionChangeListener(xThis);
+ m_bListenerAdded = sal_False;
+
+ lang::EventObject aObject;
+ aObject.Source = (cppu::OWeakObject*)this;
+ StatusListenerList::iterator aListIter = m_aListenerList.begin();
+ for(; aListIter != m_aListenerList.end(); ++aListIter)
+ {
+ StatusStruct_Impl aStatus = *aListIter;
+ aStatus.xListener->disposing(aObject);
+ }
+ m_pView = 0;
+}
+
+const sal_Char* SwXDispatch::GetDBChangeURL()
+{
+ return cInternalDBChangeNotification;
+}
+
+SwXDispatchProviderInterceptor::DispatchMutexLock_Impl::DispatchMutexLock_Impl(
+ SwXDispatchProviderInterceptor& ) :
+// aGuard(rInterceptor.m_aMutex) #102295# solar mutex has to be used currently
+ aGuard(Application::GetSolarMutex())
+{
+}
+
+SwXDispatchProviderInterceptor::DispatchMutexLock_Impl::~DispatchMutexLock_Impl()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unodoc.cxx b/sw/source/ui/uno/unodoc.cxx
new file mode 100644
index 000000000000..400c2c5be2bc
--- /dev/null
+++ b/sw/source/ui/uno/unodoc.cxx
@@ -0,0 +1,130 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+// System - Includes -----------------------------------------------------
+
+#include <tools/string.hxx>
+#include <sfx2/docfac.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#include "swdll.hxx"
+#include "docsh.hxx"
+#include "globdoc.hxx"
+#include "wdocsh.hxx"
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+
+//============================================================
+// com.sun.star.comp.Writer.TextDocument
+
+uno::Sequence< ::rtl::OUString > SAL_CALL SwTextDocument_getSupportedServiceNames() throw()
+{
+ // return only top level services here! All others must be
+ // resolved by rtti!
+ uno::Sequence< ::rtl::OUString > aRet ( 1 );
+ ::rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.TextDocument" ) );
+
+ return aRet;
+}
+
+::rtl::OUString SAL_CALL SwTextDocument_getImplementationName() throw()
+{
+ return ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.TextDocument" ) );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwTextDocument_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory >&, const sal_uInt64 _nCreationFlags )
+ throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+ SwDLL::Init();
+ SfxObjectShell* pShell = new SwDocShell( _nCreationFlags );
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
+}
+
+//============================================================
+// com.sun.star.comp.Writer.WebDocument
+
+uno::Sequence< ::rtl::OUString > SAL_CALL SwWebDocument_getSupportedServiceNames() throw()
+{
+ // return only top level services here! All others must be
+ // resolved by rtti!
+ uno::Sequence< ::rtl::OUString > aRet ( 1 );
+ ::rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.WebDocument" ) );
+
+ return aRet;
+}
+
+::rtl::OUString SAL_CALL SwWebDocument_getImplementationName() throw()
+{
+ return ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.WebDocument" ) );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwWebDocument_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & )
+ throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+ SwDLL::Init();
+ SfxObjectShell* pShell = new SwWebDocShell( SFX_CREATE_MODE_STANDARD );
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
+}
+
+//============================================================
+// com.sun.star.comp.Writer.GlobalDocument
+
+uno::Sequence< ::rtl::OUString > SAL_CALL SwGlobalDocument_getSupportedServiceNames() throw()
+{
+ uno::Sequence< ::rtl::OUString > aRet ( 1 );
+ ::rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.text.GlobalDocument" ) );
+
+ return aRet;
+}
+
+::rtl::OUString SAL_CALL SwGlobalDocument_getImplementationName() throw()
+{
+ return ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.Writer.GlobalDocument" ) );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwGlobalDocument_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > &)
+ throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+ SwDLL::Init();
+ SfxObjectShell* pShell = new SwGlobalDocShell( SFX_CREATE_MODE_STANDARD );
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unofreg.cxx b/sw/source/ui/uno/unofreg.cxx
new file mode 100644
index 000000000000..320aab5c033d
--- /dev/null
+++ b/sw/source/ui/uno/unofreg.cxx
@@ -0,0 +1,479 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+#include "SwXFilterOptions.hxx"
+#include "sal/types.h"
+#include <osl/diagnose.h>
+#include <uno/lbnames.h>
+#include <cppuhelper/factory.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#ifndef INCLUDED_STRING_H
+#include <string.h>
+#define INCLUDED_STRING_H
+#endif
+
+using namespace rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::lang;
+
+// module
+extern uno::Sequence< OUString > SAL_CALL SwUnoModule_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwUnoModule_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwUnoModule_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
+
+// writer documents
+extern uno::Sequence< OUString > SAL_CALL SwTextDocument_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwTextDocument_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwTextDocument_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr, const sal_uInt64 _nCreationFlags ) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwWebDocument_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwWebDocument_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwWebDocument_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwGlobalDocument_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwGlobalDocument_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwGlobalDocument_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception );
+
+// xml import
+extern uno::Sequence< OUString > SAL_CALL SwXMLImport_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImport_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImport_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLImportStyles_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImportStyles_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportStyles_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLImportContent_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImportContent_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportContent_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXMLImportMeta_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImportMeta_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportMeta_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXMLImportSettings_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLImportSettings_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLImportSettings_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+// xml export (OOo)
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportContentOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportContentOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportContentOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportStylesOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportStylesOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportStylesOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportMetaOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportMetaOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportMetaOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportSettingsOOO_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportSettingsOOO_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportSettingsOOO_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+// xml export (OASIS)
+extern uno::Sequence< OUString > SAL_CALL SwXMLExport_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExport_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExport_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportContent_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportContent_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportContent_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportStyles_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportStyles_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportStyles_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportMeta_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportMeta_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportMeta_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+extern uno::Sequence< OUString > SAL_CALL SwXMLExportSettings_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMLExportSettings_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMLExportSettings_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+//API objects
+extern uno::Sequence< OUString > SAL_CALL SwXAutoTextContainer_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXAutoTextContainer_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXAutoTextContainer_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXModule_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXModule_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXModule_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+extern uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() throw();
+extern OUString SAL_CALL SwXMailMerge_getImplementationName() throw();
+extern uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(const uno::Reference< XMultiServiceFactory > & rSMgr) throw( uno::Exception );
+
+// --> OD 2007-05-24 #i73788#
+#include "cppuhelper/implementationentry.hxx"
+namespace comp_FinalThreadManager {
+
+// component and service helper functions:
+::rtl::OUString SAL_CALL _getImplementationName();
+com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames();
+com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL _create(
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > const & context );
+
+}
+// <--
+
+//
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+static void lcl_uno_writeInfo(
+ registry::XRegistryKey * pRegistryKey,
+ const OUString& rImplementationName,
+ const uno::Sequence< OUString >& rServices )
+{
+ uno::Reference< registry::XRegistryKey > xNewKey(
+ pRegistryKey->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + rImplementationName + OUString(RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES") ) ) );
+
+ for( sal_Int32 i = 0; i < rServices.getLength(); i++ )
+ xNewKey->createKey( rServices.getConstArray()[i]);
+}
+
+SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void * /*pServiceManager*/,
+ void * pRegistryKey )
+{
+ if( pRegistryKey )
+ {
+ try
+ {
+ registry::XRegistryKey *pKey =
+ reinterpret_cast< registry::XRegistryKey * >( pRegistryKey );
+
+
+ // xml filter
+ lcl_uno_writeInfo( pKey, SwXMLImport_getImplementationName(),
+ SwXMLImport_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLImportStyles_getImplementationName(),
+ SwXMLImportStyles_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey,SwXMLImportContent_getImplementationName(),
+ SwXMLImportContent_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLImportMeta_getImplementationName(),
+ SwXMLImportMeta_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLImportSettings_getImplementationName(),
+ SwXMLImportSettings_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLExportOOO_getImplementationName(),
+ SwXMLExportOOO_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLExportStylesOOO_getImplementationName(),
+ SwXMLExportStylesOOO_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey,SwXMLExportContentOOO_getImplementationName(),
+ SwXMLExportContentOOO_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLExportMetaOOO_getImplementationName(),
+ SwXMLExportMetaOOO_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLExportSettingsOOO_getImplementationName(),
+ SwXMLExportSettingsOOO_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLExport_getImplementationName(),
+ SwXMLExport_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLExportStyles_getImplementationName(),
+ SwXMLExportStyles_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey,SwXMLExportContent_getImplementationName(),
+ SwXMLExportContent_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLExportMeta_getImplementationName(),
+ SwXMLExportMeta_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMLExportSettings_getImplementationName(),
+ SwXMLExportSettings_getSupportedServiceNames() );
+ //API objects
+ lcl_uno_writeInfo( pKey, SwXAutoTextContainer_getImplementationName(),
+ SwXAutoTextContainer_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXModule_getImplementationName(),
+ SwXModule_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwXMailMerge_getImplementationName(),
+ SwXMailMerge_getSupportedServiceNames() );
+ //Filter options
+ lcl_uno_writeInfo( pKey, SwXFilterOptions::getImplementationName_Static(),
+ SwXFilterOptions::getSupportedServiceNames_Static() );
+
+ // documents
+ lcl_uno_writeInfo( pKey, SwTextDocument_getImplementationName(),
+ SwTextDocument_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey, SwWebDocument_getImplementationName(),
+ SwWebDocument_getSupportedServiceNames() );
+ lcl_uno_writeInfo( pKey,SwGlobalDocument_getImplementationName(),
+ SwGlobalDocument_getSupportedServiceNames() );
+
+ // module
+ lcl_uno_writeInfo( pKey, SwUnoModule_getImplementationName(),
+ SwUnoModule_getSupportedServiceNames() );
+ // --> OD 2007-05-24 #i73788#
+ lcl_uno_writeInfo( pKey,
+ comp_FinalThreadManager::_getImplementationName(),
+ comp_FinalThreadManager::_getSupportedServiceNames() );
+ // <--
+
+ }
+ catch (registry::InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_True;
+}
+
+static ::cppu::ImplementationEntry const entries[] = {
+ { &comp_FinalThreadManager::_create,
+ &comp_FinalThreadManager::_getImplementationName,
+ &comp_FinalThreadManager::_getSupportedServiceNames,
+ &::cppu::createSingleComponentFactory, 0, 0 },
+ { 0, 0, 0, 0, 0, 0 }
+};
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName,
+ void * pServiceManager,
+ void * pRegistryKey )
+{
+ void * pRet = 0;
+ if( pServiceManager )
+ {
+ uno::Reference< XMultiServiceFactory > xMSF(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ) );
+
+ uno::Reference< XSingleServiceFactory > xFactory;
+
+ const sal_Int32 nImplNameLen = strlen( pImplName );
+ if( SwXMLImport_getImplementationName().equalsAsciiL( pImplName,
+ nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImport_getImplementationName(),
+ SwXMLImport_createInstance,
+ SwXMLImport_getSupportedServiceNames() );
+ }
+ else if( SwXMLImportStyles_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImportStyles_getImplementationName(),
+ SwXMLImportStyles_createInstance,
+ SwXMLImportStyles_getSupportedServiceNames() );
+ }
+ else if( SwXMLImportContent_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImportContent_getImplementationName(),
+ SwXMLImportContent_createInstance,
+ SwXMLImportContent_getSupportedServiceNames() );
+ }
+ else if( SwXMLImportMeta_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImportMeta_getImplementationName(),
+ SwXMLImportMeta_createInstance,
+ SwXMLImportMeta_getSupportedServiceNames() );
+ }
+ else if( SwXMLImportSettings_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLImportSettings_getImplementationName(),
+ SwXMLImportSettings_createInstance,
+ SwXMLImportSettings_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportOOO_getImplementationName().equalsAsciiL( pImplName,
+ nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportOOO_getImplementationName(),
+ SwXMLExportOOO_createInstance,
+ SwXMLExportOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportStylesOOO_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportStylesOOO_getImplementationName(),
+ SwXMLExportStylesOOO_createInstance,
+ SwXMLExportStylesOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportContentOOO_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportContentOOO_getImplementationName(),
+ SwXMLExportContentOOO_createInstance,
+ SwXMLExportContentOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportMetaOOO_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportMetaOOO_getImplementationName(),
+ SwXMLExportMetaOOO_createInstance,
+ SwXMLExportMetaOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportSettingsOOO_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportSettingsOOO_getImplementationName(),
+ SwXMLExportSettingsOOO_createInstance,
+ SwXMLExportSettingsOOO_getSupportedServiceNames() );
+ }
+ else if( SwXMLExport_getImplementationName().equalsAsciiL( pImplName,
+ nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExport_getImplementationName(),
+ SwXMLExport_createInstance,
+ SwXMLExport_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportStyles_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportStyles_getImplementationName(),
+ SwXMLExportStyles_createInstance,
+ SwXMLExportStyles_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportContent_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportContent_getImplementationName(),
+ SwXMLExportContent_createInstance,
+ SwXMLExportContent_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportMeta_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportMeta_getImplementationName(),
+ SwXMLExportMeta_createInstance,
+ SwXMLExportMeta_getSupportedServiceNames() );
+ }
+ else if( SwXMLExportSettings_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMLExportSettings_getImplementationName(),
+ SwXMLExportSettings_createInstance,
+ SwXMLExportSettings_getSupportedServiceNames() );
+ }
+ else if( SwXAutoTextContainer_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXAutoTextContainer_getImplementationName(),
+ SwXAutoTextContainer_createInstance,
+ SwXAutoTextContainer_getSupportedServiceNames() );
+ }
+ else if( SwXModule_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXModule_getImplementationName(),
+ SwXModule_createInstance,
+ SwXModule_getSupportedServiceNames() );
+ }
+ else if( SwXMailMerge_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXMailMerge_getImplementationName(),
+ SwXMailMerge_createInstance,
+ SwXMailMerge_getSupportedServiceNames() );
+ }
+ else if( SwXFilterOptions::getImplementationName_Static().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwXFilterOptions::getImplementationName_Static(),
+ SwXFilterOptions_createInstance,
+ SwXFilterOptions::getSupportedServiceNames_Static() );
+ }
+ else if( SwTextDocument_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::sfx2::createSfxModelFactory( xMSF,
+ SwTextDocument_getImplementationName(),
+ SwTextDocument_createInstance,
+ SwTextDocument_getSupportedServiceNames() );
+ }
+ else if( SwWebDocument_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwWebDocument_getImplementationName(),
+ SwWebDocument_createInstance,
+ SwWebDocument_getSupportedServiceNames() );
+ }
+ else if( SwGlobalDocument_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwGlobalDocument_getImplementationName(),
+ SwGlobalDocument_createInstance,
+ SwGlobalDocument_getSupportedServiceNames() );
+ }
+ else if( SwUnoModule_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ xFactory = ::cppu::createSingleFactory( xMSF,
+ SwUnoModule_getImplementationName(),
+ SwUnoModule_createInstance,
+ SwUnoModule_getSupportedServiceNames() );
+ }
+ // --> OD 2007-05-24 #i73788#
+ else if( comp_FinalThreadManager::_getImplementationName().equalsAsciiL(
+ pImplName, nImplNameLen ) )
+ {
+ pRet = ::cppu::component_getFactoryHelper(
+ pImplName, pServiceManager, pRegistryKey, entries);
+ }
+ // <--
+
+ if( xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unomailmerge.cxx b/sw/source/ui/uno/unomailmerge.cxx
new file mode 100644
index 000000000000..7a11f86a6e23
--- /dev/null
+++ b/sw/source/ui/uno/unomailmerge.cxx
@@ -0,0 +1,1253 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+#include <svl/itemprop.hxx>
+#include <svl/urihelper.hxx>
+#include <svx/dataaccessdescriptor.hxx>
+#include <tools/shl.hxx> // GetAppData
+#include <tools/tempfile.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/docfilt.hxx>
+#include <comphelper/processfactory.hxx>
+#include <vcl/timer.hxx>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/text/MailMergeType.hpp>
+#include <com/sun/star/text/MailMergeEvent.hpp>
+#include <com/sun/star/text/XMailMergeListener.hpp>
+#include <com/sun/star/text/XMailMergeBroadcaster.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/util/CloseVetoException.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include "com/sun/star/mail/XSmtpService.hpp"
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/event.hxx>
+#include <swevent.hxx>
+#include <unomailmerge.hxx>
+#include <swdll.hxx>
+#include <swmodule.hxx>
+#include <unoprnms.hxx>
+#include <unomap.hxx>
+#include <swunohelper.hxx>
+#include <docsh.hxx>
+#include <IDocumentDeviceAccess.hxx>
+#include <view.hxx>
+#include <dbmgr.hxx>
+#include <unotxdoc.hxx>
+#include <prtopt.hxx>
+#include <wrtsh.hxx>
+#include <shellio.hxx>
+#include <mmconfigitem.hxx>
+#include <mailmergehelper.hxx>
+#include <memory>
+
+#include <unomid.h>
+
+
+#define SN_MAIL_MERGE "com.sun.star.text.MailMerge"
+#define SN_DATA_ACCESS_DESCRIPTOR "com.sun.star.sdb.DataAccessDescriptor"
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::text;
+using ::rtl::OUString;
+using namespace SWUnoHelper;
+
+////////////////////////////////////////////////////////////
+
+typedef ::utl::SharedUNOComponent< XInterface > SharedComponent;
+
+////////////////////////////////////////////////////////////
+
+osl::Mutex & GetMailMergeMutex()
+{
+ static osl::Mutex aMutex;
+ return aMutex;
+}
+
+////////////////////////////////////////////////////////////
+
+enum CloseResult
+{
+ eSuccess, // successfully closed
+ eVetoed, // vetoed, ownership transfered to the vetoing instance
+ eFailed // failed for some unknown reason
+};
+static CloseResult CloseModelAndDocSh(
+ Reference< frame::XModel > &rxModel,
+ SfxObjectShellRef &rxDocSh )
+{
+ CloseResult eResult = eSuccess;
+
+ rxDocSh = 0;
+
+ //! models/documents should never be disposed (they may still be
+ //! used for printing which is called asynchronously for example)
+ //! instead call close
+ Reference< util::XCloseable > xClose( rxModel, UNO_QUERY );
+ if (xClose.is())
+ {
+ try
+ {
+ //! 'sal_True' -> transfer ownership to vetoing object if vetoed!
+ //! I.e. now that object is responsible for closing the model and doc shell.
+ xClose->close( sal_True );
+ }
+ catch (util::CloseVetoException &)
+ {
+ //! here we have the problem that the temporary file that is
+ //! currently being printed will never be deleted. :-(
+ eResult = eVetoed;
+ }
+ catch ( const uno::RuntimeException& )
+ {
+ eResult = eFailed;
+ }
+ }
+ return eResult;
+}
+
+////////////////////////////////////////////////////////////
+
+static BOOL LoadFromURL_impl(
+ Reference< frame::XModel > &rxModel,
+ SfxObjectShellRef &rxDocSh,
+ const String &rURL,
+ BOOL bClose )
+ throw (RuntimeException)
+{
+ // try to open the document readonly and hidden
+ Reference< frame::XModel > xTmpModel;
+ Sequence < PropertyValue > aArgs( 1 );
+ aArgs[0].Name = C2U("Hidden");
+ sal_Bool bVal = sal_True;
+ aArgs[0].Value <<= bVal;
+ try
+ {
+ Reference < XComponentLoader > xDesktop( ::comphelper::getProcessServiceFactory()->
+ createInstance( C2U("com.sun.star.frame.Desktop") ), UNO_QUERY );
+ xTmpModel = Reference < XModel >( xDesktop->loadComponentFromURL(
+ rURL, C2U("_blank"), 0, aArgs ), UNO_QUERY );
+ }
+ catch( Exception & )
+ {
+ return FALSE;
+ }
+
+ // try to get the DocShell
+ SwDocShell *pTmpDocShell = 0;
+ Reference < XUnoTunnel > xTunnel( xTmpModel, UNO_QUERY );
+ if (xTunnel.is())
+ {
+ SwXTextDocument* pTextDoc = reinterpret_cast<SwXTextDocument *>(
+ xTunnel->getSomething( SwXTextDocument::getUnoTunnelId() ));
+ pTmpDocShell = pTextDoc ? pTextDoc->GetDocShell() : 0;
+ }
+
+ BOOL bRes = FALSE;
+ if (xTmpModel.is() && pTmpDocShell) // everything available?
+ {
+ if (bClose)
+ CloseModelAndDocSh( rxModel, rxDocSh );
+ // set new stuff
+ rxModel = xTmpModel;
+ rxDocSh = pTmpDocShell;
+ bRes = TRUE;
+ }
+ else
+ {
+ SfxObjectShellRef xTmpDocSh = pTmpDocShell;
+ CloseModelAndDocSh( xTmpModel, xTmpDocSh );
+ }
+
+ return bRes;
+}
+
+//==========================================================
+namespace
+{
+ class DelayedFileDeletion : public ::cppu::WeakImplHelper1< util::XCloseListener >
+ {
+ protected:
+ ::osl::Mutex m_aMutex;
+ Reference< util::XCloseable > m_xDocument;
+ Timer m_aDeleteTimer;
+ String m_sTemporaryFile;
+ sal_Int32 m_nPendingDeleteAttempts;
+
+ public:
+ DelayedFileDeletion( const Reference< XModel >& _rxModel,
+ const String& _rTemporaryFile );
+
+ protected:
+ ~DelayedFileDeletion( );
+
+ // XCloseListener
+ virtual void SAL_CALL queryClosing( const EventObject& _rSource, sal_Bool _bGetsOwnership ) throw (util::CloseVetoException, RuntimeException);
+ virtual void SAL_CALL notifyClosing( const EventObject& _rSource ) throw (RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+
+ private:
+ void implTakeOwnership( );
+ DECL_LINK( OnTryDeleteFile, void* );
+
+ private:
+ DelayedFileDeletion( const DelayedFileDeletion& ); // never implemented
+ DelayedFileDeletion& operator=( const DelayedFileDeletion& ); // never implemented
+ };
+
+ DBG_NAME( DelayedFileDeletion )
+ //------------------------------------------------------
+ DelayedFileDeletion::DelayedFileDeletion( const Reference< XModel >& _rxModel, const String& _rTemporaryFile )
+ :
+ m_xDocument( _rxModel, UNO_QUERY )
+ ,m_sTemporaryFile( _rTemporaryFile )
+ ,m_nPendingDeleteAttempts( 0 )
+ {
+ DBG_CTOR( DelayedFileDeletion, NULL );
+
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ if ( m_xDocument.is() )
+ {
+ m_xDocument->addCloseListener( this );
+ // successfully added -> keep ourself alive
+ acquire();
+ }
+ else {
+ OSL_ENSURE(false, "DelayedFileDeletion::DelayedFileDeletion: model is no component!" );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE(false, "DelayedFileDeletion::DelayedFileDeletion: could not register as event listener at the model!" );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( DelayedFileDeletion, OnTryDeleteFile, void*, EMPTYARG )
+ {
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ sal_Bool bDeliverOwnership = ( 0 == m_nPendingDeleteAttempts );
+ // if this is our last attemt, then anybody which vetoes this has to take the consequences
+ // (means take the ownership)
+ m_xDocument->close( bDeliverOwnership );
+ bSuccess = sal_True;
+ }
+ catch( const util::CloseVetoException& )
+ {
+ // somebody vetoed -> next try
+ if ( m_nPendingDeleteAttempts )
+ {
+ // next attempt
+ --m_nPendingDeleteAttempts;
+ m_aDeleteTimer.Start();
+ }
+ else
+ bSuccess = sal_True; // can't do anything here ...
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE(false, "DelayedFileDeletion::OnTryDeleteFile: caught a strange exception!" );
+ bSuccess = sal_True;
+ // can't do anything here ...
+ }
+
+ if ( bSuccess )
+ {
+ SWUnoHelper::UCB_DeleteFile( m_sTemporaryFile );
+ aGuard.clear();
+ release(); // this should be our last reference, we should be dead after this
+ }
+ return 0L;
+ }
+
+ //--------------------------------------------------------------------
+ void DelayedFileDeletion::implTakeOwnership( )
+ {
+ // revoke ourself as listener
+ try
+ {
+ m_xDocument->removeCloseListener( this );
+ }
+ catch( const Exception & )
+ {
+ OSL_ENSURE(false, "DelayedFileDeletion::implTakeOwnership: could not revoke the listener!" );
+ }
+
+ m_aDeleteTimer.SetTimeout( 3000 ); // 3 seconds
+ m_aDeleteTimer.SetTimeoutHdl( LINK( this, DelayedFileDeletion, OnTryDeleteFile ) );
+ m_nPendingDeleteAttempts = 3; // try 3 times at most
+ m_aDeleteTimer.Start( );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DelayedFileDeletion::queryClosing( const EventObject& , sal_Bool _bGetsOwnership ) throw (util::CloseVetoException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( _bGetsOwnership )
+ implTakeOwnership( );
+
+ // always veto: We want to take the ownership ourself, as this is the only chance to delete
+ // the temporary file which the model is based on
+ throw util::CloseVetoException( );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DelayedFileDeletion::notifyClosing( const EventObject& ) throw (RuntimeException)
+ {
+ OSL_ENSURE(false, "DelayedFileDeletion::notifyClosing: how this?" );
+ // this should not happen:
+ // Either, a foreign instance closes the document, then we should veto this, and take the ownership
+ // Or, we ourself close the document, then we should not be a listener anymore
+ }
+
+ //------------------------------------------------------
+ void SAL_CALL DelayedFileDeletion::disposing( const EventObject& ) throw (RuntimeException)
+ {
+ OSL_ENSURE(false, "DelayedFileDeletion::disposing: how this?" );
+ // this should not happen:
+ // Either, a foreign instance closes the document, then we should veto this, and take the ownership
+ // Or, we ourself close the document, then we should not be a listener anymore
+ }
+
+ //------------------------------------------------------
+ DelayedFileDeletion::~DelayedFileDeletion( )
+ {
+ DBG_DTOR( DelayedFileDeletion, NULL );
+ }
+}
+
+////////////////////////////////////////////////////////////
+
+static BOOL DeleteTmpFile_Impl(
+ Reference< frame::XModel > &rxModel,
+ SfxObjectShellRef &rxDocSh,
+ const String &rTmpFileURL )
+{
+ BOOL bRes = FALSE;
+ if (rTmpFileURL.Len())
+ {
+ BOOL bDelete = TRUE;
+ if ( eVetoed == CloseModelAndDocSh( rxModel, rxDocSh ) )
+ {
+ // somebody vetoed the closing, and took the ownership of the document
+ // -> ensure that the temporary file is deleted later on
+ Reference< XEventListener > xEnsureDelete( new DelayedFileDeletion( rxModel, rTmpFileURL ) );
+ // note: as soon as #106931# is fixed, the whole DelayedFileDeletion is to be superseeded by
+ // a better solution
+ bDelete = FALSE;
+ }
+
+ rxModel = 0;
+ rxDocSh = 0; // destroy doc shell
+
+ if ( bDelete )
+ {
+ if ( !SWUnoHelper::UCB_DeleteFile( rTmpFileURL ) )
+ {
+ Reference< XEventListener > xEnsureDelete( new DelayedFileDeletion( rxModel, rTmpFileURL ) );
+ // same not as above: as soon as #106931#, ...
+ }
+ }
+ else
+ bRes = TRUE; // file will be deleted delayed
+ }
+ return bRes;
+}
+
+////////////////////////////////////////////////////////////
+
+SwXMailMerge::SwXMailMerge() :
+ aEvtListeners ( GetMailMergeMutex() ),
+ aMergeListeners ( GetMailMergeMutex() ),
+ aPropListeners ( GetMailMergeMutex() ),
+ pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_MAILMERGE ) ),
+ bSendAsHTML(sal_False),
+ bSendAsAttachment(sal_False),
+ bSaveAsSingleFile(sal_False)
+
+{
+ // create empty document
+ // like in: SwModule::InsertEnv (appenv.cxx)
+ SwDocShell *pDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
+ xDocSh = pDocShell;
+ xDocSh->DoInitNew( 0 );
+ SfxViewFrame *pFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 );
+ SwView *pView = (SwView*) pFrame->GetViewShell();
+ pView->AttrChangedNotify( &pView->GetWrtShell() );//Damit SelectShell gerufen wird.
+
+ xModel = pDocShell->GetModel();
+
+ nDataCommandType = sdb::CommandType::TABLE;
+ nOutputType = MailMergeType::PRINTER;
+ bEscapeProcessing = sal_True; //!! allow to process properties like "Filter", "Order", ...
+ bSinglePrintJobs = sal_False;
+ bFileNameFromColumn = sal_False;
+
+ bDisposing = sal_False;
+}
+
+SwXMailMerge::~SwXMailMerge()
+{
+ if (aTmpFileName.Len())
+ DeleteTmpFile_Impl( xModel, xDocSh, aTmpFileName );
+ else // there was no temporary file in use
+ {
+ //! we still need to close the model and doc shell manually
+ //! because there is no automatism that will do that later.
+ //! #120086#
+ if ( eVetoed == CloseModelAndDocSh( xModel, xDocSh ) )
+ OSL_ENSURE(false, "owner ship transfered to vetoing object!" );
+
+ xModel = 0;
+ xDocSh = 0; // destroy doc shell
+ }
+}
+
+uno::Any SAL_CALL SwXMailMerge::execute(
+ const uno::Sequence< beans::NamedValue >& rArguments )
+ throw (IllegalArgumentException, Exception, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //
+ // get property values to be used
+ // (use values from the service as default and override them with
+ // the values that are provided as arguments)
+ //
+ uno::Sequence< uno::Any > aCurSelection = aSelection;
+ uno::Reference< sdbc::XResultSet > xCurResultSet = xResultSet;
+ uno::Reference< sdbc::XConnection > xCurConnection = xConnection;
+ uno::Reference< frame::XModel > xCurModel = xModel;
+ OUString aCurDataSourceName = aDataSourceName;
+ OUString aCurDataCommand = aDataCommand;
+ OUString aCurFilter = aFilter;
+ OUString aCurDocumentURL = aDocumentURL;
+ OUString aCurOutputURL = aOutputURL;
+ OUString aCurFileNamePrefix = aFileNamePrefix;
+ sal_Int32 nCurDataCommandType = nDataCommandType;
+ sal_Int16 nCurOutputType = nOutputType;
+ sal_Bool bCurEscapeProcessing = bEscapeProcessing;
+ sal_Bool bCurSinglePrintJobs = bSinglePrintJobs;
+ sal_Bool bCurFileNameFromColumn = bFileNameFromColumn;
+ //
+ SfxObjectShellRef xCurDocSh = xDocSh; // the document
+ //
+ const beans::NamedValue *pArguments = rArguments.getConstArray();
+ sal_Int32 nArgs = rArguments.getLength();
+ for (sal_Int32 i = 0; i < nArgs; ++i)
+ {
+ const OUString &rName = pArguments[i].Name;
+ const Any &rValue = pArguments[i].Value;
+
+ BOOL bOK = TRUE;
+ if (rName.equalsAscii( GetPropName( UNO_NAME_SELECTION ) ))
+ bOK = rValue >>= aCurSelection;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_RESULT_SET ) ))
+ bOK = rValue >>= xCurResultSet;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_CONNECTION ) ))
+ bOK = rValue >>= xCurConnection;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_MODEL ) ))
+ throw PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rName, static_cast < cppu::OWeakObject * > ( this ) );
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_DATA_SOURCE_NAME ) ))
+ bOK = rValue >>= aCurDataSourceName;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_DAD_COMMAND ) ))
+ bOK = rValue >>= aCurDataCommand;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_FILTER ) ))
+ bOK = rValue >>= aCurFilter;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_DOCUMENT_URL ) ))
+ {
+ bOK = rValue >>= aCurDocumentURL;
+ if (aCurDocumentURL.getLength()
+ && !LoadFromURL_impl( xCurModel, xCurDocSh, aCurDocumentURL, FALSE ))
+ throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Failed to create document from URL: " ) ) + aCurDocumentURL, static_cast < cppu::OWeakObject * > ( this ) );
+ }
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_OUTPUT_URL ) ))
+ {
+ bOK = rValue >>= aCurOutputURL;
+ if (aCurOutputURL.getLength())
+ {
+ if (!UCB_IsDirectory(aCurOutputURL))
+ throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "URL does not point to a directory: " ) ) + aCurOutputURL, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ if (UCB_IsReadOnlyFileName(aCurOutputURL))
+ throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "URL is read-only: " ) ) + aCurOutputURL, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+ }
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_FILE_NAME_PREFIX ) ))
+ bOK = rValue >>= aCurFileNamePrefix;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_DAD_COMMAND_TYPE ) ))
+ bOK = rValue >>= nCurDataCommandType;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_OUTPUT_TYPE ) ))
+ bOK = rValue >>= nCurOutputType;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_ESCAPE_PROCESSING ) ))
+ bOK = rValue >>= bCurEscapeProcessing;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_SINGLE_PRINT_JOBS ) ))
+ bOK = rValue >>= bCurSinglePrintJobs;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_FILE_NAME_FROM_COLUMN ) ))
+ bOK = rValue >>= bCurFileNameFromColumn;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_SUBJECT ) ))
+ bOK = rValue >>= sSubject;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_ADDRESS_FROM_COLUMN ) ))
+ bOK = rValue >>= sAddressFromColumn;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_SEND_AS_HTML ) ))
+ bOK = rValue >>= bSendAsHTML;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_MAIL_BODY ) ))
+ bOK = rValue >>= sMailBody;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_ATTACHMENT_NAME ) ))
+ bOK = rValue >>= sAttachmentName;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_ATTACHMENT_FILTER ) ))
+ bOK = rValue >>= sAttachmentFilter;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_COPIES_TO ) ))
+ bOK = rValue >>= aCopiesTo;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_BLIND_COPIES_TO ) ))
+ bOK = rValue >>= aBlindCopiesTo;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_SEND_AS_ATTACHMENT ) ))
+ bOK = rValue >>= bSendAsAttachment;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_PRINT_OPTIONS ) ))
+ bOK = rValue >>= aPrintSettings;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_SAVE_AS_SINGLE_FILE ) ))
+ bOK = rValue >>= bSaveAsSingleFile;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_SAVE_FILTER ) ))
+ bOK = rValue >>= sSaveFilter;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_SAVE_FILTER_OPTIONS ) ))
+ bOK = rValue >>= sSaveFilterOptions;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_SAVE_FILTER_DATA ) ))
+ bOK = rValue >>= aSaveFilterData;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_IN_SERVER_PASSWORD ) ))
+ bOK = rValue >>= sInServerPassword;
+ else if (rName.equalsAscii( GetPropName( UNO_NAME_OUT_SERVER_PASSWORD ) ))
+ bOK = rValue >>= sOutServerPassword;
+ else
+ throw UnknownPropertyException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is unknown: " ) ) + rName, static_cast < cppu::OWeakObject * > ( this ) );
+
+ if (!bOK)
+ throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property type mismatch or property not set: " ) ) + rName, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+
+ // need to translate the selection: the API here requires a sequence of bookmarks, but the MergeNew
+ // method we will call below requires a sequence of indicies.
+ if ( aCurSelection.getLength() )
+ {
+ Sequence< Any > aTranslated( aCurSelection.getLength() );
+
+ sal_Bool bValid = sal_False;
+ Reference< sdbcx::XRowLocate > xRowLocate( xCurResultSet, UNO_QUERY );
+ if ( xRowLocate.is() )
+ {
+
+ const Any* pBookmarks = aCurSelection.getConstArray();
+ const Any* pBookmarksEnd = pBookmarks + aCurSelection.getLength();
+ Any* pTranslated = aTranslated.getArray();
+
+ try
+ {
+ sal_Bool bEverythingsFine = sal_True;
+ for ( ; ( pBookmarks != pBookmarksEnd ) && bEverythingsFine; ++pBookmarks )
+ {
+ if ( xRowLocate->moveToBookmark( *pBookmarks ) )
+ *pTranslated <<= xCurResultSet->getRow();
+ else
+ bEverythingsFine = sal_False;
+ }
+ if ( bEverythingsFine )
+ bValid = sal_True;
+ }
+ catch( const Exception& )
+ {
+ bValid = sal_False;
+ }
+ }
+
+ if ( !bValid )
+ {
+ throw IllegalArgumentException(
+ OUString ( RTL_CONSTASCII_USTRINGPARAM ( "The current 'Selection' does not describe a valid array of bookmarks, relative to the current 'ResultSet'." ) ),
+ static_cast < cppu::OWeakObject * > ( this ),
+ 0
+ );
+ }
+
+ aCurSelection = aTranslated;
+ }
+
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( xCurDocSh, FALSE);
+ SwView *pView = PTR_CAST( SwView, pFrame->GetViewShell() );
+ if (!pView)
+ throw RuntimeException();
+ SwWrtShell &rSh = *pView->GetWrtShellPtr();
+
+ // avoid assertion in 'Update' from Sfx by supplying a shell
+ // and thus avoiding the SelectShell call in Writers GetState function
+ // while still in Update of Sfx.
+ // (GetSelection in Update is not allowed)
+ if (pView && aCurDocumentURL.getLength())
+ pView->AttrChangedNotify( &pView->GetWrtShell() );//Damit SelectShell gerufen wird.
+
+ SharedComponent aRowSetDisposeHelper;
+ if (!xCurResultSet.is())
+ {
+ if (!aCurDataSourceName.getLength() || !aCurDataCommand.getLength() )
+ {
+ OSL_ENSURE(false, "PropertyValues missing or unset");
+ throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Either the ResultSet or DataSourceName and DataCommand must be set." ) ), static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+
+ //
+ // build ResultSet from DataSourceName, DataCommand and DataCommandType
+ //
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if (xMgr.is())
+ {
+ Reference< XInterface > xInstance = xMgr->createInstance(
+ C2U( "com.sun.star.sdb.RowSet" ));
+ aRowSetDisposeHelper.reset( xInstance, SharedComponent::TakeOwnership );
+ Reference< XPropertySet > xRowSetPropSet( xInstance, UNO_QUERY );
+ OSL_ENSURE( xRowSetPropSet.is(), "failed to get XPropertySet interface from RowSet" );
+ if (xRowSetPropSet.is())
+ {
+ if (xCurConnection.is())
+ xRowSetPropSet->setPropertyValue( C2U("ActiveConnection"), makeAny( xCurConnection ) );
+ xRowSetPropSet->setPropertyValue( C2U("DataSourceName"), makeAny( aCurDataSourceName ) );
+ xRowSetPropSet->setPropertyValue( C2U("Command"), makeAny( aCurDataCommand ) );
+ xRowSetPropSet->setPropertyValue( C2U("CommandType"), makeAny( nCurDataCommandType ) );
+ xRowSetPropSet->setPropertyValue( C2U("EscapeProcessing"), makeAny( bCurEscapeProcessing ) );
+ xRowSetPropSet->setPropertyValue( C2U("ApplyFilter"), makeAny( sal_True ) );
+ xRowSetPropSet->setPropertyValue( C2U("Filter"), makeAny( aCurFilter ) );
+
+ Reference< sdbc::XRowSet > xRowSet( xInstance, UNO_QUERY );
+ if (xRowSet.is())
+ xRowSet->execute(); // build ResultSet from properties
+ if( !xCurConnection.is() )
+ xCurConnection.set( xRowSetPropSet->getPropertyValue( C2U( "ActiveConnection" )), UNO_QUERY );
+ xCurResultSet = Reference< sdbc::XResultSet >( xRowSet, UNO_QUERY );
+ OSL_ENSURE( xCurResultSet.is(), "failed to build ResultSet" );
+ }
+ }
+ }
+
+ svx::ODataAccessDescriptor aDescriptor;
+ aDescriptor.setDataSource(aCurDataSourceName);
+ aDescriptor[ svx::daConnection ] <<= xCurConnection;
+ aDescriptor[ svx::daCommand ] <<= aCurDataCommand;
+ aDescriptor[ svx::daCommandType ] <<= nCurDataCommandType;
+ aDescriptor[ svx::daEscapeProcessing ] <<= bCurEscapeProcessing;
+ aDescriptor[ svx::daCursor ] <<= xCurResultSet;
+ // aDescriptor[ svx::daColumnName ] not used
+ // aDescriptor[ svx::daColumnObject ] not used
+ aDescriptor[ svx::daSelection ] <<= aCurSelection;
+
+ USHORT nMergeType;
+ switch (nCurOutputType)
+ {
+ case MailMergeType::PRINTER : nMergeType = DBMGR_MERGE_MAILMERGE; break;
+ case MailMergeType::FILE : nMergeType = DBMGR_MERGE_MAILFILES; break;
+ case MailMergeType::MAIL : nMergeType = DBMGR_MERGE_MAILING; break;
+ default:
+ throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Invalid value of property:" ) ) + C2U("OutputType"), static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+
+ SwNewDBMgr* pMgr = rSh.GetNewDBMgr();
+ //force layout creation
+ rSh.CalcLayout();
+ OSL_ENSURE( pMgr, "database manager missing" );
+
+ SwMergeDescriptor aMergeDesc( nMergeType, rSh, aDescriptor );
+
+ std::auto_ptr< SwMailMergeConfigItem > pMMConfigItem;
+ uno::Reference< mail::XMailService > xInService;
+ if (MailMergeType::PRINTER == nCurOutputType)
+ {
+ SwPrintData aPrtData = *SW_MOD()->GetPrtOptions( FALSE );
+ IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess();
+ SwPrintData* pShellPrintData = pIDDA->getPrintData();
+ if (pShellPrintData)
+ aPrtData = *pShellPrintData;
+ aPrtData.SetPrintSingleJobs( bCurSinglePrintJobs );
+ pIDDA->setPrintData( aPrtData );
+ // #i25686# printing should not be done asynchronously to prevent dangling offices
+ // when mail merge is called as command line macro
+ aMergeDesc.bPrintAsync = sal_False;
+ aMergeDesc.aPrintOptions = aPrintSettings;
+ aMergeDesc.bCreateSingleFile = true;
+ }
+ else /* FILE and MAIL*/
+ {
+ INetURLObject aURLObj;
+ aURLObj.SetSmartProtocol( INET_PROT_FILE );
+
+ if (aCurDocumentURL.getLength())
+ {
+ // if OutputURL or FileNamePrefix are missing get
+ // them from DocumentURL
+ aURLObj.SetSmartURL( aCurDocumentURL );
+ if (!aCurFileNamePrefix.getLength())
+ aCurFileNamePrefix = aURLObj.GetBase(); // filename without extension
+ if (!aCurOutputURL.getLength())
+ {
+ //aCurOutputURL = aURLObj.GetURLPath();
+ aURLObj.removeSegment();
+ aCurOutputURL = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
+ }
+ }
+ else // default empty document without URL
+ {
+ if (!aCurOutputURL.getLength())
+ throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "OutputURL is not set and can not be obtained." ) ), static_cast < cppu::OWeakObject * > ( this ) );
+ }
+
+ aURLObj.SetSmartURL( aCurOutputURL );
+ String aPath = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
+
+ String aDelim( INET_PATH_TOKEN );
+ if (aPath.Len() >= aDelim.Len() &&
+ aPath.Copy( aPath.Len()-aDelim.Len() ).CompareTo( aDelim ) != COMPARE_EQUAL)
+ aPath += aDelim;
+ if (bCurFileNameFromColumn)
+ pMgr->SetEMailColumn( aCurFileNamePrefix );
+ else
+ {
+ aPath += String( aCurFileNamePrefix );
+ pMgr->SetEMailColumn( String() );
+ }
+ pMgr->SetSubject( aPath );
+ if(MailMergeType::FILE == nCurOutputType)
+ {
+ aMergeDesc.sSaveToFilter = sSaveFilter;
+ aMergeDesc.sSaveToFilterOptions = sSaveFilterOptions;
+ aMergeDesc.aSaveToFilterData = aSaveFilterData;
+ aMergeDesc.bCreateSingleFile = bSaveAsSingleFile;
+ }
+ else /*if(MailMergeType::MAIL == nCurOutputType)*/
+ {
+ pMgr->SetEMailColumn( sAddressFromColumn );
+ if(!sAddressFromColumn.getLength())
+ throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Mail address column not set." ) ), static_cast < cppu::OWeakObject * > ( this ) );
+ aMergeDesc.sSaveToFilter = sAttachmentFilter;
+ aMergeDesc.sSubject = sSubject;
+ aMergeDesc.sMailBody = sMailBody;
+ aMergeDesc.sAttachmentName = sAttachmentName;
+ aMergeDesc.aCopiesTo = aCopiesTo;
+ aMergeDesc.aBlindCopiesTo = aBlindCopiesTo;
+ aMergeDesc.bSendAsHTML = bSendAsHTML;
+ aMergeDesc.bSendAsAttachment = bSendAsAttachment;
+
+ aMergeDesc.bCreateSingleFile = sal_False;
+ pMMConfigItem = std::auto_ptr< SwMailMergeConfigItem >(new SwMailMergeConfigItem);
+ aMergeDesc.pMailMergeConfigItem = pMMConfigItem.get();
+ aMergeDesc.xSmtpServer = SwMailMergeHelper::ConnectToSmtpServer(
+ *pMMConfigItem,
+ xInService,
+ sInServerPassword, sOutServerPassword );
+ if( !aMergeDesc.xSmtpServer.is() || !aMergeDesc.xSmtpServer->isConnected())
+ throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Failed to connect to mail server." ) ), static_cast < cppu::OWeakObject * > ( this ) );
+ }
+ }
+
+
+ // save document with temporary filename
+ const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat(
+ String::CreateFromAscii( FILTER_XML ),
+ SwDocShell::Factory().GetFilterContainer() );
+ String aExtension( pSfxFlt->GetDefaultExtension() );
+ aExtension.EraseLeadingChars( '*' );
+ TempFile aTempFile( C2U("SwMM"), &aExtension );
+ aTmpFileName = aTempFile.GetName();
+
+ Reference< XStorable > xStorable( xCurModel, UNO_QUERY );
+ sal_Bool bStoredAsTemporary = sal_False;
+ if ( xStorable.is() )
+ {
+ try
+ {
+ xStorable->storeAsURL( aTmpFileName, Sequence< PropertyValue >() );
+ bStoredAsTemporary = sal_True;
+ }
+ catch( const Exception& )
+ {
+ }
+ }
+ if ( !bStoredAsTemporary )
+ throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Failed to save temporary file." ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ pMgr->SetMergeSilent( TRUE ); // suppress dialogs, message boxes, etc.
+ const SwXMailMerge *pOldSrc = pMgr->GetMailMergeEvtSrc();
+ OSL_ENSURE( !pOldSrc || pOldSrc == this, "Ooops... different event source already set." );
+ pMgr->SetMailMergeEvtSrc( this ); // launch events for listeners
+
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE), xCurDocSh));
+ BOOL bSucc = pMgr->MergeNew( aMergeDesc );
+ SFX_APP()->NotifyEvent(SfxEventHint(SW_EVENT_MAIL_MERGE_END, SwDocShell::GetEventName(STR_SW_EVENT_MAIL_MERGE_END), xCurDocSh));
+
+ pMgr->SetMailMergeEvtSrc( pOldSrc );
+
+ if ( xCurModel.get() != xModel.get() )
+ { // in case it was a temporary model -> close it, and delete the file
+ DeleteTmpFile_Impl( xCurModel, xCurDocSh, aTmpFileName );
+ aTmpFileName.Erase();
+ }
+ // (in case it wasn't a temporary model, it will be closed in the dtor, at the latest)
+
+ if (!bSucc)
+ throw Exception( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Mail merge failed. Sorry, no further information available." ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ //de-initialize services
+ if(xInService.is() && xInService->isConnected())
+ xInService->disconnect();
+ if(aMergeDesc.xSmtpServer.is() && aMergeDesc.xSmtpServer->isConnected())
+ aMergeDesc.xSmtpServer->disconnect();
+
+ return makeAny( sal_True );
+}
+
+void SwXMailMerge::LaunchMailMergeEvent( const MailMergeEvent &rEvt ) const
+{
+ cppu::OInterfaceIteratorHelper aIt( ((SwXMailMerge *) this)->aMergeListeners );
+ while (aIt.hasMoreElements())
+ {
+ Reference< XMailMergeListener > xRef( aIt.next(), UNO_QUERY );
+ if (xRef.is())
+ xRef->notifyMailMergeEvent( rEvt );
+ }
+}
+
+void SwXMailMerge::launchEvent( const PropertyChangeEvent &rEvt ) const
+{
+ cppu::OInterfaceContainerHelper *pContainer =
+ aPropListeners.getContainer( rEvt.PropertyHandle );
+ if (pContainer)
+ {
+ cppu::OInterfaceIteratorHelper aIt( *pContainer );
+ while (aIt.hasMoreElements())
+ {
+ Reference< XPropertyChangeListener > xRef( aIt.next(), UNO_QUERY );
+ if (xRef.is())
+ xRef->propertyChange( rEvt );
+ }
+ }
+}
+
+
+uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXMailMerge::getPropertySetInfo( )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static Reference< XPropertySetInfo > aRef = pPropSet->getPropertySetInfo();
+ return aRef;
+}
+
+void SAL_CALL SwXMailMerge::setPropertyValue(
+ const OUString& rPropertyName, const uno::Any& rValue )
+ throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap()->getByName( rPropertyName );
+ if (!pCur)
+ throw UnknownPropertyException();
+ else if (pCur->nFlags & PropertyAttribute::READONLY)
+ throw PropertyVetoException();
+ else
+ {
+ void *pData = NULL;
+ const uno::Type* pType = pCur->pType;
+ switch (pCur->nWID)
+ {
+ case WID_SELECTION : pData = &aSelection; break;
+ case WID_RESULT_SET : pData = &xResultSet; break;
+ case WID_CONNECTION : pData = &xConnection; break;
+ case WID_MODEL : pData = &xModel; break;
+ case WID_DATA_SOURCE_NAME : pData = &aDataSourceName; break;
+ case WID_DATA_COMMAND : pData = &aDataCommand; break;
+ case WID_FILTER : pData = &aFilter; break;
+ case WID_DOCUMENT_URL : pData = &aDocumentURL; break;
+ case WID_OUTPUT_URL : pData = &aOutputURL; break;
+ case WID_DATA_COMMAND_TYPE : pData = &nDataCommandType; break;
+ case WID_OUTPUT_TYPE : pData = &nOutputType; break;
+ case WID_ESCAPE_PROCESSING : pData = &bEscapeProcessing; break;
+ case WID_SINGLE_PRINT_JOBS : pData = &bSinglePrintJobs; break;
+ case WID_FILE_NAME_FROM_COLUMN : pData = &bFileNameFromColumn; break;
+ case WID_FILE_NAME_PREFIX : pData = &aFileNamePrefix; break;
+ case WID_MAIL_SUBJECT: pData = &sSubject; break;
+ case WID_ADDRESS_FROM_COLUMN: pData = &sAddressFromColumn; break;
+ case WID_SEND_AS_HTML: pData = &bSendAsHTML; break;
+ case WID_SEND_AS_ATTACHMENT: pData = &bSendAsAttachment; break;
+ case WID_MAIL_BODY: pData = &sMailBody; break;
+ case WID_ATTACHMENT_NAME: pData = &sAttachmentName; break;
+ case WID_ATTACHMENT_FILTER: pData = &sAttachmentFilter;break;
+ case WID_PRINT_OPTIONS: pData = &aPrintSettings; break;
+ case WID_SAVE_AS_SINGLE_FILE: pData = &bSaveAsSingleFile; break;
+ case WID_SAVE_FILTER: pData = &sSaveFilter; break;
+ case WID_SAVE_FILTER_OPTIONS: pData = &sSaveFilterOptions; break;
+ case WID_SAVE_FILTER_DATA: pData = &aSaveFilterData; break;
+ case WID_COPIES_TO: pData = &aCopiesTo; break;
+ case WID_BLIND_COPIES_TO: pData = &aBlindCopiesTo;break;
+ case WID_IN_SERVER_PASSWORD: pData = &sInServerPassword; break;
+ case WID_OUT_SERVER_PASSWORD: pData = &sOutServerPassword; break;
+ default :
+ OSL_ENSURE(false, "unknown WID");
+ }
+ Any aOld( pData, *pType );
+
+ sal_Bool bChanged = sal_False;
+ sal_Bool bOK = sal_True;
+ if (aOld != rValue)
+ {
+ if (pData == &aSelection)
+ bOK = rValue >>= aSelection;
+ else if (pData == &xResultSet)
+ bOK = rValue >>= xResultSet;
+ else if (pData == &xConnection)
+ bOK = rValue >>= xConnection;
+ else if (pData == &xModel)
+ bOK = rValue >>= xModel;
+ else if (pData == &aDataSourceName)
+ bOK = rValue >>= aDataSourceName;
+ else if (pData == &aDataCommand)
+ bOK = rValue >>= aDataCommand;
+ else if (pData == &aFilter)
+ bOK = rValue >>= aFilter;
+ else if (pData == &aDocumentURL)
+ {
+ OUString aText;
+ bOK = rValue >>= aText;
+ if (aText.getLength()
+ && !LoadFromURL_impl( xModel, xDocSh, aText, TRUE ))
+ throw RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Failed to create document from URL: " ) ) + aText, static_cast < cppu::OWeakObject * > ( this ) );
+ aDocumentURL = aText;
+ }
+ else if (pData == &aOutputURL)
+ {
+ OUString aText;
+ bOK = rValue >>= aText;
+ if (aText.getLength())
+ {
+ if (!UCB_IsDirectory(aText))
+ throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "URL does not point to a directory: " ) ) + aText, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ if (UCB_IsReadOnlyFileName(aText))
+ throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "URL is read-only: " ) ) + aText, static_cast < cppu::OWeakObject * > ( this ), 0 );
+ }
+ aOutputURL = aText;
+ }
+ else if (pData == &nDataCommandType)
+ bOK = rValue >>= nDataCommandType;
+ else if (pData == &nOutputType)
+ bOK = rValue >>= nOutputType;
+ else if (pData == &bEscapeProcessing)
+ bOK = rValue >>= bEscapeProcessing;
+ else if (pData == &bSinglePrintJobs)
+ bOK = rValue >>= bSinglePrintJobs;
+ else if (pData == &bFileNameFromColumn)
+ bOK = rValue >>= bFileNameFromColumn;
+ else if (pData == &aFileNamePrefix)
+ bOK = rValue >>= aFileNamePrefix;
+ else if (pData == &sSubject)
+ bOK = rValue >>= sSubject;
+ else if (pData == &sAddressFromColumn)
+ bOK = rValue >>= sAddressFromColumn;
+ else if (pData == &bSendAsHTML)
+ bOK = rValue >>= bSendAsHTML;
+ else if (pData == &bSendAsAttachment)
+ bOK = rValue >>= bSendAsAttachment;
+ else if (pData == &sMailBody)
+ bOK = rValue >>= sMailBody;
+ else if (pData == &sAttachmentName)
+ bOK = rValue >>= sAttachmentName;
+ else if (pData == &sAttachmentFilter)
+ bOK = rValue >>= sAttachmentFilter;
+ else if (pData == &aPrintSettings)
+ bOK = rValue >>= aPrintSettings;
+ else if (pData == &bSaveAsSingleFile)
+ bOK = rValue >>= bSaveAsSingleFile;
+ else if (pData == &sSaveFilter)
+ bOK = rValue >>= sSaveFilter;
+ else if (pData == &sSaveFilterOptions)
+ bOK = rValue >>= sSaveFilterOptions;
+ else if (pData == &aSaveFilterData)
+ bOK = rValue >>= aSaveFilterData;
+ else if (pData == &aCopiesTo)
+ bOK = rValue >>= aCopiesTo;
+ else if (pData == &aBlindCopiesTo)
+ bOK = rValue >>= aBlindCopiesTo;
+ else if(pData == &sInServerPassword)
+ bOK = rValue >>= sInServerPassword;
+ else if(pData == &sOutServerPassword)
+ bOK = rValue >>= sInServerPassword;
+ else {
+ OSL_ENSURE(false, "invalid pointer" );
+ }
+ OSL_ENSURE( bOK, "set value failed" );
+ bChanged = sal_True;
+ }
+ if (!bOK)
+ throw IllegalArgumentException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property type mismatch or property not set: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ), 0 );
+
+ if (bChanged)
+ {
+ PropertyChangeEvent aChgEvt( (XPropertySet *) this, rPropertyName,
+ FALSE, pCur->nWID, aOld, rValue );
+ launchEvent( aChgEvt );
+ }
+ }
+}
+
+uno::Any SAL_CALL SwXMailMerge::getPropertyValue(
+ const OUString& rPropertyName )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ Any aRet;
+
+ const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap()->getByName( rPropertyName );
+ if (!pCur)
+ throw UnknownPropertyException();
+ else
+ {
+ switch (pCur->nWID)
+ {
+ case WID_SELECTION : aRet <<= aSelection; break;
+ case WID_RESULT_SET : aRet <<= xResultSet; break;
+ case WID_CONNECTION : aRet <<= xConnection; break;
+ case WID_MODEL : aRet <<= xModel; break;
+ case WID_DATA_SOURCE_NAME : aRet <<= aDataSourceName; break;
+ case WID_DATA_COMMAND : aRet <<= aDataCommand; break;
+ case WID_FILTER : aRet <<= aFilter; break;
+ case WID_DOCUMENT_URL : aRet <<= aDocumentURL; break;
+ case WID_OUTPUT_URL : aRet <<= aOutputURL; break;
+ case WID_DATA_COMMAND_TYPE : aRet <<= nDataCommandType; break;
+ case WID_OUTPUT_TYPE : aRet <<= nOutputType; break;
+ case WID_ESCAPE_PROCESSING : aRet <<= bEscapeProcessing; break;
+ case WID_SINGLE_PRINT_JOBS : aRet <<= bSinglePrintJobs; break;
+ case WID_FILE_NAME_FROM_COLUMN : aRet <<= bFileNameFromColumn; break;
+ case WID_FILE_NAME_PREFIX : aRet <<= aFileNamePrefix; break;
+ case WID_MAIL_SUBJECT: aRet <<= sSubject; break;
+ case WID_ADDRESS_FROM_COLUMN: aRet <<= sAddressFromColumn; break;
+ case WID_SEND_AS_HTML: aRet <<= bSendAsHTML; break;
+ case WID_SEND_AS_ATTACHMENT: aRet <<= bSendAsAttachment; break;
+ case WID_MAIL_BODY: aRet <<= sMailBody; break;
+ case WID_ATTACHMENT_NAME: aRet <<= sAttachmentName; break;
+ case WID_ATTACHMENT_FILTER: aRet <<= sAttachmentFilter;break;
+ case WID_PRINT_OPTIONS: aRet <<= aPrintSettings; break;
+ case WID_SAVE_AS_SINGLE_FILE: aRet <<= bSaveAsSingleFile; break;
+ case WID_SAVE_FILTER: aRet <<= sSaveFilter; break;
+ case WID_SAVE_FILTER_OPTIONS: aRet <<= sSaveFilterOptions; break;
+ case WID_SAVE_FILTER_DATA: aRet <<= aSaveFilterData; break;
+ case WID_COPIES_TO: aRet <<= aCopiesTo; break;
+ case WID_BLIND_COPIES_TO: aRet <<= aBlindCopiesTo;break;
+ case WID_IN_SERVER_PASSWORD: aRet <<= sInServerPassword; break;
+ case WID_OUT_SERVER_PASSWORD: aRet <<= sOutServerPassword; break;
+ default :
+ OSL_ENSURE(false, "unknown WID");
+ }
+ }
+
+ return aRet;
+}
+
+void SAL_CALL SwXMailMerge::addPropertyChangeListener(
+ const OUString& rPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& rListener )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rListener.is())
+ {
+ const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap()->getByName( rPropertyName );
+ if (pCur)
+ aPropListeners.addInterface( pCur->nWID, rListener );
+ else
+ throw UnknownPropertyException();
+ }
+}
+
+void SAL_CALL SwXMailMerge::removePropertyChangeListener(
+ const OUString& rPropertyName,
+ const uno::Reference< beans::XPropertyChangeListener >& rListener )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rListener.is())
+ {
+ const SfxItemPropertySimpleEntry* pCur = pPropSet->getPropertyMap()->getByName( rPropertyName );
+ if (pCur)
+ aPropListeners.removeInterface( pCur->nWID, rListener );
+ else
+ throw UnknownPropertyException();
+ }
+}
+
+void SAL_CALL SwXMailMerge::addVetoableChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*rListener*/ )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ // no vetoable property, thus no support for vetoable change listeners
+ OSL_ENSURE(false, "not implemented");
+}
+
+void SAL_CALL SwXMailMerge::removeVetoableChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*rListener*/ )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ // no vetoable property, thus no support for vetoable change listeners
+ OSL_ENSURE(false,"not implemented");
+}
+
+
+void SAL_CALL SwXMailMerge::dispose()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if (!bDisposing)
+ {
+ bDisposing = sal_True;
+
+ EventObject aEvtObj( (XPropertySet *) this );
+ aEvtListeners.disposeAndClear( aEvtObj );
+ aMergeListeners.disposeAndClear( aEvtObj );
+ aPropListeners.disposeAndClear( aEvtObj );
+ }
+}
+
+void SAL_CALL SwXMailMerge::addEventListener(
+ const Reference< XEventListener >& rxListener )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rxListener.is())
+ aEvtListeners.addInterface( rxListener );
+}
+
+void SAL_CALL SwXMailMerge::removeEventListener(
+ const Reference< XEventListener >& rxListener )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rxListener.is())
+ aEvtListeners.removeInterface( rxListener );
+}
+
+void SAL_CALL SwXMailMerge::addMailMergeEventListener(
+ const uno::Reference< XMailMergeListener >& rxListener )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rxListener.is())
+ aMergeListeners.addInterface( rxListener );
+}
+
+void SAL_CALL SwXMailMerge::removeMailMergeEventListener(
+ const uno::Reference< XMailMergeListener >& rxListener )
+ throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if (!bDisposing && rxListener.is())
+ aMergeListeners.removeInterface( rxListener );
+}
+
+OUString SAL_CALL SwXMailMerge::getImplementationName()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return SwXMailMerge_getImplementationName();
+}
+
+sal_Bool SAL_CALL SwXMailMerge::supportsService( const OUString& rServiceName )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return C2U( SN_MAIL_MERGE ) == rServiceName ||
+ C2U( SN_DATA_ACCESS_DESCRIPTOR ) == rServiceName;
+}
+
+uno::Sequence< OUString > SAL_CALL SwXMailMerge::getSupportedServiceNames()
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ return SwXMailMerge_getSupportedServiceNames();
+}
+
+////////////////////////////////////////////////////////////
+
+uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames()
+ throw()
+{
+ uno::Sequence< OUString > aNames(2);
+ OUString *pName = aNames.getArray();
+ pName[0] = C2U( SN_MAIL_MERGE );
+ pName[1] = C2U( SN_DATA_ACCESS_DESCRIPTOR );
+ return aNames;
+}
+
+OUString SAL_CALL SwXMailMerge_getImplementationName()
+ throw()
+{
+ return OUString( C2U( "SwXMailMerge" ) );
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwXMailMerge_createInstance(
+ const uno::Reference< XMultiServiceFactory > & /*rSMgr*/)
+ throw( uno::Exception )
+{
+ SolarMutexGuard aGuard;
+
+ //the module may not be loaded
+ SwDLL::Init();
+ uno::Reference< uno::XInterface > xRef = (cppu::OWeakObject *) new SwXMailMerge();
+ return xRef;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unomod.cxx b/sw/source/ui/uno/unomod.cxx
new file mode 100644
index 000000000000..70f8b9978f07
--- /dev/null
+++ b/sw/source/ui/uno/unomod.cxx
@@ -0,0 +1,1026 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+
+#include <swtypes.hxx>
+#include <osl/diagnose.h>
+#include <unomod.hxx>
+#include <unomid.h>
+#include <unoprnms.hxx>
+#include <unomap.hxx>
+#include <prtopt.hxx>
+#include <tools/shl.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+#include <docsh.hxx>
+#include <wrtsh.hxx>
+#include <viewopt.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+#include <com/sun/star/text/NotePrintMode.hpp>
+#include <doc.hxx>
+#include <comphelper/TypeGeneration.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/view/DocumentZoomType.hpp>
+#include <comphelper/ChainablePropertySetInfo.hxx>
+#include <edtwin.hxx>
+#include <rtl/ustrbuf.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::comphelper;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+enum SwViewSettingsPropertyHandles
+{
+ HANDLE_VIEWSET_ANNOTATIONS,
+ HANDLE_VIEWSET_BREAKS,
+ HANDLE_VIEWSET_DRAWINGS,
+ HANDLE_VIEWSET_FIELD_COMMANDS,
+ HANDLE_VIEWSET_FOOTNOTE_BACKGROUND,
+ HANDLE_VIEWSET_GRAPHICS,
+ HANDLE_VIEWSET_HIDDEN_CHARACTERS,
+ HANDLE_VIEWSET_HIDDEN_PARAGRAPHS,
+ HANDLE_VIEWSET_HIDDEN_TEXT,
+ HANDLE_VIEWSET_HRULER,
+ HANDLE_VIEWSET_HSCROLL,
+ HANDLE_VIEWSET_INDEX_MARK_BACKGROUND,
+ HANDLE_VIEWSET_NONPRINTING_CHARACTERS,
+ HANDLE_VIEWSET_ONLINE_LAYOUT,
+ HANDLE_VIEWSET_PARA_BREAKS,
+ HANDLE_VIEWSET_PROTECTED_SPACES,
+ HANDLE_VIEWSET_SOFT_HYPHENS,
+ HANDLE_VIEWSET_SPACES,
+ HANDLE_VIEWSET_TABLE_BOUNDARIES,
+ HANDLE_VIEWSET_TABLES,
+ HANDLE_VIEWSET_TABSTOPS,
+ HANDLE_VIEWSET_TEXT_BOUNDARIES,
+ HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND,
+ HANDLE_VIEWSET_VRULER,
+ HANDLE_VIEWSET_VSCROLL,
+ HANDLE_VIEWSET_SMOOTH_SCROLLING,
+ HANDLE_VIEWSET_SOLID_MARK_HANDLES,
+ HANDLE_VIEWSET_ZOOM_TYPE,
+ HANDLE_VIEWSET_ZOOM,
+ HANDLE_VIEWSET_PREVENT_TIPS,
+ HANDLE_VIEWSET_HELP_URL,
+ HANDLE_VIEWSET_VRULER_RIGHT,
+ HANDLE_VIEWSET_SHOW_RULER,
+ HANDLE_VIEWSET_IS_RASTER_VISIBLE,
+ HANDLE_VIEWSET_IS_SNAP_TO_RASTER,
+ HANDLE_VIEWSET_RASTER_RESOLUTION_X,
+ HANDLE_VIEWSET_RASTER_RESOLUTION_Y,
+ HANDLE_VIEWSET_RASTER_SUBDIVISION_X,
+ HANDLE_VIEWSET_RASTER_SUBDIVISION_Y,
+ HANDLE_VIEWSET_HORI_RULER_METRIC,
+ HANDLE_VIEWSET_VERT_RULER_METRIC
+};
+
+enum SwPrintSettingsPropertyHandles
+{
+ HANDLE_PRINTSET_ANNOTATION_MODE,
+ HANDLE_PRINTSET_BLACK_FONTS,
+ HANDLE_PRINTSET_CONTROLS,
+ HANDLE_PRINTSET_DRAWINGS,
+ HANDLE_PRINTSET_GRAPHICS,
+ HANDLE_PRINTSET_LEFT_PAGES,
+ HANDLE_PRINTSET_PAGE_BACKGROUND,
+ HANDLE_PRINTSET_PROSPECT,
+ HANDLE_PRINTSET_REVERSED,
+ HANDLE_PRINTSET_RIGHT_PAGES,
+ HANDLE_PRINTSET_FAX_NAME,
+ HANDLE_PRINTSET_PAPER_FROM_SETUP,
+ HANDLE_PRINTSET_TABLES,
+ HANDLE_PRINTSET_SINGLE_JOBS,
+ HANDLE_PRINTSET_EMPTY_PAGES,
+ HANDLE_PRINTSET_PROSPECT_RTL,
+ HANDLE_PRINTSET_PLACEHOLDER,
+ HANDLE_PRINTSET_HIDDEN_TEXT
+};
+
+static ChainablePropertySetInfo * lcl_createViewSettingsInfo()
+{
+ static PropertyInfo aViewSettingsMap_Impl[] =
+ {
+ { RTL_CONSTASCII_STRINGPARAM ( "HelpURL" ), HANDLE_VIEWSET_HELP_URL , CPPUTYPE_OUSTRING, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "HorizontalRulerMetric"),HANDLE_VIEWSET_HORI_RULER_METRIC , CPPUTYPE_INT32, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "IsRasterVisible"), HANDLE_VIEWSET_IS_RASTER_VISIBLE, CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "IsSnapToRaster"), HANDLE_VIEWSET_IS_SNAP_TO_RASTER, CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "IsVertRulerRightAligned"),HANDLE_VIEWSET_VRULER_RIGHT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PreventHelpTips" ), HANDLE_VIEWSET_PREVENT_TIPS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "RasterResolutionX"), HANDLE_VIEWSET_RASTER_RESOLUTION_X, CPPUTYPE_INT32, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "RasterResolutionY"), HANDLE_VIEWSET_RASTER_RESOLUTION_Y, CPPUTYPE_INT32, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "RasterSubdivisionX"), HANDLE_VIEWSET_RASTER_SUBDIVISION_X, CPPUTYPE_INT32, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "RasterSubdivisionY"), HANDLE_VIEWSET_RASTER_SUBDIVISION_Y, CPPUTYPE_INT32, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowAnnotations" ), HANDLE_VIEWSET_ANNOTATIONS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowBreaks"), HANDLE_VIEWSET_BREAKS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowDrawings"), HANDLE_VIEWSET_DRAWINGS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowFieldCommands"), HANDLE_VIEWSET_FIELD_COMMANDS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowFootnoteBackground"),HANDLE_VIEWSET_FOOTNOTE_BACKGROUND , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowGraphics"), HANDLE_VIEWSET_GRAPHICS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenCharacters"), HANDLE_VIEWSET_HIDDEN_CHARACTERS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenParagraphs"), HANDLE_VIEWSET_HIDDEN_PARAGRAPHS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowHiddenText"), HANDLE_VIEWSET_HIDDEN_TEXT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowHoriRuler"), HANDLE_VIEWSET_HRULER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowHoriScrollBar"), HANDLE_VIEWSET_HSCROLL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowIndexMarkBackground"),HANDLE_VIEWSET_INDEX_MARK_BACKGROUND, CPPUTYPE_BOOLEAN,PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowNonprintingCharacters"),HANDLE_VIEWSET_NONPRINTING_CHARACTERS, CPPUTYPE_BOOLEAN,PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowOnlineLayout"), HANDLE_VIEWSET_ONLINE_LAYOUT , CPPUTYPE_BOOLEAN, PropertyAttribute::MAYBEVOID, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowParaBreaks"), HANDLE_VIEWSET_PARA_BREAKS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowProtectedSpaces"), HANDLE_VIEWSET_PROTECTED_SPACES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowRulers"), HANDLE_VIEWSET_SHOW_RULER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowSoftHyphens"), HANDLE_VIEWSET_SOFT_HYPHENS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowSpaces"), HANDLE_VIEWSET_SPACES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowTableBoundaries"), HANDLE_VIEWSET_TABLE_BOUNDARIES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowTables"), HANDLE_VIEWSET_TABLES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowTabstops"), HANDLE_VIEWSET_TABSTOPS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowTextBoundaries"), HANDLE_VIEWSET_TEXT_BOUNDARIES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowTextFieldBackground"),HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND, CPPUTYPE_BOOLEAN,PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowVertRuler"), HANDLE_VIEWSET_VRULER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ShowVertScrollBar"), HANDLE_VIEWSET_VSCROLL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "SmoothScrolling"), HANDLE_VIEWSET_SMOOTH_SCROLLING , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "SolidMarkHandles"), HANDLE_VIEWSET_SOLID_MARK_HANDLES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "VerticalRulerMetric"), HANDLE_VIEWSET_VERT_RULER_METRIC , CPPUTYPE_INT32, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ZoomType"), HANDLE_VIEWSET_ZOOM_TYPE , CPPUTYPE_INT16, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "ZoomValue"), HANDLE_VIEWSET_ZOOM , CPPUTYPE_INT16, PROPERTY_NONE, 0},
+ { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
+ };
+ return new ChainablePropertySetInfo ( aViewSettingsMap_Impl );
+}
+
+static ChainablePropertySetInfo * lcl_createPrintSettingsInfo()
+{
+ static PropertyInfo aPrintSettingsMap_Impl[] =
+ {
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintAnnotationMode" ), HANDLE_PRINTSET_ANNOTATION_MODE , CPPUTYPE_INT16, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintBlackFonts" ), HANDLE_PRINTSET_BLACK_FONTS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintControls" ), HANDLE_PRINTSET_CONTROLS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintDrawings" ), HANDLE_PRINTSET_DRAWINGS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintGraphics" ), HANDLE_PRINTSET_GRAPHICS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintHiddenText"), HANDLE_PRINTSET_HIDDEN_TEXT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintLeftPages" ), HANDLE_PRINTSET_LEFT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintPageBackground" ), HANDLE_PRINTSET_PAGE_BACKGROUND , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintProspect" ), HANDLE_PRINTSET_PROSPECT , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintProspectRTL" ), HANDLE_PRINTSET_PROSPECT_RTL , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintReversed" ), HANDLE_PRINTSET_REVERSED , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintRightPages" ), HANDLE_PRINTSET_RIGHT_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintFaxName" ), HANDLE_PRINTSET_FAX_NAME , CPPUTYPE_OUSTRING, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintPaperFromSetup" ), HANDLE_PRINTSET_PAPER_FROM_SETUP , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintTables" ), HANDLE_PRINTSET_TABLES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintTextPlaceholder"), HANDLE_PRINTSET_PLACEHOLDER , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintSingleJobs" ), HANDLE_PRINTSET_SINGLE_JOBS , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { RTL_CONSTASCII_STRINGPARAM ( "PrintEmptyPages" ), HANDLE_PRINTSET_EMPTY_PAGES , CPPUTYPE_BOOLEAN, PROPERTY_NONE, 0},
+ { 0, 0, 0, CPPUTYPE_UNKNOWN, 0, 0 }
+ };
+ return new ChainablePropertySetInfo ( aPrintSettingsMap_Impl );
+}
+
+/******************************************************************
+ * SwXModule
+ ******************************************************************/
+Reference< uno::XInterface > SAL_CALL SwXModule_createInstance(
+ const Reference< XMultiServiceFactory > & /*rSMgr*/) throw( Exception )
+{
+ static Reference< uno::XInterface > xModule = (cppu::OWeakObject*)new SwXModule();;
+ return xModule;
+}
+
+Sequence< OUString > SAL_CALL SwXModule_getSupportedServiceNames() throw()
+{
+ OUString sService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GlobalSettings"));
+ const Sequence< OUString > aSeq( &sService, 1 );
+ return aSeq;
+}
+
+OUString SAL_CALL SwXModule_getImplementationName() throw()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM("SwXModule" ) );
+}
+
+SwXModule::SwXModule() :
+ pxViewSettings(0),
+ pxPrintSettings(0)
+{
+}
+
+SwXModule::~SwXModule()
+{
+ delete pxViewSettings;
+ delete pxPrintSettings;
+}
+
+Reference< XPropertySet > SwXModule::getViewSettings(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!pxViewSettings)
+ {
+ ((SwXModule*)this)->pxViewSettings = new Reference< XPropertySet > ;
+ OSL_ENSURE(false, "Web or Text?");
+ *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, 0 ) );
+ }
+ return *pxViewSettings;
+}
+
+Reference< XPropertySet > SwXModule::getPrintSettings(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!pxPrintSettings)
+ {
+ ((SwXModule*)this)->pxPrintSettings = new Reference< XPropertySet > ;
+ OSL_ENSURE(false, "Web or Text?");
+ *pxPrintSettings = static_cast < HelperBaseNoState * > ( new SwXPrintSettings ( PRINT_SETTINGS_MODULE ) );
+ }
+ return *pxPrintSettings;
+}
+
+OUString SwXModule::getImplementationName(void) throw( RuntimeException )
+{
+ return SwXModule_getImplementationName();
+}
+
+sal_Bool SwXModule::supportsService(const OUString& rServiceName) throw( RuntimeException )
+{
+ const Sequence< OUString > aNames = SwXModule_getSupportedServiceNames();
+ for(sal_Int32 nService = 0; nService < aNames.getLength(); nService++)
+ {
+ if(aNames.getConstArray()[nService] == rServiceName)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+Sequence< OUString > SwXModule::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ return SwXModule_getSupportedServiceNames();
+}
+
+/******************************************************************
+ * SwXPrintSettings
+ ******************************************************************/
+SwXPrintSettings::SwXPrintSettings(SwXPrintSettingsType eType, SwDoc* pDoc)
+: ChainableHelperNoState ( lcl_createPrintSettingsInfo (), &Application::GetSolarMutex() )
+, meType(eType)
+, mpPrtOpt ( NULL )
+, mpDoc ( pDoc )
+{
+}
+
+SwXPrintSettings::~SwXPrintSettings()
+ throw()
+{
+}
+
+void SwXPrintSettings::_preSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ switch (meType)
+ {
+ case PRINT_SETTINGS_MODULE:
+ mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
+ break;
+ case PRINT_SETTINGS_WEB:
+ mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
+ break;
+ case PRINT_SETTINGS_DOCUMENT:
+ {
+ if (!mpDoc)
+ throw IllegalArgumentException ();
+ if ( !mpDoc->getPrintData() )
+ {
+ mpPrtOpt = new SwPrintData;
+ mpDoc->setPrintData ( *mpPrtOpt );
+ delete mpPrtOpt;
+ }
+ mpPrtOpt = mpDoc->getPrintData();
+ }
+ break;
+ }
+}
+
+void SwXPrintSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ sal_Bool bVal;
+ if ( rInfo.mnHandle != HANDLE_PRINTSET_ANNOTATION_MODE &&
+ rInfo.mnHandle != HANDLE_PRINTSET_FAX_NAME )
+ bVal = *(sal_Bool*)rValue.getValue();
+
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_PRINTSET_LEFT_PAGES:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintLeftPage(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_RIGHT_PAGES:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintRightPage(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_REVERSED:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintReverse(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_PROSPECT:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintProspect(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_GRAPHICS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintGraphic(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_TABLES:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintTable(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_DRAWINGS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintDraw(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_CONTROLS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintControl(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_PAGE_BACKGROUND:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintPageBackground(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_BLACK_FONTS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintBlackFont(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_SINGLE_JOBS:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintSingleJobs(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_PAPER_FROM_SETUP:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPaperFromSetup(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_ANNOTATION_MODE:
+ {
+ sal_Int16 nVal = 0;
+ rValue >>= nVal;
+ if(nVal <= text::NotePrintMode_PAGE_END)
+ mpPrtOpt->SetPrintPostIts(nVal);
+ else
+ throw lang::IllegalArgumentException();
+ }
+ break;
+ case HANDLE_PRINTSET_EMPTY_PAGES:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintEmptyPages(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_FAX_NAME:
+ {
+ OUString sString;
+ if ( rValue >>= sString)
+ mpPrtOpt->SetFaxName(sString);
+ else
+ throw lang::IllegalArgumentException();
+ }
+ break;
+ case HANDLE_PRINTSET_PROSPECT_RTL:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintProspect_RTL(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_PLACEHOLDER:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintTextPlaceholder(bVal);
+ }
+ break;
+ case HANDLE_PRINTSET_HIDDEN_TEXT:
+ {
+ bVal = *(sal_Bool*)rValue.getValue();
+ mpPrtOpt->SetPrintHiddenText(bVal);
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXPrintSettings::_postSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ mpPrtOpt = NULL;
+}
+
+void SwXPrintSettings::_preGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ switch (meType)
+ {
+ case PRINT_SETTINGS_MODULE:
+ mpPrtOpt = SW_MOD()->GetPrtOptions( sal_False );
+ break;
+ case PRINT_SETTINGS_WEB:
+ mpPrtOpt = SW_MOD()->GetPrtOptions( sal_True );
+ break;
+ case PRINT_SETTINGS_DOCUMENT:
+ {
+ if (!mpDoc)
+ throw IllegalArgumentException ();
+ if ( !mpDoc->getPrintData() )
+ {
+ mpPrtOpt = new SwPrintData;
+ mpDoc->setPrintData ( *mpPrtOpt );
+ delete mpPrtOpt;
+ }
+ mpPrtOpt = mpDoc->getPrintData();
+ }
+ break;
+ }
+}
+
+void SwXPrintSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
+ throw(UnknownPropertyException, WrappedTargetException )
+{
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_PRINTSET_LEFT_PAGES:
+ rValue <<= mpPrtOpt->IsPrintLeftPage();
+ break;
+ case HANDLE_PRINTSET_RIGHT_PAGES:
+ rValue <<= mpPrtOpt->IsPrintRightPage();
+ break;
+ case HANDLE_PRINTSET_REVERSED:
+ rValue <<= mpPrtOpt->IsPrintReverse();
+ break;
+ case HANDLE_PRINTSET_PROSPECT:
+ rValue <<= mpPrtOpt->IsPrintProspect();
+ break;
+ case HANDLE_PRINTSET_GRAPHICS:
+ rValue <<= mpPrtOpt->IsPrintGraphic();
+ break;
+ case HANDLE_PRINTSET_TABLES:
+ rValue <<= mpPrtOpt->IsPrintTable();
+ break;
+ case HANDLE_PRINTSET_DRAWINGS:
+ rValue <<= mpPrtOpt->IsPrintDraw();
+ break;
+ case HANDLE_PRINTSET_CONTROLS:
+ rValue <<= mpPrtOpt->IsPrintControl();
+ break;
+ case HANDLE_PRINTSET_PAGE_BACKGROUND:
+ rValue <<= mpPrtOpt->IsPrintPageBackground();
+ break;
+ case HANDLE_PRINTSET_BLACK_FONTS:
+ rValue <<= mpPrtOpt->IsPrintBlackFont();
+ break;
+ case HANDLE_PRINTSET_SINGLE_JOBS:
+ rValue <<= mpPrtOpt->IsPrintSingleJobs();
+ break;
+ case HANDLE_PRINTSET_EMPTY_PAGES:
+ rValue <<= mpPrtOpt->IsPrintEmptyPages();
+ break;
+ case HANDLE_PRINTSET_PAPER_FROM_SETUP:
+ rValue <<= mpPrtOpt->IsPaperFromSetup();
+ break;
+ case HANDLE_PRINTSET_ANNOTATION_MODE:
+ {
+ rValue <<= static_cast < sal_Int16 > ( mpPrtOpt->GetPrintPostIts() );
+ }
+ break;
+ case HANDLE_PRINTSET_FAX_NAME :
+ {
+ rValue <<= mpPrtOpt->GetFaxName();
+ }
+ break;
+ case HANDLE_PRINTSET_PROSPECT_RTL:
+ {
+ rValue <<= mpPrtOpt->IsPrintProspectRTL();
+ }
+ break;
+ case HANDLE_PRINTSET_PLACEHOLDER:
+ {
+ rValue <<= mpPrtOpt->IsPrintTextPlaceholder();
+ }
+ break;
+ case HANDLE_PRINTSET_HIDDEN_TEXT:
+ {
+ rValue <<= mpPrtOpt->IsPrintHiddenText();
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXPrintSettings::_postGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ mpPrtOpt = NULL;
+}
+
+OUString SwXPrintSettings::getImplementationName(void) throw( RuntimeException )
+{
+ return C2U("SwXPrintSettings");
+}
+
+sal_Bool SwXPrintSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
+{
+ return C2U("com.sun.star.text.PrintSettings") == rServiceName;
+}
+
+Sequence< OUString > SwXPrintSettings::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = C2U("com.sun.star.text.PrintSettings");
+ return aRet;
+}
+
+SwXViewSettings::SwXViewSettings(sal_Bool bWebView, SwView* pVw)
+: ChainableHelperNoState( lcl_createViewSettingsInfo (), &Application::GetSolarMutex() )
+, pView(pVw)
+, mpViewOption ( NULL )
+, mpConstViewOption ( NULL )
+, bObjectValid(sal_True)
+, bWeb(bWebView)
+, eHRulerUnit( FUNIT_CM )
+, mbApplyHRulerMetric( sal_False )
+, eVRulerUnit( FUNIT_CM )
+, mbApplyVRulerMetric( sal_False )
+{
+ // This property only exists if we have a view (ie, not at the module )
+ if ( !pView )
+ mpInfo->remove ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "HelpURL" ) ) );
+
+}
+
+SwXViewSettings::~SwXViewSettings()
+ throw()
+{
+
+}
+
+void SwXViewSettings::_preSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ const SwViewOption* pVOpt = 0;
+ if(pView)
+ {
+ if(!IsValid())
+ return;
+ pVOpt = pView->GetWrtShell().GetViewOptions();
+ }
+ else
+ pVOpt = SW_MOD()->GetViewOption(bWeb);
+
+ mpViewOption = new SwViewOption (*pVOpt);
+ mbApplyZoom = sal_False;
+ if(pView)
+ mpViewOption->SetStarOneSetting(sal_True);
+}
+
+void SwXViewSettings::_setSingleValue( const comphelper::PropertyInfo & rInfo, const uno::Any &rValue )
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ sal_Bool bVal = HANDLE_VIEWSET_ZOOM != rInfo.mnHandle ?
+ *(sal_Bool*)rValue.getValue() : sal_False;
+ // the API flag should not be set to the application's view settings
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_VIEWSET_SHOW_RULER : mpViewOption->SetViewAnyRuler(bVal); break;
+ case HANDLE_VIEWSET_HRULER : mpViewOption->SetViewHRuler(bVal); break;
+ case HANDLE_VIEWSET_VRULER : mpViewOption->SetViewVRuler(bVal);break;
+ case HANDLE_VIEWSET_VRULER_RIGHT : mpViewOption->SetVRulerRight(bVal);break;
+ case HANDLE_VIEWSET_HSCROLL : mpViewOption->SetViewHScrollBar(bVal);break;
+ case HANDLE_VIEWSET_VSCROLL : mpViewOption->SetViewVScrollBar(bVal);break;
+ case HANDLE_VIEWSET_GRAPHICS : mpViewOption->SetGraphic(bVal);break;
+ case HANDLE_VIEWSET_TABLES : mpViewOption->SetTable(bVal); break;
+ case HANDLE_VIEWSET_DRAWINGS : mpViewOption->SetDraw(bVal); break;
+ case HANDLE_VIEWSET_FIELD_COMMANDS : mpViewOption->SetFldName(bVal); break;
+ case HANDLE_VIEWSET_ANNOTATIONS : mpViewOption->SetPostIts(bVal); break;
+ case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, TRUE); break;
+ case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: mpViewOption->SetViewMetaChars( bVal ); break;
+ case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, TRUE); break;
+ case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, TRUE); break;
+ case HANDLE_VIEWSET_PARA_BREAKS : mpViewOption->SetParagraph(bVal); break;
+ case HANDLE_VIEWSET_SOFT_HYPHENS : mpViewOption->SetSoftHyph(bVal); break;
+ case HANDLE_VIEWSET_SPACES : mpViewOption->SetBlank(bVal); break;
+ case HANDLE_VIEWSET_PROTECTED_SPACES : mpViewOption->SetHardBlank(bVal); break;
+ case HANDLE_VIEWSET_TABSTOPS : mpViewOption->SetTab(bVal); break;
+ case HANDLE_VIEWSET_BREAKS : mpViewOption->SetLineBreak(bVal); break;
+ case HANDLE_VIEWSET_HIDDEN_TEXT : mpViewOption->SetShowHiddenField(bVal); break;
+ case HANDLE_VIEWSET_HIDDEN_CHARACTERS : mpViewOption->SetShowHiddenChar(bVal); break;
+ case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : mpViewOption->SetShowHiddenPara(bVal); break;
+ case HANDLE_VIEWSET_TABLE_BOUNDARIES : mpViewOption->SetAppearanceFlag(VIEWOPT_TABLE_BOUNDARIES, bVal, TRUE); break;
+ case HANDLE_VIEWSET_TEXT_BOUNDARIES : mpViewOption->SetDocBoundaries(bVal); break;
+ case HANDLE_VIEWSET_SMOOTH_SCROLLING : mpViewOption->SetSmoothScroll(bVal); break;
+ case HANDLE_VIEWSET_SOLID_MARK_HANDLES : mpViewOption->SetSolidMarkHdl(bVal); break;
+ case HANDLE_VIEWSET_PREVENT_TIPS : mpViewOption->SetPreventTips(bVal); break;
+ case HANDLE_VIEWSET_IS_RASTER_VISIBLE : mpViewOption->SetGridVisible(bVal); break;
+ case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : mpViewOption->SetSnap(bVal); break;
+ case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
+ {
+ sal_Int32 nTmp = 0;
+ if(!(rValue >>= nTmp) || nTmp < 10)
+ throw IllegalArgumentException();
+ Size aSize( mpViewOption->GetSnapSize() );
+ aSize.Width() = MM100_TO_TWIP( nTmp );
+ mpViewOption->SetSnapSize( aSize );
+ }
+ break;
+ case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
+ {
+ sal_Int32 nTmp = 0;
+ if(!(rValue >>= nTmp) || nTmp < 10)
+ throw IllegalArgumentException();
+ Size aSize( mpViewOption->GetSnapSize() );
+ aSize.Height() = MM100_TO_TWIP( nTmp );
+ mpViewOption->SetSnapSize( aSize );
+ }
+ break;
+ case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
+ {
+ sal_Int32 nTmp = 0;
+ if(!(rValue >>= nTmp) || !(0 <= nTmp && nTmp < 100))
+ throw IllegalArgumentException();
+ mpViewOption->SetDivisionX( (short) nTmp );
+ }
+ break;
+ case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
+ {
+ sal_Int32 nTmp = 0;
+ if(!(rValue >>= nTmp) || !(0 <= nTmp && nTmp < 100))
+ throw IllegalArgumentException();
+ mpViewOption->SetDivisionY( (short) nTmp );
+ }
+ break;
+ case HANDLE_VIEWSET_ZOOM :
+ {
+ sal_Int16 nZoom = 0;
+ if(!(rValue >>= nZoom) || nZoom > 1000 || nZoom < 5)
+ throw lang::IllegalArgumentException();
+ mpViewOption->SetZoom((sal_uInt16)nZoom);
+ mbApplyZoom = sal_True;
+ }
+ break;
+ case HANDLE_VIEWSET_ZOOM_TYPE:
+ {
+ sal_Int16 nZoom = 0;
+ if(!(rValue >>= nZoom))
+ throw IllegalArgumentException();
+ SvxZoomType eZoom = (SvxZoomType)USHRT_MAX;
+ switch (nZoom)
+ {
+ case view::DocumentZoomType::OPTIMAL:
+ eZoom = SVX_ZOOM_OPTIMAL;
+ break;
+ case view::DocumentZoomType::PAGE_WIDTH:
+ eZoom = SVX_ZOOM_PAGEWIDTH;
+ break;
+ case view::DocumentZoomType::ENTIRE_PAGE:
+ eZoom = SVX_ZOOM_WHOLEPAGE;
+ break;
+ case view::DocumentZoomType::BY_VALUE:
+ eZoom = SVX_ZOOM_PERCENT;
+ break;
+ case view::DocumentZoomType::PAGE_WIDTH_EXACT:
+ eZoom = SVX_ZOOM_PAGEWIDTH_NOBORDER;
+ break;
+ default:
+ throw IllegalArgumentException(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "SwXViewSettings: invalid zoom type")), 0, 0);
+ break;
+ }
+ if(eZoom < USHRT_MAX)
+ {
+ mpViewOption->SetZoomType( eZoom );
+ mbApplyZoom = sal_True;
+ }
+ }
+ break;
+ case HANDLE_VIEWSET_ONLINE_LAYOUT :
+ {
+ if( pView && !bVal != !pView->GetWrtShell().getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE) )
+ pView->GetDocShell()->ToggleBrowserMode(bVal, pView );
+ }
+ break;
+ case HANDLE_VIEWSET_HELP_URL :
+ {
+ if ( pView )
+ {
+ OUString sHelpURL;
+ if ( ! ( rValue >>= sHelpURL ) )
+ throw IllegalArgumentException();
+ SwEditWin &rEditWin = pView->GetEditWin();
+ OUString sPrefix = sHelpURL.copy ( 0, 4 );
+ // Make sure we have a valid string...should be in the format HID:12345
+ if ( ! sPrefix.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "HID:" ) ) )
+ throw IllegalArgumentException ();
+ OUString sNumber = sHelpURL.copy ( 4 );
+ sal_uInt32 nHelpId = sNumber.toInt32();
+ rEditWin.SetHelpId ( nHelpId );
+ }
+ else
+ throw UnknownPropertyException();
+ }
+ break;
+ case HANDLE_VIEWSET_HORI_RULER_METRIC:
+ case HANDLE_VIEWSET_VERT_RULER_METRIC:
+ {
+ sal_Int32 nUnit = -1;
+ if( rValue >>= nUnit )
+ switch( nUnit )
+ {
+ case FUNIT_MM:
+ case FUNIT_CM:
+ case FUNIT_POINT:
+ case FUNIT_PICA:
+ case FUNIT_INCH:
+ if( rInfo.mnHandle == HANDLE_VIEWSET_HORI_RULER_METRIC )
+ {
+ eHRulerUnit = nUnit;
+ mbApplyHRulerMetric = sal_True;
+ }
+ else
+ {
+ eVRulerUnit = nUnit;
+ mbApplyVRulerMetric = sal_True;
+ }
+ break;
+ default:
+ throw IllegalArgumentException();
+ }
+ }
+ break;
+ default:
+ throw UnknownPropertyException();
+ }
+}
+
+void SwXViewSettings::_postSetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ if( pView )
+ {
+ if(mbApplyZoom )
+ pView->SetZoom( (SvxZoomType)mpViewOption->GetZoomType(),
+ mpViewOption->GetZoom(), sal_True );
+ if(mbApplyHRulerMetric)
+ pView->ChangeTabMetric((FieldUnit)eHRulerUnit);
+ if(mbApplyVRulerMetric)
+ pView->ChangeVLinealMetric((FieldUnit)eVRulerUnit);
+
+ }
+ else
+ {
+ if(mbApplyHRulerMetric)
+ SW_MOD()->ApplyRulerMetric( (FieldUnit)eHRulerUnit, sal_True, bWeb );
+ if(mbApplyVRulerMetric)
+ SW_MOD()->ApplyRulerMetric( (FieldUnit)eVRulerUnit, sal_False, bWeb );
+ }
+
+
+ SW_MOD()->ApplyUsrPref( *mpViewOption, pView, pView ? VIEWOPT_DEST_VIEW_ONLY
+ : bWeb ? VIEWOPT_DEST_WEB
+ : VIEWOPT_DEST_TEXT );
+
+
+ delete mpViewOption;
+ mpViewOption = NULL;
+}
+
+void SwXViewSettings::_preGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ if(pView)
+ {
+ if(!IsValid())
+ return;
+ mpConstViewOption = pView->GetWrtShell().GetViewOptions();
+ }
+ else
+ mpConstViewOption = SW_MOD()->GetViewOption(bWeb);
+}
+
+void SwXViewSettings::_getSingleValue( const comphelper::PropertyInfo & rInfo, uno::Any & rValue )
+ throw(UnknownPropertyException, WrappedTargetException )
+{
+ sal_Bool bBool = TRUE;
+ sal_Bool bBoolVal;
+ switch( rInfo.mnHandle )
+ {
+ case HANDLE_VIEWSET_SHOW_RULER: bBoolVal = mpConstViewOption->IsViewAnyRuler(); break;
+ case HANDLE_VIEWSET_HRULER : bBoolVal = mpConstViewOption->IsViewHRuler(TRUE); break;
+ case HANDLE_VIEWSET_VRULER : bBoolVal = mpConstViewOption->IsViewVRuler(TRUE);break;
+ case HANDLE_VIEWSET_VRULER_RIGHT : bBoolVal = mpConstViewOption->IsVRulerRight();break;
+ case HANDLE_VIEWSET_HSCROLL: bBoolVal = mpConstViewOption->IsViewHScrollBar();break;
+ case HANDLE_VIEWSET_VSCROLL: bBoolVal = mpConstViewOption->IsViewVScrollBar();break;
+ case HANDLE_VIEWSET_GRAPHICS : bBoolVal = mpConstViewOption->IsGraphic();break;
+ case HANDLE_VIEWSET_TABLES : bBoolVal = mpConstViewOption->IsTable(); break;
+ case HANDLE_VIEWSET_DRAWINGS : bBoolVal = mpConstViewOption->IsDraw(); break;
+ case HANDLE_VIEWSET_FIELD_COMMANDS : bBoolVal = mpConstViewOption->IsFldName(); break;
+ case HANDLE_VIEWSET_ANNOTATIONS : bBoolVal = mpConstViewOption->IsPostIts(); break;
+ case HANDLE_VIEWSET_INDEX_MARK_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
+ case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: bBoolVal = mpConstViewOption->IsViewMetaChars(); break;
+ case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
+ case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : bBoolVal = SwViewOption::IsFieldShadings(); break;
+ case HANDLE_VIEWSET_PARA_BREAKS : bBoolVal = mpConstViewOption->IsParagraph(sal_True); break;
+ case HANDLE_VIEWSET_SOFT_HYPHENS : bBoolVal = mpConstViewOption->IsSoftHyph(); break;
+ case HANDLE_VIEWSET_SPACES : bBoolVal = mpConstViewOption->IsBlank(sal_True); break;
+ case HANDLE_VIEWSET_PROTECTED_SPACES : bBoolVal = mpConstViewOption->IsHardBlank(); break;
+ case HANDLE_VIEWSET_TABSTOPS : bBoolVal = mpConstViewOption->IsTab(sal_True); break;
+ case HANDLE_VIEWSET_BREAKS : bBoolVal = mpConstViewOption->IsLineBreak(sal_True); break;
+ case HANDLE_VIEWSET_HIDDEN_TEXT : bBoolVal = mpConstViewOption->IsShowHiddenField(); break;
+ case HANDLE_VIEWSET_HIDDEN_CHARACTERS : bBoolVal = mpConstViewOption->IsShowHiddenChar(sal_True); break;
+ case HANDLE_VIEWSET_HIDDEN_PARAGRAPHS : bBoolVal = mpConstViewOption->IsShowHiddenPara(); break;
+ case HANDLE_VIEWSET_TABLE_BOUNDARIES : bBoolVal = SwViewOption::IsTableBoundaries(); break;
+ case HANDLE_VIEWSET_TEXT_BOUNDARIES : bBoolVal = SwViewOption::IsDocBoundaries(); break;
+ case HANDLE_VIEWSET_SMOOTH_SCROLLING : bBoolVal = mpConstViewOption->IsSmoothScroll(); break;
+ case HANDLE_VIEWSET_SOLID_MARK_HANDLES : bBoolVal = mpConstViewOption->IsSolidMarkHdl(); break;
+ case HANDLE_VIEWSET_PREVENT_TIPS : bBoolVal = mpConstViewOption->IsPreventTips(); break;
+ case HANDLE_VIEWSET_IS_RASTER_VISIBLE : bBoolVal = mpConstViewOption->IsGridVisible(); break;
+ case HANDLE_VIEWSET_IS_SNAP_TO_RASTER : bBoolVal = mpConstViewOption->IsSnap(); break;
+ case HANDLE_VIEWSET_RASTER_RESOLUTION_X :
+ bBool = FALSE;
+ rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Width());
+ break;
+ case HANDLE_VIEWSET_RASTER_RESOLUTION_Y :
+ bBool = FALSE;
+ rValue <<= (sal_Int32) TWIP_TO_MM100(mpConstViewOption->GetSnapSize().Height());
+ break;
+ case HANDLE_VIEWSET_RASTER_SUBDIVISION_X :
+ bBool = FALSE;
+ rValue <<= (sal_Int32) mpConstViewOption->GetDivisionX();
+ break;
+ case HANDLE_VIEWSET_RASTER_SUBDIVISION_Y :
+ bBool = FALSE;
+ rValue <<= (sal_Int32) mpConstViewOption->GetDivisionY();
+ break;
+ case HANDLE_VIEWSET_ZOOM :
+ bBool = FALSE;
+ rValue <<= (sal_Int16)mpConstViewOption->GetZoom();
+ break;
+ case HANDLE_VIEWSET_ZOOM_TYPE:
+ {
+ bBool = FALSE;
+ sal_Int16 nRet(0);
+ switch (mpConstViewOption->GetZoomType())
+ {
+ case SVX_ZOOM_OPTIMAL:
+ nRet = view::DocumentZoomType::OPTIMAL;
+ break;
+ case SVX_ZOOM_PAGEWIDTH:
+ nRet = view::DocumentZoomType::PAGE_WIDTH;
+ break;
+ case SVX_ZOOM_WHOLEPAGE:
+ nRet = view::DocumentZoomType::ENTIRE_PAGE;
+ break;
+ case SVX_ZOOM_PERCENT:
+ nRet = view::DocumentZoomType::BY_VALUE;
+ break;
+ case SVX_ZOOM_PAGEWIDTH_NOBORDER:
+ nRet = view::DocumentZoomType::PAGE_WIDTH_EXACT;
+ break;
+ default:
+ OSL_ENSURE(false, "SwXViewSettings: invalid zoom type");
+ break;
+ }
+ rValue <<= nRet;
+ }
+ break;
+ case HANDLE_VIEWSET_ONLINE_LAYOUT:
+ if(pView)
+ bBoolVal = pView->GetWrtShell().getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE);
+ break;
+ case HANDLE_VIEWSET_HELP_URL :
+ {
+ if ( pView )
+ {
+ bBool = sal_False;
+ OUStringBuffer sHelpURL;
+ sHelpURL.appendAscii ( "HID:" );
+ SwEditWin &rEditWin = pView->GetEditWin();
+ sHelpURL.append ( static_cast < sal_Int32 > ( rEditWin.GetHelpId() ) );
+ rValue <<= sHelpURL.makeStringAndClear();
+ }
+ else
+ throw UnknownPropertyException();
+ }
+ break;
+ case HANDLE_VIEWSET_HORI_RULER_METRIC:
+ {
+ if ( pView )
+ {
+ FieldUnit eUnit;
+ pView->GetHLinealMetric( eUnit );
+ rValue <<= (sal_Int32)eUnit;
+ }
+ else
+ {
+ const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
+ rValue <<= (sal_Int32)pUsrPref->GetHScrollMetric();
+ }
+ bBool = sal_False;
+ }
+ break;
+ case HANDLE_VIEWSET_VERT_RULER_METRIC:
+ {
+ if ( pView )
+ {
+ FieldUnit eUnit;
+ pView->GetVLinealMetric( eUnit );
+ rValue <<= (sal_Int32)eUnit;
+ }
+ else
+ {
+ const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb );
+ rValue <<= (sal_Int32)pUsrPref->GetVScrollMetric();
+ }
+ bBool = sal_False;
+ }
+ break;
+ default: OSL_ENSURE(false, "there is no such ID!");
+ }
+ if( bBool )
+ rValue.setValue(&bBoolVal, ::getBooleanCppuType());
+}
+
+void SwXViewSettings::_postGetValues ()
+ throw(UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException )
+{
+ mpConstViewOption = NULL;
+}
+
+OUString SwXViewSettings::getImplementationName(void) throw( RuntimeException )
+{
+ return C2U("SwXViewSettings");
+}
+
+sal_Bool SwXViewSettings::supportsService(const OUString& rServiceName) throw( RuntimeException )
+{
+ return C2U("com.sun.star.text.ViewSettings") == rServiceName;
+}
+
+Sequence< OUString > SwXViewSettings::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ Sequence< OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = C2U("com.sun.star.text.ViewSettings");
+ return aRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unomodule.cxx b/sw/source/ui/uno/unomodule.cxx
new file mode 100644
index 000000000000..12f4736eb10b
--- /dev/null
+++ b/sw/source/ui/uno/unomodule.cxx
@@ -0,0 +1,174 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+// System - Includes -----------------------------------------------------
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/frame/DispatchResultState.hpp>
+
+#include "swmodule.hxx"
+#include "swdll.hxx"
+#include "unomodule.hxx"
+#include <sfx2/objface.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <osl/mutex.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+
+::rtl::OUString SAL_CALL SwUnoModule_getImplementationName() throw( uno::RuntimeException )
+{
+ return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.Writer.WriterModule" ) );
+}
+
+uno::Sequence< rtl::OUString > SAL_CALL SwUnoModule_getSupportedServiceNames() throw( uno::RuntimeException )
+{
+ uno::Sequence< rtl::OUString > aSeq( 1 );
+ aSeq[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.ModuleDispatcher"));
+ return aSeq;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL SwUnoModule_createInstance(
+ const uno::Reference< lang::XMultiServiceFactory > & rSMgr )
+{
+ SolarMutexGuard aGuard;
+ return uno::Reference< uno::XInterface >( dynamic_cast< frame::XDispatch * >(new SwUnoModule( rSMgr )), uno::UNO_QUERY );
+}
+
+ // XNotifyingDispatch
+void SAL_CALL SwUnoModule::dispatchWithNotification( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs, const uno::Reference< frame::XDispatchResultListener >& xListener ) throw (uno::RuntimeException)
+{
+ // there is no guarantee, that we are holded alive during this method!
+ // May the outside dispatch container will be updated by a CONTEXT_CHANGED
+ // asynchronous ...
+ uno::Reference< uno::XInterface > xThis(static_cast< frame::XNotifyingDispatch* >(this));
+
+ SolarMutexGuard aGuard;
+ SwDLL::Init();
+ const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete );
+
+ sal_Int16 aState = frame::DispatchResultState::DONTKNOW;
+ if ( !pSlot )
+ aState = frame::DispatchResultState::FAILURE;
+ else
+ {
+ SfxRequest aReq( pSlot, aArgs, SFX_CALLMODE_SYNCHRON, SW_MOD()->GetPool() );
+ const SfxPoolItem* pResult = SW_MOD()->ExecuteSlot( aReq );
+ if ( pResult )
+ aState = frame::DispatchResultState::SUCCESS;
+ else
+ aState = frame::DispatchResultState::FAILURE;
+ }
+
+ if ( xListener.is() )
+ {
+ xListener->dispatchFinished(
+ frame::DispatchResultEvent(
+ xThis, aState, uno::Any()));
+ }
+}
+
+ // XDispatch
+void SAL_CALL SwUnoModule::dispatch( const util::URL& aURL, const uno::Sequence< beans::PropertyValue >& aArgs ) throw( uno::RuntimeException )
+{
+ dispatchWithNotification(aURL, aArgs, uno::Reference< frame::XDispatchResultListener >());
+}
+
+void SAL_CALL SwUnoModule::addStatusListener(
+ const uno::Reference< frame::XStatusListener > & /*xControl*/,
+ const util::URL& /*aURL*/)
+ throw( uno::RuntimeException )
+{
+}
+
+void SAL_CALL SwUnoModule::removeStatusListener(
+ const uno::Reference< frame::XStatusListener > & /*xControl*/,
+ const util::URL& /*aURL*/) throw( uno::RuntimeException )
+{
+}
+
+SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL SwUnoModule::queryDispatches(
+ const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescripts ) throw( uno::RuntimeException )
+{
+ sal_Int32 nCount = seqDescripts.getLength();
+ SEQUENCE< REFERENCE< XDISPATCH > > lDispatcher( nCount );
+
+ for( sal_Int32 i=0; i<nCount; ++i )
+ {
+ lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL ,
+ seqDescripts[i].FrameName ,
+ seqDescripts[i].SearchFlags );
+ }
+
+ return lDispatcher;
+}
+
+// XDispatchProvider
+REFERENCE< XDISPATCH > SAL_CALL SwUnoModule::queryDispatch(
+ const UNOURL& aURL, const OUSTRING& /*sTargetFrameName*/,
+ sal_Int32 /*eSearchFlags*/ ) throw( uno::RuntimeException )
+{
+ REFERENCE< XDISPATCH > xReturn;
+
+ SolarMutexGuard aGuard;
+ SwDLL::Init();
+ const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete );
+ if ( pSlot )
+ xReturn = REFERENCE< XDISPATCH >(static_cast< XDISPATCH* >(this), uno::UNO_QUERY);
+
+ return xReturn;
+}
+
+// XServiceInfo
+::rtl::OUString SAL_CALL SwUnoModule::getImplementationName( ) throw(uno::RuntimeException)
+{
+ return SwUnoModule_getImplementationName();
+}
+
+sal_Bool SAL_CALL SwUnoModule::supportsService( const ::rtl::OUString& sServiceName ) throw(uno::RuntimeException)
+{
+ UNOSEQUENCE< UNOOUSTRING > seqServiceNames = getSupportedServiceNames();
+ const UNOOUSTRING* pArray = seqServiceNames.getConstArray();
+ for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
+ {
+ if ( pArray[nCounter] == sServiceName )
+ {
+ return sal_True ;
+ }
+ }
+ return sal_False ;
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL SwUnoModule::getSupportedServiceNames( ) throw(uno::RuntimeException)
+{
+ return SwUnoModule_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unomodule.hxx b/sw/source/ui/uno/unomodule.hxx
new file mode 100644
index 000000000000..405f712da49e
--- /dev/null
+++ b/sw/source/ui/uno/unomodule.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SW_UNOMODULE_HXX
+#define _SW_UNOMODULE_HXX
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XNotifyingDispatch.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/frame/DispatchDescriptor.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include <cppuhelper/implbase3.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace lang
+ {
+ class XMultiServiceFactory;
+ }
+ namespace beans
+ {
+ struct PropertyValue;
+ }
+ }
+ }
+}
+
+#define REFERENCE ::com::sun::star::uno::Reference
+#define SEQUENCE ::com::sun::star::uno::Sequence
+#define RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException
+#define REFERENCE ::com::sun::star::uno::Reference
+#define SEQUENCE ::com::sun::star::uno::Sequence
+#define XDISPATCH ::com::sun::star::frame::XDispatch
+#define XNOTIFYINGDISPATCH ::com::sun::star::frame::XNotifyingDispatch
+#define OUSTRING ::rtl::OUString
+#define UNOURL ::com::sun::star::util::URL
+#define DISPATCHDESCRIPTOR ::com::sun::star::frame::DispatchDescriptor
+
+class SwUnoModule : public ::cppu::WeakImplHelper3< ::com::sun::star::frame::XDispatchProvider, ::com::sun::star::frame::XNotifyingDispatch, ::com::sun::star::lang::XServiceInfo >
+{
+ REFERENCE < ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+
+public:
+ SwUnoModule( const REFERENCE < ::com::sun::star::lang::XMultiServiceFactory >& xFactory )
+ : m_xFactory( xFactory )
+ {}
+
+ // XNotifyingDispatch
+ virtual void SAL_CALL dispatchWithNotification( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XDispatch
+ virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XDispatchProvider
+ virtual SEQUENCE< REFERENCE< XDISPATCH > > SAL_CALL queryDispatches( const SEQUENCE< DISPATCHDESCRIPTOR >& seqDescriptor ) throw( RUNTIMEEXCEPTION ) ;
+ virtual REFERENCE< XDISPATCH > SAL_CALL queryDispatch( const UNOURL & aURL ,
+ const OUSTRING & sTargetFrameName,
+ sal_Int32 eSearchFlags ) throw( RUNTIMEEXCEPTION ) ;
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx
new file mode 100644
index 000000000000..3a9574872941
--- /dev/null
+++ b/sw/source/ui/uno/unotxdoc.cxx
@@ -0,0 +1,3893 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include <osl/mutex.hxx>
+#include <vcl/image.hxx>
+#include <vcl/virdev.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/print.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/sfxbasecontroller.hxx>
+#include <sfx2/docfile.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <toolkit/awt/vclxdevice.hxx>
+#include <cmdid.h>
+#include <swtypes.hxx>
+#include <wdocsh.hxx>
+#include <wrtsh.hxx>
+#include <view.hxx>
+#include <pview.hxx>
+#include <srcview.hxx>
+#include <viewsh.hxx>
+#include <pvprtdat.hxx>
+#include <swprtopt.hxx>
+#include <svl/stritem.hxx>
+#include <unotxdoc.hxx>
+#include <svl/numuno.hxx>
+#include <fldbas.hxx>
+#include <unotextbodyhf.hxx>
+#include <unotextrange.hxx>
+#include <unotextcursor.hxx>
+#include <unosett.hxx>
+#include <unocoll.hxx>
+#include <unoredlines.hxx>
+#include <unosrch.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/request.hxx>
+#include <sfx2/objsh.hxx> // SfxObjectShellRef <-> SV_DECL_REF(SfxObjectShell)
+#include <unoprnms.hxx>
+#include <unostyle.hxx>
+#include <unodraw.hxx>
+#include <svl/eitem.hxx>
+#include <pagedesc.hxx>
+#include <svtools/txtcmp.hxx>
+#include <unocrsr.hxx>
+#include <unofield.hxx>
+#include <unoidx.hxx>
+#include <unoflatpara.hxx>
+#include <unotxvw.hxx>
+#include <poolfmt.hxx>
+#include <globdoc.hxx>
+#include <viewopt.hxx>
+#include <unochart.hxx>
+#include <doc.hxx>
+#include <charatr.hxx>
+#include <svx/xmleohlp.hxx>
+#include <globals.hrc>
+#include <unomid.h>
+#include <unotools/printwarningoptions.hxx>
+
+#include <com/sun/star/util/SearchOptions.hpp>
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/document/RedlineDisplayType.hpp>
+#include <com/sun/star/document/XDocumentEventBroadcaster.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/reflection/XIdlClassProvider.hpp>
+#include <sfx2/linkmgr.hxx>
+#include <svx/unofill.hxx>
+#include <editeng/unolingu.hxx>
+#include <sfx2/progress.hxx>
+#include <swmodule.hxx>
+#include <docstat.hxx>
+#include <modcfg.hxx>
+#include <ndtxt.hxx>
+#include <utlui.hrc>
+#include <swcont.hxx>
+#include <unodefaults.hxx>
+#include <SwXDocumentSettings.hxx>
+#include <SwXPrintPreviewSettings.hxx>
+#include <doc.hxx>
+#include <editeng/forbiddencharacterstable.hxx>
+#include <svl/zforlist.hxx>
+#include <drawdoc.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <osl/file.hxx>
+#include <comphelper/storagehelper.hxx>
+
+// --> FME 2004-06-08 #i12836# enhanced pdf export
+#include <EnhancedPDFExportHelper.hxx>
+// <--
+#include <numrule.hxx>
+
+///////////////////////////Modified on Jun. 14th//////////////////////////
+///////////////////////for getDocumentLanguages///////////////////////////
+//-->
+#include <editeng/langitem.hxx>
+#include <doc.hxx>
+#include <docary.hxx> //SwCharFmts
+#include <i18npool/mslangid.hxx>
+
+#include <format.hxx>
+#include <charfmt.hxx> //SwCharFmt
+#include <fmtcol.hxx> //SwTxtFmtColl
+#include <unostyle.hxx> //SwAutoStyleFamily
+#include <istyleaccess.hxx> // handling of automatic styles
+
+#include <svl/stylepool.hxx>
+#include <swatrset.hxx>
+#include <view.hxx>
+#include <srcview.hxx>
+
+#include <svtools/langtab.hxx>
+#include <map>
+#include <set>
+#include <vector>
+
+#include <editeng/eeitem.hxx>
+#include <editeng/editeng.hxx>
+#include <svx/svdoutl.hxx>
+#include <svl/languageoptions.hxx>
+#include <svx/svdview.hxx>
+
+//
+//<--
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::i18n;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::i18n;
+using ::rtl::OUString;
+using ::osl::FileBase;
+
+#define SW_CREATE_DASH_TABLE 0x01
+#define SW_CREATE_GRADIENT_TABLE 0x02
+#define SW_CREATE_HATCH_TABLE 0x03
+#define SW_CREATE_BITMAP_TABLE 0x04
+#define SW_CREATE_TRANSGRADIENT_TABLE 0x05
+#define SW_CREATE_MARKER_TABLE 0x06
+#define SW_CREATE_DRAW_DEFAULTS 0x07
+
+#include <comphelper/processfactory.hxx>
+
+/******************************************************************************
+ *
+ ******************************************************************************/
+
+extern bool lcl_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst );
+
+SwPrintUIOptions * lcl_GetPrintUIOptions(
+ SwDocShell * pDocShell,
+ const SfxViewShell * pView )
+{
+ if (!pDocShell)
+ return NULL;
+
+ const BOOL bWebDoc = NULL != dynamic_cast< const SwWebDocShell * >(pDocShell);
+ const bool bSwSrcView = NULL != dynamic_cast< const SwSrcView * >(pView);
+ const SwView * pSwView = dynamic_cast< const SwView * >(pView);
+ const bool bHasSelection = pSwView ? pSwView->HasSelection( sal_False ) : false; // check for any selection, not just text selection
+ const bool bHasPostIts = lcl_GetPostIts( pDocShell->GetDoc(), 0 );
+
+ // get default values to use in dialog from documents SwPrintData
+ const SwPrintData *pPrintData = pDocShell->GetDoc()->getPrintData();
+ OSL_ENSURE( pPrintData, "failed to get SwPrintData from document" );
+
+ return new SwPrintUIOptions( bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, *pPrintData );
+}
+
+SwTxtFmtColl *lcl_GetParaStyle(const String& rCollName, SwDoc* pDoc)
+{
+ SwTxtFmtColl* pColl = pDoc->FindTxtFmtCollByName( rCollName );
+ if( !pColl )
+ {
+ sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( rCollName, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL );
+ if( USHRT_MAX != nId )
+ pColl = pDoc->GetTxtCollFromPool( nId );
+ }
+ return pColl;
+}
+
+void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell* pDocShell )
+{
+ // check if the view frame still exists
+ SfxViewFrame* pFound = SfxViewFrame::GetFirst( pDocShell,
+ FALSE );
+ while(pFound)
+ {
+ if( pFound == pToClose)
+ {
+ pToClose->DoClose();
+ break;
+ }
+ pFound = SfxViewFrame::GetNext( *pFound,
+ pDocShell,
+ FALSE );
+ }
+}
+
+const Sequence< sal_Int8 > & SwXTextDocument::getUnoTunnelId()
+{
+ static Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
+ return aSeq;
+}
+
+sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId )
+ throw(RuntimeException)
+{
+ if( rId.getLength() == 16
+ && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ if( rId.getLength() == 16
+ && 0 == rtl_compareMemory( SfxObjectShell::getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(pDocShell ));
+ }
+
+ sal_Int64 nRet = SfxBaseModel::getSomething( rId );
+ if ( nRet )
+ return nRet;
+ else
+ {
+ GetNumberFormatter();
+ Any aNumTunnel = xNumFmtAgg->queryAggregation(::getCppuType((Reference<XUnoTunnel>*)0));
+ Reference<XUnoTunnel> xNumTunnel;
+ aNumTunnel >>= xNumTunnel;
+ if(xNumTunnel.is())
+ return xNumTunnel->getSomething(rId);
+ }
+
+ return SfxBaseModel::getSomething( rId );
+}
+
+Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType ) throw(RuntimeException)
+{
+ Any aRet = SwXTextDocumentBaseClass::queryInterface(rType);
+ if ( !aRet.hasValue() )
+ aRet = SfxBaseModel::queryInterface(rType);
+ if ( !aRet.hasValue() &&
+ rType == ::getCppuType((Reference<lang::XMultiServiceFactory>*)0))
+ {
+ Reference<lang::XMultiServiceFactory> xTmp = this;
+ aRet <<= xTmp;
+ }
+
+ if ( !aRet.hasValue()
+ && rType != ::getCppuType((Reference< com::sun::star::document::XDocumentEventBroadcaster>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::frame::XController>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::frame::XFrame>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::script::XInvocation>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::reflection::XIdlClassProvider>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::beans::XFastPropertySet>*)0)
+ && rType != ::getCppuType((Reference< com::sun::star::awt::XWindow>*)0))
+ {
+ GetNumberFormatter();
+ if(xNumFmtAgg.is())
+ aRet = xNumFmtAgg->queryAggregation(rType);
+ }
+ return aRet;
+}
+
+void SAL_CALL SwXTextDocument::acquire()throw()
+{
+ SfxBaseModel::acquire();
+}
+
+void SAL_CALL SwXTextDocument::release()throw()
+{
+ SfxBaseModel::release();
+}
+
+Reference< XAdapter > SwXTextDocument::queryAdapter( ) throw(RuntimeException)
+{
+ return SfxBaseModel::queryAdapter();
+}
+
+Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes() throw(RuntimeException)
+{
+ Sequence< uno::Type > aBaseTypes = SfxBaseModel::getTypes();
+ Sequence< uno::Type > aTextTypes = SwXTextDocumentBaseClass::getTypes();
+
+ Sequence< uno::Type > aNumTypes;
+ GetNumberFormatter();
+ if(xNumFmtAgg.is())
+ {
+ const uno::Type& rProvType = ::getCppuType((Reference <XTypeProvider>*)0);
+ Any aNumProv = xNumFmtAgg->queryAggregation(rProvType);
+ Reference<XTypeProvider> xNumProv;
+ if(aNumProv >>= xNumProv)
+ {
+ aNumTypes = xNumProv->getTypes();
+ }
+ }
+ long nIndex = aBaseTypes.getLength();
+ // don't forget the lang::XMultiServiceFactory
+ aBaseTypes.realloc(aBaseTypes.getLength() + aTextTypes.getLength() + aNumTypes.getLength() + 1);
+ uno::Type* pBaseTypes = aBaseTypes.getArray();
+ const uno::Type* pTextTypes = aTextTypes.getConstArray();
+ long nPos;
+ for(nPos = 0; nPos < aTextTypes.getLength(); nPos++)
+ {
+ pBaseTypes[nIndex++] = pTextTypes[nPos];
+ }
+ const uno::Type* pNumTypes = aNumTypes.getConstArray();
+ for(nPos = 0; nPos < aNumTypes.getLength(); nPos++)
+ {
+ pBaseTypes[nIndex++] = pNumTypes[nPos];
+ }
+ pBaseTypes[nIndex++] = ::getCppuType((Reference<lang::XMultiServiceFactory>*)0);
+ return aBaseTypes;
+}
+
+SwXTextDocument::SwXTextDocument(SwDocShell* pShell) :
+ SfxBaseModel(pShell),
+
+ aRefreshCont ( static_cast < XTextDocument* > ( this ) ),
+
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_DOCUMENT)),
+
+ pDocShell(pShell),
+
+ bObjectValid(pShell != 0),
+
+ pDrawPage(0),
+ pxXDrawPage(0),
+
+ pxXNumberingRules(0),
+ pxXFootnotes(0),
+ pxXFootnoteSettings(0),
+ pxXEndnotes(0),
+ pxXEndnoteSettings(0),
+ pxXReferenceMarks(0),
+ pxXTextFieldTypes(0),
+ pxXTextFieldMasters(0),
+ pxXTextSections(0),
+ pxXBookmarks(0),
+ pxXTextTables(0),
+ pxXTextFrames(0),
+ pxXGraphicObjects(0),
+ pxXEmbeddedObjects(0),
+ pxXStyleFamilies(0),
+ pxXAutoStyles(0),
+ pxXChapterNumbering(0),
+ pxXDocumentIndexes(0),
+
+ pxXLineNumberingProperties(0),
+ pxLinkTargetSupplier(0),
+ pxXRedlines(0),
+ m_pHiddenViewFrame(0),
+ m_pPrintUIOptions( NULL ),
+ m_pRenderData( NULL )
+{
+ uno::Reference< document::XDocumentProperties > xWriterProps( ::comphelper::getProcessServiceFactory()->createInstance( DEFINE_CONST_UNICODE("com.sun.star.writer.DocumentProperties") ), uno::UNO_QUERY_THROW);
+
+ SfxBaseModel::setDocumentProperties( xWriterProps );
+}
+
+SwXTextDocument::~SwXTextDocument()
+{
+ InitNewDoc();
+ if(xNumFmtAgg.is())
+ {
+ Reference< XInterface > x0;
+ xNumFmtAgg->setDelegator(x0);
+ xNumFmtAgg = 0;
+ }
+ delete m_pPrintUIOptions;
+ delete m_pRenderData;
+}
+
+SwXDocumentPropertyHelper * SwXTextDocument::GetPropertyHelper ()
+{
+ if(!xPropertyHelper.is())
+ {
+ pPropertyHelper = new SwXDocumentPropertyHelper(*pDocShell->GetDoc());
+ xPropertyHelper = (cppu::OWeakObject*)pPropertyHelper;
+ }
+ return pPropertyHelper;
+}
+
+void SwXTextDocument::GetNumberFormatter()
+{
+ if(IsValid())
+ {
+ if(!xNumFmtAgg.is())
+ {
+ if ( pDocShell->GetDoc() )
+ {
+ SvNumberFormatsSupplierObj* pNumFmt = new SvNumberFormatsSupplierObj(
+ pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
+ Reference< util::XNumberFormatsSupplier > xTmp = pNumFmt;
+ xNumFmtAgg = Reference< XAggregation >(xTmp, UNO_QUERY);
+ }
+ if(xNumFmtAgg.is())
+ xNumFmtAgg->setDelegator((cppu::OWeakObject*)(SwXTextDocumentBaseClass*)this);
+ }
+ else
+ {
+ const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
+ Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
+ SvNumberFormatsSupplierObj* pNumFmt = 0;
+ Reference< XUnoTunnel > xNumTunnel;
+ if(aNumTunnel >>= xNumTunnel)
+ {
+ pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
+ xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+
+ }
+ OSL_ENSURE(pNumFmt, "No number formatter available");
+ if(!pNumFmt->GetNumberFormatter())
+ pNumFmt->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter( sal_True ));
+ }
+ }
+}
+
+Reference< XText > SwXTextDocument::getText(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!xBodyText.is())
+ {
+ pBodyText = new SwXBodyText(pDocShell->GetDoc());
+ xBodyText = pBodyText;
+ }
+ return xBodyText;
+}
+
+void SwXTextDocument::reformat(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+}
+
+void SwXTextDocument::lockControllers(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(IsValid())
+ {
+ UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc());
+ aActionArr.Insert(pContext, 0);
+ }
+ else
+ throw RuntimeException();
+}
+
+void SwXTextDocument::unlockControllers(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(aActionArr.Count())
+ {
+ UnoActionContext* pContext = aActionArr.GetObject(0);
+ aActionArr.Remove(0);
+ delete pContext;
+ }
+ else
+ throw RuntimeException();
+}
+
+sal_Bool SwXTextDocument::hasControllersLocked(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ return aActionArr.Count() > 0;
+}
+
+Reference< frame::XController > SwXTextDocument::getCurrentController(void) throw( RuntimeException )
+{
+ return SfxBaseModel::getCurrentController();
+}
+
+void SwXTextDocument::setCurrentController(const Reference< frame::XController > & xController)
+ throw( NoSuchElementException, RuntimeException )
+{
+ SfxBaseModel::setCurrentController(xController);
+}
+
+Reference< XInterface > SwXTextDocument::getCurrentSelection() throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ Reference< XInterface > xRef;
+ if(IsValid())
+ {
+
+ const TypeId aTypeId = TYPE(SwView);
+ SwView* pView = (SwView*)SfxViewShell::GetFirst(&aTypeId);
+ while(pView && pView->GetObjectShell() != pDocShell)
+ {
+ pView = (SwView*)SfxViewShell::GetNext(*pView, &aTypeId);
+ }
+ if(pView)
+ {
+ Any aRef = pView->GetUNOObject()->getSelection();
+ aRef >>= xRef;
+ }
+ }
+ return xRef;
+}
+
+sal_Bool SwXTextDocument::attachResource(const OUString& aURL, const Sequence< beans::PropertyValue >& aArgs)
+ throw( RuntimeException )
+{
+ return SfxBaseModel::attachResource(aURL, aArgs);
+}
+
+OUString SwXTextDocument::getURL(void) throw( RuntimeException )
+{
+ return SfxBaseModel::getURL();
+}
+
+Sequence< beans::PropertyValue > SwXTextDocument::getArgs(void) throw( RuntimeException )
+{
+ return SfxBaseModel::getArgs();
+}
+
+void SwXTextDocument::connectController(const Reference< frame::XController > & xController) throw( RuntimeException )
+{
+ SfxBaseModel::connectController(xController);
+}
+
+void SwXTextDocument::disconnectController(const Reference< frame::XController > & xController) throw( RuntimeException )
+{
+ SfxBaseModel::disconnectController(xController);
+}
+
+void SwXTextDocument::dispose(void) throw( RuntimeException )
+{
+ SfxBaseModel::dispose();
+}
+
+void SwXTextDocument::close( sal_Bool bDeliverOwnership ) throw( util::CloseVetoException, RuntimeException )
+{
+ if(IsValid() && m_pHiddenViewFrame)
+ lcl_DisposeView( m_pHiddenViewFrame, pDocShell);
+ SfxBaseModel::close(bDeliverOwnership);
+}
+
+void SwXTextDocument::addEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException )
+{
+ SfxBaseModel::addEventListener(aListener);
+}
+
+void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException )
+{
+ SfxBaseModel::removeEventListener(aListener);
+}
+
+Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties(void)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(IsValid())
+ {
+ if(!pxXLineNumberingProperties)
+ {
+ pxXLineNumberingProperties = new Reference<XPropertySet>;
+ (*pxXLineNumberingProperties) = new SwXLineNumberingProperties(pDocShell->GetDoc());
+ }
+ }
+ else
+ throw RuntimeException();
+ return *pxXLineNumberingProperties;
+}
+
+Reference< XIndexReplace > SwXTextDocument::getChapterNumberingRules(void)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXChapterNumbering)
+ {
+ pxXChapterNumbering = new Reference< XIndexReplace > ;
+ *pxXChapterNumbering = new SwXChapterNumbering(*pDocShell);
+ }
+ return *pxXChapterNumbering;
+}
+
+Reference< XIndexAccess > SwXTextDocument::getNumberingRules(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXNumberingRules )
+ {
+ ((SwXTextDocument*)this)->pxXNumberingRules = new Reference< XIndexAccess > ;
+ *pxXNumberingRules = new SwXNumberingRulesCollection( pDocShell->GetDoc() );
+ }
+ return *pxXNumberingRules;
+}
+
+Reference< XIndexAccess > SwXTextDocument::getFootnotes(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXFootnotes)
+ {
+ ((SwXTextDocument*)this)->pxXFootnotes = new Reference< XIndexAccess > ;
+ *pxXFootnotes = new SwXFootnotes(sal_False, pDocShell->GetDoc());
+ }
+ return *pxXFootnotes;
+}
+
+Reference< XPropertySet > SAL_CALL
+ SwXTextDocument::getFootnoteSettings(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXFootnoteSettings)
+ {
+ ((SwXTextDocument*)this)->pxXFootnoteSettings = new Reference< XPropertySet > ;
+ *pxXFootnoteSettings = new SwXFootnoteProperties(pDocShell->GetDoc());
+ }
+ return *pxXFootnoteSettings;
+}
+
+Reference< XIndexAccess > SwXTextDocument::getEndnotes(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXEndnotes)
+ {
+ ((SwXTextDocument*)this)->pxXEndnotes = new Reference< XIndexAccess > ;
+ *pxXEndnotes = new SwXFootnotes(sal_True, pDocShell->GetDoc());
+ }
+ return *pxXEndnotes;
+}
+
+Reference< XPropertySet > SwXTextDocument::getEndnoteSettings(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXEndnoteSettings)
+ {
+ ((SwXTextDocument*)this)->pxXEndnoteSettings = new Reference< XPropertySet > ;
+ *pxXEndnoteSettings = new SwXEndnoteProperties(pDocShell->GetDoc());
+ }
+ return *pxXEndnoteSettings;
+}
+
+Reference< util::XReplaceDescriptor > SwXTextDocument::createReplaceDescriptor(void)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ Reference< util::XReplaceDescriptor > xRet = new SwXTextSearch;
+ return xRet;
+}
+
+SwUnoCrsr* SwXTextDocument::CreateCursorForSearch(Reference< XTextCursor > & xCrsr)
+{
+ getText();
+ XText *const pText = xBodyText.get();
+ SwXBodyText* pBText = (SwXBodyText*)pText;
+ SwXTextCursor *const pXTextCursor = pBText->CreateTextCursor(true);
+ xCrsr.set( static_cast<text::XWordCursor*>(pXTextCursor) );
+
+ SwUnoCrsr *const pUnoCrsr = pXTextCursor->GetCursor();
+ pUnoCrsr->SetRemainInSection(sal_False);
+ return pUnoCrsr;
+}
+
+sal_Int32 SwXTextDocument::replaceAll(const Reference< util::XSearchDescriptor > & xDesc)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
+ if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
+ throw RuntimeException();
+
+ Reference< XTextCursor > xCrsr;
+ SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
+
+ const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
+ xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
+
+ int eRanges(FND_IN_BODY|FND_IN_SELALL);
+
+ util::SearchOptions aSearchOpt;
+ pSearch->FillSearchOptions( aSearchOpt );
+
+ SwDocPositions eStart = pSearch->bBack ? DOCPOS_END : DOCPOS_START;
+ SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
+
+ // Suche soll ueberall stattfinden
+ pUnoCrsr->SetRemainInSection(sal_False);
+ sal_uInt32 nResult;
+ UnoActionContext aContext(pDocShell->GetDoc());
+ //try attribute search first
+ if(pSearch->HasSearchAttributes()||pSearch->HasReplaceAttributes())
+ {
+ SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ 0);
+ SfxItemSet aReplace(pDocShell->GetDoc()->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ 0);
+ pSearch->FillSearchItemSet(aSearch);
+ pSearch->FillReplaceItemSet(aReplace);
+ BOOL bCancel;
+ nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges,
+ pSearch->sSearchText.Len() ? &aSearchOpt : 0,
+ &aReplace );
+ }
+ else if(pSearch->bStyles)
+ {
+ SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
+ SwTxtFmtColl *pReplaceColl = lcl_GetParaStyle(pSearch->sReplaceText, pUnoCrsr->GetDoc());;
+
+ BOOL bCancel;
+ nResult = pUnoCrsr->Find( *pSearchColl,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges, pReplaceColl );
+
+ }
+ else
+ {
+ //todo/mba: assuming that notes should be omitted
+ BOOL bSearchInNotes = FALSE;
+ BOOL bCancel;
+ nResult = pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges,
+ sal_True );
+ }
+ return (sal_Int32)nResult;
+
+}
+
+Reference< util::XSearchDescriptor > SwXTextDocument::createSearchDescriptor(void)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ Reference< util::XSearchDescriptor > xRet = new SwXTextSearch;
+ return xRet;
+
+}
+
+/* -----------------26.02.99 16:08-------------------
+ * wird fuer findAll/First/Next verwendet
+ * --------------------------------------------------*/
+SwUnoCrsr* SwXTextDocument::FindAny(const Reference< util::XSearchDescriptor > & xDesc,
+ Reference< XTextCursor > & xCrsr, sal_Bool bAll,
+ sal_Int32& nResult,
+ Reference< XInterface > xLastResult)
+{
+ Reference< XUnoTunnel > xDescTunnel(xDesc, UNO_QUERY);
+ if(!IsValid() || !xDescTunnel.is() || !xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()))
+ return 0;
+
+ SwUnoCrsr* pUnoCrsr = CreateCursorForSearch(xCrsr);
+ const SwXTextSearch* pSearch = reinterpret_cast<const SwXTextSearch*>(
+ xDescTunnel->getSomething(SwXTextSearch::getUnoTunnelId()));
+
+ sal_Bool bParentInExtra = sal_False;
+ if(xLastResult.is())
+ {
+ Reference<XUnoTunnel> xCursorTunnel( xLastResult, UNO_QUERY);
+ OTextCursorHelper* pPosCrsr = 0;
+ if(xCursorTunnel.is())
+ {
+ pPosCrsr = reinterpret_cast<OTextCursorHelper*>(xCursorTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId()));
+ }
+ SwPaM* pCrsr = pPosCrsr ? pPosCrsr->GetPaM() : 0;
+ if(pCrsr)
+ {
+ *pUnoCrsr->GetPoint() = *pCrsr->End();
+ pUnoCrsr->DeleteMark();
+ }
+ else
+ {
+ SwXTextRange* pRange = 0;
+ if(xCursorTunnel.is())
+ {
+ pRange = reinterpret_cast<SwXTextRange*>(xCursorTunnel->getSomething(
+ SwXTextRange::getUnoTunnelId()));
+ }
+ if(!pRange)
+ return 0;
+ pRange->GetPositions(*pUnoCrsr);
+ if(pUnoCrsr->HasMark())
+ {
+ if(*pUnoCrsr->GetPoint() < *pUnoCrsr->GetMark())
+ pUnoCrsr->Exchange();
+ pUnoCrsr->DeleteMark();
+ }
+ }
+ const SwNode* pRangeNode = pUnoCrsr->GetNode();
+ bParentInExtra = pRangeNode->FindFlyStartNode() ||
+ pRangeNode->FindFootnoteStartNode() ||
+ pRangeNode->FindHeaderStartNode() ||
+ pRangeNode->FindFooterStartNode() ;
+ }
+
+ util::SearchOptions aSearchOpt;
+ pSearch->FillSearchOptions( aSearchOpt );
+
+/*
+ * folgende Kombinationen sind erlaubt:
+ * - suche einen im Body: -> FND_IN_BODY
+ * - suche alle im Body: -> FND_IN_BODYONLY | FND_IN_SELALL
+ * - suche in Selectionen: einen / alle -> FND_IN_SEL [ | FND_IN_SELALL ]
+ * - suche im nicht Body: einen / alle -> FND_IN_OTHER [ | FND_IN_SELALL ]
+ * - suche ueberall alle: -> FND_IN_SELALL
+ */
+ int eRanges(FND_IN_BODY);
+ if(bParentInExtra)
+ eRanges = FND_IN_OTHER;
+ if(bAll) //immer - ueberall?
+ eRanges = FND_IN_SELALL;
+ SwDocPositions eStart = !bAll ? DOCPOS_CURR : pSearch->bBack ? DOCPOS_END : DOCPOS_START;
+ SwDocPositions eEnd = pSearch->bBack ? DOCPOS_START : DOCPOS_END;
+
+ nResult = 0;
+ sal_uInt16 nSearchProc = 0;
+ while(nSearchProc < 2)
+ {
+ //try attribute search first
+ if(pSearch->HasSearchAttributes())
+ {
+ SfxItemSet aSearch(pDocShell->GetDoc()->GetAttrPool(),
+ RES_CHRATR_BEGIN, RES_CHRATR_END-1,
+ RES_PARATR_BEGIN, RES_PARATR_END-1,
+ RES_FRMATR_BEGIN, RES_FRMATR_END-1,
+ RES_TXTATR_INETFMT, RES_TXTATR_INETFMT,
+ 0);
+ pSearch->FillSearchItemSet(aSearch);
+ BOOL bCancel;
+ nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges,
+ pSearch->sSearchText.Len() ? &aSearchOpt : 0,
+ 0 );
+ }
+ else if(pSearch->bStyles)
+ {
+ SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc());
+ //pSearch->sReplaceText
+ SwTxtFmtColl *pReplaceColl = 0;
+ BOOL bCancel;
+ nResult = (sal_Int32)pUnoCrsr->Find( *pSearchColl,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges, pReplaceColl );
+ }
+ else
+ {
+ //todo/mba: assuming that notes should be omitted
+ BOOL bSearchInNotes = FALSE;
+ BOOL bCancel;
+ nResult = (sal_Int32)pUnoCrsr->Find( aSearchOpt, bSearchInNotes,
+ eStart, eEnd, bCancel,
+ (FindRanges)eRanges,
+ /*int bReplace =*/sal_False );
+ }
+ nSearchProc++;
+ if(nResult || (eRanges&(FND_IN_SELALL|FND_IN_OTHER)))
+ break;
+ //second step - find in other
+ eRanges = FND_IN_OTHER;
+ }
+ return pUnoCrsr;
+}
+
+Reference< XIndexAccess >
+ SwXTextDocument::findAll(const Reference< util::XSearchDescriptor > & xDesc)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ Reference< XInterface > xTmp;
+ sal_Int32 nResult = 0;
+ Reference< XTextCursor > xCrsr;
+ SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_True, nResult, xTmp);
+ if(!pResultCrsr)
+ throw RuntimeException();
+ Reference< XIndexAccess > xRet;
+ xRet = new SwXTextRanges( (nResult) ? pResultCrsr : 0 );
+ delete pResultCrsr;
+ return xRet;
+}
+
+Reference< XInterface > SwXTextDocument::findFirst(const Reference< util::XSearchDescriptor > & xDesc)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ Reference< XInterface > xTmp;
+ sal_Int32 nResult = 0;
+ Reference< XTextCursor > xCrsr;
+ SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xTmp);
+ if(!pResultCrsr)
+ throw RuntimeException();
+ Reference< XInterface > xRet;
+ if(nResult)
+ {
+ const uno::Reference< text::XText > xParent =
+ ::sw::CreateParentXText(*pDocShell->GetDoc(),
+ *pResultCrsr->GetPoint());
+ xRet = *new SwXTextCursor(xParent, *pResultCrsr);
+ delete pResultCrsr;
+ }
+ return xRet;
+}
+
+Reference< XInterface > SwXTextDocument::findNext(const Reference< XInterface > & xStartAt,
+ const Reference< util::XSearchDescriptor > & xDesc)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ Reference< XInterface > xTmp;
+ sal_Int32 nResult = 0;
+ Reference< XTextCursor > xCrsr;
+ if(!xStartAt.is())
+ throw RuntimeException();
+ SwUnoCrsr* pResultCrsr = FindAny(xDesc, xCrsr, sal_False, nResult, xStartAt);
+ if(!pResultCrsr)
+ throw RuntimeException();
+ Reference< XInterface > xRet;
+ if(nResult)
+ {
+ const uno::Reference< text::XText > xParent =
+ ::sw::CreateParentXText(*pDocShell->GetDoc(),
+ *pResultCrsr->GetPoint());
+
+ xRet = *new SwXTextCursor(xParent, *pResultCrsr);
+ delete pResultCrsr;
+ }
+ return xRet;
+}
+
+Sequence< beans::PropertyValue > SwXTextDocument::getPagePrintSettings(void)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ Sequence< beans::PropertyValue > aSeq(9);
+ if(IsValid())
+ {
+ beans::PropertyValue* pArray = aSeq.getArray();
+ SwPagePreViewPrtData aData;
+ const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData();
+ if(pData)
+ aData = *pData;
+ Any aVal;
+ aVal <<= (sal_Int16)aData.GetRow();
+ pArray[0] = beans::PropertyValue(C2U("PageRows"), -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int16)aData.GetCol();
+ pArray[1] = beans::PropertyValue(C2U("PageColumns"), -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetLeftSpace());
+ pArray[2] = beans::PropertyValue(C2U("LeftMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetRightSpace());
+ pArray[3] = beans::PropertyValue(C2U("RightMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetTopSpace());
+ pArray[4] = beans::PropertyValue(C2U("TopMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetBottomSpace());
+ pArray[5] = beans::PropertyValue(C2U("BottomMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetHorzSpace());
+ pArray[6] = beans::PropertyValue(C2U("HoriMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
+ aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetVertSpace());
+ pArray[7] = beans::PropertyValue(C2U("VertMargin"), -1, aVal, PropertyState_DIRECT_VALUE);
+ BOOL bTemp = aData.GetLandscape();
+ aVal.setValue(&bTemp, ::getCppuBooleanType());
+ pArray[8] = beans::PropertyValue(C2U("IsLandscape"), -1, aVal, PropertyState_DIRECT_VALUE);
+ }
+ else
+ throw RuntimeException();
+ return aSeq;
+}
+
+sal_uInt32 lcl_Any_To_ULONG(const Any& rValue, sal_Bool& bException)
+{
+ bException = sal_False;
+ TypeClass eType = rValue.getValueType().getTypeClass();
+
+ sal_uInt32 nRet = 0;
+ if( eType == TypeClass_UNSIGNED_LONG )
+ rValue >>= nRet;
+ else
+ {
+ sal_Int32 nVal=0;
+ bException = !(rValue >>= nVal);
+ if( !bException )
+ nRet = (sal_uInt32)nVal;
+ }
+
+ return nRet;
+}
+
+String lcl_CreateOutlineString( USHORT nIndex,
+ const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule)
+{
+ String sEntry;
+ const SwTxtNode * pTxtNd = rOutlineNodes[ nIndex ]->GetTxtNode();
+ SwNumberTree::tNumberVector aNumVector = pTxtNd->GetNumberVector();
+ if( pOutlRule && pTxtNd->GetNumRule())
+ for( sal_Int8 nLevel = 0;
+ nLevel <= pTxtNd->GetActualListLevel();
+ nLevel++ )
+ {
+ long nVal = aNumVector[nLevel];
+ nVal ++;
+ nVal -= pOutlRule->Get(nLevel).GetStart();
+ sEntry += String::CreateFromInt32( nVal );
+ sEntry += '.';
+ }
+ sEntry += rOutlineNodes[ nIndex ]->
+ GetTxtNode()->GetExpandTxt( 0, STRING_LEN, sal_False );
+ return sEntry;
+}
+
+void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(IsValid())
+ {
+ SwPagePreViewPrtData aData;
+ //falls nur einige Properties kommen, dann die akt. Einstellungen benutzen
+ const SwPagePreViewPrtData* pData = pDocShell->GetDoc()->GetPreViewPrtData();
+ if(pData)
+ aData = *pData;
+ const beans::PropertyValue* pProperties = aSettings.getConstArray();
+ int nCount = aSettings.getLength();
+ for(int i = 0; i < nCount; i++)
+ {
+ String sName = pProperties[i].Name;
+ const Any& rVal = pProperties[i].Value;
+ sal_Bool bException;
+ sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException);
+ if( COMPARE_EQUAL == sName.CompareToAscii("PageRows" ) )
+ {
+ if(!nVal || nVal > 0xff)
+ throw RuntimeException();
+ aData.SetRow((BYTE)nVal);
+ }
+ else if(COMPARE_EQUAL == sName.CompareToAscii("PageColumns"))
+ {
+ if(!nVal || nVal > 0xff)
+ throw RuntimeException();
+ aData.SetCol((BYTE)nVal);
+ }
+ else if(COMPARE_EQUAL == sName.CompareToAscii("LeftMargin"))
+ {
+ aData.SetLeftSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(COMPARE_EQUAL == sName.CompareToAscii("RightMargin"))
+ {
+ aData.SetRightSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(COMPARE_EQUAL == sName.CompareToAscii("TopMargin"))
+ {
+ aData.SetTopSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(COMPARE_EQUAL == sName.CompareToAscii("BottomMargin"))
+ {
+ aData.SetBottomSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(COMPARE_EQUAL == sName.CompareToAscii("HoriMargin"))
+ {
+ aData.SetHorzSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(COMPARE_EQUAL == sName.CompareToAscii("VertMargin"))
+ {
+ aData.SetVertSpace(MM100_TO_TWIP_UNSIGNED(nVal));
+ }
+ else if(COMPARE_EQUAL == sName.CompareToAscii("IsLandscape"))
+ {
+ bException = (::getBooleanCppuType() != rVal.getValueType());
+ aData.SetLandscape(*(sal_Bool*)rVal.getValue());
+ }
+ else
+ bException = sal_True;
+ if(bException)
+ throw RuntimeException();
+ }
+ pDocShell->GetDoc()->SetPreViewPrtData(&aData);
+ }
+ else
+ throw RuntimeException();
+}
+
+void SwXTextDocument::printPages(const Sequence< beans::PropertyValue >& xOptions)
+ throw( IllegalArgumentException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(IsValid())
+ {
+ SfxViewFrame* pFrame = SfxViewFrame::LoadHiddenDocument( *pDocShell, 7 );
+ SfxRequest aReq(FN_PRINT_PAGEPREVIEW, SFX_CALLMODE_SYNCHRON,
+ pDocShell->GetDoc()->GetAttrPool());
+ aReq.AppendItem(SfxBoolItem(FN_PRINT_PAGEPREVIEW, sal_True));
+
+ OUString sFileName( C2U(SW_PROP_NAME_STR(UNO_NAME_FILE_NAME)));
+ OUString sCopyCount(C2U(SW_PROP_NAME_STR(UNO_NAME_COPY_COUNT)));
+ OUString sCollate(C2U(SW_PROP_NAME_STR(UNO_NAME_COLLATE)));
+ OUString sSort(C2U(SW_PROP_NAME_STR(UNO_NAME_SORT)));
+ OUString sPages(C2U(SW_PROP_NAME_STR(UNO_NAME_PAGES)));
+
+ for ( int n = 0; n < xOptions.getLength(); ++n )
+ {
+ // get Property-Value from options
+ const beans::PropertyValue &rProp = xOptions.getConstArray()[n];
+ Any aValue( rProp.Value );
+
+ // FileName-Property?
+ if ( rProp.Name == sFileName )
+ {
+ OUString sFileURL;
+ if ( (rProp.Value >>= sFileURL ) )
+ {
+ // Convert the File URL into a system dependant path, as the SalPrinter expects
+ OUString sSystemPath;
+ FileBase::getSystemPathFromFileURL ( sFileURL, sSystemPath );
+ aReq.AppendItem(SfxStringItem( SID_FILE_NAME, sSystemPath ) );
+ }
+ else if ( rProp.Value.getValueType() != ::getVoidCppuType() )
+ throw IllegalArgumentException();
+ }
+
+ // CopyCount-Property
+ else if ( rProp.Name == sCopyCount )
+ {
+ sal_Int32 nCopies = 0;
+ aValue >>= nCopies;
+ aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) );
+ }
+
+ // Collate-Property
+ else if ( rProp.Name == sCollate )
+ {
+ if ( rProp.Value.getValueType() == ::getBooleanCppuType())
+
+ aReq.AppendItem(SfxBoolItem( SID_PRINT_COLLATE, *(sal_Bool*)rProp.Value.getValue() ) );
+ else
+ throw IllegalArgumentException();
+ }
+
+ // Sort-Property
+ else if ( rProp.Name == sSort )
+ {
+ if ( rProp.Value.getValueType() == ::getBooleanCppuType() )
+ aReq.AppendItem(SfxBoolItem( SID_PRINT_SORT, *(sal_Bool*)rProp.Value.getValue() ) );
+ else
+ throw IllegalArgumentException();
+ }
+
+ // Pages-Property
+ else if ( rProp.Name == sPages )
+ {
+ OUString sTmp;
+ if ( rProp.Value >>= sTmp )
+ aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) );
+ else
+ throw IllegalArgumentException();
+ }
+ }
+
+
+ pFrame->GetViewShell()->ExecuteSlot(aReq);
+ // Frame schliessen
+ pFrame->DoClose();
+
+ }
+ else
+ throw RuntimeException();
+}
+
+Reference< XNameAccess > SwXTextDocument::getReferenceMarks(void)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXReferenceMarks)
+ {
+ ((SwXTextDocument*)this)->pxXReferenceMarks = new Reference< XNameAccess > ;
+ *pxXReferenceMarks = new SwXReferenceMarks(pDocShell->GetDoc());
+ }
+ return *pxXReferenceMarks;
+}
+
+Reference< XEnumerationAccess > SwXTextDocument::getTextFields(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextFieldTypes)
+ {
+ ((SwXTextDocument*)this)->pxXTextFieldTypes = new Reference< XEnumerationAccess > ;
+ *pxXTextFieldTypes = new SwXTextFieldTypes(pDocShell->GetDoc());
+ }
+ return *pxXTextFieldTypes;
+}
+
+Reference< XNameAccess > SwXTextDocument::getTextFieldMasters(void)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextFieldMasters)
+ {
+ ((SwXTextDocument*)this)->pxXTextFieldMasters = new Reference< XNameAccess > ;
+ *pxXTextFieldMasters = new SwXTextFieldMasters(pDocShell->GetDoc());
+ }
+ return *pxXTextFieldMasters;
+}
+
+Reference< XNameAccess > SwXTextDocument::getEmbeddedObjects(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXEmbeddedObjects)
+ {
+ ((SwXTextDocument*)this)->pxXEmbeddedObjects = new Reference< XNameAccess > ;
+ *pxXEmbeddedObjects = new SwXTextEmbeddedObjects(pDocShell->GetDoc());
+ }
+ return *pxXEmbeddedObjects;
+}
+
+Reference< XNameAccess > SwXTextDocument::getBookmarks(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXBookmarks)
+ {
+ ((SwXTextDocument*)this)->pxXBookmarks = new Reference< XNameAccess > ;
+ *pxXBookmarks = new SwXBookmarks(pDocShell->GetDoc());
+ }
+ return *pxXBookmarks;
+}
+
+Reference< XNameAccess > SwXTextDocument::getTextSections(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextSections)
+ {
+ ((SwXTextDocument*)this)->pxXTextSections = new Reference< XNameAccess > ;
+ *pxXTextSections = new SwXTextSections(pDocShell->GetDoc());
+ }
+ return *pxXTextSections;
+}
+
+Reference< XNameAccess > SwXTextDocument::getTextTables(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextTables)
+ {
+ ((SwXTextDocument*)this)->pxXTextTables = new Reference< XNameAccess > ;
+ *pxXTextTables = new SwXTextTables(pDocShell->GetDoc());
+ }
+ return *pxXTextTables;
+}
+
+Reference< XNameAccess > SwXTextDocument::getGraphicObjects(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXGraphicObjects)
+ {
+ ((SwXTextDocument*)this)->pxXGraphicObjects = new Reference< XNameAccess > ;
+ *pxXGraphicObjects = new SwXTextGraphicObjects(pDocShell->GetDoc());
+ }
+ return *pxXGraphicObjects;
+}
+
+Reference< XNameAccess > SwXTextDocument::getTextFrames(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXTextFrames)
+ {
+ ((SwXTextDocument*)this)->pxXTextFrames = new Reference< XNameAccess > ;
+ *pxXTextFrames = new SwXTextFrames(pDocShell->GetDoc());
+ }
+ return *pxXTextFrames;
+}
+
+Reference< XNameAccess > SwXTextDocument::getStyleFamilies(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXStyleFamilies)
+ {
+ ((SwXTextDocument*)this)->pxXStyleFamilies = new Reference< XNameAccess > ;
+ *pxXStyleFamilies = new SwXStyleFamilies(*pDocShell);
+ }
+ return *pxXStyleFamilies;
+}
+
+uno::Reference< style::XAutoStyles > SwXTextDocument::getAutoStyles( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXAutoStyles)
+ {
+ pxXAutoStyles = new Reference< style::XAutoStyles > ;
+ *pxXAutoStyles = new SwXAutoStyles(*pDocShell);
+ }
+ return *pxXAutoStyles;
+
+}
+
+Reference< drawing::XDrawPage > SwXTextDocument::getDrawPage(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXDrawPage)
+ {
+ // simplified this creation, keeping original below as reference
+ // for the case that it did something by purpose
+ ((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc());
+ ((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage >(pDrawPage);
+
+ //((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage > ;
+ //((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc());
+ //Reference< drawing::XShapes > xTmp = pDrawPage;
+ //*pxXDrawPage = Reference< drawing::XDrawPage>(xTmp, UNO_QUERY);
+ }
+ return *pxXDrawPage;
+}
+
+SwXDrawPage* SwXTextDocument::GetDrawPage()
+{
+ if(!IsValid())
+ return 0;
+ if(!pDrawPage)
+ getDrawPage();
+ return pDrawPage;
+}
+
+void SwXTextDocument::Invalidate()
+{
+ bObjectValid = sal_False;
+ if(xNumFmtAgg.is())
+ {
+ const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
+ Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
+ SvNumberFormatsSupplierObj* pNumFmt = 0;
+ Reference< XUnoTunnel > xNumTunnel;
+ if(aNumTunnel >>= xNumTunnel)
+ {
+ pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
+ xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+ pNumFmt->SetNumberFormatter(0);
+ }
+ OSL_ENSURE(pNumFmt, "No number formatter available");
+ }
+ InitNewDoc();
+ pDocShell = 0;
+ aRefreshCont.Disposing();
+}
+
+void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell)
+{
+ if(pDocShell && pDocShell != pNewDocShell)
+ Invalidate();
+ pDocShell = pNewDocShell;
+ bObjectValid = TRUE;
+}
+
+void SwXTextDocument::InitNewDoc()
+{
+ // zunaechst alle Collections invalidieren, dann Referenzen loeschen und Null setzen
+ if(pxXTextTables)
+ {
+ XNameAccess* pTbls = pxXTextTables->get();
+ ((SwXTextTables*)pTbls)->Invalidate();
+ delete pxXTextTables;
+ pxXTextTables = 0;
+ }
+
+ if(pxXTextFrames)
+ {
+ XNameAccess* pFrms = pxXTextFrames->get();
+ ((SwXTextFrames*)pFrms)->Invalidate();
+ delete pxXTextFrames;
+ pxXTextFrames = 0;
+ }
+
+ if(pxXGraphicObjects)
+ {
+ XNameAccess* pFrms = pxXGraphicObjects->get();
+ ((SwXTextGraphicObjects*)pFrms)->Invalidate();
+ delete pxXGraphicObjects;
+ pxXGraphicObjects = 0;
+ }
+
+ if(pxXEmbeddedObjects)
+ {
+ XNameAccess* pOLE = pxXEmbeddedObjects->get();
+ ((SwXTextEmbeddedObjects*)pOLE)->Invalidate();
+ delete pxXEmbeddedObjects;
+ pxXEmbeddedObjects = 0;
+ }
+
+ if(xBodyText.is())
+ {
+ xBodyText = 0;
+ pBodyText = 0;
+ }
+
+ if(xNumFmtAgg.is())
+ {
+ const uno::Type& rTunnelType = ::getCppuType((Reference <XUnoTunnel>*)0);
+ Any aNumTunnel = xNumFmtAgg->queryAggregation(rTunnelType);
+ SvNumberFormatsSupplierObj* pNumFmt = 0;
+ Reference< XUnoTunnel > xNumTunnel;
+ if(aNumTunnel >>= xNumTunnel)
+ {
+ pNumFmt = reinterpret_cast<SvNumberFormatsSupplierObj*>(
+ xNumTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+
+ }
+ OSL_ENSURE(pNumFmt, "No number formatter available");
+ pNumFmt->SetNumberFormatter(0);
+ }
+
+ if(pxXTextFieldTypes)
+ {
+ XEnumerationAccess* pT = pxXTextFieldTypes->get();
+ ((SwXTextFieldTypes*)pT)->Invalidate();
+ delete pxXTextFieldTypes;
+ pxXTextFieldTypes = 0;
+ }
+
+ if(pxXTextFieldMasters)
+ {
+ XNameAccess* pT = pxXTextFieldMasters->get();
+ ((SwXTextFieldMasters*)pT)->Invalidate();
+ delete pxXTextFieldMasters;
+ pxXTextFieldMasters = 0;
+ }
+
+ if(pxXTextSections)
+ {
+ XNameAccess* pSect = pxXTextSections->get();
+ ((SwXTextSections*)pSect)->Invalidate();
+ delete pxXTextSections;
+ pxXTextSections = 0;
+ }
+
+ if(pxXDrawPage)
+ {
+ // --> OD 2008-07-23 #i91798#, #i91895#
+ // dispose XDrawPage here. We are the owner and know that it is no longer in a valid condition.
+ uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::UNO_QUERY );
+ xComp->dispose();
+ // <--
+ pDrawPage->InvalidateSwDoc();
+ delete pxXDrawPage;
+ pxXDrawPage = 0;
+ }
+
+ if ( pxXNumberingRules )
+ {
+ XIndexAccess* pNum = pxXNumberingRules->get();
+ ((SwXNumberingRulesCollection*)pNum)->Invalidate();
+ delete pxXNumberingRules;
+ pxXNumberingRules = 0;
+ }
+
+ if(pxXFootnotes)
+ {
+ XIndexAccess* pFtn = pxXFootnotes->get();
+ ((SwXFootnotes*)pFtn)->Invalidate();
+ delete pxXFootnotes;
+ pxXFootnotes = 0;
+ }
+
+ if(pxXEndnotes)
+ {
+ XIndexAccess* pFtn = pxXEndnotes->get();
+ ((SwXFootnotes*)pFtn)->Invalidate();
+ delete pxXEndnotes;
+ pxXEndnotes = 0;
+ }
+
+ if(pxXDocumentIndexes)
+ {
+ XIndexAccess* pIdxs = pxXDocumentIndexes->get();
+ ((SwXDocumentIndexes*)pIdxs)->Invalidate();
+ delete pxXDocumentIndexes;
+ pxXDocumentIndexes = 0;
+ }
+
+ if(pxXStyleFamilies)
+ {
+ XNameAccess* pStyles = pxXStyleFamilies->get();
+ ((SwXStyleFamilies*)pStyles)->Invalidate();
+ delete pxXStyleFamilies;
+ pxXStyleFamilies = 0;
+ }
+ if(pxXAutoStyles)
+ {
+ XNameAccess* pStyles = pxXAutoStyles->get();
+ ((SwXAutoStyles*)pStyles)->Invalidate();
+ delete pxXAutoStyles;
+ pxXAutoStyles = 0;
+ }
+
+ if(pxXBookmarks)
+ {
+ XNameAccess* pBm = pxXBookmarks->get();
+ ((SwXBookmarks*)pBm)->Invalidate();
+ delete pxXBookmarks;
+ pxXBookmarks = 0;
+ }
+
+ if(pxXChapterNumbering)
+ {
+ XIndexReplace* pCh = pxXChapterNumbering->get();
+ ((SwXChapterNumbering*)pCh)->Invalidate();
+ delete pxXChapterNumbering;
+ pxXChapterNumbering = 0;
+ }
+
+ if(pxXFootnoteSettings)
+ {
+ XPropertySet* pFntSet = pxXFootnoteSettings->get();
+ ((SwXFootnoteProperties*)pFntSet)->Invalidate();
+ delete pxXFootnoteSettings;
+ pxXFootnoteSettings = 0;
+ }
+
+ if(pxXEndnoteSettings)
+ {
+ XPropertySet* pEndSet = pxXEndnoteSettings->get();
+ ((SwXEndnoteProperties*)pEndSet)->Invalidate();
+ delete pxXEndnoteSettings;
+ pxXEndnoteSettings = 0;
+ }
+
+ if(pxXLineNumberingProperties)
+ {
+ XPropertySet* pLine = pxXLineNumberingProperties->get();
+ ((SwXLineNumberingProperties*)pLine)->Invalidate();
+ delete pxXLineNumberingProperties;
+ pxXLineNumberingProperties = 0;
+ }
+ if(pxXReferenceMarks)
+ {
+ XNameAccess* pMarks = pxXReferenceMarks->get();
+ ((SwXReferenceMarks*)pMarks)->Invalidate();
+ delete pxXReferenceMarks;
+ pxXReferenceMarks = 0;
+ }
+ if(pxLinkTargetSupplier)
+ {
+ XNameAccess* pAccess = (*pxLinkTargetSupplier).get();
+ ((SwXLinkTargetSupplier*)pAccess)->Invalidate();
+ delete pxLinkTargetSupplier;
+ pxLinkTargetSupplier = 0;
+ }
+ if(pxXRedlines)
+ {
+ XEnumerationAccess* pMarks = pxXRedlines->get();
+ ((SwXRedlines*)pMarks)->Invalidate();
+ delete pxXRedlines;
+ pxXRedlines = 0;
+ }
+ if(xPropertyHelper.is())
+ {
+ pPropertyHelper->Invalidate();
+ xPropertyHelper = 0;
+ pPropertyHelper = 0;
+ }
+}
+
+#define COM_SUN_STAR__DRAWING_LENGTH 13
+Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName)
+ throw( Exception, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ Reference< XInterface > xRet;
+ sal_uInt16 nType = SwXServiceProvider::GetProviderType(rServiceName);
+ if(nType != SW_SERVICE_INVALID)
+ {
+ xRet = SwXServiceProvider::MakeInstance(nType, pDocShell->GetDoc());
+ }
+ else
+ {
+ if( rServiceName.compareToAscii( "com.sun.star.", 13 ) == 0 )
+ {
+ sal_Int32 nIndex = COM_SUN_STAR__DRAWING_LENGTH;
+ OUString sCategory = rServiceName.getToken( 0, '.', nIndex );
+ sal_Bool bShape = sCategory == C2U("drawing");
+ if( bShape || sCategory == C2U("form"))
+ {
+ if(bShape)
+ {
+ short nTable = 0;
+ if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
+ nTable = SW_CREATE_DASH_TABLE;
+ else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
+ nTable = SW_CREATE_GRADIENT_TABLE;
+ else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
+ nTable = SW_CREATE_HATCH_TABLE;
+ else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
+ nTable = SW_CREATE_BITMAP_TABLE;
+ else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
+ nTable = SW_CREATE_TRANSGRADIENT_TABLE;
+ else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
+ nTable = SW_CREATE_MARKER_TABLE;
+ else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.Defaults") ) )
+ nTable = SW_CREATE_DRAW_DEFAULTS;
+ if(nTable)
+ {
+ xRet = GetPropertyHelper()->GetDrawTable(nTable);
+ }
+ }
+ }
+ else if (sCategory == C2U ("document") )
+ {
+ if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.Settings") ) )
+ xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) );
+ if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.document.ImportEmbeddedObjectResolver") ) )
+ {
+ xRet = (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pDocShell, EMBEDDEDOBJECTHELPER_MODE_READ );
+ }
+ }
+ else if (sCategory == C2U ("text") )
+ {
+ if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.PrintPreviewSettings") ) )
+ xRet = Reference < XInterface > ( *new SwXPrintPreviewSettings ( pDocShell->GetDoc() ) );
+ else if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.DocumentSettings") ) )
+ xRet = Reference < XInterface > ( *new SwXDocumentSettings ( this ) );
+ }
+ else if (sCategory == C2U ("chart2") )
+ {
+ if( 0 == rServiceName.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.chart2.data.DataProvider") ) )
+ xRet = Reference < XInterface > ( dynamic_cast< chart2::data::XDataProvider * >(pDocShell->getIDocumentChartDataProviderAccess()->GetChartDataProvider()) );
+ }
+
+ if(!xRet.is())
+ {
+ //! we don't want to insert OLE2 Shapes (e.g. "com.sun.star.drawing.OLE2Shape", ...)
+ //! like this (by creating them with the documents factory and
+ //! adding the shapes to the draw page).
+ //! For inserting OLE objects the proper way is to use
+ //! "com.sun.star.text.TextEmbeddedObject"!
+ if (rServiceName.lastIndexOf( C2U(".OLE2Shape") ) == rServiceName.getLength() - 10)
+ throw ServiceNotRegisteredException(); // declare service to be not registered with this factory
+
+ // --> OD 2006-02-22 #b6382898#
+ // the XML import is allowed to create instances of com.sun.star.drawing.OLE2Shape.
+ // Thus, a temporary service name is introduced to make this possible.
+ OUString aTmpServiceName( rServiceName );
+ if ( bShape &&
+ rServiceName.compareToAscii( "com.sun.star.drawing.temporaryForXMLImportOLE2Shape" ) == 0 )
+ {
+ aTmpServiceName = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.OLE2Shape"));
+ }
+ //hier den Draw - Service suchen
+ Reference< XInterface > xTmp = SvxFmMSFactory::createInstance(aTmpServiceName);
+ // <--
+ if(bShape)
+ {
+ nIndex = COM_SUN_STAR__DRAWING_LENGTH;
+ if( 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.GroupShape" ) ) ||
+ 0 == rServiceName.reverseCompareToAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.drawing.Shape3DSceneObject" ) ) )
+ xRet = *new SwXGroupShape( xTmp );
+ else
+ xRet = *new SwXShape( xTmp );
+ }
+ else
+ xRet = xTmp;
+ }
+ }
+ else
+ throw ServiceNotRegisteredException();
+ }
+ return xRet;
+}
+
+Reference< XInterface > SwXTextDocument::createInstanceWithArguments(
+ const OUString& ServiceSpecifier,
+ const Sequence< Any >& /*Arguments*/)
+ throw( Exception, RuntimeException )
+{
+ Reference< XInterface > xInt = createInstance(ServiceSpecifier);
+ //die Any-Sequence dient zur Initialisierung von Objekten, die auf
+ //Parameter zwingend angewiesen sind - bis jetzt haben wir das nicht
+ return xInt;
+}
+
+Sequence< OUString > SwXTextDocument::getAvailableServiceNames(void)
+ throw( RuntimeException )
+{
+ static Sequence< OUString > aServices;
+ if ( aServices.getLength() == 0 )
+ {
+ Sequence< OUString > aRet = SvxFmMSFactory::getAvailableServiceNames();
+ OUString* pRet = aRet.getArray();
+ for ( sal_Int32 i = 0; i < aRet.getLength(); ++i )
+ {
+ if ( pRet[i].compareToAscii( "com.sun.star.drawing.OLE2Shape" ) == 0 )
+ {
+ pRet[i] = pRet[aRet.getLength() - 1];
+ aRet.realloc( aRet.getLength() - 1 ); // <pRet> no longer valid.
+ break;
+ }
+ }
+ Sequence< OUString > aOwn = SwXServiceProvider::GetAllServiceNames();
+ aServices = SvxFmMSFactory::concatServiceNames(aRet, aOwn);
+ }
+
+ return aServices;
+}
+
+OUString SwXTextDocument::getImplementationName(void) throw( RuntimeException )
+{
+ return C2U("SwXTextDocument");
+}
+
+sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName) throw( RuntimeException )
+{
+ if (
+ (rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.document.OfficeDocument" ))) ||
+ (rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM ( "com.sun.star.text.GenericTextDocument")))
+ )
+ return sal_True;
+
+ BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
+ BOOL bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell));
+ BOOL bTextDoc = (!bWebDoc && !bGlobalDoc);
+
+ return (
+ (bWebDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.WebDocument" ))) ||
+ (bGlobalDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.GlobalDocument"))) ||
+ (bTextDoc && rServiceName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextDocument" )))
+ );
+}
+
+Sequence< OUString > SwXTextDocument::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ BOOL bWebDoc = (0 != PTR_CAST(SwWebDocShell, pDocShell));
+ BOOL bGlobalDoc = (0 != PTR_CAST(SwGlobalDocShell, pDocShell));
+ BOOL bTextDoc = (!bWebDoc && !bGlobalDoc);
+
+ Sequence< OUString > aRet (3);
+ OUString* pArray = aRet.getArray();
+
+ pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.document.OfficeDocument" ) ) );
+ pArray[1] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GenericTextDocument" ) ) );
+
+ if (bTextDoc)
+ pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.TextDocument" ) ) );
+ else
+ if (bWebDoc)
+ pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.WebDocument" ) ) );
+ else
+ if (bGlobalDoc)
+ pArray[2] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( ( "com.sun.star.text.GlobalDocument" ) ) );
+
+ return aRet;
+}
+
+Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ if(!pxXDocumentIndexes)
+ {
+ ((SwXTextDocument*)this)->pxXDocumentIndexes = new Reference< XIndexAccess > ;
+ *pxXDocumentIndexes = new SwXDocumentIndexes(pDocShell->GetDoc());
+ }
+ return *pxXDocumentIndexes;
+}
+
+Reference< XPropertySetInfo > SwXTextDocument::getPropertySetInfo(void) throw( RuntimeException )
+{
+ static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
+ return xRet;
+}
+
+void SwXTextDocument::setPropertyValue(const OUString& rPropertyName,
+ const Any& aValue)
+ throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException,
+ WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
+
+ if(!pEntry)
+ throw UnknownPropertyException();
+ if(pEntry->nFlags & PropertyAttribute::READONLY)
+ throw PropertyVetoException();
+ switch(pEntry->nWID)
+ {
+ case WID_DOC_CHAR_COUNT :
+ case WID_DOC_PARA_COUNT :
+ case WID_DOC_WORD_COUNT :
+ throw RuntimeException();
+ case WID_DOC_WORD_SEPARATOR :
+ {
+ OUString sDelim;
+ aValue >>= sDelim;
+ SW_MOD()->GetModuleConfig()->SetWordDelimiter(sDelim);
+ }
+ break;
+ case WID_DOC_CHANGES_RECORD:
+ case WID_DOC_CHANGES_SHOW:
+ {
+ sal_Bool bSet = *(sal_Bool*)aValue.getValue();
+ sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
+ if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
+ {
+ eMode &= ~(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE);
+ eMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT;
+ if( bSet )
+ eMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
+ }
+ else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
+ {
+ eMode = bSet ? eMode|nsRedlineMode_t::REDLINE_ON : eMode&~nsRedlineMode_t::REDLINE_ON;
+ }
+ pDocShell->GetDoc()->SetRedlineMode( (RedlineMode_t)(eMode ));
+ }
+ break;
+ case WID_DOC_CHANGES_PASSWORD:
+ {
+ Sequence <sal_Int8> aNew;
+ if(aValue >>= aNew)
+ {
+ SwDoc* pDoc = pDocShell->GetDoc();
+ pDoc->SetRedlinePassword(aNew);
+ if(aNew.getLength())
+ {
+ sal_uInt16 eMode = pDoc->GetRedlineMode();
+ eMode = eMode|nsRedlineMode_t::REDLINE_ON;
+ pDoc->SetRedlineMode( (RedlineMode_t)(eMode ));
+ }
+ }
+ }
+ break;
+ case WID_DOC_AUTO_MARK_URL :
+ {
+ OUString sURL;
+ aValue >>= sURL;
+ pDocShell->GetDoc()->SetTOIAutoMarkURL(sURL);
+ }
+ break;
+ case WID_DOC_HIDE_TIPS :
+ SW_MOD()->GetModuleConfig()->SetHideFieldTips(*(sal_Bool*)aValue.getValue());
+ break;
+ case WID_DOC_REDLINE_DISPLAY:
+ {
+ sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
+ eRedMode = eRedMode & (~nsRedlineMode_t::REDLINE_SHOW_MASK);
+ sal_Int16 nSet = 0;
+ aValue >>= nSet;
+ switch(nSet)
+ {
+ case RedlineDisplayType::NONE: break;
+ case RedlineDisplayType::INSERTED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT; break;
+ case RedlineDisplayType::REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE; break;
+ case RedlineDisplayType::
+ INSERTED_AND_REMOVED: eRedMode |= nsRedlineMode_t::REDLINE_SHOW_INSERT|nsRedlineMode_t::REDLINE_SHOW_DELETE;
+ break;
+ default: throw IllegalArgumentException();
+ }
+ pDocShell->GetDoc()->SetRedlineMode(eRedMode);
+ }
+ break;
+ case WID_DOC_TWO_DIGIT_YEAR:
+ {
+ sal_Int16 nYear = 0;
+ aValue >>= nYear;
+ SfxRequest aRequest ( SID_ATTR_YEAR2000, SFX_CALLMODE_SLOT, pDocShell->GetDoc()->GetAttrPool());
+ aRequest.AppendItem(SfxUInt16Item( SID_ATTR_YEAR2000, static_cast < sal_uInt16 > ( nYear ) ) );
+ pDocShell->Execute ( aRequest );
+ }
+ break;
+ case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
+ {
+ SwDrawDocument * pDrawDoc;
+ sal_Bool bAuto = *(sal_Bool*) aValue.getValue();
+
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * >( pDocShell->GetDoc()->GetDrawModel() ) ) )
+ pDrawDoc->SetAutoControlFocus( bAuto );
+ else if (bAuto)
+ {
+ // if setting to true, and we don't have an
+ // SdrModel, then we are changing the default and
+ // must thus create an SdrModel, if we don't have an
+ // SdrModel and we are leaving the default at false,
+ // we don't need to make an SdrModel and can do nothing
+ // --> OD 2005-08-08 #i52858# - method name changed
+ pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
+ // <--
+ pDrawDoc->SetAutoControlFocus ( bAuto );
+ }
+ }
+ break;
+ case WID_DOC_APPLY_FORM_DESIGN_MODE:
+ {
+ SwDrawDocument * pDrawDoc;
+ sal_Bool bMode = *(sal_Bool*)aValue.getValue();
+
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
+ pDrawDoc->SetOpenInDesignMode( bMode );
+ else if (!bMode)
+ {
+ // if setting to false, and we don't have an
+ // SdrModel, then we are changing the default and
+ // must thus create an SdrModel, if we don't have an
+ // SdrModel and we are leaving the default at true,
+ // we don't need to make an SdrModel and can do
+ // nothing
+ // --> OD 2005-08-08 #i52858# - method name changed
+ pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() );
+ // <--
+ pDrawDoc->SetOpenInDesignMode ( bMode );
+ }
+ }
+ break;
+ // --> FME 2005-02-25 #i42634# New property to set the bInReading
+ // flag at the document, used during binary import
+ case WID_DOC_LOCK_UPDATES :
+ {
+ SwDoc* pDoc = pDocShell->GetDoc();
+ bool bBool (false);
+ if( aValue >>= bBool )
+ pDoc->SetInReading( bBool );
+ }
+ break;
+ // <--
+ case WID_DOC_BUILDID:
+ aValue >>= maBuildId;
+ break;
+ // --> OD 2006-03-21 #b6375613#
+ case WID_APPLY_WORKAROUND_FOR_B6375613:
+ {
+ bool bApplyWorkaroundForB6375613( false );
+ aValue >>= bApplyWorkaroundForB6375613;
+ pDocShell->GetDoc()->SetApplyWorkaroundForB6375613( bApplyWorkaroundForB6375613 );
+ }
+ break;
+ // <--
+
+ default:
+ {
+ const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
+ SfxPoolItem* pNewItem = rItem.Clone();
+ pNewItem->PutValue(aValue, pEntry->nMemberId);
+ pDocShell->GetDoc()->SetDefault(*pNewItem);
+ delete pNewItem;
+ }
+ }
+}
+
+Any SwXTextDocument::getPropertyValue(const OUString& rPropertyName)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
+
+ if(!pEntry)
+ throw UnknownPropertyException();
+ Any aAny;
+ switch(pEntry->nWID)
+ {
+ case WID_DOC_ISTEMPLATEID :
+ aAny <<= pDocShell->IsTemplate();
+ break;
+ case WID_DOC_CHAR_COUNT :
+ case WID_DOC_PARA_COUNT :
+ case WID_DOC_WORD_COUNT :
+ {
+ SwDocStat aStat(pDocShell->GetDoc()->GetDocStat());
+ if(aStat.bModified)
+ pDocShell->GetDoc()->UpdateDocStat( aStat );
+ sal_Int32 nValue;
+ switch(pEntry->nWID)
+ {
+ case WID_DOC_CHAR_COUNT :nValue = aStat.nChar;break;
+ case WID_DOC_PARA_COUNT :nValue = aStat.nPara;break;
+ case WID_DOC_WORD_COUNT :nValue = aStat.nWord;break;
+ }
+ aAny <<= nValue;
+ }
+ break;
+ case WID_DOC_WORD_SEPARATOR :
+ {
+ aAny <<= OUString(SW_MOD()->GetDocStatWordDelim());
+ }
+ break;
+ case WID_DOC_CHANGES_RECORD:
+ case WID_DOC_CHANGES_SHOW:
+ {
+ sal_uInt16 eMode = pDocShell->GetDoc()->GetRedlineMode();
+ sal_Bool bSet = sal_False;
+ if(WID_DOC_CHANGES_SHOW == pEntry->nWID)
+ {
+ sal_uInt16 nMask = nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE;
+ bSet = (eMode & nMask) == nMask;
+ }
+ else if(WID_DOC_CHANGES_RECORD == pEntry->nWID)
+ {
+ bSet = (eMode& nsRedlineMode_t::REDLINE_ON) != 0;
+ }
+ aAny.setValue(&bSet, ::getBooleanCppuType());
+ }
+ break;
+ case WID_DOC_CHANGES_PASSWORD:
+ {
+ SwDoc* pDoc = pDocShell->GetDoc();
+ aAny <<= pDoc->GetRedlinePassword();
+ }
+ break;
+ case WID_DOC_AUTO_MARK_URL :
+ aAny <<= OUString(pDocShell->GetDoc()->GetTOIAutoMarkURL());
+ break;
+ case WID_DOC_HIDE_TIPS :
+ {
+ BOOL bTemp = SW_MOD()->GetModuleConfig()->IsHideFieldTips();
+ aAny.setValue(&bTemp, ::getBooleanCppuType());
+ }
+ break;
+ case WID_DOC_REDLINE_DISPLAY:
+ {
+ sal_Int16 eRedMode = pDocShell->GetDoc()->GetRedlineMode();
+ eRedMode = eRedMode & nsRedlineMode_t::REDLINE_SHOW_MASK;
+ sal_Int16 nRet = RedlineDisplayType::NONE;
+ if(nsRedlineMode_t::REDLINE_SHOW_INSERT == eRedMode)
+ nRet = RedlineDisplayType::INSERTED;
+ else if(nsRedlineMode_t::REDLINE_SHOW_DELETE == eRedMode)
+ nRet = RedlineDisplayType::REMOVED;
+ else if(nsRedlineMode_t::REDLINE_SHOW_MASK == eRedMode)
+ nRet = RedlineDisplayType::INSERTED_AND_REMOVED;
+ aAny <<= nRet;
+ }
+ break;
+ case WID_DOC_FORBIDDEN_CHARS:
+ {
+ GetPropertyHelper();
+ Reference<XForbiddenCharacters> xRet(xPropertyHelper, UNO_QUERY);
+ aAny <<= xRet;
+ }
+ break;
+ case WID_DOC_TWO_DIGIT_YEAR:
+ {
+ aAny <<= static_cast < sal_Int16 > (pDocShell->GetDoc()->GetNumberFormatter ( TRUE )->GetYear2000());
+ }
+ break;
+ case WID_DOC_AUTOMATIC_CONTROL_FOCUS:
+ {
+ SwDrawDocument * pDrawDoc;
+ sal_Bool bAuto;
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
+ bAuto = pDrawDoc->GetAutoControlFocus();
+ else
+ bAuto = sal_False;
+ aAny.setValue(&bAuto, ::getBooleanCppuType());
+ }
+ break;
+ case WID_DOC_APPLY_FORM_DESIGN_MODE:
+ {
+ SwDrawDocument * pDrawDoc;
+ sal_Bool bMode;
+ if ( 0 != ( pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetDrawModel() ) ) )
+ bMode = pDrawDoc->GetOpenInDesignMode();
+ else
+ bMode = sal_True;
+ aAny.setValue(&bMode, ::getBooleanCppuType());
+ }
+ break;
+ case WID_DOC_BASIC_LIBRARIES:
+ aAny <<= pDocShell->GetBasicContainer();
+ break;
+ case WID_DOC_DIALOG_LIBRARIES:
+ aAny <<= pDocShell->GetDialogContainer();
+ break;
+ case WID_DOC_VBA_DOCOBJ:
+ {
+ beans::PropertyValue aProp;
+ aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisWordDoc") );
+ aProp.Value <<= pDocShell->GetModel();
+ aAny <<= aProp;
+ }
+ break;
+ case WID_DOC_RUNTIME_UID:
+ aAny <<= getRuntimeUID();
+ break;
+ case WID_DOC_LOCK_UPDATES :
+ aAny <<= static_cast<bool>( pDocShell->GetDoc()->IsInReading() );
+ break;
+ case WID_DOC_BUILDID:
+ aAny <<= maBuildId;
+ break;
+ case WID_DOC_HAS_VALID_SIGNATURES:
+ aAny <<= hasValidSignatures();
+ break;
+ // --> OD 2006-03-21 #b6375613#
+ case WID_APPLY_WORKAROUND_FOR_B6375613:
+ {
+ aAny <<= pDocShell->GetDoc()->ApplyWorkaroundForB6375613();
+ }
+ break;
+ // <--
+
+ default:
+ {
+ const SfxPoolItem& rItem = pDocShell->GetDoc()->GetDefault(pEntry->nWID);
+ rItem.QueryValue(aAny, pEntry->nMemberId);
+ }
+ }
+ return aAny;
+}
+
+void SwXTextDocument::addPropertyChangeListener(const OUString& /*PropertyName*/,
+ const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ OSL_ENSURE(false, "not implemented");
+}
+
+void SwXTextDocument::removePropertyChangeListener(const OUString& /*PropertyName*/,
+ const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ OSL_ENSURE(false, "not implemented");
+}
+
+void SwXTextDocument::addVetoableChangeListener(const OUString& /*PropertyName*/,
+ const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ OSL_ENSURE(false, "not implemented");
+}
+
+void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyName*/,
+ const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ OSL_ENSURE(false, "not implemented");
+}
+
+Reference< XNameAccess > SwXTextDocument::getLinks(void) throw( RuntimeException )
+{
+ if(!pxLinkTargetSupplier)
+ {
+ pxLinkTargetSupplier = new Reference< XNameAccess > ;
+ (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*(SwXTextDocument*)this);
+ }
+ return (*pxLinkTargetSupplier);
+}
+
+Reference< XEnumerationAccess > SwXTextDocument::getRedlines( ) throw(RuntimeException)
+{
+ if(!pxXRedlines)
+ {
+ pxXRedlines = new Reference< XEnumerationAccess > ;
+ (*pxXRedlines) = new SwXRedlines(pDocShell->GetDoc());
+ }
+ return *pxXRedlines;
+}
+
+void SwXTextDocument::refresh(void) throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ SwWrtShell *pWrtShell = pDocShell->GetWrtShell();
+ notifyRefreshListeners();
+ if(pWrtShell)
+ pWrtShell->CalcLayout();
+}
+
+void SwXTextDocument::addRefreshListener(const Reference< util::XRefreshListener > & l)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if ( !IsValid() )
+ throw RuntimeException();
+ aRefreshCont.AddListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ));
+}
+
+void SwXTextDocument::removeRefreshListener(const Reference< util::XRefreshListener > & l)
+ throw( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if ( !IsValid() || !aRefreshCont.RemoveListener ( reinterpret_cast < const Reference < lang::XEventListener > &> ( l ) ) )
+ throw RuntimeException();
+}
+
+void SwXTextDocument::updateLinks( ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ SwDoc* pDoc = pDocShell->GetDoc();
+ sfx2::LinkManager& rLnkMan = pDoc->GetLinkManager();
+ if( rLnkMan.GetLinks().Count() )
+ {
+ UnoActionContext aAction(pDoc);
+ rLnkMan.UpdateAllLinks( FALSE, FALSE, TRUE );
+ }
+}
+
+//XPropertyState
+PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName )
+ throw (UnknownPropertyException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ PropertyState eRet = PropertyState_DIRECT_VALUE;
+ if(!IsValid())
+ throw RuntimeException();
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
+
+ if(!pEntry)
+ throw UnknownPropertyException();
+ Any aAny;
+ switch(pEntry->nWID)
+ {
+ case 0:default:break;
+ }
+ return eRet;
+}
+
+Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Sequence< OUString >& rPropertyNames )
+ throw (UnknownPropertyException, RuntimeException)
+{
+ const sal_Int32 nCount = rPropertyNames.getLength();
+ const OUString * pNames = rPropertyNames.getConstArray();
+ Sequence < PropertyState > aRet ( nCount );
+ PropertyState *pState = aRet.getArray();
+
+ for ( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++)
+ pState[nIndex] = getPropertyState( pNames[nIndex] );
+
+ return aRet;
+}
+
+void SAL_CALL SwXTextDocument::setPropertyToDefault( const OUString& rPropertyName )
+ throw (UnknownPropertyException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
+ if(!pEntry)
+ throw UnknownPropertyException();
+ switch(pEntry->nWID)
+ {
+ case 0:default:break;
+ }
+}
+
+Any SAL_CALL SwXTextDocument::getPropertyDefault( const OUString& rPropertyName )
+ throw (UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap()->getByName( rPropertyName);
+ if(!pEntry)
+ throw UnknownPropertyException();
+ Any aAny;
+ switch(pEntry->nWID)
+ {
+ case 0:default:break;
+ }
+ return aAny;
+}
+
+static OutputDevice * lcl_GetOutputDevice( const SwPrintUIOptions &rPrintUIOptions )
+{
+ OutputDevice *pOut = 0;
+
+ uno::Any aAny( rPrintUIOptions.getValue( C2U( "RenderDevice" ) ));
+ uno::Reference< awt::XDevice > xRenderDevice;
+ aAny >>= xRenderDevice;
+ if (xRenderDevice.is())
+ {
+ VCLXDevice* pDevice = VCLXDevice::GetImplementation( xRenderDevice );
+ pOut = pDevice ? pDevice->GetOutputDevice() : 0;
+ }
+
+ return pOut;
+}
+
+static bool lcl_SeqHasProperty(
+ const uno::Sequence< beans::PropertyValue >& rOptions,
+ const sal_Char *pPropName )
+{
+ bool bRes = false;
+ const sal_Int32 nLen = rOptions.getLength();
+ const beans::PropertyValue *pProps = rOptions.getConstArray();
+ for (sal_Int32 i = 0; i < nLen && !bRes; ++i)
+ {
+ if (pProps[i].Name.equalsAscii( pPropName ))
+ bRes = true;
+ }
+ return bRes;
+}
+
+SfxViewShell * SwXTextDocument::GetRenderView(
+ bool &rbIsSwSrcView,
+ const uno::Sequence< beans::PropertyValue >& rOptions,
+ bool bIsPDFExport )
+{
+ // get view shell to use
+ SfxViewShell *pView = 0;
+ if (bIsPDFExport)
+ pView = GuessViewShell( rbIsSwSrcView );
+ else
+ {
+ uno::Any aTmp;
+ const sal_Int32 nLen = rOptions.getLength();
+ const beans::PropertyValue *pProps = rOptions.getConstArray();
+ for (sal_Int32 i = 0; i < nLen; ++i)
+ {
+ if (pProps[i].Name.equalsAscii( "View" ))
+ {
+ aTmp = pProps[i].Value;
+ break;
+ }
+ }
+
+ uno::Reference< frame::XController > xController;
+ if (aTmp >>= xController)
+ {
+ OSL_ENSURE( xController.is(), "controller is empty!" );
+ pView = GuessViewShell( rbIsSwSrcView, xController );
+ }
+ }
+ return pView;
+}
+
+/*
+ * GetRenderDoc:
+ * returns the document to be rendered, usually this will be the 'regular'
+ * document but in case of PDF export of (multi-)selection it will
+ * be a temporary document that gets created if not already done.
+ * The rpView variable will be set (if not already done) to the used
+ * SfxViewShell.
+*/
+SwDoc * SwXTextDocument::GetRenderDoc(
+ SfxViewShell *&rpView,
+ const uno::Any& rSelection,
+ bool bIsPDFExport )
+{
+ SwDoc *pDoc = 0;
+
+ uno::Reference< frame::XModel > xModel;
+ rSelection >>= xModel;
+ if (xModel == pDocShell->GetModel())
+ pDoc = pDocShell->GetDoc();
+ else
+ {
+ OSL_ENSURE( !xModel.is(), "unexpected model found" );
+
+ if (rSelection.hasValue()) // is anything selected ?
+ {
+ // this part should only be called when a temporary document needs to be created,
+ // for example for PDF export or printing of (multi-)selection only.
+
+ bool bIsSwSrcView = false;
+ if (!rpView)
+ {
+ (void) bIsPDFExport;
+ // aside from maybe PDF export the view should always have been provided!
+ OSL_ENSURE( bIsPDFExport, "view is missing, guessing one..." );
+
+ rpView = GuessViewShell( bIsSwSrcView );
+ }
+ OSL_ENSURE( rpView, "ViewShell missing" );
+ // the view shell should be SwView for documents PDF export.
+ // for the page preview no selection should be possible
+ // (the export dialog does not allow for this option)
+ const TypeId aSwViewTypeId = TYPE(SwView);
+ if (rpView && rpView->IsA(aSwViewTypeId))
+ {
+ SfxObjectShellRef xDocSh(((SwView*)rpView)->GetOrCreateTmpSelectionDoc());
+ if (xDocSh.Is())
+ {
+ pDoc = ((SwDocShell*)&xDocSh)->GetDoc();
+ rpView = pDoc->GetDocShell()->GetView();
+ }
+ }
+ else
+ {
+ OSL_ENSURE(false, "unexpected ViewShell" );
+ }
+ }
+ }
+ return pDoc;
+}
+
+static void lcl_SavePrintUIOptionsToDocumentPrintData(
+ SwDoc &rDoc,
+ const SwPrintUIOptions &rPrintUIOptions,
+ bool bIsPDFEXport )
+{
+ if (!rDoc.getPrintData())
+ {
+ SwPrintData *pTmpData = new SwPrintData;
+ rDoc.setPrintData ( *pTmpData );
+ delete pTmpData; // setPrintData does make its own copy!
+ }
+
+ SwPrintData *pDocPrintData = rDoc.getPrintData();
+
+ pDocPrintData->SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() );
+ pDocPrintData->SetPrintTable( rPrintUIOptions.IsPrintTables() );
+ pDocPrintData->SetPrintDraw( rPrintUIOptions.IsPrintDrawings() );
+ pDocPrintData->SetPrintControl( rPrintUIOptions.IsPrintFormControls() );
+ pDocPrintData->SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() );
+ pDocPrintData->SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() );
+ pDocPrintData->SetPrintReverse( rPrintUIOptions.IsPrintReverse() );
+ pDocPrintData->SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() );
+ pDocPrintData->SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) );
+ pDocPrintData->SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() );
+ pDocPrintData->SetPrintProspect( rPrintUIOptions.IsPrintProspect() );
+ pDocPrintData->SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() );
+ pDocPrintData->SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() );
+ pDocPrintData->SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() );
+ // pDocPrintData->SetPrintSingleJobs( b ); handled by File/Print dialog itself
+ // pDocPrintData->SetFaxName( s ); n/a in File/Print dialog
+ pDocPrintData->SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() );
+ pDocPrintData->SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() );
+}
+
+sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
+ const uno::Any& rSelection,
+ const uno::Sequence< beans::PropertyValue >& rxOptions )
+ throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+
+ const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
+ bool bIsSwSrcView = false;
+ SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
+
+ if (!bIsSwSrcView && !m_pRenderData)
+ m_pRenderData = new SwRenderData;
+ if (!m_pPrintUIOptions)
+ m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
+ bool bFormat = m_pPrintUIOptions->processPropertiesAndCheckFormat( rxOptions );
+ // const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
+
+ SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
+ OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
+ if (!pDoc || !pView)
+ return 0;
+
+ // save current UI options from the print dialog for the next call to that dialog
+ lcl_SavePrintUIOptionsToDocumentPrintData( *pDoc, *m_pPrintUIOptions, bIsPDFExport );
+
+ sal_Int32 nRet = 0;
+ if (bIsSwSrcView)
+ {
+ SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView);
+ OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+ nRet = pSwSrcView->PrintSource( pOutDev, 1 /* dummy */, true /* get page count only */ );
+ }
+ else
+ {
+ SwDocShell *pRenderDocShell = pDoc->GetDocShell();
+ SwWrtShell *pWrtShell = pRenderDocShell->GetWrtShell();
+ if (bFormat)
+ {
+ // #i38289
+ if(pDoc->get(IDocumentSettingAccess::BROWSE_MODE))
+ {
+ pRenderDocShell->ToggleBrowserMode(false,NULL);
+ }
+
+ if (!pWrtShell)
+ {
+ //create a hidden view to be able to export as PDF also in print preview
+ m_pHiddenViewFrame = SfxViewFrame::LoadHiddenDocument( *pRenderDocShell, 2 );
+ SwView* pSwView = (SwView*) m_pHiddenViewFrame->GetViewShell();
+ pWrtShell = pSwView->GetWrtShellPtr();
+ }
+
+ // reformating the document for printing will show the changes in the view
+ // which is likely to produce many unwanted and not nice to view actions.
+ // We don't want that! Thus we disable updating of the view.
+ pWrtShell->StartAction();
+
+ const TypeId aSwViewTypeId = TYPE(SwView);
+ if (pView->IsA(aSwViewTypeId))
+ {
+ if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pWrtShell ) )
+ m_pRenderData->ViewOptionAdjustStop();
+ if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust())
+ m_pRenderData->ViewOptionAdjustStart( *pWrtShell, *pWrtShell->GetViewOptions() );
+ }
+
+ m_pRenderData->SetSwPrtOptions( new SwPrtOptions( C2U( bIsPDFExport ? "PDF export" : "Printing" ) ) );
+ m_pRenderData->MakeSwPrtOptions( m_pRenderData->GetSwPrtOptionsRef(), pRenderDocShell,
+ m_pPrintUIOptions, m_pRenderData, bIsPDFExport );
+
+ if (pView->IsA(aSwViewTypeId))
+ {
+ // PDF export should not make use of the SwPrtOptions
+ const SwPrtOptions *pPrtOptions = bIsPDFExport? NULL : m_pRenderData->GetSwPrtOptions();
+ m_pRenderData->ViewOptionAdjust( pPrtOptions );
+ }
+
+ // since printing now also use the API for PDF export this option
+ // should be set for printing as well ...
+ pWrtShell->SetPDFExportOption( sal_True );
+ bool bOrigStatus = pRenderDocShell->IsEnableSetModified();
+ // check configuration: shall update of printing information in DocInfo set the document to "modified"?
+ bool bStateChanged = false;
+ if ( bOrigStatus && !SvtPrintWarningOptions().IsModifyDocumentOnPrintingAllowed() )
+ {
+ pRenderDocShell->EnableSetModified( sal_False );
+ bStateChanged = true;
+ }
+
+
+ // --> FME 2005-05-23 #122919# Force field update before PDF export:
+ pWrtShell->ViewShell::UpdateFlds(TRUE);
+ // <--
+ if( bStateChanged )
+ pRenderDocShell->EnableSetModified( sal_True );
+
+ // there is some redundancy between those two function calls, but right now
+ // there is no time to sort this out.
+ //TODO: check what exatly needs to be done and make just one function for that
+ pWrtShell->CalcLayout();
+ pWrtShell->CalcPagesForPrint( pDoc->GetPageCount() );
+
+ pWrtShell->SetPDFExportOption( sal_False );
+
+
+ // enable view again
+ pWrtShell->EndAction();
+ }
+
+ const sal_Int32 nPageCount = pDoc->GetPageCount();
+
+ //
+ // get number of pages to be rendered
+ //
+ const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
+ if (bPrintProspect)
+ {
+ pDoc->CalculatePagePairsForProspectPrinting( *m_pRenderData, *m_pPrintUIOptions, nPageCount );
+ nRet = m_pRenderData->GetPagePairsForProspectPrinting().size();
+ }
+ else
+ {
+ const sal_Int16 nPostItMode = (sal_Int16) m_pPrintUIOptions->getIntValue( "PrintAnnotationMode", 0 );
+ if (nPostItMode != POSTITS_NONE)
+ {
+ OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+ m_pRenderData->CreatePostItData( pDoc, pWrtShell->GetViewOptions(), pOutDev );
+ }
+
+ // get set of valid document pages (according to the current settings)
+ // and their start frames
+ pDoc->CalculatePagesForPrinting( *m_pRenderData, *m_pPrintUIOptions, bIsPDFExport, nPageCount );
+
+ if (nPostItMode != POSTITS_NONE)
+ {
+ pDoc->UpdatePagesForPrintingWithPostItData( *m_pRenderData,
+ *m_pPrintUIOptions, bIsPDFExport, nPageCount );
+ }
+
+ nRet = m_pRenderData->GetPagesToPrint().size();
+ }
+ }
+ OSL_ENSURE( nRet >= 0, "negative number of pages???" );
+
+ return nRet;
+}
+
+uno::Sequence< beans::PropertyValue > SAL_CALL SwXTextDocument::getRenderer(
+ sal_Int32 nRenderer,
+ const uno::Any& rSelection,
+ const uno::Sequence< beans::PropertyValue >& rxOptions )
+ throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+
+ const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
+ bool bIsSwSrcView = false;
+ SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
+
+ // m_pRenderData should NOT be created here!
+ // That should only be done in getRendererCount. If this function is called before
+ // getRendererCount was called then the caller will probably just retrieve the extra UI options
+ // and is not interested in getting valid information about the other data that would
+ // otherwise be provided here!
+// if( ! m_pRenderData )
+// m_pRenderData = new SwRenderData;
+ if (!m_pPrintUIOptions)
+ m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
+ m_pPrintUIOptions->processProperties( rxOptions );
+ const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
+ const bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
+ const bool bPrintPaperFromSetup = m_pPrintUIOptions->getBoolValue( "PrintPaperFromSetup", false );
+
+ SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
+ OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
+ if (!pDoc || !pView)
+ return uno::Sequence< beans::PropertyValue >();
+
+ // due to #110067# (document page count changes sometimes during
+ // PDF export/printing) we can not check for the upper bound properly.
+ // Thus instead of throwing the exception we silently return.
+ if (0 > nRenderer)
+ throw IllegalArgumentException();
+ sal_Int32 nMaxRenderer = 0;
+ if (!bIsSwSrcView && m_pRenderData)
+ {
+ OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
+ nMaxRenderer = bPrintProspect?
+ m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
+ m_pRenderData->GetPagesToPrint().size() - 1;
+ }
+ // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
+ // we obmit checking of the upper bound in this case.
+ if (!bIsSwSrcView && m_pRenderData && nRenderer > nMaxRenderer)
+ return uno::Sequence< beans::PropertyValue >();
+
+ uno::Sequence< beans::PropertyValue > aRenderer;
+ if (m_pRenderData)
+ {
+ // --> TL, OD 2010-09-07 #i114210#
+ // determine the correct page number from the renderer index
+ // --> OD 2010-10-01 #i114875
+ // consider brochure print
+ const USHORT nPage = bPrintProspect
+ ? nRenderer + 1
+ : m_pRenderData->GetPagesToPrint()[ nRenderer ];
+ // <--
+
+ // get paper tray to use ...
+ sal_Int32 nPrinterPaperTray = -1;
+ if (! bPrintPaperFromSetup)
+ {
+ // ... from individual page style (see the page tab in Format/Page dialog)
+ const std::map< sal_Int32, sal_Int32 > &rPaperTrays = m_pRenderData->GetPrinterPaperTrays();
+ std::map< sal_Int32, sal_Int32 >::const_iterator aIt( rPaperTrays.find( nPage ) );
+ if (aIt != rPaperTrays.end())
+ nPrinterPaperTray = aIt->second;
+ }
+
+ awt::Size aPageSize;
+ awt::Size aPreferredPageSize;
+ Size aTmpSize;
+ if (bIsSwSrcView || bPrintProspect)
+ {
+ // for printing of HTML source code and prospect printing we should use
+ // the printers paper size since
+ // a) HTML source view has no page size
+ // b) prospect printing has a different page size from the documents page
+ // since two document pages will get rendered on one printer page
+
+ // since PageIncludesNonprintableArea will be set to true we can return the
+ // printers paper size here.
+ // Sometimes 'getRenderer' is only called to get "ExtraPrintUIOptions", in this
+ // case we won't get an OutputDevice here, but then the caller also has no need
+ // for the correct PageSisze right now...
+ Printer *pPrinter = dynamic_cast< Printer * >(lcl_GetOutputDevice( *m_pPrintUIOptions ));
+ if (pPrinter)
+ {
+ // HTML source view and prospect adapt to the printer's paper size
+ aTmpSize = pPrinter->GetPaperSize();
+ aTmpSize = pPrinter->LogicToLogic( aTmpSize,
+ pPrinter->GetMapMode(), MapMode( MAP_100TH_MM ));
+ aPageSize = awt::Size( aTmpSize.Width(), aTmpSize.Height() );
+ if (bPrintProspect)
+ {
+ // we just state what output size we would need
+ // which may cause vcl to set that page size on the printer
+ // (if available and not overriden by the user)
+ aTmpSize = pDoc->GetPageSize( nPage, bIsSkipEmptyPages );
+ aPreferredPageSize = awt::Size ( TWIP_TO_MM100( 2 * aTmpSize.Width() ),
+ TWIP_TO_MM100( aTmpSize.Height() ));
+ }
+ }
+ }
+ else
+ {
+ aTmpSize = pDoc->GetPageSize( nPage, bIsSkipEmptyPages );
+ aPageSize = awt::Size ( TWIP_TO_MM100( aTmpSize.Width() ),
+ TWIP_TO_MM100( aTmpSize.Height() ));
+ }
+
+ sal_Int32 nLen = 2;
+ aRenderer.realloc(2);
+ aRenderer[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) );
+ aRenderer[0].Value <<= aPageSize;
+ aRenderer[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageIncludesNonprintableArea" ) );
+ aRenderer[1].Value <<= sal_True;
+ if (aPreferredPageSize.Width && aPreferredPageSize.Height)
+ {
+ ++nLen;
+ aRenderer.realloc( nLen );
+ aRenderer[ nLen - 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PreferredPageSize" ) );
+ aRenderer[ nLen - 1 ].Value <<= aPreferredPageSize;
+ }
+ if (nPrinterPaperTray >= 0)
+ {
+ ++nLen;
+ aRenderer.realloc( nLen );
+ aRenderer[ nLen - 1 ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PrinterPaperTray" ) );
+ aRenderer[ nLen - 1 ].Value <<= nPrinterPaperTray;
+ }
+ }
+
+ m_pPrintUIOptions->appendPrintUIOptions( aRenderer );
+
+ return aRenderer;
+}
+
+SfxViewShell * SwXTextDocument::GuessViewShell(
+ /* out */ bool &rbIsSwSrcView,
+ const uno::Reference< css::frame::XController > xController )
+{
+ // #130810# SfxViewShell::Current() / SfxViewShell::GetObjectShell()
+ // must not be used (see comment from MBA)
+ //
+ SfxViewShell *pView = 0;
+ SwView *pSwView = 0;
+ SwPagePreView *pSwPagePreView = 0;
+ SwSrcView *pSwSrcView = 0;
+ SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pDocShell, sal_False );
+
+ // look for the view shell with the same controller in use,
+ // otherwise look for a suitable view, preferably a SwView,
+ // if that one is not found use a SwPagePreView if found.
+ while (pFrame)
+ {
+ pView = pFrame->GetViewShell();
+ pSwView = dynamic_cast< SwView * >(pView);
+ pSwSrcView = dynamic_cast< SwSrcView * >(pView);
+ if (!pSwPagePreView)
+ pSwPagePreView = dynamic_cast< SwPagePreView * >(pView);
+ if (xController.is())
+ {
+ if (pView && pView->GetController() == xController)
+ break;
+ }
+ else if (pSwView || pSwSrcView)
+ break;
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, sal_False );
+ }
+
+ OSL_ENSURE( pSwView || pSwPagePreView || pSwSrcView, "failed to get view shell" );
+ if (pView)
+ rbIsSwSrcView = pSwSrcView != 0;
+ return pView;
+// return pSwView ? dynamic_cast< SfxViewShell * >(pSwView) :
+// (pSwSrcView ? dynamic_cast< SfxViewShell * >(pSwSrcView) :
+// dynamic_cast< SfxViewShell * >(pSwPagePreView) );
+}
+
+void SAL_CALL SwXTextDocument::render(
+ sal_Int32 nRenderer,
+ const uno::Any& rSelection,
+ const uno::Sequence< beans::PropertyValue >& rxOptions )
+ throw (IllegalArgumentException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+
+ // due to #110067# (document page count changes sometimes during
+ // PDF export/printing) we can not check for the upper bound properly.
+ // Thus instead of throwing the exception we silently return.
+ if (0 > nRenderer)
+ throw IllegalArgumentException();
+
+ const bool bIsPDFExport = !lcl_SeqHasProperty( rxOptions, "IsPrinter" );
+ bool bIsSwSrcView = false;
+ SfxViewShell *pView = GetRenderView( bIsSwSrcView, rxOptions, bIsPDFExport );
+
+ OSL_ENSURE( m_pRenderData, "data should have been created already in getRendererCount..." );
+ OSL_ENSURE( m_pPrintUIOptions, "data should have been created already in getRendererCount..." );
+ if (!bIsSwSrcView && !m_pRenderData)
+ m_pRenderData = new SwRenderData;
+ if (!m_pPrintUIOptions)
+ m_pPrintUIOptions = lcl_GetPrintUIOptions( pDocShell, pView );
+ m_pPrintUIOptions->processProperties( rxOptions );
+ const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false );
+ const bool bLastPage = m_pPrintUIOptions->getBoolValue( "IsLastPage", sal_False );
+
+ SwDoc *pDoc = GetRenderDoc( pView, rSelection, bIsPDFExport );
+ OSL_ENSURE( pDoc && pView, "doc or view shell missing!" );
+ if (pDoc && pView)
+ {
+ sal_Int32 nMaxRenderer = 0;
+ if (!bIsSwSrcView)
+ {
+ OSL_ENSURE( m_pRenderData, "m_pRenderData missing!!" );
+ nMaxRenderer = bPrintProspect?
+ m_pRenderData->GetPagePairsForProspectPrinting().size() - 1 :
+ m_pRenderData->GetPagesToPrint().size() - 1;
+ }
+ // since SwSrcView::PrintSource is a poor implementation to get the number of pages to print
+ // we obmit checking of the upper bound in this case.
+ if (bIsSwSrcView || nRenderer <= nMaxRenderer)
+ {
+ if (bIsSwSrcView)
+ {
+ SwSrcView *pSwSrcView = dynamic_cast< SwSrcView * >(pView);
+ OutputDevice *pOutDev = lcl_GetOutputDevice( *m_pPrintUIOptions );
+ pSwSrcView->PrintSource( pOutDev, nRenderer + 1, false );
+ }
+ else
+ {
+ // the view shell should be SwView for documents PDF export
+ // or SwPagePreView for PDF export of the page preview
+ //!! (check for SwView first as in GuessViewShell) !!
+ OSL_ENSURE( pView, "!! view missing !!" );
+ const TypeId aSwViewTypeId = TYPE(SwView);
+ ViewShell* pVwSh = 0;
+ if (pView)
+ {
+ pVwSh = pView->IsA(aSwViewTypeId) ?
+ ((SwView*)pView)->GetWrtShellPtr() :
+ ((SwPagePreView*)pView)->GetViewShell();
+ }
+
+ // get output device to use
+ OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions );
+
+ if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions())
+ {
+ const rtl::OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() );
+ const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", sal_False );
+ bool bIsSkipEmptyPages = !m_pPrintUIOptions->IsPrintEmptyPages( bIsPDFExport );
+
+ OSL_ENSURE(( pView->IsA(aSwViewTypeId) && m_pRenderData->IsViewOptionAdjust())
+ || (!pView->IsA(aSwViewTypeId) && !m_pRenderData->IsViewOptionAdjust()),
+ "SwView / SwViewOptionAdjust_Impl availability mismatch" );
+
+ // since printing now also use the API for PDF export this option
+ // should be set for printing as well ...
+ pVwSh->SetPDFExportOption( sal_True );
+
+ // --> FME 2004-06-08 #i12836# enhanced pdf export
+ //
+ // First, we have to export hyperlinks, notes, and outline to pdf.
+ // During this process, additional information required for tagging
+ // the pdf file are collected, which are evaulated during painting.
+ //
+ SwWrtShell* pWrtShell = pView->IsA(aSwViewTypeId) ?
+ ((SwView*)pView)->GetWrtShellPtr() :
+ 0;
+
+ if (bIsPDFExport && bFirstPage && pWrtShell)
+ {
+ SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_False );
+ }
+ // <--
+
+ const SwPrtOptions &rSwPrtOptions = *m_pRenderData->GetSwPrtOptions();
+ if (bPrintProspect)
+ pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer );
+ else // normal printing and PDF export
+ pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer );
+
+ // --> FME 2004-10-08 #i35176#
+ //
+ // After printing the last page, we take care for the links coming
+ // from the EditEngine. The links are generated during the painting
+ // process, but the destinations are still missing.
+ //
+ if (bIsPDFExport && bLastPage && pWrtShell)
+ {
+ SwEnhancedPDFExportHelper aHelper( *pWrtShell, *pOut, aPageRange, bIsSkipEmptyPages, sal_True );
+ }
+ // <--
+
+ pVwSh->SetPDFExportOption( sal_False );
+
+ // last page to be rendered? (not necessarily the last page of the document)
+ // -> do clean-up of data
+ if (bLastPage)
+ {
+ // #i96167# haggai: delete ViewOptionsAdjust here because it makes use
+ // of the shell, which might get destroyed in lcl_DisposeView!
+ if (m_pRenderData && m_pRenderData->IsViewOptionAdjust())
+ m_pRenderData->ViewOptionAdjustStop();
+
+ if (m_pRenderData && m_pRenderData->HasPostItData())
+ m_pRenderData->DeletePostItData();
+ if (m_pHiddenViewFrame)
+ {
+ lcl_DisposeView( m_pHiddenViewFrame, pDocShell );
+ m_pHiddenViewFrame = 0;
+
+ // prevent crash described in #i108805
+ SwDocShell *pRenderDocShell = pDoc->GetDocShell();
+ SfxItemSet *pSet = pRenderDocShell->GetMedium()->GetItemSet();
+ pSet->Put( SfxBoolItem( SID_HIDDEN, sal_False ) );
+
+ }
+ }
+ }
+ }
+ }
+ }
+ if( bLastPage )
+ {
+ delete m_pRenderData; m_pRenderData = NULL;
+ delete m_pPrintUIOptions; m_pPrintUIOptions = NULL;
+ }
+}
+
+// xforms::XFormsSupplier
+Reference<XNameContainer> SAL_CALL SwXTextDocument::getXForms()
+ throw( RuntimeException )
+{
+ if ( !pDocShell )
+ throw DisposedException( ::rtl::OUString(), static_cast< XTextDocument* >( this ) );
+ SwDoc* pDoc = pDocShell->GetDoc();
+ return pDoc->getXForms();
+}
+
+uno::Reference< text::XFlatParagraphIterator > SAL_CALL SwXTextDocument::getFlatParagraphIterator(::sal_Int32 nTextMarkupType, sal_Bool bAutomatic)
+ throw ( uno::RuntimeException )
+{
+ return new SwXFlatParagraphIterator( *pDocShell->GetDoc(), nTextMarkupType, bAutomatic );
+}
+
+uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(!IsValid())
+ throw RuntimeException();
+ //create a new document - hidden - copy the storage and return it
+ SfxObjectShell* pShell = pDocShell->GetDoc()->CreateCopy(false);
+ uno::Reference< frame::XModel > xNewModel = pShell->GetModel();
+ uno::Reference< embed::XStorage > xNewStorage = ::comphelper::OStorageHelper::GetTemporaryStorage( );
+ uno::Sequence< beans::PropertyValue > aTempMediaDescriptor;
+ storeToStorage( xNewStorage, aTempMediaDescriptor );
+ uno::Reference< document::XStorageBasedDocument > xStorageDoc( xNewModel, uno::UNO_QUERY );
+ xStorageDoc->loadFromStorage( xNewStorage, aTempMediaDescriptor );
+ return uno::Reference< util::XCloneable >( xNewModel, UNO_QUERY );
+}
+
+void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
+{
+ return SwXTextDocumentBaseClass::operator new(t);
+}
+
+void SAL_CALL SwXTextDocument::operator delete( void * p) throw()
+{
+ SwXTextDocumentBaseClass::operator delete(p);
+}
+
+/*---------------------------------------------------
+retrieve languages already used in current document
+-----------------------------------------------------*/
+uno::Sequence< lang::Locale > SAL_CALL SwXTextDocument::getDocumentLanguages(
+ ::sal_Int16 nScriptTypes,
+ ::sal_Int16 nMaxCount )
+ throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+
+ // possible canonical values for nScriptTypes
+ // any bit wise combination is allowed
+ const sal_Int16 nLatin = 0x001;
+ const sal_Int16 nAsian = 0x002;
+ const sal_Int16 nComplex = 0x004;
+
+ // script types for which to get the languages
+ const bool bLatin = 0 != (nScriptTypes & nLatin);
+ const bool bAsian = 0 != (nScriptTypes & nAsian);
+ const bool bComplex = 0 != (nScriptTypes & nComplex);
+
+ if (nScriptTypes < nLatin || nScriptTypes > (nLatin | nAsian | nComplex))
+ throw IllegalArgumentException(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nScriptTypes ranges from 1 to 7!")), Reference< XInterface >(), 1);
+ if (!pDocShell)
+ throw DisposedException();
+ SwDoc* pDoc = pDocShell->GetDoc();
+
+ // avoid duplicate values
+ std::set< LanguageType > aAllLangs;
+
+ //USER STYLES
+
+ const SwCharFmts *pFmts = pDoc->GetCharFmts();
+ for(USHORT i = 0; i < pFmts->Count(); ++i)
+ {
+ const SwAttrSet &rAttrSet = (*pFmts)[i]->GetAttrSet();
+ LanguageType nLang = LANGUAGE_DONTKNOW;
+ if (bLatin)
+ {
+ nLang = rAttrSet.GetLanguage( FALSE ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bAsian)
+ {
+ nLang = rAttrSet.GetCJKLanguage( FALSE ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bComplex)
+ {
+ nLang = rAttrSet.GetCTLLanguage( FALSE ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ }
+
+ const SwTxtFmtColls *pColls = pDoc->GetTxtFmtColls();
+ for (USHORT i = 0; i < pColls->Count(); ++i)
+ {
+ const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet();
+ LanguageType nLang = LANGUAGE_DONTKNOW;;
+ if (bLatin)
+ {
+ nLang = rAttrSet.GetLanguage( FALSE ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bAsian)
+ {
+ nLang = rAttrSet.GetCJKLanguage( FALSE ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bComplex)
+ {
+ nLang = rAttrSet.GetCTLLanguage( FALSE ).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ }
+
+ //AUTO STYLES
+ const IStyleAccess::SwAutoStyleFamily aFam[2] =
+ {
+ IStyleAccess::AUTO_STYLE_CHAR,
+ IStyleAccess::AUTO_STYLE_PARA
+ };
+ for (sal_uInt16 i = 0; i < 2; ++i)
+ {
+ std::vector< SfxItemSet_Pointer_t > rStyles;
+ pDoc->GetIStyleAccess().getAllStyles(rStyles, aFam[i]);
+ while (!rStyles.empty())
+ {
+ SfxItemSet_Pointer_t pStyle = rStyles.back();
+ rStyles.pop_back();
+ const SfxItemSet *pSet = dynamic_cast< const SfxItemSet * >(pStyle.get());
+
+ LanguageType nLang = LANGUAGE_DONTKNOW;
+ if (bLatin)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_LANGUAGE, FALSE )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bAsian)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CJK_LANGUAGE, FALSE )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bComplex)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(pSet->Get( RES_CHRATR_CTL_LANGUAGE, FALSE )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ }
+ }
+
+ //get languages from "drawobject"
+ SwWrtShell *pWrtSh = pDocShell->GetWrtShell();
+ SdrView *pSdrView = pWrtSh->GetDrawView();
+
+ if( pSdrView )
+ {
+ SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner();
+ if(pOutliner)
+ {
+ EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine();
+ ULONG nParCount = pOutliner->GetParagraphCount();
+ for (ULONG nPar=0; nPar<nParCount; nPar++)
+ {
+ //every paragraph
+ SvUShorts aPortions;
+ rEditEng.GetPortions( (USHORT)nPar, aPortions );
+
+ for ( USHORT nPos = aPortions.Count(); nPos; )
+ {
+ //every position
+ --nPos;
+ USHORT nEnd = aPortions.GetObject( nPos );
+ USHORT nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0;
+ ESelection aSelection( (USHORT)nPar, nStart, (USHORT)nPar, nEnd );
+ SfxItemSet aAttr = rEditEng.GetAttribs( aSelection );
+
+ LanguageType nLang = LANGUAGE_DONTKNOW;
+ if (bLatin)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, FALSE )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bAsian)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CJK, FALSE )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ if (bComplex)
+ {
+ nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE_CTL, FALSE )).GetLanguage();
+ if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM)
+ aAllLangs.insert( nLang );
+ }
+ }
+ }
+ }
+ }
+ // less than nMaxCount languages
+ if (nMaxCount > static_cast< sal_Int16 >( aAllLangs.size() ))
+ nMaxCount = static_cast< sal_Int16 >( aAllLangs.size() );
+
+ // build return value
+ sal_Int32 nCount = 0;
+ uno::Sequence< lang::Locale > aLanguages( nMaxCount );
+ lang::Locale* pLanguage = aLanguages.getArray();
+ if (nMaxCount > 0)
+ {
+ const SvtLanguageTable aLangTab;
+ for (std::set< LanguageType >::const_iterator it = aAllLangs.begin(); it != aAllLangs.end(); ++it)
+ {
+ if (nCount >= nMaxCount)
+ break;
+ if (LANGUAGE_NONE != *it)
+ {
+ MsLangId::convertLanguageToLocale( *it, pLanguage[nCount] );
+ pLanguage[nCount].Language = aLangTab.GetString( *it );
+ nCount += 1;
+ }
+ }
+ }
+
+ return aLanguages;
+}
+
+SwXLinkTargetSupplier::SwXLinkTargetSupplier(SwXTextDocument& rxDoc) :
+ pxDoc(&rxDoc)
+{
+ sTables = String(SW_RES(STR_CONTENT_TYPE_TABLE));
+ sFrames = String(SW_RES(STR_CONTENT_TYPE_FRAME));
+ sGraphics = String(SW_RES(STR_CONTENT_TYPE_GRAPHIC));
+ sOLEs = String(SW_RES(STR_CONTENT_TYPE_OLE));
+ sSections = String(SW_RES(STR_CONTENT_TYPE_REGION));
+ sOutlines = String(SW_RES(STR_CONTENT_TYPE_OUTLINE));
+ sBookmarks = String(SW_RES(STR_CONTENT_TYPE_BOOKMARK));
+}
+
+SwXLinkTargetSupplier::~SwXLinkTargetSupplier()
+{
+}
+
+Any SwXLinkTargetSupplier::getByName(const OUString& rName)
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException )
+{
+ Any aRet;
+ if(!pxDoc)
+ throw RuntimeException();
+ String sToCompare(rName);
+ String sSuffix('|');
+ if(sToCompare == sTables)
+ {
+ sSuffix += UniString::CreateFromAscii(pMarkToTable);
+
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getTextTables(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference<XPropertySet>*)0));
+ }
+ else if(sToCompare == sFrames)
+ {
+ sSuffix += UniString::CreateFromAscii(pMarkToFrame);
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getTextFrames(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else if(sToCompare == sSections)
+ {
+ sSuffix += UniString::CreateFromAscii(pMarkToRegion);
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getTextSections(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+/* else if(sToCompare == )
+ {
+ sSuffix += UniString::CreateFromAscii(pMarkToText);
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((const XPropertySet*)0));
+ }*/
+ else if(sToCompare == sGraphics)
+ {
+ sSuffix += UniString::CreateFromAscii(pMarkToGraphic);
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getGraphicObjects(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else if(sToCompare == sOLEs)
+ {
+ sSuffix += UniString::CreateFromAscii(pMarkToOLE);
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ pxDoc->getEmbeddedObjects(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else if(sToCompare == sOutlines)
+ {
+ sSuffix += UniString::CreateFromAscii(pMarkToOutline);
+ Reference< XNameAccess > xTbls = new SwXLinkNameAccessWrapper(
+ *pxDoc, sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xTbls, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else if(sToCompare == sBookmarks)
+ {
+ sSuffix.Erase();
+ Reference< XNameAccess > xBkms = new SwXLinkNameAccessWrapper(
+ pxDoc->getBookmarks(), sToCompare, sSuffix );
+ Reference< XPropertySet > xRet(xBkms, UNO_QUERY);
+ aRet.setValue(&xRet, ::getCppuType((Reference< XPropertySet>*)0));
+ }
+ else
+ throw NoSuchElementException();
+ return aRet;
+}
+
+Sequence< OUString > SwXLinkTargetSupplier::getElementNames(void)
+ throw( RuntimeException )
+{
+ Sequence< OUString > aRet(7);
+ OUString* pNames = aRet.getArray();
+ pNames[0] = sTables;
+ pNames[1] = sFrames ;
+ pNames[2] = sGraphics;
+ pNames[3] = sOLEs ;
+ pNames[4] = sSections;
+ pNames[5] = sOutlines;
+ pNames[6] = sBookmarks;
+ return aRet;
+}
+
+sal_Bool SwXLinkTargetSupplier::hasByName(const OUString& rName)
+ throw( RuntimeException )
+{
+ String sToCompare(rName);
+ if( sToCompare == sTables ||
+ sToCompare == sFrames ||
+ sToCompare == sGraphics||
+ sToCompare == sOLEs ||
+ sToCompare == sSections ||
+ sToCompare == sOutlines ||
+ sToCompare == sBookmarks )
+ return sal_True;
+ return sal_False;
+}
+
+uno::Type SwXLinkTargetSupplier::getElementType(void)
+ throw( RuntimeException )
+{
+ return ::getCppuType((Reference< XPropertySet>*)0);
+
+}
+
+sal_Bool SwXLinkTargetSupplier::hasElements(void) throw( RuntimeException )
+{
+ return 0 != pxDoc;
+}
+
+OUString SwXLinkTargetSupplier::getImplementationName(void) throw( RuntimeException )
+{
+ return C2U("SwXLinkTargetSupplier");
+}
+
+sal_Bool SwXLinkTargetSupplier::supportsService(const OUString& rServiceName)
+ throw( RuntimeException )
+{
+ return (rServiceName == C2U("com.sun.star.document.LinkTargets"));
+}
+
+Sequence< OUString > SwXLinkTargetSupplier::getSupportedServiceNames(void)
+ throw( RuntimeException )
+{
+ Sequence< OUString > aRet(1);
+ OUString* pNames = aRet.getArray();
+ pNames[0] = C2U("com.sun.star.document.LinkTargets");
+ return aRet;
+}
+
+SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(
+ Reference< XNameAccess > xAccess, const String& rLinkDisplayName, String sSuffix ) :
+ xRealAccess(xAccess),
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
+ sLinkSuffix(sSuffix),
+ sLinkDisplayName(rLinkDisplayName),
+ pxDoc(0)
+{
+}
+
+SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(SwXTextDocument& rxDoc,
+ const String& rLinkDisplayName, String sSuffix) :
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
+ sLinkSuffix(sSuffix),
+ sLinkDisplayName(rLinkDisplayName),
+ xDoc(&rxDoc),
+ pxDoc(&rxDoc)
+{
+}
+
+SwXLinkNameAccessWrapper::~SwXLinkNameAccessWrapper()
+{
+}
+
+Any SwXLinkNameAccessWrapper::getByName(const OUString& rName)
+ throw( NoSuchElementException, WrappedTargetException, RuntimeException )
+{
+ Any aRet;
+ sal_Bool bFound = sal_False;
+ //cut link extension and call the real NameAccess
+ String sParam = rName;
+ String sSuffix(sLinkSuffix);
+ if(sParam.Len() > sSuffix.Len() )
+ {
+ String sCmp = sParam.Copy(sParam.Len() - sSuffix.Len(),
+ sSuffix.Len());
+ if(sCmp == sSuffix)
+ {
+ if(pxDoc)
+ {
+ sParam = sParam.Copy(0, sParam.Len() - sSuffix.Len());
+ if(!pxDoc->GetDocShell())
+ throw RuntimeException();
+ SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
+ sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().Count();
+
+ for (sal_uInt16 i = 0; i < nOutlineCount && !bFound; ++i)
+ {
+ const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
+ const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
+ if(sParam ==
+ lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
+ {
+ Reference< XPropertySet > xOutline = new SwXOutlineTarget(sParam);
+ aRet.setValue(&xOutline, ::getCppuType((Reference<XPropertySet>*)0));
+ bFound = sal_True;
+ }
+ }
+ }
+ else
+ {
+ aRet = xRealAccess->getByName(sParam.Copy(0, sParam.Len() - sSuffix.Len()));
+ Reference< XInterface > xInt;
+ if(!(aRet >>= xInt))
+ throw RuntimeException();
+ Reference< XPropertySet > xProp(xInt, UNO_QUERY);
+ aRet <<= xProp;
+ bFound = sal_True;
+ }
+ }
+ }
+ if(!bFound)
+ throw NoSuchElementException();
+ return aRet;
+}
+
+Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames(void)
+ throw( RuntimeException )
+{
+ Sequence< OUString > aRet;
+ if(pxDoc)
+ {
+ if(!pxDoc->GetDocShell())
+ throw RuntimeException();
+
+ SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
+ const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
+ sal_uInt16 nOutlineCount = rOutlineNodes.Count();
+ aRet.realloc(nOutlineCount);
+ OUString* pResArr = aRet.getArray();
+ String sSuffix('|');
+ sSuffix += UniString::CreateFromAscii(pMarkToOutline);
+ const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
+ for (sal_uInt16 i = 0; i < nOutlineCount; ++i)
+ {
+ String sEntry = lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule);
+ sEntry += sSuffix;
+ pResArr[i] = sEntry;
+ }
+ }
+ else
+ {
+ Sequence< OUString > aOrg = xRealAccess->getElementNames();
+ const OUString* pOrgArr = aOrg.getConstArray();
+ aRet.realloc(aOrg.getLength());
+ OUString* pResArr = aRet.getArray();
+ for(long i = 0; i < aOrg.getLength(); i++)
+ {
+ pResArr[i] = pOrgArr[i] + sLinkSuffix;
+ }
+ }
+ return aRet;
+}
+
+sal_Bool SwXLinkNameAccessWrapper::hasByName(const OUString& rName)
+ throw( RuntimeException )
+{
+ sal_Bool bRet = sal_False;
+ String sParam(rName);
+ if(sParam.Len() > sLinkSuffix.Len() )
+ {
+ String sCmp = sParam.Copy(sParam.Len() - sLinkSuffix.Len(),
+ sLinkSuffix.Len());
+ if(sCmp == sLinkSuffix)
+ {
+ sParam = sParam.Copy(0, sParam.Len() - sLinkSuffix.Len());
+ if(pxDoc)
+ {
+ if(!pxDoc->GetDocShell())
+ throw RuntimeException();
+ SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc();
+ sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().Count();
+
+ for (sal_uInt16 i = 0; i < nOutlineCount && !bRet; ++i)
+ {
+ const SwOutlineNodes& rOutlineNodes = pDoc->GetNodes().GetOutLineNds();
+ const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule();
+ if(sParam ==
+ lcl_CreateOutlineString(i, rOutlineNodes, pOutlRule))
+ {
+ bRet = sal_True;
+ }
+ }
+ }
+ else
+ {
+ bRet = xRealAccess->hasByName(sParam);
+ }
+ }
+ }
+ return bRet;
+}
+
+uno::Type SwXLinkNameAccessWrapper::getElementType(void)
+ throw( RuntimeException )
+{
+ return ::getCppuType((Reference<XPropertySet>*)0);
+}
+
+sal_Bool SwXLinkNameAccessWrapper::hasElements(void) throw( RuntimeException )
+{
+ sal_Bool bRet = sal_False;
+ if(pxDoc)
+ {
+ OSL_ENSURE(false, "not implemented");
+ }
+ else
+ {
+ bRet = xRealAccess->hasElements();
+ }
+ return bRet;
+}
+
+Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo(void)
+ throw( RuntimeException )
+{
+ static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
+ return xRet;
+}
+
+void SwXLinkNameAccessWrapper::setPropertyValue(
+ const OUString& , const Any& )
+ throw( UnknownPropertyException,
+ PropertyVetoException,
+ IllegalArgumentException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ throw UnknownPropertyException();
+}
+
+Any lcl_GetDisplayBitmap(String sLinkSuffix)
+{
+ Any aRet;
+ if(sLinkSuffix.Len())
+ sLinkSuffix.Erase(0, 1);
+ sal_uInt16 nImgId = USHRT_MAX;
+
+ if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOutline))
+ nImgId = CONTENT_TYPE_OUTLINE;
+ else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToTable))
+ nImgId = CONTENT_TYPE_TABLE;
+ else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToFrame))
+ nImgId = CONTENT_TYPE_FRAME;
+ else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToGraphic))
+ nImgId = CONTENT_TYPE_GRAPHIC;
+// else if(== sLinkSuffix)
+// nImgId = CONTENT_TYPE_BOOKMARK;
+ else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToRegion))
+ nImgId = CONTENT_TYPE_REGION;
+ else if(COMPARE_EQUAL == sLinkSuffix.CompareToAscii(pMarkToOLE))
+ nImgId = CONTENT_TYPE_OLE;
+ else if(!sLinkSuffix.Len())
+ nImgId = CONTENT_TYPE_BOOKMARK;
+ if(USHRT_MAX != nImgId)
+ {
+ nImgId += 20000;
+ BOOL bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
+ ImageList aEntryImages( SW_RES(bHighContrast ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP) );
+ const Image& rImage = aEntryImages.GetImage( nImgId );
+ Bitmap aBitmap( rImage.GetBitmapEx().GetBitmap() );
+ Reference<awt::XBitmap> xBmp = VCLUnoHelper::CreateBitmap( aBitmap );
+ aRet.setValue( &xBmp, ::getCppuType((Reference<awt::XBitmap>*)0) );
+ }
+ return aRet;
+}
+
+Any SwXLinkNameAccessWrapper::getPropertyValue(const OUString& rPropertyName)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ Any aRet;
+ if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME)))
+ {
+ aRet <<= OUString(sLinkDisplayName);
+ }
+ else if( rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_BITMAP)))
+ {
+ aRet = lcl_GetDisplayBitmap(sLinkSuffix);
+ }
+ else
+ throw UnknownPropertyException();
+ return aRet;
+}
+
+void SwXLinkNameAccessWrapper::addPropertyChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{}
+
+void SwXLinkNameAccessWrapper::removePropertyChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{}
+
+void SwXLinkNameAccessWrapper::addVetoableChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{}
+
+void SwXLinkNameAccessWrapper::removeVetoableChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{}
+
+Reference< XNameAccess > SwXLinkNameAccessWrapper::getLinks(void)
+ throw( RuntimeException )
+{
+ return (SwXLinkNameAccessWrapper*)this;
+}
+
+OUString SwXLinkNameAccessWrapper::getImplementationName(void) throw( RuntimeException )
+{
+ return C2U("SwXLinkNameAccessWrapper");
+}
+
+sal_Bool SwXLinkNameAccessWrapper::supportsService(const OUString& rServiceName)
+ throw( RuntimeException )
+{
+ return (rServiceName == C2U("com.sun.star.document.LinkTargets"));
+}
+
+Sequence< OUString > SwXLinkNameAccessWrapper::getSupportedServiceNames(void)
+ throw( RuntimeException )
+{
+ Sequence< OUString > aRet(1);
+ OUString* pNames = aRet.getArray();
+ pNames[0] = C2U("com.sun.star.document.LinkTargets");
+ return aRet;
+}
+
+SwXOutlineTarget::SwXOutlineTarget(const String& rOutlineText) :
+ pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)),
+ sOutlineText(rOutlineText)
+{
+}
+
+SwXOutlineTarget::~SwXOutlineTarget()
+{
+}
+
+Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo(void) throw( RuntimeException )
+{
+ static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo();
+ return xRet;
+}
+
+void SwXOutlineTarget::setPropertyValue(
+ const OUString& /*PropertyName*/, const Any& /*aValue*/)
+ throw( UnknownPropertyException, PropertyVetoException,
+ IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ throw UnknownPropertyException();
+}
+
+Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ Any aRet;
+ if(rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_LINK_DISPLAY_NAME)))
+ aRet <<= OUString(sOutlineText);
+ else
+ throw UnknownPropertyException();
+ return aRet;
+}
+
+void SwXOutlineTarget::addPropertyChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+}
+
+void SwXOutlineTarget::removePropertyChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+}
+
+void SwXOutlineTarget::addVetoableChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+}
+
+void SwXOutlineTarget::removeVetoableChangeListener(
+ const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+}
+
+OUString SwXOutlineTarget::getImplementationName(void) throw( RuntimeException )
+{
+ return C2U("SwXOutlineTarget");
+}
+
+sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName) throw( RuntimeException )
+{
+ return C2U("com.sun.star.document.LinkTarget") == ServiceName;
+}
+
+Sequence< OUString > SwXOutlineTarget::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ Sequence < OUString > aRet(1);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = C2U("com.sun.star.document.LinkTarget");
+
+ return aRet;
+}
+
+SwXDocumentPropertyHelper::SwXDocumentPropertyHelper(SwDoc& rDoc) :
+SvxUnoForbiddenCharsTable ( rDoc.getForbiddenCharacterTable() )
+,m_pDoc(&rDoc)
+{
+}
+
+SwXDocumentPropertyHelper::~SwXDocumentPropertyHelper()
+{
+}
+
+Reference<XInterface> SwXDocumentPropertyHelper::GetDrawTable(short nWhich)
+{
+ Reference<XInterface> xRet;
+ if(m_pDoc)
+ {
+ switch(nWhich)
+ {
+ // --> OD 2005-08-08 #i52858#
+ // assure that Draw model is created, if it doesn't exist.
+ case SW_CREATE_DASH_TABLE :
+ if(!xDashTable.is())
+ xDashTable = SvxUnoDashTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xDashTable;
+ break;
+ case SW_CREATE_GRADIENT_TABLE :
+ if(!xGradientTable.is())
+ xGradientTable = SvxUnoGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xGradientTable;
+ break;
+ case SW_CREATE_HATCH_TABLE :
+ if(!xHatchTable.is())
+ xHatchTable = SvxUnoHatchTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xHatchTable;
+ break;
+ case SW_CREATE_BITMAP_TABLE :
+ if(!xBitmapTable.is())
+ xBitmapTable = SvxUnoBitmapTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xBitmapTable;
+ break;
+ case SW_CREATE_TRANSGRADIENT_TABLE:
+ if(!xTransGradientTable.is())
+ xTransGradientTable = SvxUnoTransGradientTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xTransGradientTable;
+ break;
+ case SW_CREATE_MARKER_TABLE :
+ if(!xMarkerTable.is())
+ xMarkerTable = SvxUnoMarkerTable_createInstance( m_pDoc->GetOrCreateDrawModel() );
+ xRet = xMarkerTable;
+ break;
+ // <--
+ case SW_CREATE_DRAW_DEFAULTS:
+ if(!xDrawDefaults.is())
+ xDrawDefaults = (cppu::OWeakObject*)new SwSvxUnoDrawPool(m_pDoc);
+ xRet = xDrawDefaults;
+ break;
+#if OSL_DEBUG_LEVEL > 1
+ default: OSL_ENSURE(false, "which table?");
+#endif
+ }
+ }
+ return xRet;
+}
+
+void SwXDocumentPropertyHelper::Invalidate()
+{
+ xDashTable = 0;
+ xGradientTable = 0;
+ xHatchTable = 0;
+ xBitmapTable = 0;
+ xTransGradientTable = 0;
+ xMarkerTable = 0;
+ xDrawDefaults = 0;
+ m_pDoc = 0;
+ SvxUnoForbiddenCharsTable::mxForbiddenChars.clear();
+}
+
+void SwXDocumentPropertyHelper::onChange()
+{
+ if(m_pDoc)
+ m_pDoc->SetModified();
+}
+
+SwViewOptionAdjust_Impl::SwViewOptionAdjust_Impl( SwWrtShell& rSh, const SwViewOption &rViewOptions ) :
+ m_rShell( rSh ),
+ m_aOldViewOptions( rViewOptions )
+{
+}
+
+SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl()
+{
+ m_rShell.ApplyViewOptions( m_aOldViewOptions );
+}
+
+void SwViewOptionAdjust_Impl::AdjustViewOptions(
+ const SwPrtOptions *pPrtOptions )
+{
+ // to avoid unnecessary reformatting the view options related to the content
+ // below should only change if necessary, that is if respective content is present
+ const bool bContainsHiddenChars = m_rShell.GetDoc()->ContainsHiddenChars();
+ const SwFieldType* pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENTXTFLD );
+ const bool bContainsHiddenFields = pFldType && pFldType->GetDepends();
+ pFldType = m_rShell.GetDoc()->GetSysFldType( RES_HIDDENPARAFLD );
+ const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends();
+ pFldType = m_rShell.GetDoc()->GetSysFldType( RES_JUMPEDITFLD );
+ const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends();
+ const bool bContainsFields = m_rShell.IsAnyFieldInDoc();
+
+ SwViewOption aRenderViewOptions( m_aOldViewOptions );
+
+ // disable anything in the view that should not be printed (or exported to PDF) by default
+ // (see also dialog "Tools/Options - StarOffice Writer - Formatting Aids"
+ // in section "Display of ...")
+ aRenderViewOptions.SetParagraph( FALSE ); // paragraph end
+ aRenderViewOptions.SetSoftHyph( FALSE ); // aka custom hyphens
+ aRenderViewOptions.SetBlank( FALSE ); // spaces
+ aRenderViewOptions.SetHardBlank( FALSE ); // non-breaking spaces
+ aRenderViewOptions.SetTab( FALSE ); // tabs
+ aRenderViewOptions.SetLineBreak( FALSE ); // breaks (type 1)
+ aRenderViewOptions.SetPageBreak( FALSE ); // breaks (type 2)
+ aRenderViewOptions.SetColumnBreak( FALSE ); // breaks (type 3)
+ BOOL bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : FALSE;
+ if (bContainsHiddenChars)
+ aRenderViewOptions.SetShowHiddenChar( bVal ); // hidden text
+ if (bContainsHiddenFields)
+ aRenderViewOptions.SetShowHiddenField( bVal );
+ if (bContainsHiddenParagraphs)
+ aRenderViewOptions.SetShowHiddenPara( bVal );
+
+ if (bContainsPlaceHolders)
+ {
+ // should always be printed in PDF export!
+ bVal = pPrtOptions ? pPrtOptions->bPrintTextPlaceholder : TRUE;
+ aRenderViewOptions.SetShowPlaceHolderFields( bVal );
+ }
+
+ if (bContainsFields)
+ aRenderViewOptions.SetFldName( FALSE );
+
+ // we need to set this flag in order to get to see the visible effect of
+ // some of the above settings (needed for correct rendering)
+ aRenderViewOptions.SetViewMetaChars( TRUE );
+
+ if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary
+ {
+ aRenderViewOptions.SetPrinting( pPrtOptions != NULL );
+ m_rShell.ApplyViewOptions( aRenderViewOptions );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/uno/unotxvw.cxx b/sw/source/ui/uno/unotxvw.cxx
new file mode 100644
index 000000000000..a4c276c8382f
--- /dev/null
+++ b/sw/source/ui/uno/unotxvw.cxx
@@ -0,0 +1,2023 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_sw.hxx"
+
+#include "viscrs.hxx"
+#include <sfx2/frame.hxx>
+#include <sfx2/printer.hxx>
+#include <cmdid.h>
+#include <hintids.hxx>
+#include <docsh.hxx>
+#include <rubylist.hxx>
+#include <doc.hxx>
+#include <unotxvw.hxx>
+#include <unodispatch.hxx>
+#include <unomap.hxx>
+#include <unostyle.hxx>
+#include <unoprnms.hxx>
+#include <view.hxx>
+#include <viewopt.hxx>
+#include <unomod.hxx>
+#include <unoframe.hxx>
+#include <unocrsr.hxx>
+#include <wrtsh.hxx>
+#include <unotbl.hxx>
+#include <svx/fmshell.hxx>
+#include <svx/svdview.hxx>
+#include <svx/svdpage.hxx>
+#include <svx/svdouno.hxx>
+#include <svx/svdogrp.hxx>
+#include <editeng/pbinitem.hxx>
+#include <pagedesc.hxx>
+#include <editeng/lrspitem.hxx>
+#include <editeng/ulspitem.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/request.hxx>
+#include <frmatr.hxx>
+#include <osl/mutex.hxx>
+#include <IMark.hxx>
+#include <unotxdoc.hxx>
+#include <unodraw.hxx>
+#include <svx/unoshcol.hxx>
+#include <svx/unoshape.hxx>
+#include <svx/svdpagv.hxx>
+#include <swerror.h>
+#include <tools/cachestr.hxx>
+#include <shellio.hxx>
+#include <ndtxt.hxx>
+#include <SwStyleNameMapper.hxx>
+#include <crsskip.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <editeng/outliner.hxx>
+#include <editeng/editview.hxx>
+#include <unobookmark.hxx>
+#include <unoparagraph.hxx>
+#include <unocrsrhelper.hxx>
+#include <unotextrange.hxx>
+#include <sfx2/docfile.hxx>
+
+#include "swdtflvr.hxx"
+#include <vcl/svapp.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::view;
+using namespace ::com::sun::star::frame;
+using namespace rtl;
+
+using ::com::sun::star::util::URL;
+using comphelper::HelperBaseNoState;
+
+SV_IMPL_PTRARR( SelectionChangeListenerArr, XSelectionChangeListenerPtr );
+
+SwPaM* lcl_createPamCopy(const SwPaM& rPam)
+{
+ SwPaM *const pRet = new SwPaM(*rPam.GetPoint());
+ ::sw::DeepCopyPaM(rPam, *pRet);
+ return pRet;
+}
+
+/******************************************************************
+ * SwXTextView
+ ******************************************************************/
+SwXTextView::SwXTextView(SwView* pSwView) :
+ SfxBaseController(pSwView),
+ m_pView(pSwView),
+ m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_TEXT_VIEW ) ),
+ pxViewSettings(0),
+ pxTextViewCursor(0)
+{
+
+}
+
+SwXTextView::~SwXTextView()
+{
+ Invalidate();
+}
+
+void SwXTextView::Invalidate()
+{
+ if(pxViewSettings)
+ {
+ HelperBaseNoState *pSettings = static_cast < HelperBaseNoState * > ( pxViewSettings->get() );
+ static_cast < SwXViewSettings* > ( pSettings )->Invalidate();
+ DELETEZ(pxViewSettings);
+ }
+ if(pxTextViewCursor)
+ {
+ text::XTextViewCursor* pCrsr = pxTextViewCursor->get();
+ ((SwXTextViewCursor*)pCrsr)->Invalidate();
+ DELETEZ(pxTextViewCursor);
+ }
+
+ m_refCount++; //prevent second d'tor call
+
+ sal_uInt16 nCount = aSelChangedListeners.Count();
+ if(nCount)
+ {
+ uno::Reference< uno::XInterface > xInt = (cppu::OWeakObject*)(SfxBaseController*)this;
+ lang::EventObject aEvent(xInt);
+ for ( sal_uInt16 i = nCount; i--; )
+ {
+ uno::Reference< view::XSelectionChangeListener > *pObj = aSelChangedListeners[i];
+ (*pObj)->disposing(aEvent);
+ }
+ }
+
+ // #i85580: now clean up any possibly remaining entries in the array...
+ // (i.e. listeners that did not call removeSelectionChangeListener in their disposing.)
+ while ((nCount = aSelChangedListeners.Count()) != 0)
+ {
+ removeSelectionChangeListener( *aSelChangedListeners[0] );
+ }
+
+ m_refCount--;
+ m_pView = 0;
+}
+
+Sequence< uno::Type > SAL_CALL SwXTextView::getTypes( ) throw(uno::RuntimeException)
+{
+// uno::Sequence< uno::Type > aViewTypes = SwXTextViewBaseClass::getTypes();
+ uno::Sequence< uno::Type > aBaseTypes = SfxBaseController::getTypes();
+
+ long nIndex = aBaseTypes.getLength();
+ aBaseTypes.realloc(
+ aBaseTypes.getLength() + 8 );
+
+ uno::Type* pBaseTypes = aBaseTypes.getArray();
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XSelectionSupplier >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XServiceInfo >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XFormLayerAccess >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XTextViewCursorSupplier>*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XViewSettingsSupplier >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XRubySelection >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<XPropertySet >*)0);
+ pBaseTypes[nIndex++] = ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier >*)0);
+ return aBaseTypes;
+}
+
+Sequence< sal_Int8 > SAL_CALL SwXTextView::getImplementationId( ) throw(uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static Sequence< sal_Int8 > aId( 16 );
+ static sal_Bool bInit = sal_False;
+ if(!bInit)
+ {
+ rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True );
+ bInit = sal_True;
+ }
+ return aId;
+}
+
+void SAL_CALL SwXTextView::acquire( )throw()
+{
+ SfxBaseController::acquire();
+}
+
+void SAL_CALL SwXTextView::release( )throw()
+{
+ SfxBaseController::release();
+}
+
+uno::Any SAL_CALL SwXTextView::queryInterface( const uno::Type& aType )
+ throw (RuntimeException)
+{
+ uno::Any aRet;
+ if(aType == ::getCppuType((uno::Reference<view::XSelectionSupplier >*)0))
+ {
+ uno::Reference<view::XSelectionSupplier> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<lang::XServiceInfo >*)0))
+ {
+ uno::Reference<lang::XServiceInfo> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<view::XControlAccess >*)0))
+ {
+ uno::Reference<view::XControlAccess> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<view::XFormLayerAccess >*)0))
+ {
+ uno::Reference<view::XFormLayerAccess> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<text::XTextViewCursorSupplier>*)0))
+ {
+ uno::Reference<text::XTextViewCursorSupplier> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<view::XViewSettingsSupplier >*)0))
+ {
+ uno::Reference<view::XViewSettingsSupplier> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<XRubySelection>*)0))
+ {
+ uno::Reference<XRubySelection> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<XPropertySet>*)0))
+ {
+ uno::Reference<XPropertySet> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else if(aType == ::getCppuType((uno::Reference<datatransfer::XTransferableSupplier >*)0))
+ {
+ uno::Reference<datatransfer::XTransferableSupplier> xRet = this;
+ aRet.setValue(&xRet, aType);
+ }
+ else
+ aRet = SfxBaseController::queryInterface(aType);
+ return aRet;
+}
+
+sal_Bool SwXTextView::select(const uno::Any& aInterface) throw( lang::IllegalArgumentException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< uno::XInterface > xInterface;
+ if(GetView() && (aInterface >>= xInterface))
+ {
+ SwWrtShell& rSh = GetView()->GetWrtShell();
+ SwDoc* pDoc = GetView()->GetDocShell()->GetDoc();
+ uno::Reference< lang::XUnoTunnel > xIfcTunnel(xInterface, uno::UNO_QUERY);
+ uno::Reference< text::XTextCursor > xCrsr(xInterface, uno::UNO_QUERY);
+ uno::Reference< container::XIndexAccess > xPosN(xInterface, uno::UNO_QUERY);
+ uno::Reference< text::XTextRange > xPos(xInterface, uno::UNO_QUERY);
+ SwXFrame* pFrame = xIfcTunnel.is() ? reinterpret_cast<SwXFrame*>(
+ xIfcTunnel->getSomething(SwXFrame::getUnoTunnelId())) : 0;
+
+ SwXCell* pCell = xIfcTunnel.is() ? reinterpret_cast<SwXCell*>(
+ xIfcTunnel->getSomething(SwXCell::getUnoTunnelId())) : 0;
+
+ SwPaM * pPam = 0;
+ SwXTextRanges* pPosN = 0;
+ if(xCrsr.is())
+ {
+ //
+ OTextCursorHelper* pCursor =
+ xIfcTunnel.is() ?
+ reinterpret_cast<OTextCursorHelper*>(xIfcTunnel->getSomething(OTextCursorHelper::getUnoTunnelId()))
+ : 0;
+
+ if(pCursor && pCursor->GetDoc() == GetView()->GetDocShell()->GetDoc())
+ {
+ pPam = lcl_createPamCopy(*pCursor->GetPaM());
+ }
+ }
+ else if(xPosN.is() &&
+ xIfcTunnel.is() &&
+ 0 != (pPosN = reinterpret_cast<SwXTextRanges*>(xIfcTunnel->getSomething(SwXTextRanges::getUnoTunnelId()))))
+ {
+ const SwUnoCrsr* pUnoCrsr = pPosN->GetCursor();
+ if(pUnoCrsr)
+ {
+ pPam = lcl_createPamCopy(*pUnoCrsr);
+ }
+ }
+ // prevent misinterpretation of text frames that provide a XTextRange interface, too
+ else if(!pFrame && !pCell && xPos.is())
+ {
+ SwUnoInternalPaM aPam(*pDoc);
+ if (::sw::XTextRangeToSwPaM(aPam, xPos))
+ {
+ pPam = lcl_createPamCopy(aPam);
+ }
+ }
+ if(pPam)
+ {
+ rSh.EnterStdMode();
+ rSh.SetSelection(*pPam);
+ while( pPam->GetNext() != pPam )
+ delete pPam->GetNext();
+ delete pPam;
+ return sal_True;
+ }
+ if(pFrame)
+ {
+
+ SwFrmFmt* pFrmFmt = pFrame->GetFrmFmt();
+ if(pFrmFmt && pFrmFmt->GetDoc() == pDoc)
+ {
+ sal_Bool bSuccess = rSh.GotoFly( pFrmFmt->GetName(), pFrame->GetFlyCntType());
+ if (bSuccess)
+ {
+ rSh.HideCrsr();
+ rSh.EnterSelFrmMode();
+ }
+ return sal_True;
+ }
+ }
+
+ uno::Reference< text::XTextTable > xTbl(xInterface, uno::UNO_QUERY);;
+
+ if(xTbl.is() && xIfcTunnel.is())
+ {
+ SwXTextTable* pTable = reinterpret_cast<SwXTextTable*>(
+ xIfcTunnel->getSomething(SwXTextTable::getUnoTunnelId()));
+
+ SwFrmFmt* pTblFrmFmt = pTable ? ((SwXTextTable*)pTable)->GetFrmFmt() : 0;
+ if(pTblFrmFmt &&pTblFrmFmt->GetDoc() == pDoc)
+ {
+ rSh.EnterStdMode();
+ rSh.GotoTable(pTblFrmFmt->GetName());
+ }
+ return sal_True;
+ }
+
+ if(pCell)
+ {
+ SwFrmFmt* pTblFrmFmt = pCell->GetFrmFmt();
+ if(pTblFrmFmt && pTblFrmFmt->GetDoc() == pDoc)
+ {
+ SwTableBox* pBox = pCell->GetTblBox();
+ SwTable* pTable = SwTable::FindTable( pTblFrmFmt );
+ pBox = pCell->FindBox(pTable, pBox);
+ if(pBox)
+ {
+ const SwStartNode* pSttNd = pBox->GetSttNd();
+ SwPosition aPos(*pSttNd);
+ SwPaM aPam(aPos);
+ aPam.Move(fnMoveForward, fnGoNode);
+ rSh.EnterStdMode();
+ rSh.SetSelection(aPam);
+ return sal_True;
+ }
+ }
+ }
+ SwXCellRange* pRange = xIfcTunnel.is() ? reinterpret_cast<SwXCellRange*>(
+ xIfcTunnel->getSomething(SwXCellRange::getUnoTunnelId())) : 0;
+ if(pRange)
+ {
+ const SwUnoCrsr* pUnoCrsr = pRange->GetTblCrsr();
+ if(pUnoCrsr)
+ {
+ UnoActionRemoveContext aContext(pDoc);
+ rSh.EnterStdMode();
+ rSh.SetSelection(*pUnoCrsr);
+ return sal_True;
+ }
+ }
+ uno::Reference< text::XTextContent > xBkm(xInterface, uno::UNO_QUERY);;
+
+ if(xBkm.is() && xIfcTunnel.is())
+ {
+ ::sw::mark::IMark const*const pMark(
+ SwXBookmark::GetBookmarkInDoc(pDoc, xIfcTunnel) );
+ if (pMark)
+ {
+ rSh.EnterStdMode();
+ rSh.GotoMark(pMark);
+ }
+ return sal_True;
+ }
+ // IndexMark, Index, TextField, Draw, Section, Footnote, Paragraph
+ //
+
+ // detect controls
+
+ uno::Reference< awt::XControlModel > xCtrlModel(xInterface, UNO_QUERY);
+ if(xCtrlModel.is())
+ {
+ uno::Reference<awt::XControl> XControl;
+ SdrObject* pObj = GetControl(xCtrlModel, XControl);
+ if(pObj)
+ {
+ SdrView* pDrawView = rSh.GetDrawView();
+ SdrPageView* pPV = pDrawView->GetSdrPageView();
+ if ( pPV && pObj->GetPage() == pPV->GetPage() )
+ {
+ pDrawView->SdrEndTextEdit();
+ pDrawView->UnmarkAll();
+ pDrawView->MarkObj( pObj, pPV );
+ }
+ return sal_True;
+ }
+ }
+
+ uno::Reference< drawing::XShapes > xShapeColl( xInterface, uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xTmpProp(xInterface, uno::UNO_QUERY);
+ SwXShape* pSwXShape = 0;
+ if(xIfcTunnel.is())
+ pSwXShape = reinterpret_cast<SwXShape*>(xIfcTunnel->getSomething(SwXShape::getUnoTunnelId()));
+ SvxShape* pSvxShape = 0;
+ if(pSwXShape)
+ {
+ uno::Reference< uno::XAggregation > xAgg = pSwXShape->GetAggregationInterface();
+ if(xAgg.is())
+ {
+ pSvxShape = reinterpret_cast<SvxShape*>(xIfcTunnel->getSomething(SvxShape::getUnoTunnelId()));
+ }
+ }
+
+ if ( pSvxShape || xShapeColl.is() ) // Drawing drawing::Layer
+ {
+ SdrView* pDrawView = rSh.GetDrawView();
+ if (pDrawView)
+ {
+ pDrawView->SdrEndTextEdit();
+ pDrawView->UnmarkAll();
+
+ if (pSvxShape) // einzelnes Shape
+ {
+ SdrObject *pObj = pSvxShape->GetSdrObject();
+ if (pObj)
+ {
+// lcl_ShowObject( *m_pViewSh, *pDrawView, pObj );
+ SdrPageView* pPV = pDrawView->GetSdrPageView();
+ if ( pPV && pObj->GetPage() == pPV->GetPage() )
+ {
+ pDrawView->MarkObj( pObj, pPV );
+ return sal_True;
+ }
+ }
+ }
+ else // Shape Collection
+ {
+ sal_Bool bSelected = sal_False;
+ SdrPageView* pPV = NULL;
+ long nCount = xShapeColl->getCount();
+ for ( long i = 0; i < nCount; i++ )
+ {
+ uno::Reference< drawing::XShape > xShapeInt;
+ uno::Any aAny = xShapeColl->getByIndex(i);
+ aAny >>= xShapeInt;
+ if (xShapeInt.is())
+ {
+ uno::Reference< lang::XUnoTunnel> xShapeTunnel(xShapeInt, uno::UNO_QUERY);
+
+ SvxShape* pShape = xShapeTunnel.is() ?
+ reinterpret_cast<SvxShape*>(xShapeTunnel->getSomething(SvxShape::getUnoTunnelId())) : 0;
+
+ if (pShape)
+ {
+ SdrObject *pObj = pShape->GetSdrObject();
+ if (pObj)
+ {
+ if (!pPV) // erstes Objekt
+ {
+// lcl_ShowObject( *m_pViewSh, *pDrawView, pObj );
+ pPV = pDrawView->GetSdrPageView();
+ }
+ if ( pPV && pObj->GetPage() == pPV->GetPage() )
+ {
+ pDrawView->MarkObj( pObj, pPV );
+ bSelected = sal_True;
+ }
+ }
+ }
+ }
+ }
+ return bSelected;
+ }
+ }
+ }
+ }
+ return sal_False;
+
+}
+
+uno::Any SwXTextView::getSelection(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< uno::XInterface > aRef;
+ if(GetView())
+ {
+ //force immediat shell update
+ m_pView->StopShellTimer();
+ // ein interface aus der aktuellen Selektion erzeugen
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ ShellModes eSelMode = m_pView->GetShellMode();
+ switch(eSelMode)
+ {
+ case SHELL_MODE_TABLE_TEXT :
+ {
+ if(rSh.GetTableCrsr())
+ {
+ OSL_ENSURE(rSh.GetTableFmt(), "kein Tabellenformat?");
+ uno::Reference< text::XTextTableCursor > xCrsr = new SwXTextTableCursor(*rSh.GetTableFmt(),
+ rSh.GetTableCrsr());
+ aRef = uno::Reference< uno::XInterface > (xCrsr, uno::UNO_QUERY);;
+ break;
+ }
+
+ }
+ // ohne Tabellenselektion wird der Text geliefert
+ //break;
+ case SHELL_MODE_LIST_TEXT :
+ case SHELL_MODE_TABLE_LIST_TEXT:
+ case SHELL_MODE_TEXT :
+ {
+ uno::Reference< container::XIndexAccess > xPos = new SwXTextRanges(rSh.GetCrsr());
+ aRef = uno::Reference< uno::XInterface >(xPos, uno::UNO_QUERY);
+ }
+ break;
+ case SHELL_MODE_FRAME :
+ case SHELL_MODE_GRAPHIC :
+ case SHELL_MODE_OBJECT :
+ {
+ //Get FlyFrameFormat; fuer UI Macro Anbindung an Flys
+ const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt();
+ if (pFmt)
+ {
+ SwXFrame* pxFrame = (SwXFrame*)SwClientIter((SwFrmFmt&)*pFmt).
+ First(TYPE(SwXFrame));
+
+ if(pxFrame) //das einzige gemeinsame interface fuer alle Frames
+ {
+ aRef = uno::Reference< uno::XInterface >((cppu::OWeakObject*)pxFrame, uno::UNO_QUERY);
+ }
+ else
+ {
+ if(SHELL_MODE_FRAME == eSelMode)
+ {
+ uno::Reference< text::XTextFrame > xFrm = new SwXTextFrame((SwFrmFmt&)*pFmt);
+ aRef = uno::Reference< uno::XInterface >(xFrm, uno::UNO_QUERY);
+ }
+ else if(SHELL_MODE_GRAPHIC == eSelMode)
+ {
+ uno::Reference< text::XTextContent > xFrm = new SwXTextGraphicObject((SwFrmFmt&)*pFmt);
+ aRef = xFrm;
+ }
+ else
+ {
+ uno::Reference< text::XTextContent > xFrm = new SwXTextEmbeddedObject((SwFrmFmt&)*pFmt);
+ aRef = xFrm;
+ }
+ }
+ }
+ }
+ break;
+ case SHELL_MODE_DRAW :
+ case SHELL_MODE_DRAW_CTRL :
+ case SHELL_MODE_DRAW_FORM :
+ case SHELL_MODE_DRAWTEXT :
+ case SHELL_MODE_BEZIER :
+ {
+ uno::Reference< drawing::XDrawPageSupplier > xPageSupp;
+ uno::Reference< frame::XModel > xModel = m_pView->GetDocShell()->GetBaseModel();
+ uno::Reference< lang::XUnoTunnel > xModelTunnel(xModel, uno::UNO_QUERY);
+ SwXTextDocument* pTextDoc = reinterpret_cast<SwXTextDocument*>(xModelTunnel->
+ getSomething(SwXTextDocument::getUnoTunnelId()));
+
+ SwFmDrawPage* pSvxDrawPage = pTextDoc->GetDrawPage()->GetSvxPage();
+ uno::Reference< drawing::XShapes > xShCol = new SvxShapeCollection();
+
+ const SdrMarkList& rMarkList = rSh.GetDrawView()->GetMarkedObjectList();
+ for(sal_uInt16 i = 0; i < rMarkList.GetMarkCount(); i++)
+ {
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
+ uno::Reference< uno::XInterface > xInt = pSvxDrawPage->GetInterface( pObj );
+ uno::Reference< drawing::XShape > xShape(xInt, uno::UNO_QUERY);;
+ xShCol->add(xShape);
+ }
+ aRef = uno::Reference< uno::XInterface >(xShCol, uno::UNO_QUERY);
+ }
+ break;
+ default:;//prevent warning
+ }
+ }
+ uno::Any aRet(&aRef, ::getCppuType((uno::Reference<uno::XInterface>*)0));
+ return aRet;
+}
+
+void SwXTextView::addSelectionChangeListener(
+ const uno::Reference< view::XSelectionChangeListener > & rxListener)
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< view::XSelectionChangeListener > * pInsert = new uno::Reference< view::XSelectionChangeListener > ;
+ *pInsert = rxListener;
+ aSelChangedListeners.Insert(pInsert, aSelChangedListeners.Count());
+}
+
+void SwXTextView::removeSelectionChangeListener(
+ const uno::Reference< view::XSelectionChangeListener > & rxListener)
+ throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ view::XSelectionChangeListener* pLeft = rxListener.get();
+ for(sal_uInt16 i = 0; i < aSelChangedListeners.Count(); i++)
+ {
+ uno::Reference< view::XSelectionChangeListener > * pElem = aSelChangedListeners.GetObject(i);
+ view::XSelectionChangeListener* pRight = pElem->get();
+ if(pLeft == pRight)
+ {
+ aSelChangedListeners.Remove(i);
+ delete pElem;
+ break;
+ }
+ }
+}
+
+SdrObject* SwXTextView::GetControl(
+ const uno::Reference< awt::XControlModel > & xModel,
+ uno::Reference< awt::XControl >& xToFill )
+{
+ SwView* pView2 = GetView();
+ FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
+ SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL;
+ Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL;
+
+ OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::GetControl: how could I?" );
+
+ SdrObject* pControl = NULL;
+ if ( pFormShell && pDrawView && pWindow )
+ pControl = pFormShell->GetFormControl( xModel, *pDrawView, *pWindow, xToFill );
+ return pControl;
+}
+
+uno::Reference< awt::XControl > SwXTextView::getControl(const uno::Reference< awt::XControlModel > & xModel)
+ throw( container::NoSuchElementException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< awt::XControl > xRet;
+ GetControl(xModel, xRet);
+ return xRet;
+}
+
+uno::Reference< form::runtime::XFormController > SAL_CALL SwXTextView::getFormController( const uno::Reference< form::XForm >& _Form ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ SwView* pView2 = GetView();
+ FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
+ SdrView* pDrawView = pView2 ? pView2->GetDrawView() : NULL;
+ Window* pWindow = pView2 ? pView2->GetWrtShell().GetWin() : NULL;
+ OSL_ENSURE( pFormShell && pDrawView && pWindow, "SwXTextView::getFormController: how could I?" );
+
+ uno::Reference< form::runtime::XFormController > xController;
+ if ( pFormShell && pDrawView && pWindow )
+ xController = pFormShell->GetFormController( _Form, *pDrawView, *pWindow );
+ return xController;
+}
+
+::sal_Bool SAL_CALL SwXTextView::isFormDesignMode( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SwView* pView2 = GetView();
+ FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
+ return pFormShell ? pFormShell->IsDesignMode() : sal_True;
+}
+
+void SAL_CALL SwXTextView::setFormDesignMode( ::sal_Bool _DesignMode ) throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ SwView* pView2 = GetView();
+ FmFormShell* pFormShell = pView2 ? pView2->GetFormShell() : NULL;
+ if ( pFormShell )
+ pFormShell->SetDesignMode( _DesignMode );
+}
+
+uno::Reference< text::XTextViewCursor > SwXTextView::getViewCursor(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(GetView())
+ {
+ if(!pxTextViewCursor)
+ {
+ ((SwXTextView*)this)->pxTextViewCursor = new uno::Reference< text::XTextViewCursor > ;
+ *pxTextViewCursor = new SwXTextViewCursor(GetView());
+ }
+ return *pxTextViewCursor;
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+uno::Reference< beans::XPropertySet > SwXTextView::getViewSettings(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if(!pxViewSettings)
+ {
+ ((SwXTextView*)this)->pxViewSettings = new uno::Reference< beans::XPropertySet > ;
+ *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, m_pView ) );
+ }
+ }
+ else
+ throw uno::RuntimeException();
+ return *pxViewSettings;
+}
+
+Sequence< Sequence< PropertyValue > > SwXTextView::getRubyList( sal_Bool /*bAutomatic*/ ) throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if(!GetView())
+ throw RuntimeException();
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ ShellModes eSelMode = m_pView->GetShellMode();
+ if (eSelMode != SHELL_MODE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_TEXT &&
+ eSelMode != SHELL_MODE_TEXT )
+ return Sequence< Sequence< PropertyValue > > ();
+
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ SwRubyList aList;
+
+ USHORT nCount = pDoc->FillRubyList( *rSh.GetCrsr(), aList, 0 );
+ Sequence< Sequence< PropertyValue > > aRet(nCount);
+ Sequence< PropertyValue >* pRet = aRet.getArray();
+ String aString;
+ for(USHORT n = 0; n < nCount; n++)
+ {
+ const SwRubyListEntryPtr pEntry = aList[n];
+
+ const String& rEntryText = pEntry->GetText();
+ const SwFmtRuby& rAttr = pEntry->GetRubyAttr();
+
+ pRet[n].realloc(5);
+ PropertyValue* pValues = pRet[n].getArray();
+ pValues[0].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_BASE_TEXT));
+ pValues[0].Value <<= OUString(rEntryText);
+ pValues[1].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_TEXT));
+ pValues[1].Value <<= OUString(rAttr.GetText());
+ pValues[2].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_CHAR_STYLE_NAME));
+ SwStyleNameMapper::FillProgName(rAttr.GetCharFmtName(), aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
+ pValues[2].Value <<= OUString( aString );
+ pValues[3].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_ADJUST));
+ pValues[3].Value <<= (sal_Int16)rAttr.GetAdjustment();
+ pValues[4].Name = C2U(SW_PROP_NAME_STR(UNO_NAME_RUBY_IS_ABOVE));
+ sal_Bool bVal = !rAttr.GetPosition();
+ pValues[4].Value.setValue(&bVal, ::getBooleanCppuType());
+ }
+ return aRet;
+}
+
+void SAL_CALL SwXTextView::setRubyList(
+ const Sequence< Sequence< PropertyValue > >& rRubyList, sal_Bool /*bAutomatic*/ )
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if(!GetView() || !rRubyList.getLength())
+ throw RuntimeException();
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ ShellModes eSelMode = m_pView->GetShellMode();
+ if (eSelMode != SHELL_MODE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_TEXT &&
+ eSelMode != SHELL_MODE_TEXT )
+ throw RuntimeException();
+
+ SwRubyList aList;
+
+ const Sequence<PropertyValue>* pRubyList = rRubyList.getConstArray();
+ for(sal_Int32 nPos = 0; nPos < rRubyList.getLength(); nPos++)
+ {
+ SwRubyListEntryPtr pEntry = new SwRubyListEntry;
+ const PropertyValue* pProperties = pRubyList[nPos].getConstArray();
+ OUString sTmp;
+ for(sal_Int32 nProp = 0; nProp < pRubyList[nPos].getLength(); nProp++)
+ {
+ if(pProperties[nProp].Name.equalsAsciiL(
+ SW_PROP_NAME(UNO_NAME_RUBY_BASE_TEXT)))
+ {
+ pProperties[nProp].Value >>= sTmp;
+ pEntry->SetText(sTmp);
+ }
+ else if(pProperties[nProp].Name.equalsAsciiL(
+ SW_PROP_NAME(UNO_NAME_RUBY_TEXT)))
+ {
+ pProperties[nProp].Value >>= sTmp;
+ pEntry->GetRubyAttr().SetText(sTmp);
+ }
+ else if(pProperties[nProp].Name.equalsAsciiL(
+ SW_PROP_NAME(UNO_NAME_RUBY_CHAR_STYLE_NAME)))
+ {
+ if((pProperties[nProp].Value >>= sTmp))
+ {
+ String sName;
+ SwStyleNameMapper::FillUIName(sTmp, sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, sal_True );
+ sal_uInt16 nPoolId = sName.Len() ?
+ SwStyleNameMapper::GetPoolIdFromUIName( sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ) : 0;
+
+ pEntry->GetRubyAttr().SetCharFmtName( sName );
+ pEntry->GetRubyAttr().SetCharFmtId( nPoolId );
+ }
+ }
+ else if(pProperties[nProp].Name.equalsAsciiL(
+ SW_PROP_NAME(UNO_NAME_RUBY_ADJUST)))
+ {
+ sal_Int16 nTmp = 0;
+ if((pProperties[nProp].Value >>= nTmp))
+ pEntry->GetRubyAttr().SetAdjustment(nTmp);
+ }
+ else if(pProperties[nProp].Name.equalsAsciiL(
+ SW_PROP_NAME(UNO_NAME_RUBY_IS_ABOVE)))
+ {
+ sal_Bool bValue = pProperties[nProp].Value.hasValue() ?
+ *(sal_Bool*)pProperties[nProp].Value.getValue() : sal_True;
+ pEntry->GetRubyAttr().SetPosition(bValue ? 0 : 1);
+ }
+ }
+ aList.Insert(pEntry, (USHORT)nPos);
+ }
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ pDoc->SetRubyList( *rSh.GetCrsr(), aList, 0 );
+}
+
+SfxObjectShellRef SwXTextView::BuildTmpSelectionDoc( SfxObjectShellRef& /*rRef*/ )
+{
+ SwWrtShell& rOldSh = m_pView->GetWrtShell();
+ SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess()->getPrinter( false );
+ SwDocShell* pDocSh;
+ SfxObjectShellRef xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) );
+ xDocSh->DoInitNew( 0 );
+ rOldSh.FillPrtDoc(pDocSh->GetDoc(), pPrt);
+ SfxViewFrame* pDocFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 );
+ SwView* pDocView = (SwView*) pDocFrame->GetViewShell();
+ pDocView->AttrChangedNotify( &pDocView->GetWrtShell() );//Damit SelectShell gerufen wird.
+ SwWrtShell* pSh = pDocView->GetWrtShellPtr();
+
+ IDocumentDeviceAccess* pIDDA = pSh->getIDocumentDeviceAccess();
+ SfxPrinter* pTempPrinter = pIDDA->getPrinter( true );
+
+ const SwPageDesc& rCurPageDesc = rOldSh.GetPageDesc(rOldSh.GetCurPageDesc());
+
+ IDocumentDeviceAccess* pIDDA_old = rOldSh.getIDocumentDeviceAccess();
+
+ if( pIDDA_old->getPrinter( false ) )
+ {
+ pIDDA->setJobsetup( *pIDDA_old->getJobsetup() );
+ //#69563# if it isn't the same printer then the pointer has been invalidated!
+ pTempPrinter = pIDDA->getPrinter( true );
+ }
+
+ pTempPrinter->SetPaperBin(rCurPageDesc.GetMaster().GetPaperBin().GetValue());
+
+ return xDocSh;
+}
+
+void SwXTextView::NotifySelChanged()
+{
+ OSL_ENSURE( m_pView, "view is missing" );
+
+ // destroy temporary document with selected text that is used
+ // in PDF export of (multi-)selections.
+ if (m_pView && m_pView->GetTmpSelectionDoc().Is())
+ {
+ m_pView->GetTmpSelectionDoc()->DoClose();
+ m_pView->GetTmpSelectionDoc() = 0;
+ }
+
+ uno::Reference< uno::XInterface > xInt = (cppu::OWeakObject*)(SfxBaseController*)this;
+
+ lang::EventObject aEvent(xInt);
+
+ sal_uInt16 nCount = aSelChangedListeners.Count();
+ for ( sal_uInt16 i = nCount; i--; )
+ {
+ uno::Reference< view::XSelectionChangeListener > *pObj = aSelChangedListeners[i];
+ (*pObj)->selectionChanged(aEvent);
+ }
+}
+
+void SwXTextView::NotifyDBChanged()
+{
+ URL aURL;
+ aURL.Complete = C2U(SwXDispatch::GetDBChangeURL());
+
+ sal_uInt16 nCount = aSelChangedListeners.Count();
+ for ( sal_uInt16 i = nCount; i--; )
+ {
+ uno::Reference< view::XSelectionChangeListener > *pObj = aSelChangedListeners[i];
+ uno::Reference<XDispatch> xDispatch((*pObj), UNO_QUERY);
+ if(xDispatch.is())
+ xDispatch->dispatch(aURL, Sequence<PropertyValue>(0));
+ }
+}
+
+uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXTextView::getPropertySetInfo( )
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ static uno::Reference< XPropertySetInfo > aRef = m_pPropSet->getPropertySetInfo();
+ return aRef;
+}
+
+void SAL_CALL SwXTextView::setPropertyValue(
+ const OUString& rPropertyName, const uno::Any& rValue )
+ throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
+ if (!pEntry)
+ throw UnknownPropertyException();
+ else if (pEntry->nFlags & PropertyAttribute::READONLY)
+ throw PropertyVetoException();
+ else
+ {
+ switch (pEntry->nWID)
+ {
+ case WID_IS_HIDE_SPELL_MARKS :
+ // deprecated #i91949
+ break;
+ case WID_IS_CONSTANT_SPELLCHECK :
+ {
+ sal_Bool bVal = sal_False;
+ const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
+ if (!pOpt || !(rValue >>= bVal))
+ throw RuntimeException();
+ SwViewOption aNewOpt( *pOpt );
+ if (pEntry->nWID == WID_IS_CONSTANT_SPELLCHECK)
+ aNewOpt.SetOnlineSpell(bVal);
+ m_pView->GetWrtShell().ApplyViewOptions( aNewOpt );
+ }
+ break;
+ default :
+ OSL_ENSURE(false, "unknown WID");
+ }
+ }
+}
+
+uno::Any SAL_CALL SwXTextView::getPropertyValue(
+ const OUString& rPropertyName )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ Any aRet;
+
+ const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName( rPropertyName );
+ if (!pEntry)
+ throw UnknownPropertyException();
+ else
+ {
+ sal_Int16 nWID = pEntry->nWID;
+ switch (nWID)
+ {
+ case WID_PAGE_COUNT :
+ case WID_LINE_COUNT :
+ {
+ // format document completely in order to get meaningful
+ // values for page count and line count
+ m_pView->GetWrtShell().CalcLayout();
+
+ sal_Int32 nCount = -1;
+ if (nWID == WID_PAGE_COUNT)
+ nCount = m_pView->GetDocShell()->GetDoc()->GetPageCount();
+ else // WID_LINE_COUNT
+ nCount = m_pView->GetWrtShell().GetLineCount( FALSE /*of whole document*/ );
+ aRet <<= nCount;
+ }
+ break;
+ case WID_IS_HIDE_SPELL_MARKS :
+ // deprecated #i91949
+ break;
+ case WID_IS_CONSTANT_SPELLCHECK :
+ {
+ const SwViewOption *pOpt = m_pView->GetWrtShell().GetViewOptions();
+ if (!pOpt)
+ throw RuntimeException();
+ UINT32 nFlag = VIEWOPT_1_ONLINESPELL;
+ sal_Bool bVal = 0 != (pOpt->GetCoreOptions() & nFlag);
+ aRet <<= bVal;
+ }
+ break;
+ default :
+ OSL_ENSURE(false, "unknown WID");
+ }
+ }
+
+ return aRet;
+}
+
+void SAL_CALL SwXTextView::addPropertyChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE(false, "not implemented");
+}
+
+void SAL_CALL SwXTextView::removePropertyChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE(false, "not implemented");
+}
+
+void SAL_CALL SwXTextView::addVetoableChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE(false, "not implemented");
+}
+
+void SAL_CALL SwXTextView::removeVetoableChangeListener(
+ const OUString& /*rPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ )
+ throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ OSL_ENSURE(false, "not implemented");
+}
+
+OUString SwXTextView::getImplementationName(void) throw( RuntimeException )
+{
+ return C2U("SwXTextView");
+}
+
+BOOL SwXTextView::supportsService(const OUString& rServiceName) throw( RuntimeException )
+{
+ return rServiceName.equalsAscii("com.sun.star.text.TextDocumentView") ||
+ rServiceName.equalsAscii("com.sun.star.view.OfficeDocumentView");
+}
+
+Sequence< OUString > SwXTextView::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ Sequence< OUString > aRet(2);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = C2U("com.sun.star.text.TextDocumentView");
+ pArray[1] = C2U("com.sun.star.view.OfficeDocumentView");
+ return aRet;
+}
+
+/******************************************************************
+ * SwXTextViewCursor
+ ******************************************************************/
+SwXTextViewCursor::SwXTextViewCursor(SwView* pVw) :
+ m_pView(pVw),
+ m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
+{
+}
+
+SwXTextViewCursor::~SwXTextViewCursor()
+{
+}
+
+// used to determine if there is a text selction or not.
+// If there is no text selection the functions that need a working
+// cursor will be disabled (throw RuntimeException). This will be the case
+// for the following interfaces:
+// - XViewCursor
+// - XTextCursor
+// - XTextRange
+// - XLineCursor
+sal_Bool SwXTextViewCursor::IsTextSelection( sal_Bool bAllowTables ) const
+{
+
+ sal_Bool bRes = sal_False;
+ OSL_ENSURE(m_pView, "m_pView is NULL ???");
+ if(m_pView)
+ {
+ //! m_pView->GetShellMode() will only work after the shell
+ //! has already changed and thus can not be used here!
+ SelectionType eSelType = m_pView->GetWrtShell().GetSelectionType();
+ bRes = ( (nsSelectionType::SEL_TXT & eSelType) ||
+ (nsSelectionType::SEL_NUM & eSelType) ) &&
+ (!(nsSelectionType::SEL_TBL_CELLS & eSelType) || bAllowTables);
+ }
+ return bRes;
+}
+
+sal_Bool SwXTextViewCursor::isVisible(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ OSL_ENSURE(false, "not implemented");
+ return sal_True;
+}
+
+void SwXTextViewCursor::setVisible(sal_Bool /*bVisible*/) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ OSL_ENSURE(false, "not implemented");
+}
+
+awt::Point SwXTextViewCursor::getPosition(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ awt::Point aRet;
+ if(m_pView)
+ {
+ const SwWrtShell& rSh = m_pView->GetWrtShell();
+ const SwRect aCharRect(rSh.GetCharRect());
+
+ const SwFrmFmt& rMaster = rSh.GetPageDesc( rSh.GetCurPageDesc() ).GetMaster();
+
+ const SvxULSpaceItem& rUL = rMaster.GetULSpace();
+ const long nY = aCharRect.Top() - (rUL.GetUpper() + DOCUMENTBORDER);
+ aRet.Y = TWIP_TO_MM100(nY);
+
+ const SvxLRSpaceItem& rLR = rMaster.GetLRSpace();
+ const long nX = aCharRect.Left() - (rLR.GetLeft() + DOCUMENTBORDER);
+ aRet.X = TWIP_TO_MM100(nX);
+ }
+ else
+ throw uno::RuntimeException();
+ return aRet;
+}
+
+void SwXTextViewCursor::collapseToStart(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ if(rSh.HasSelection())
+ {
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ if(*pShellCrsr->GetPoint() > *pShellCrsr->GetMark())
+ pShellCrsr->Exchange();
+ pShellCrsr->DeleteMark();
+ rSh.EnterStdMode();
+ rSh.SetSelection(*pShellCrsr);
+ }
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+void SwXTextViewCursor::collapseToEnd(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ if(rSh.HasSelection())
+ {
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ if(*pShellCrsr->GetPoint() < *pShellCrsr->GetMark())
+ pShellCrsr->Exchange();
+ pShellCrsr->DeleteMark();
+ rSh.EnterStdMode();
+ rSh.SetSelection(*pShellCrsr);
+ }
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+sal_Bool SwXTextViewCursor::isCollapsed(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ const SwWrtShell& rSh = m_pView->GetWrtShell();
+ bRet = !rSh.HasSelection();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+
+}
+
+sal_Bool SwXTextViewCursor::goLeft(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ bRet = m_pView->GetWrtShell().Left( CRSR_SKIP_CHARS, bExpand, 1, sal_True );
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::goRight(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ bRet = m_pView->GetWrtShell().Right( CRSR_SKIP_CHARS, bExpand, 1, sal_True );
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+
+}
+
+void SwXTextViewCursor::gotoRange(
+ const uno::Reference< text::XTextRange > & xRange,
+ sal_Bool bExpand)
+ throw(RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView && xRange.is())
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwUnoInternalPaM rDestPam(*m_pView->GetDocShell()->GetDoc());
+ if (!::sw::XTextRangeToSwPaM(rDestPam, xRange))
+ {
+ throw uno::RuntimeException();
+ }
+
+ ShellModes eSelMode = m_pView->GetShellMode();
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ // call EnterStdMode in non-text selections only
+ if(!bExpand ||
+ (eSelMode != SHELL_MODE_TABLE_TEXT &&
+ eSelMode != SHELL_MODE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TEXT ))
+ rSh.EnterStdMode();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwPaM aOwnPaM(*pShellCrsr->GetPoint());
+ if(pShellCrsr->HasMark())
+ {
+ aOwnPaM.SetMark();
+ *aOwnPaM.GetMark() = *pShellCrsr->GetMark();
+ }
+
+ uno::Reference<lang::XUnoTunnel> xRangeTunnel( xRange, uno::UNO_QUERY);
+ SwXTextRange* pRange = 0;
+ SwXParagraph* pPara = 0;
+ OTextCursorHelper* pCursor = 0;
+ if(xRangeTunnel.is())
+ {
+ pRange = reinterpret_cast<SwXTextRange*>(xRangeTunnel->getSomething(
+ SwXTextRange::getUnoTunnelId()));
+ pCursor = reinterpret_cast<OTextCursorHelper*>(xRangeTunnel->getSomething(
+ OTextCursorHelper::getUnoTunnelId()));
+ pPara = reinterpret_cast<SwXParagraph*>(xRangeTunnel->getSomething(
+ SwXParagraph::getUnoTunnelId()));
+ }
+
+ const sal_uInt16 nFrmType = rSh.GetFrmType(0,sal_True);
+
+ SwStartNodeType eSearchNodeType = SwNormalStartNode;
+ if(nFrmType & FRMTYPE_FLY_ANY)
+ eSearchNodeType = SwFlyStartNode;
+ else if(nFrmType &FRMTYPE_HEADER)
+ eSearchNodeType = SwHeaderStartNode;
+ else if(nFrmType & FRMTYPE_FOOTER)
+ eSearchNodeType = SwFooterStartNode;
+ else if(nFrmType & FRMTYPE_TABLE)
+ eSearchNodeType = SwTableBoxStartNode;
+ else if(nFrmType & FRMTYPE_FOOTNOTE)
+ eSearchNodeType = SwFootnoteStartNode;
+
+ const SwStartNode* pOwnStartNode = aOwnPaM.GetNode()->
+ FindSttNodeByType(eSearchNodeType);
+
+ const SwNode* pSrcNode = 0;
+ if(pCursor && pCursor->GetPaM())
+ {
+ pSrcNode = pCursor->GetPaM()->GetNode();
+ }
+ else if (pRange)
+ {
+ SwPaM aPam(pRange->GetDoc()->GetNodes());
+ if (pRange->GetPositions(aPam))
+ {
+ pSrcNode = aPam.GetNode();
+ }
+ }
+ else if (pPara && pPara->GetTxtNode())
+ {
+ pSrcNode = pPara->GetTxtNode();
+ }
+ const SwStartNode* pTmp = pSrcNode ? pSrcNode->FindSttNodeByType(eSearchNodeType) : 0;
+
+ //SectionNodes ueberspringen
+ while(pTmp && pTmp->IsSectionNode())
+ {
+ pTmp = pTmp->StartOfSectionNode();
+ }
+ while(pOwnStartNode && pOwnStartNode->IsSectionNode())
+ {
+ pOwnStartNode = pOwnStartNode->StartOfSectionNode();
+ }
+ //ohne Expand darf mit dem ViewCursor ueberall hingesprungen werden
+ //mit Expand nur in der gleichen Umgebung
+ if(bExpand &&
+ (pOwnStartNode != pTmp ||
+ (eSelMode != SHELL_MODE_TABLE_TEXT &&
+ eSelMode != SHELL_MODE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TABLE_LIST_TEXT &&
+ eSelMode != SHELL_MODE_TEXT)))
+ throw uno::RuntimeException();
+
+ //jetzt muss die Selektion erweitert werden
+ if(bExpand)
+ {
+ // der Cursor soll alles einschliessen, was bisher von ihm und dem uebergebenen
+ // Range eingeschlossen wurde
+ SwPosition aOwnLeft(*aOwnPaM.Start());
+ SwPosition aOwnRight(*aOwnPaM.End());
+ SwPosition* pParamLeft = rDestPam.Start();
+ SwPosition* pParamRight = rDestPam.End();
+ // jetzt sind vier SwPositions da, zwei davon werden gebraucht, also welche?
+ if(aOwnRight > *pParamRight)
+ *aOwnPaM.GetPoint() = aOwnRight;
+ else
+ *aOwnPaM.GetPoint() = *pParamRight;
+ aOwnPaM.SetMark();
+ if(aOwnLeft < *pParamLeft)
+ *aOwnPaM.GetMark() = aOwnLeft;
+ else
+ *aOwnPaM.GetMark() = *pParamLeft;
+ }
+ else
+ {
+ //der Cursor soll dem uebergebenen Range entsprechen
+ *aOwnPaM.GetPoint() = *rDestPam.GetPoint();
+ if(rDestPam.HasMark())
+ {
+ aOwnPaM.SetMark();
+ *aOwnPaM.GetMark() = *rDestPam.GetMark();
+ }
+ else
+ aOwnPaM.DeleteMark();
+ }
+ rSh.SetSelection(aOwnPaM);
+ }
+ else
+ throw uno::RuntimeException();
+
+}
+
+void SwXTextViewCursor::gotoStart(sal_Bool bExpand) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ m_pView->GetWrtShell().SttDoc( bExpand );
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+void SwXTextViewCursor::gotoEnd(sal_Bool bExpand) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ m_pView->GetWrtShell().EndDoc( bExpand );
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+sal_Bool SwXTextViewCursor::jumpToFirstPage(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ if (rSh.IsSelFrmMode())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+ rSh.EnterStdMode();
+ bRet = rSh.SttEndDoc(TRUE);
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToLastPage(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ if (rSh.IsSelFrmMode())
+ {
+ rSh.UnSelectFrm();
+ rSh.LeaveSelFrmMode();
+ }
+ rSh.EnterStdMode();
+ bRet = rSh.SttEndDoc(FALSE);
+ rSh.SttPg();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToPage(sal_Int16 nPage) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().GotoPage(nPage, TRUE);
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToNextPage(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().SttNxtPg();
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToPreviousPage(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().EndPrvPg();
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToEndOfPage(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().EndPg();
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::jumpToStartOfPage(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ bRet = m_pView->GetWrtShell().SttPg();
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Int16 SwXTextViewCursor::getPage(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ short nRet = 0;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ nRet = (short)pShellCrsr->GetPageNum( TRUE, 0 );
+ }
+ else
+ throw uno::RuntimeException();
+ return nRet;
+}
+
+sal_Bool SwXTextViewCursor::screenDown(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ SfxRequest aReq(FN_PAGEDOWN, SFX_CALLMODE_SLOT, m_pView->GetPool());
+ m_pView->Execute(aReq);
+ const SfxPoolItem* pRet = aReq.GetReturnValue();
+ bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::screenUp(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ SfxRequest aReq(FN_PAGEUP, SFX_CALLMODE_SLOT, m_pView->GetPool());
+ m_pView->Execute(aReq);
+ const SfxPoolItem* pRet = aReq.GetReturnValue();
+ bRet = pRet && ((const SfxBoolItem*)pRet)->GetValue();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+uno::Reference< text::XText > SwXTextViewCursor::getText(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XText > xRet;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ xRet = ::sw::CreateParentXText(*pDoc, *pShellCrsr->Start());
+ }
+ else
+ throw uno::RuntimeException();
+ return xRet;
+}
+
+uno::Reference< text::XTextRange > SwXTextViewCursor::getStart(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XTextRange > xRet;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->Start(), 0);
+ }
+ else
+ throw uno::RuntimeException();
+ return xRet;
+}
+
+uno::Reference< text::XTextRange > SwXTextViewCursor::getEnd(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ uno::Reference< text::XTextRange > xRet;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwDoc* pDoc = m_pView->GetDocShell()->GetDoc();
+ xRet = SwXTextRange::CreateXTextRange(*pDoc, *pShellCrsr->End(), 0);
+ }
+ else
+ throw uno::RuntimeException();
+ return xRet;
+}
+
+OUString SwXTextViewCursor::getString(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ OUString uRet;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ ShellModes eSelMode = m_pView->GetShellMode();
+ switch(eSelMode)
+ {
+ //! since setString for SEL_TABLE_TEXT (with possible
+ //! multi selection of cells) would not work properly we
+ //! will ignore this case for both
+ //! functions (setString AND getString) because of symmetrie.
+
+ case SHELL_MODE_LIST_TEXT :
+ case SHELL_MODE_TABLE_LIST_TEXT:
+ case SHELL_MODE_TEXT :
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwUnoCursorHelper::GetTextFromPam(*pShellCrsr, uRet);
+ }
+ default:;//prevent warning
+ }
+ }
+ return uRet;
+}
+
+void SwXTextViewCursor::setString(const OUString& aString) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ ShellModes eSelMode = m_pView->GetShellMode();
+ switch(eSelMode)
+ {
+ //! since setString for SEL_TABLE_TEXT (with possible
+ //! multi selection of cells) would not work properly we
+ //! will ignore this case for both
+ //! functions (setString AND getString) because of symmetrie.
+
+ case SHELL_MODE_LIST_TEXT :
+ case SHELL_MODE_TABLE_LIST_TEXT :
+ case SHELL_MODE_TEXT :
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwCursor* pShellCrsr = rSh.GetSwCrsr();
+ SwUnoCursorHelper::SetString(*pShellCrsr, aString);
+ }
+ default:;//prevent warning
+ }
+ }
+}
+
+uno::Reference< XPropertySetInfo > SwXTextViewCursor::getPropertySetInfo( ) throw(RuntimeException)
+{
+ static uno::Reference< XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
+ return xRef;
+}
+
+void SwXTextViewCursor::setPropertyValue( const OUString& rPropertyName, const Any& aValue )
+ throw(UnknownPropertyException, PropertyVetoException,
+ IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwNode *pNode = pShellCrsr->GetNode();
+ if (pNode && pNode->IsTxtNode())
+ {
+ SwUnoCursorHelper::SetPropertyValue(
+ *pShellCrsr, *m_pPropSet, rPropertyName, aValue );
+ }
+ else
+ throw RuntimeException();
+ }
+ else
+ throw RuntimeException();
+}
+
+Any SwXTextViewCursor::getPropertyValue( const OUString& rPropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Any aRet;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ aRet = SwUnoCursorHelper::GetPropertyValue(
+ *pShellCrsr, *m_pPropSet, rPropertyName);
+ }
+ else
+ throw RuntimeException();
+ return aRet;
+}
+
+void SwXTextViewCursor::addPropertyChangeListener(
+ const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*xListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+void SwXTextViewCursor::removePropertyChangeListener(
+ const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*aListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+void SwXTextViewCursor::addVetoableChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+void SwXTextViewCursor::removeVetoableChangeListener(
+ const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+}
+
+PropertyState SwXTextViewCursor::getPropertyState( const OUString& rPropertyName )
+ throw(UnknownPropertyException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ PropertyState eState;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ eState = SwUnoCursorHelper::GetPropertyState(
+ *pShellCrsr, *m_pPropSet, rPropertyName);
+ }
+ else
+ throw RuntimeException();
+ return eState;
+}
+
+Sequence< PropertyState > SwXTextViewCursor::getPropertyStates(
+ const Sequence< OUString >& rPropertyNames ) throw(UnknownPropertyException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ Sequence< PropertyState > aRet;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ aRet = SwUnoCursorHelper::GetPropertyStates(
+ *pShellCrsr, *m_pPropSet, rPropertyNames);
+ }
+ return aRet;
+}
+
+void SwXTextViewCursor::setPropertyToDefault( const OUString& rPropertyName )
+ throw(UnknownPropertyException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ SwUnoCursorHelper::SetPropertyToDefault(
+ *pShellCrsr, *m_pPropSet, rPropertyName);
+ }
+}
+
+Any SwXTextViewCursor::getPropertyDefault( const OUString& rPropertyName )
+ throw(UnknownPropertyException, WrappedTargetException, RuntimeException)
+{
+ Any aRet;
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ SwPaM* pShellCrsr = rSh.GetCrsr();
+ aRet = SwUnoCursorHelper::GetPropertyDefault(
+ *pShellCrsr, *m_pPropSet, rPropertyName);
+ }
+ return aRet;
+}
+
+sal_Bool SwXTextViewCursor::goDown(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ bRet = m_pView->GetWrtShell().Down( bExpand, 1, sal_True );
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::goUp(sal_Int16 nCount, sal_Bool bExpand) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection())
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ for( sal_uInt16 i = 0; i < nCount; i++ )
+ bRet = m_pView->GetWrtShell().Up( bExpand, 1, sal_True );
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::isAtStartOfLine(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ bRet = m_pView->GetWrtShell().IsAtLeftMargin();
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+sal_Bool SwXTextViewCursor::isAtEndOfLine(void) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ sal_Bool bRet = sal_False;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ bRet = m_pView->GetWrtShell().IsAtRightMargin(sal_True);
+ }
+ else
+ throw uno::RuntimeException();
+ return bRet;
+}
+
+void SwXTextViewCursor::gotoEndOfLine(sal_Bool bExpand) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ m_pView->GetWrtShell().RightMargin(bExpand, sal_True);
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+void SwXTextViewCursor::gotoStartOfLine(sal_Bool bExpand) throw( uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+ if(m_pView)
+ {
+ if (!IsTextSelection( sal_False ))
+ throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "no text selection" ) ), static_cast < cppu::OWeakObject * > ( this ) );
+
+ m_pView->GetWrtShell().LeftMargin(bExpand, sal_True);
+ }
+ else
+ throw uno::RuntimeException();
+}
+
+OUString SwXTextViewCursor::getImplementationName(void) throw( RuntimeException )
+{
+ return C2U("SwXTextViewCursor");
+}
+
+BOOL SwXTextViewCursor::supportsService(const OUString& rServiceName) throw( RuntimeException )
+{
+ return !rServiceName.compareToAscii("com.sun.star.text.TextViewCursor") ||
+ !rServiceName.compareToAscii("com.sun.star.style.CharacterProperties") ||
+ !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesAsian") ||
+ !rServiceName.compareToAscii("com.sun.star.style.CharacterPropertiesComplex") ||
+ !rServiceName.compareToAscii("com.sun.star.style.ParagraphProperties") ||
+ !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesAsian") ||
+ !rServiceName.compareToAscii("com.sun.star.style.ParagraphPropertiesComplex");
+}
+
+Sequence< OUString > SwXTextViewCursor::getSupportedServiceNames(void) throw( RuntimeException )
+{
+ Sequence< OUString > aRet(7);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = C2U("com.sun.star.text.TextViewCursor");
+ pArray[1] = C2U("com.sun.star.style.CharacterProperties");
+ pArray[2] = C2U("com.sun.star.style.CharacterPropertiesAsian");
+ pArray[3] = C2U("com.sun.star.style.CharacterPropertiesComplex");
+ pArray[4] = C2U("com.sun.star.style.ParagraphProperties");
+ pArray[5] = C2U("com.sun.star.style.ParagraphPropertiesAsian");
+ pArray[6] = C2U("com.sun.star.style.ParagraphPropertiesComplex");
+ return aRet;
+}
+
+const uno::Sequence< sal_Int8 > & SwXTextViewCursor::getUnoTunnelId()
+{
+ static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId();
+ return aSeq;
+}
+
+//XUnoTunnel
+sal_Int64 SAL_CALL SwXTextViewCursor::getSomething(
+ const uno::Sequence< sal_Int8 >& rId )
+ throw(uno::RuntimeException)
+{
+ if( rId.getLength() == 16
+ && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(),
+ rId.getConstArray(), 16 ) )
+ {
+ return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this ));
+ }
+ return OTextCursorHelper::getSomething(rId);;
+}
+
+IMPLEMENT_FORWARD_XINTERFACE2(SwXTextViewCursor,SwXTextViewCursor_Base,OTextCursorHelper)
+const SwDoc* SwXTextViewCursor::GetDoc() const
+{
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ return rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0;
+}
+
+SwDoc* SwXTextViewCursor::GetDoc()
+{
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ return rSh.GetCrsr() ? rSh.GetCrsr()->GetDoc() : 0;
+}
+
+const SwPaM* SwXTextViewCursor::GetPaM() const
+{
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ return rSh.GetCrsr();
+}
+
+SwPaM* SwXTextViewCursor::GetPaM()
+{
+ SwWrtShell& rSh = m_pView->GetWrtShell();
+ return rSh.GetCrsr();
+}
+
+uno::Reference< datatransfer::XTransferable > SAL_CALL SwXTextView::getTransferable( ) throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //force immediat shell update
+ GetView()->StopShellTimer();
+ SwWrtShell& rSh = GetView()->GetWrtShell();
+ if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT )
+ {
+ SdrView *pSdrView = rSh.GetDrawView();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ return pOLV->GetEditView().GetTransferable();
+ }
+ else
+ {
+ SwTransferable* pTransfer = new SwTransferable( rSh );
+ const BOOL bLockedView = rSh.IsViewLocked();
+ rSh.LockView( TRUE ); //lock visible section
+ pTransfer->PrepareForCopy();
+ rSh.LockView( bLockedView );
+ return uno::Reference< datatransfer::XTransferable >( pTransfer );
+ }
+}
+
+void SAL_CALL SwXTextView::insertTransferable( const uno::Reference< datatransfer::XTransferable >& xTrans ) throw (datatransfer::UnsupportedFlavorException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ //force immediat shell update
+ GetView()->StopShellTimer();
+ SwWrtShell& rSh = GetView()->GetWrtShell();
+ if ( GetView()->GetShellMode() == SHELL_MODE_DRAWTEXT )
+ {
+ SdrView *pSdrView = rSh.GetDrawView();
+ OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
+ pOLV->GetEditView().InsertText( xTrans, GetView()->GetDocShell()->GetMedium()->GetBaseURL(), FALSE );
+ }
+ else
+ {
+ TransferableDataHelper aDataHelper( xTrans );
+ if ( SwTransferable::IsPaste( rSh, aDataHelper ) )
+ {
+ SwTransferable::Paste( rSh, aDataHelper );
+ if( rSh.IsFrmSelected() || rSh.IsObjSelected() )
+ rSh.EnterSelFrmMode();
+ GetView()->AttrChangedNotify( &rSh );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */