diff options
author | roopak12345 <mailstorpk@gmail.com> | 2014-03-09 21:40:44 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-03-09 21:53:34 +0100 |
commit | a652ea0fc4cc789f715b461819127ee80afa9e6f (patch) | |
tree | 0858def8201a45024721f4a98b537cd3274ac4c5 /sw/source/ui/uno | |
parent | f4dfd811344604e119670eb7cdda0ab2e85bcea5 (diff) |
fdo#70422 Moved the linked files from sw/source/ui to a new core/uibase dir
Moved the files linked in sw/Library_sw.mk from sw/source/ui to
sw/source/core/uibase and modified the make files as per the new
directory location.
Reviewed on:
https://gerrit.libreoffice.org/8447
Change-Id: I05f6ccdeee5e76fb0ae477d16721d9ddc6eaff32
Diffstat (limited to 'sw/source/ui/uno')
-rw-r--r-- | sw/source/ui/uno/SwXDocumentSettings.cxx | 1254 | ||||
-rw-r--r-- | sw/source/ui/uno/SwXDocumentSettings.hxx | 93 | ||||
-rw-r--r-- | sw/source/ui/uno/SwXFilterOptions.cxx | 179 | ||||
-rw-r--r-- | sw/source/ui/uno/dlelstnr.cxx | 165 | ||||
-rw-r--r-- | sw/source/ui/uno/unoatxt.cxx | 1121 | ||||
-rw-r--r-- | sw/source/ui/uno/unodefaults.cxx | 51 | ||||
-rw-r--r-- | sw/source/ui/uno/unodefaults.hxx | 40 | ||||
-rw-r--r-- | sw/source/ui/uno/unodispatch.cxx | 392 | ||||
-rw-r--r-- | sw/source/ui/uno/unodoc.cxx | 113 | ||||
-rw-r--r-- | sw/source/ui/uno/unofreg.cxx | 373 | ||||
-rw-r--r-- | sw/source/ui/uno/unomailmerge.cxx | 1227 | ||||
-rw-r--r-- | sw/source/ui/uno/unomod.cxx | 990 | ||||
-rw-r--r-- | sw/source/ui/uno/unomodule.cxx | 154 | ||||
-rw-r--r-- | sw/source/ui/uno/unomodule.hxx | 81 | ||||
-rw-r--r-- | sw/source/ui/uno/unotxdoc.cxx | 3994 | ||||
-rw-r--r-- | sw/source/ui/uno/unotxvw.cxx | 1851 |
16 files changed, 0 insertions, 12078 deletions
diff --git a/sw/source/ui/uno/SwXDocumentSettings.cxx b/sw/source/ui/uno/SwXDocumentSettings.cxx deleted file mode 100644 index 48f68dbe6dfd..000000000000 --- a/sw/source/ui/uno/SwXDocumentSettings.cxx +++ /dev/null @@ -1,1254 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/mutex.hxx> -#include <sfx2/sfxbasecontroller.hxx> -#include <SwXDocumentSettings.hxx> -#include <comphelper/MasterPropertySetInfo.hxx> -#include <cppuhelper/supportsservice.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 <sfx2/zoomitem.hxx> -#include <unomod.hxx> -#include <vcl/svapp.hxx> -#include <comphelper/servicehelper.hxx> - -#include "swmodule.hxx" -#include "cfgitems.hxx" -#include "prtopt.hxx" - -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, - HANDLE_RSID, - HANDLE_RSID_ROOT, - // #i89181# - HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, - HANDLE_MODIFYPASSWORDINFO, - HANDLE_MATH_BASELINE_ALIGNMENT, - HANDLE_INVERT_BORDER_SPACING, - HANDLE_COLLAPSE_EMPTY_CELL_PARA, - HANDLE_SMALL_CAPS_PERCENTAGE_66, - HANDLE_TAB_OVERFLOW, - HANDLE_UNBREAKABLE_NUMBERINGS, - HANDLE_STYLES_NODEFAULT, - HANDLE_FLOATTABLE_NOMARGINS, - HANDLE_CLIPPED_PICTURES, - HANDLE_BACKGROUND_PARA_OVER_DRAWINGS, - HANDLE_EMBED_FONTS, - HANDLE_EMBED_SYSTEM_FONTS, - HANDLE_TAB_OVER_MARGIN, - HANDLE_SURROUND_TEXT_WRAP_SMALL -}; - -static MasterPropertySetInfo * lcl_createSettingsInfo() -{ - static PropertyInfo const aWriterSettingsInfoMap[] = - { - { OUString("ForbiddenCharacters"), HANDLE_FORBIDDEN_CHARS, cppu::UnoType<css::i18n::XForbiddenCharacters>::get(), 0, 0}, - { OUString("LinkUpdateMode"), HANDLE_LINK_UPDATE_MODE, cppu::UnoType<sal_Int16>::get(), 0, 0}, - { OUString("FieldAutoUpdate"), HANDLE_FIELD_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ChartAutoUpdate"), HANDLE_CHART_AUTO_UPDATE, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("AddParaTableSpacing"), HANDLE_ADD_PARA_TABLE_SPACING, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("AddParaTableSpacingAtStart"), HANDLE_ADD_PARA_TABLE_SPACING_AT_START, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("AlignTabStopPosition"), HANDLE_ALIGN_TAB_STOP_POSITION, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("PrinterName"), HANDLE_PRINTER_NAME, cppu::UnoType<OUString>::get(), 0, 0}, - { OUString("PrinterSetup"), HANDLE_PRINTER_SETUP, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0, 0}, - { OUString("IsKernAsianPunctuation"), HANDLE_IS_KERN_ASIAN_PUNCTUATION, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("CharacterCompressionType"), HANDLE_CHARACTER_COMPRESSION_TYPE, cppu::UnoType<sal_Int16>::get(), 0, 0}, - { OUString("ApplyUserData"), HANDLE_APPLY_USER_DATA, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("SaveGlobalDocumentLinks"), HANDLE_SAVE_GLOBAL_DOCUMENT_LINKS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("CurrentDatabaseDataSource"), HANDLE_CURRENT_DATABASE_DATA_SOURCE, cppu::UnoType<OUString>::get(), 0, 0}, - { OUString("CurrentDatabaseCommand"), HANDLE_CURRENT_DATABASE_COMMAND, cppu::UnoType<OUString>::get(), 0, 0}, - { OUString("CurrentDatabaseCommandType"), HANDLE_CURRENT_DATABASE_COMMAND_TYPE, cppu::UnoType<sal_Int32>::get(), 0, 0}, - { OUString("SaveVersionOnClose"), HANDLE_SAVE_VERSION_ON_CLOSE, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("UpdateFromTemplate"), HANDLE_UPDATE_FROM_TEMPLATE, cppu::UnoType<bool>::get(), 0, 0}, - - { OUString("PrinterIndependentLayout"), HANDLE_PRINTER_INDEPENDENT_LAYOUT, cppu::UnoType<sal_Int16>::get(), 0, 0}, - { OUString("IsLabelDocument"), HANDLE_IS_LABEL_DOC, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("AddFrameOffsets"), HANDLE_IS_ADD_FLY_OFFSET, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("AddExternalLeading"), HANDLE_IS_ADD_EXTERNAL_LEADING, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("UseOldNumbering"), HANDLE_OLD_NUMBERING, cppu::UnoType<bool>::get(), 0, 0}, // #111955# - { OUString("OutlineLevelYieldsNumbering"), HANDLE_OUTLINELEVEL_YIELDS_NUMBERING, cppu::UnoType<bool>::get(), 0, 0}, - /* Stampit It disable the print cancel button of the shown progress dialog. */ - { OUString("AllowPrintJobCancel"), HANDLE_ALLOW_PRINTJOB_CANCEL, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("UseFormerLineSpacing"), HANDLE_USE_FORMER_LINE_SPACING, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("AddParaSpacingToTableCells"), HANDLE_ADD_PARA_SPACING_TO_TABLE_CELLS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("UseFormerObjectPositioning"), HANDLE_USE_FORMER_OBJECT_POSITIONING, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("UseFormerTextWrapping"), HANDLE_USE_FORMER_TEXT_WRAPPING, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("RedlineProtectionKey"), HANDLE_CHANGES_PASSWORD, cppu::UnoType< cppu::UnoSequenceType<sal_Int8> >::get(), 0, 0}, - { OUString("ConsiderTextWrapOnObjPos"), HANDLE_CONSIDER_WRAP_ON_OBJPOS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("IgnoreFirstLineIndentInNumbering"), HANDLE_IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("DoNotJustifyLinesWithManualBreak"), HANDLE_DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("DoNotResetParaAttrsForNumFont"), HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("TableRowKeep"), HANDLE_TABLE_ROW_KEEP, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("IgnoreTabsAndBlanksForLineCalculation"), HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("LoadReadonly"), HANDLE_LOAD_READONLY, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("DoNotCaptureDrawObjsOnPage"), HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ClipAsCharacterAnchoredWriterFlyFrames"), HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("UnxForceZeroExtLeading"), HANDLE_UNIX_FORCE_ZERO_EXT_LEADING, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("UseOldPrinterMetrics"), HANDLE_USE_OLD_PRINTER_METRICS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("TabsRelativeToIndent"), HANDLE_TABS_RELATIVE_TO_INDENT, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("Rsid"), HANDLE_RSID, cppu::UnoType<sal_Int32>::get(), 0, 0}, - { OUString("RsidRoot"), HANDLE_RSID_ROOT, cppu::UnoType<sal_Int32>::get(), 0, 0}, - { OUString("ProtectForm"), HANDLE_PROTECT_FORM, cppu::UnoType<bool>::get(), 0, 0}, - // #i89181# - { OUString("TabAtLeftIndentForParagraphsInList"), HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ModifyPasswordInfo"), HANDLE_MODIFYPASSWORDINFO, cppu::UnoType< cppu::UnoSequenceType<css::beans::PropertyValue> >::get(), 0, 0}, - { OUString("MathBaselineAlignment"), HANDLE_MATH_BASELINE_ALIGNMENT, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("InvertBorderSpacing"), HANDLE_INVERT_BORDER_SPACING, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("CollapseEmptyCellPara"), HANDLE_COLLAPSE_EMPTY_CELL_PARA, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("SmallCapsPercentage66"), HANDLE_SMALL_CAPS_PERCENTAGE_66, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("TabOverflow"), HANDLE_TAB_OVERFLOW, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("UnbreakableNumberings"), HANDLE_UNBREAKABLE_NUMBERINGS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("StylesNoDefault"), HANDLE_STYLES_NODEFAULT, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("FloattableNomargins"), HANDLE_FLOATTABLE_NOMARGINS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ClippedPictures"), HANDLE_CLIPPED_PICTURES, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("BackgroundParaOverDrawings"), HANDLE_BACKGROUND_PARA_OVER_DRAWINGS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("EmbedFonts"), HANDLE_EMBED_FONTS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, cppu::UnoType<bool>::get(), 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 - { OUString("IsGridVisible"), HANDLE_IS_GRID_VISIBLE, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("IsSnapToGrid"), HANDLE_IS_SNAP_TO_GRID, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("IsSynchroniseAxes"), HANDLE_IS_SYNCHRONISE_AXES, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("HorizontalGridResolution"), HANDLE_HORIZONTAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0}, - { OUString("HorizontalGridSubdivision"), HANDLE_HORIZONTAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0}, - { OUString("VerticalGridResolution"), HANDLE_VERTICAL_GRID_RESOLUTION, cppu::UnoType<sal_Int32>::get(), 0, 0}, - { OUString("VerticalGridSubdivision"), HANDLE_VERTICAL_GRID_SUBDIVISION, cppu::UnoType<sal_Int16>::get(), 0, 0}, - - { OUString("ShowParagraphEnd"), HANDLE_SHOW_PARAGRAPH_END, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ShowOptionalHyphens"), HANDLE_SHOW_OPTIONAL_HYPHENS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ShowSpaces"), HANDLE_SHOW_SPACES, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ShowTabs"), HANDLE_SHOW_TABS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ShowBreaks"), HANDLE_SHOW_BREAKS, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ShowHiddenText"), HANDLE_SHOW_HIDDEN_TEXT, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ShowHiddenParagraphs"), HANDLE_SHOW_HIDDEN_PARAGRAPHS, cppu::UnoType<bool>::get(), 0, 0}, - - { OUString("ShowTextLimitGuide"), HANDLE_SHOW_TEXT_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ShowTableLimitGuide"), HANDLE_SHOW_TABLE_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ShowSectionLimitGuide"), HANDLE_SHOW_SECTION_LIMIT_GUIDE, cppu::UnoType<bool>::get(), 0, 0}, - { OUString("ShowGuidesWhileMoving"), HANDLE_SHOW_GUIDES_WHILE_MOVING, cppu::UnoType<bool>::get(), 0, 0}, -*/ - { OUString(), 0, css::uno::Type(), 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() ) ); -} - -SwXDocumentSettings::~SwXDocumentSettings() - throw() -{ -} - -Any SAL_CALL SwXDocumentSettings::queryInterface( const Type& rType ) - throw(RuntimeException, std::exception) -{ - 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, std::exception) -{ - 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; -} - -namespace -{ - class theSwXDocumentSettingsImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXDocumentSettingsImplementationId > {}; -} - -uno::Sequence< sal_Int8 > SAL_CALL SwXDocumentSettings::getImplementationId( ) - throw (RuntimeException, std::exception) -{ - return theSwXDocumentSettingsImplementationId::get().getSeq(); -} - -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 ("Property is read-only: " + rInfo.maName, 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.isEmpty() && 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 const 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 ); - - SAL_WARN_IF( aData.sDataSource.isEmpty() && !aData.sCommand.isEmpty(), "sw.uno", - "\"CurrentDatabaseCommand\" property possibly set before \"CurrentDatabaseDataSource\"" ); - } - break; - case HANDLE_CURRENT_DATABASE_COMMAND_TYPE: - { - SwDBData aData = mpDoc->GetDBData(); - if ( rValue >>= aData.nCommandType ) - mpDoc->ChgDBData( aData ); - SAL_WARN_IF( aData.nCommandType && aData.sDataSource.isEmpty(), "sw.uno", - "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseDataSource\"" ); - SAL_WARN_IF( aData.nCommandType && aData.sCommand.isEmpty(), "sw.uno", - "\"CurrentDatabaseCommandType\" property possibly set before \"CurrentDatabaseCommand\"" ); - } - 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); - } - break; - 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: - // ignore - this is a dead property - 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_RSID: - { - sal_uInt32 nTmp = 0; - rValue >>= nTmp; - mpDoc->setRsid( nTmp ); - } - break; - case HANDLE_RSID_ROOT: - { - sal_uInt32 nTmp = 0; - rValue >>= nTmp; - mpDoc->setRsidRoot( nTmp ); - } - break; - case HANDLE_PROTECT_FORM: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::PROTECT_FORM, bTmp); - } - break; - // #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( - OUString( "Value of type Sequence<PropertyValue> expected!" ), - uno::Reference< uno::XInterface >(), - 2 ); - - if ( !mpDocSh->SetModifyPasswordInfo( aInfo ) ) - throw beans::PropertyVetoException( - OUString( "The hash is not allowed to be changed now!" ), - uno::Reference< uno::XInterface >() ); - } - break; - case HANDLE_MATH_BASELINE_ALIGNMENT: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT, bTmp ); - } - 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; - case HANDLE_SMALL_CAPS_PERCENTAGE_66: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66, bTmp); - } - break; - case HANDLE_TAB_OVERFLOW: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::TAB_OVERFLOW, bTmp); - } - break; - case HANDLE_UNBREAKABLE_NUMBERINGS: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS, bTmp); - } - break; - case HANDLE_STYLES_NODEFAULT: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::STYLES_NODEFAULT, bTmp); - } - break; - case HANDLE_FLOATTABLE_NOMARGINS: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::FLOATTABLE_NOMARGINS, bTmp); - } - break; - case HANDLE_CLIPPED_PICTURES: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::CLIPPED_PICTURES, bTmp); - } - break; - case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::BACKGROUND_PARA_OVER_DRAWINGS, bTmp); - } - break; - case HANDLE_EMBED_FONTS: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::EMBED_FONTS, bTmp); - } - case HANDLE_EMBED_SYSTEM_FONTS: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::EMBED_SYSTEM_FONTS, bTmp); - } - break; - case HANDLE_TAB_OVER_MARGIN: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::TAB_OVER_MARGIN, bTmp); - } - break; - case HANDLE_SURROUND_TEXT_WRAP_SMALL: - { - sal_Bool bTmp = *(sal_Bool*)rValue.getValue(); - mpDoc->set(IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL, 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( mpDoc->getPrintData() ); - 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); - sal_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); - sal_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( false ); - rValue <<= pPrinter ? OUString ( pPrinter->GetName()) : OUString(); - } - break; - case HANDLE_PRINTER_SETUP: - { - SfxPrinter *pPrinter = mpDoc->getPrinter( 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->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 = sal_False; - 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_RSID: - { - rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsid() ); - } - break; - case HANDLE_RSID_ROOT: - { - rValue <<= static_cast < sal_Int32 > ( mpDoc->getRsidRoot() ); - } - break; - case HANDLE_PROTECT_FORM: - { - sal_Bool bTmp = mpDoc->get(IDocumentSettingAccess::PROTECT_FORM); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - // #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_MATH_BASELINE_ALIGNMENT: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - 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; - case HANDLE_SMALL_CAPS_PERCENTAGE_66: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::SMALL_CAPS_PERCENTAGE_66 ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_TAB_OVERFLOW: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVERFLOW ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_UNBREAKABLE_NUMBERINGS: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::UNBREAKABLE_NUMBERINGS ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_STYLES_NODEFAULT: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::STYLES_NODEFAULT ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_FLOATTABLE_NOMARGINS: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::FLOATTABLE_NOMARGINS ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_CLIPPED_PICTURES: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::CLIPPED_PICTURES ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_BACKGROUND_PARA_OVER_DRAWINGS: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::BACKGROUND_PARA_OVER_DRAWINGS ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_EMBED_FONTS: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_FONTS ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_EMBED_SYSTEM_FONTS: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::EMBED_SYSTEM_FONTS ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_TAB_OVER_MARGIN: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::TAB_OVER_MARGIN ); - rValue.setValue( &bTmp, ::getBooleanCppuType() ); - } - break; - case HANDLE_SURROUND_TEXT_WRAP_SMALL: - { - sal_Bool bTmp = mpDoc->get( IDocumentSettingAccess::SURROUND_TEXT_WRAP_SMALL ); - 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, std::exception) -{ - return OUString("com.sun.star.comp.Writer.DocumentSettings"); -} - -sal_Bool SAL_CALL SwXDocumentSettings::supportsService( const OUString& ServiceName ) - throw(RuntimeException, std::exception) -{ - return cppu::supportsService(this, ServiceName); -} - -Sequence< OUString > SAL_CALL SwXDocumentSettings::getSupportedServiceNames( ) - throw(RuntimeException, std::exception) -{ - Sequence< OUString > aSeq( 3 ); - aSeq[0] = "com.sun.star.document.Settings"; - aSeq[1] = "com.sun.star.text.DocumentSettings"; - aSeq[2] = "com.sun.star.text.PrintSettings"; - 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 deleted file mode 100644 index 49edf23964a0..000000000000 --- a/sw/source/ui/uno/SwXDocumentSettings.hxx +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SW_SOURCE_UI_UNO_SWXDOCUMENTSETTINGS_HXX -#define INCLUDED_SW_SOURCE_UI_UNO_SWXDOCUMENTSETTINGS_HXX - -#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, std::exception); - virtual void SAL_CALL acquire( ) - throw (); - virtual void SAL_CALL release( ) - throw (); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) - throw(com::sun::star::uno::RuntimeException, std::exception); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) - throw(com::sun::star::uno::RuntimeException, std::exception); - virtual com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) - throw(com::sun::star::uno::RuntimeException, std::exception); - - // XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException, std::exception); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException, std::exception); -}; -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/uno/SwXFilterOptions.cxx b/sw/source/ui/uno/SwXFilterOptions.cxx deleted file mode 100644 index b944a9e0b6f4..000000000000 --- a/sw/source/ui/uno/SwXFilterOptions.cxx +++ /dev/null @@ -1,179 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <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 <cppuhelper/supportsservice.hxx> -#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_IMPLNAME "com.sun.star.comp.Writer.FilterOptionsDialog" -#define FILTER_OPTIONS_NAME "FilterOptions" - -SwXFilterOptions::SwXFilterOptions() : - bExport( sal_False ) -{ -} - -SwXFilterOptions::~SwXFilterOptions() -{ -} - -OUString SwXFilterOptions::getImplementationName_Static() -{ - return OUString(SWFILTEROPTIONSOBJ_IMPLNAME); -} - -uno::Sequence< OUString> SwXFilterOptions::getSupportedServiceNames_Static() -{ - OUString sService("com.sun.star.ui.dialogs.FilterOptionsDialog"); - return uno::Sequence< OUString> (&sService, 1); -} - -uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues() throw (uno::RuntimeException, std::exception) -{ - uno::Sequence<beans::PropertyValue> aRet(1); - beans::PropertyValue* pArray = aRet.getArray(); - - pArray[0].Name = 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, std::exception) -{ - const beans::PropertyValue* pPropArray = aProps.getConstArray(); - long nPropCount = aProps.getLength(); - for (long i = 0; i < nPropCount; i++) - { - const beans::PropertyValue& rProp = pPropArray[i]; - OUString aPropName = rProp.Name; - - if ( aPropName == UNO_NAME_FILTER_NAME ) - rProp.Value >>= sFilterName; - else if ( aPropName == FILTER_OPTIONS_NAME ) - rProp.Value >>= sFilterOptions; - else if ( aPropName == "InputStream" ) - rProp.Value >>= xInputStream; - } -} - -void SwXFilterOptions::setTitle( const OUString& /*rTitle*/ ) - throw (uno::RuntimeException, std::exception) -{ -} - -sal_Int16 SwXFilterOptions::execute() throw (uno::RuntimeException, std::exception) -{ - 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); - OSL_ENSURE(pAsciiDlg, "Dialogdiet fail!"); - if(RET_OK == pAsciiDlg->Execute()) - { - SwAsciiOptions aOptions; - pAsciiDlg->FillOptions( aOptions ); - aOptions.WriteUserData(sFilterOptions); - nRet = ui::dialogs::ExecutableDialogResults::OK; - } - delete pAsciiDlg; - } - - delete pInStream; - - return nRet; -} - -void SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc ) - throw (IllegalArgumentException, uno::RuntimeException, std::exception) -{ - bExport = sal_False; - xModel = xDoc; -} - -void SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc ) - throw (IllegalArgumentException,uno::RuntimeException, std::exception) -{ - bExport = sal_True; - xModel = xDoc; -} - -OUString SwXFilterOptions::getImplementationName() throw(uno::RuntimeException, std::exception) -{ - return OUString(SWFILTEROPTIONSOBJ_IMPLNAME); -} - -sal_Bool SwXFilterOptions::supportsService( const OUString& rServiceName ) - throw(uno::RuntimeException, std::exception) -{ - return cppu::supportsService(this, rServiceName); -} - -uno::Sequence< OUString > SwXFilterOptions::getSupportedServiceNames() - throw(uno::RuntimeException, std::exception) -{ - return SwXFilterOptions::getSupportedServiceNames_Static(); -} - -uno::Reference<uno::XInterface> SAL_CALL SwXFilterOptions_createInstance( - const uno::Reference<lang::XMultiServiceFactory>& ) -{ - SolarMutexGuard aGuard; - SwGlobals::ensure(); - return (::cppu::OWeakObject*) new SwXFilterOptions; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/uno/dlelstnr.cxx b/sw/source/ui/uno/dlelstnr.cxx deleted file mode 100644 index 802d45c40f4b..000000000000 --- a/sw/source/ui/uno/dlelstnr.cxx +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <com/sun/star/frame/Desktop.hpp> -#include <com/sun/star/linguistic2/DictionaryListEventFlags.hpp> -#include <com/sun/star/linguistic2/XDictionaryList.hpp> -#include <com/sun/star/linguistic2/LinguServiceManager.hpp> -#include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> -#include <com/sun/star/linguistic2/ProofreadingIterator.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 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; - -SwLinguServiceEventListener::SwLinguServiceEventListener() -{ - Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() ); - try - { - xDesktop = frame::Desktop::create(xContext); - xDesktop->addTerminateListener( this ); - - xLngSvcMgr = LinguServiceManager::create(xContext); - xLngSvcMgr->addLinguServiceManagerListener( (XLinguServiceEventListener *) this ); - - if (SvtLinguConfig().HasGrammarChecker()) - { - xGCIterator = ProofreadingIterator::create(xContext); - Reference< XLinguServiceEventBroadcaster > xBC( xGCIterator, UNO_QUERY ); - if (xBC.is()) - xBC->addLinguServiceEventListener( (XLinguServiceEventListener *) this ); - } - } - catch (const uno::Exception&) - { - OSL_FAIL("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; - bool bIsSpellWrong = 0 != (nEvt & nSpellWrongFlags); - sal_Int16 nSpellAllFlags = - DictionaryListEventFlags::ADD_NEG_ENTRY | - DictionaryListEventFlags::DEL_POS_ENTRY | - DictionaryListEventFlags::ACTIVATE_NEG_DIC | - DictionaryListEventFlags::DEACTIVATE_POS_DIC; - bool bIsSpellAll = 0 != (nEvt & nSpellAllFlags); - - if (bIsSpellWrong || bIsSpellAll) - SW_MOD()->CheckSpellChanges( false, bIsSpellWrong, bIsSpellAll, false ); -} - -void SAL_CALL SwLinguServiceEventListener::processLinguServiceEvent( - const LinguServiceEvent& rLngSvcEvent ) - throw(RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - - bool bIsSpellWrong = 0 != (rLngSvcEvent.nEvent & SPELL_WRONG_WORDS_AGAIN); - bool bIsSpellAll = 0 != (rLngSvcEvent.nEvent & SPELL_CORRECT_WORDS_AGAIN); - if (0 != (rLngSvcEvent.nEvent & PROOFREAD_AGAIN)) - bIsSpellWrong = bIsSpellAll = true; // have all spelling and grammar checked... - if (bIsSpellWrong || bIsSpellAll) - { - SW_MOD()->CheckSpellChanges( false, bIsSpellWrong, bIsSpellAll, 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, std::exception) -{ - 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, std::exception) -{ -} - -void SAL_CALL SwLinguServiceEventListener::notifyTermination( - const EventObject& rEventObj ) - throw(RuntimeException, std::exception) -{ - 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/unoatxt.cxx b/sw/source/ui/uno/unoatxt.cxx deleted file mode 100644 index 3b381151a758..000000000000 --- a/sw/source/ui/uno/unoatxt.cxx +++ /dev/null @@ -1,1121 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <osl/mutex.hxx> -#include <osl/diagnose.h> -#include <vcl/svapp.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 <swmodule.hxx> -#include <svl/smplhint.hxx> -#include <svl/macitem.hxx> -#include <editeng/acorrcfg.hxx> -#include <comphelper/servicehelper.hxx> -#include <comphelper/string.hxx> -#include <cppuhelper/supportsservice.hxx> - -#include <boost/scoped_ptr.hpp> - -SV_IMPL_REF ( SwDocShell ) -using namespace ::com::sun::star; - -uno::Reference< uno::XInterface > SAL_CALL SwXAutoTextContainer_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & ) throw( uno::Exception ) -{ - //the module may not be loaded - SolarMutexGuard aGuard; - SwGlobals::ensure(); - static uno::Reference< uno::XInterface > xAText = (cppu::OWeakObject*)new SwXAutoTextContainer(); - return xAText; -} - -uno::Sequence< OUString > SAL_CALL SwXAutoTextContainer_getSupportedServiceNames() throw() -{ - OUString sService("com.sun.star.text.AutoTextContainer"); - const uno::Sequence< OUString > aSeq( &sService, 1 ); - return aSeq; -} - -OUString SAL_CALL SwXAutoTextContainer_getImplementationName() throw() -{ - return OUString("SwXAutoTextContainer" ); -} - -SwXAutoTextContainer::SwXAutoTextContainer() -{ - pGlossaries = ::GetGlossaries(); - -} - -SwXAutoTextContainer::~SwXAutoTextContainer() -{ - -} - -sal_Int32 SwXAutoTextContainer::getCount(void) throw( uno::RuntimeException, std::exception ) -{ - return pGlossaries->GetGroupCnt(); -} - -uno::Any SwXAutoTextContainer::getByIndex(sal_Int32 nIndex) - throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - uno::Any aRet; - sal_uInt16 nCount = pGlossaries->GetGroupCnt(); - if ( 0 <= nIndex && nIndex < nCount ) - aRet = getByName(pGlossaries->GetGroupName( static_cast< sal_uInt16 >(nIndex) )); - else - throw lang::IndexOutOfBoundsException(); - return aRet; -} - -uno::Type SwXAutoTextContainer::getElementType(void) throw( uno::RuntimeException, std::exception ) -{ - return ::getCppuType((const uno::Reference<text::XAutoTextGroup>*)0); - -} - -sal_Bool SwXAutoTextContainer::hasElements(void) throw( uno::RuntimeException, std::exception ) -{ - // At least standard should always exists! - return sal_True; -} - -uno::Any SwXAutoTextContainer::getByName(const OUString& GroupName) - throw( container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - - uno::Reference< text::XAutoTextGroup > xGroup; - if ( pGlossaries && hasByName( GroupName ) ) // group name already known? - // sal_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, std::exception ) -{ - SolarMutexGuard aGuard; - sal_uInt16 nCount = pGlossaries->GetGroupCnt(); - - uno::Sequence< OUString > aGroupNames(nCount); - OUString *pArr = aGroupNames.getArray(); - - for ( sal_uInt16 i = 0; i < nCount; i++ ) - { - // The names will be passed without a path extension. - OUString sGroupName(pGlossaries->GetGroupName(i)); - pArr[i] = sGroupName.getToken(0, GLOS_DELIM); - } - return aGroupNames; -} -// Finds group names with or without path index. -sal_Bool SwXAutoTextContainer::hasByName(const OUString& Name) - throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - OUString sGroupName( pGlossaries->GetCompleteGroupName( Name ) ); - if(!sGroupName.isEmpty()) - return sal_True; - return sal_False; -} - -uno::Reference< text::XAutoTextGroup > SwXAutoTextContainer::insertNewByName( - const OUString& aGroupName) - throw( lang::IllegalArgumentException, container::ElementExistException, uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(hasByName(aGroupName)) - throw container::ElementExistException(); - //check for non-ASCII characters - if(aGroupName.isEmpty()) - { - lang::IllegalArgumentException aIllegal; - aIllegal.Message = "group name must not be empty"; - throw aIllegal; - } - for(sal_Int32 nPos = 0; nPos < aGroupName.getLength(); nPos++) - { - sal_Unicode cChar = aGroupName[nPos]; - if (comphelper::string::isalnumAscii(cChar) || - (cChar == '_') || - (cChar == 0x20) || - (cChar == GLOS_DELIM) ) - { - continue; - } - lang::IllegalArgumentException aIllegal; - aIllegal.Message = "group name must contain a-z, A-z, '_', ' ' only"; - throw aIllegal; - } - OUString sGroup(aGroupName); - if (sGroup.indexOf(GLOS_DELIM)<0) - { - sGroup += OUString(GLOS_DELIM) + "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, std::exception ) -{ - SolarMutexGuard aGuard; - // At first find the name with path extension - OUString sGroupName = pGlossaries->GetCompleteGroupName( aGroupName ); - if(sGroupName.isEmpty()) - throw container::NoSuchElementException(); - pGlossaries->DelGroupDoc(sGroupName); -} - -OUString SwXAutoTextContainer::getImplementationName(void) throw( uno::RuntimeException, std::exception ) -{ - return SwXAutoTextContainer_getImplementationName(); -} - -sal_Bool SwXAutoTextContainer::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -uno::Sequence< OUString > SwXAutoTextContainer::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) -{ - return SwXAutoTextContainer_getSupportedServiceNames(); -} - -namespace -{ - class theSwXAutoTextGroupUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXAutoTextGroupUnoTunnelId > {}; -} - -const uno::Sequence< sal_Int8 > & SwXAutoTextGroup::getUnoTunnelId() -{ - return theSwXAutoTextGroupUnoTunnelId::get().getSeq(); -} - -sal_Int64 SAL_CALL SwXAutoTextGroup::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException, std::exception) -{ - if( rId.getLength() == 16 - && 0 == memcmp( 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, std::exception ) -{ - 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, std::exception) -{ - 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(); - OUString aNewShort(aNewElementName); - OUString 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(); -} - -static 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, std::exception ) -{ - SolarMutexGuard aGuard; - if(hasByName(aName)) - throw container::ElementExistException(); - if(!xTextRange.is()) - throw uno::RuntimeException(); - - SwTextBlocks* pGlosGroup = pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName, sal_False) : 0; - OUString sShortName(aName); - OUString sLongName(aTitle); - if(pGlosGroup && !pGlosGroup->GetError()) - { - 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())); - } - - OUString sOnlyTxt; - OUString* pOnlyTxt = 0; - bool bNoAttr = !pxCursor && !pxRange; - if(bNoAttr) - { - sOnlyTxt = OUString(xTextRange->getString()); - pOnlyTxt = &sOnlyTxt; - } - - const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get(); - - SwDoc* pGDoc = pGlosGroup->GetDoc(); - - // Until there is an option for that, delete base util::URL - if(rCfg.IsSaveRelFile()) - { - INetURLObject aTemp(pGlosGroup->GetFileName()); - pGlosGroup->SetBaseURL( aTemp.GetMainURL(INetURLObject::NO_DECODE)); - } - else - pGlosGroup->SetBaseURL( OUString() ); - - 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, std::exception ) -{ - 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, std::exception ) -{ - SolarMutexGuard aGuard; - return sName; -} - -void SwXAutoTextGroup::setName(const OUString& rName) throw( uno::RuntimeException, std::exception ) -{ - 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; - OUString sNewGroup(rName); - if (sNewGroup.indexOf(GLOS_DELIM)<0) - { - sNewGroup += OUString(GLOS_DELIM) + "0"; - } - - //the name must be saved, the group may be invalidated while in RenameGroupDoc() - SwGlossaries* pTempGlossaries = pGlossaries; - - OUString 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - return ::getCppuType((uno::Reference<text::XAutoTextEntry>*)0); - -} - -sal_Bool SwXAutoTextGroup::hasElements(void) throw( uno::RuntimeException, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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 ) - { - OUString sCompare(pGlosGroup->GetShortName(i)); - if(sCompare.equalsIgnoreAsciiCase(rName)) - { - bRet = true; - break; - } - } - delete pGlosGroup; - return bRet; -} - -uno::Reference< beans::XPropertySetInfo > SwXAutoTextGroup::getPropertySetInfo(void) - throw( uno::RuntimeException, std::exception ) -{ - 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, std::exception) -{ - 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.isEmpty()) - throw lang::IllegalArgumentException(); - 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, std::exception ) -{ - 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, std::exception ) -{ -} - -void SwXAutoTextGroup::removePropertyChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ -} - -void SwXAutoTextGroup::addVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ -} - -void SwXAutoTextGroup::removeVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) - throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ -} - -void SwXAutoTextGroup::Invalidate() -{ - pGlossaries = 0; - sName = OUString(); - m_sGroupName = OUString(); -} - -OUString SwXAutoTextGroup::getImplementationName(void) throw( uno::RuntimeException, std::exception ) -{ - return OUString("SwXAutoTextGroup"); -} - -sal_Bool SwXAutoTextGroup::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -uno::Sequence< OUString > SwXAutoTextGroup::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) -{ - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.AutoTextGroup"; - return aRet; -} - -namespace -{ - class theSwXAutoTextEntryUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXAutoTextEntryUnoTunnelId > {}; -} - -const uno::Sequence< sal_Int8 > & SwXAutoTextEntry::getUnoTunnelId() -{ - return theSwXAutoTextEntryUnoTunnelId::get().getSeq(); -} - -sal_Int64 SAL_CALL SwXAutoTextEntry::getSomething( const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException, std::exception) -{ - if( rId.getLength() == 16 - && 0 == memcmp( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this )); - } - return 0; -} - -SwXAutoTextEntry::SwXAutoTextEntry(SwGlossaries* pGlss, const OUString& rGroupName, - const OUString& 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( false ); - xBodyText = 0; - xDocSh.Clear(); - } - } - } -} - -void SwXAutoTextEntry::GetBodyText () -{ - SolarMutexGuard aGuard; - - xDocSh = pGlossaries->EditGroupDoc ( sGroupName, sEntryName, sal_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, std::exception ) -{ - SolarMutexGuard aGuard; - EnsureBodyText(); - return pBodyText->createTextCursor(); -} - -uno::Reference< text::XTextCursor > SwXAutoTextEntry::createTextCursorByRange( - const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - SolarMutexGuard aGuard; - EnsureBodyText(); - pBodyText->insertTextContent ( xRange, xContent, bAbsorb ); -} - -void SwXAutoTextEntry::removeTextContent( - const uno::Reference< text::XTextContent > & xContent) - throw( container::NoSuchElementException, uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - EnsureBodyText(); - pBodyText->removeTextContent ( xContent ); -} - -uno::Reference< text::XText > SwXAutoTextEntry::getText(void) throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - uno::Reference< text::XText > xRet = (text::XText*)this; - return xRet; -} - -uno::Reference< text::XTextRange > SwXAutoTextEntry::getStart(void) throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - EnsureBodyText(); - return pBodyText->getStart(); -} - -uno::Reference< text::XTextRange > SwXAutoTextEntry::getEnd(void) throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - EnsureBodyText(); - return pBodyText->getEnd(); -} - -OUString SwXAutoTextEntry::getString(void) throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - EnsureBodyText(); - return pBodyText->getString(); -} - -void SwXAutoTextEntry::setString(const OUString& aString) throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - EnsureBodyText(); - pBodyText->setString( aString ); -} - -void SwXAutoTextEntry::applyTo(const uno::Reference< text::XTextRange > & xTextRange)throw( uno::RuntimeException, std::exception ) -{ - 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(); - } - - boost::scoped_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, std::exception ) -{ - return OUString("SwXAutoTextEntry"); -} - -sal_Bool SwXAutoTextEntry::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -uno::Sequence< OUString > SwXAutoTextEntry::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) -{ - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.AutoTextEntry"; - return aRet; -} - -uno::Reference< container::XNameReplace > SwXAutoTextEntry::getEvents() - throw( uno::RuntimeException, std::exception ) -{ - 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( - "SwAutoTextEventDescriptor"), - rAutoTextEntry(rAutoText) -{ -} - -SwAutoTextEventDescriptor::~SwAutoTextEventDescriptor() -{ -} - -OUString SwAutoTextEventDescriptor::getImplementationName() - throw( uno::RuntimeException, std::exception ) -{ - return sSwAutoTextEventDescriptor; -} - -void SwAutoTextEventDescriptor::replaceByName( - const sal_uInt16 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" ); - - SwGlossaries *const pGlossaries = - const_cast<SwGlossaries*>(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()) - { - sal_uInt16 nIndex = pBlocks->GetIndex( rAutoTextEntry.GetEntryName() ); - if( nIndex != USHRT_MAX ) - { - SvxMacroTableDtor aMacroTable; - if( pBlocks->GetMacroTable( nIndex, aMacroTable ) ) - { - aMacroTable.Insert( nEvent, rMacro ); - pBlocks->SetMacroTable( nIndex, aMacroTable ); - } - } - - delete pBlocks; - } - // else: ignore -} - -void SwAutoTextEventDescriptor::getByName( - SvxMacro& rMacro, - const sal_uInt16 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" ); - - SwGlossaries *const pGlossaries = - const_cast<SwGlossaries*>(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()) - { - sal_uInt16 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 deleted file mode 100644 index 1959f742947c..000000000000 --- a/sw/source/ui/uno/unodefaults.cxx +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <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( 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(); - // #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 deleted file mode 100644 index dc4a160596ed..000000000000 --- a/sw/source/ui/uno/unodefaults.hxx +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_SW_SOURCE_UI_UNO_UNODEFAULTS_HXX -#define INCLUDED_SW_SOURCE_UI_UNO_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( bool bReadOnly ) throw() SAL_OVERRIDE; - - 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 deleted file mode 100644 index 9815c9f3b424..000000000000 --- a/sw/source/ui/uno/unodispatch.cxx +++ /dev/null @@ -1,392 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <vcl/svapp.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/dispatch.hxx> -#include <svx/dataaccessdescriptor.hxx> -#include <comphelper/servicehelper.hxx> -#include <unodispatch.hxx> -#include <unobaseclass.hxx> -#include <view.hxx> -#include <cmdid.h> -#include "wrtsh.hxx" -#include "dbmgr.hxx" - -using namespace ::com::sun::star; - -static const char* cURLFormLetter = ".uno:DataSourceBrowser/FormLetter"; -static const char* cURLInsertContent = ".uno:DataSourceBrowser/InsertContent";//data into fields -static const char* cURLInsertColumns = ".uno:DataSourceBrowser/InsertColumns";//data into text -static const char* cURLDocumentDataSource = ".uno:DataSourceBrowser/DocumentDataSource";//current data source of the document -static 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, std::exception) -{ - DispatchMutexLock_Impl aLock(*this); - uno::Reference< frame::XDispatch> xResult; - // create some dispatch ... - if(m_pView && aURL.Complete.startsWith(".uno:DataSourceBrowser/")) - { - if(aURL.Complete.equalsAscii(cURLFormLetter) || - aURL.Complete.equalsAscii(cURLInsertContent) || - aURL.Complete.equalsAscii(cURLInsertColumns)|| - aURL.Complete.equalsAscii(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, std::exception) -{ - 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, std::exception) -{ - DispatchMutexLock_Impl aLock(*this); - return m_xSlaveDispatcher; -} - -void SwXDispatchProviderInterceptor::setSlaveDispatchProvider( - const uno::Reference< frame::XDispatchProvider >& xNewDispatchProvider ) throw(uno::RuntimeException, std::exception) -{ - DispatchMutexLock_Impl aLock(*this); - m_xSlaveDispatcher = xNewDispatchProvider; -} - -uno::Reference< frame::XDispatchProvider > SwXDispatchProviderInterceptor::getMasterDispatchProvider( ) - throw(uno::RuntimeException, std::exception) -{ - DispatchMutexLock_Impl aLock(*this); - return m_xMasterDispatcher; -} - -void SwXDispatchProviderInterceptor::setMasterDispatchProvider( - const uno::Reference< frame::XDispatchProvider >& xNewSupplier ) throw(uno::RuntimeException, std::exception) -{ - DispatchMutexLock_Impl aLock(*this); - m_xMasterDispatcher = xNewSupplier; -} - -void SwXDispatchProviderInterceptor::disposing( const lang::EventObject& ) - throw(uno::RuntimeException, std::exception) -{ - 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; -} - -namespace -{ - class theSwXDispatchProviderInterceptorUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXDispatchProviderInterceptorUnoTunnelId > {}; -} - -const uno::Sequence< sal_Int8 > & SwXDispatchProviderInterceptor::getUnoTunnelId() -{ - return theSwXDispatchProviderInterceptorUnoTunnelId::get().getSeq(); -} - -sal_Int64 SwXDispatchProviderInterceptor::getSomething( - const uno::Sequence< sal_Int8 >& aIdentifier ) - throw(uno::RuntimeException, std::exception) -{ - if( aIdentifier.getLength() == 16 - && 0 == memcmp( 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, std::exception) -{ - if(!m_pView) - throw uno::RuntimeException(); - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwNewDBMgr* pNewDBMgr = rSh.GetNewDBMgr(); - if(aURL.Complete.equalsAscii(cURLInsertContent)) - { - ::svx::ODataAccessDescriptor aDescriptor(aArgs); - SwMergeDescriptor aMergeDesc( DBMGR_MERGE, rSh, aDescriptor ); - pNewDBMgr->MergeNew(aMergeDesc); - } - else if(aURL.Complete.equalsAscii(cURLInsertColumns)) - { - pNewDBMgr->InsertText(rSh, aArgs); - } - else if(aURL.Complete.equalsAscii(cURLFormLetter)) - { - SfxUsrAnyItem aDBProperties(FN_PARAM_DATABASE_PROPERTIES, uno::makeAny(aArgs)); - m_pView->GetViewFrame()->GetDispatcher()->Execute( - FN_MAILMERGE_WIZARD, - SFX_CALLMODE_ASYNCHRON, - &aDBProperties, 0L); - } - else if(aURL.Complete.equalsAscii(cURLDocumentDataSource)) - { - OSL_FAIL("SwXDispatch::dispatch: this URL is not to be dispatched!"); - } - else if(aURL.Complete.equalsAscii(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.isEmpty(); - - StatusListenerList::iterator aListIter = m_aListenerList.begin(); - for(aListIter = m_aListenerList.begin(); aListIter != m_aListenerList.end(); ++aListIter) - { - StatusStruct_Impl aStatus = *aListIter; - if(aStatus.aURL.Complete.equalsAscii(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, std::exception) -{ - 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.equalsAscii(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.isEmpty(); - } - - 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, std::exception) -{ - 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, std::exception) -{ - 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 (!aStatus.aURL.Complete.equalsAscii(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, std::exception) -{ - 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(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 deleted file mode 100644 index 94c2f8570561..000000000000 --- a/sw/source/ui/uno/unodoc.cxx +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <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< OUString > SAL_CALL SwTextDocument_getSupportedServiceNames() throw() -{ - // return only top level services here! All others must be - // resolved by rtti! - uno::Sequence< OUString > aRet ( 1 ); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.TextDocument"; - - return aRet; -} - -OUString SAL_CALL SwTextDocument_getImplementationName() throw() -{ - return OUString( "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; - SwGlobals::ensure(); - SfxObjectShell* pShell = new SwDocShell( _nCreationFlags ); - return uno::Reference< uno::XInterface >( pShell->GetModel() ); -} - -// com.sun.star.comp.Writer.WebDocument - -uno::Sequence< OUString > SAL_CALL SwWebDocument_getSupportedServiceNames() throw() -{ - // return only top level services here! All others must be - // resolved by rtti! - uno::Sequence< OUString > aRet ( 1 ); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.WebDocument"; - - return aRet; -} - -OUString SAL_CALL SwWebDocument_getImplementationName() throw() -{ - return OUString( "com.sun.star.comp.Writer.WebDocument" ); -} - -uno::Reference< uno::XInterface > SAL_CALL SwWebDocument_createInstance( - const uno::Reference< lang::XMultiServiceFactory > & ) - throw( uno::Exception ) -{ - SolarMutexGuard aGuard; - SwGlobals::ensure(); - SfxObjectShell* pShell = new SwWebDocShell( SFX_CREATE_MODE_STANDARD ); - return uno::Reference< uno::XInterface >( pShell->GetModel() ); -} - -// com.sun.star.comp.Writer.GlobalDocument - -uno::Sequence< OUString > SAL_CALL SwGlobalDocument_getSupportedServiceNames() throw() -{ - uno::Sequence< OUString > aRet ( 1 ); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.GlobalDocument"; - - return aRet; -} - -OUString SAL_CALL SwGlobalDocument_getImplementationName() throw() -{ - return OUString( "com.sun.star.comp.Writer.GlobalDocument" ); -} - -uno::Reference< uno::XInterface > SAL_CALL SwGlobalDocument_createInstance( - const uno::Reference< lang::XMultiServiceFactory > &) - throw( uno::Exception ) -{ - SolarMutexGuard aGuard; - SwGlobals::ensure(); - 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 deleted file mode 100644 index c8b3252df75b..000000000000 --- a/sw/source/ui/uno/unofreg.cxx +++ /dev/null @@ -1,373 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "SwXFilterOptions.hxx" -#include "sal/types.h" -#include <osl/diagnose.h> -#include <cppuhelper/factory.hxx> -#include <sfx2/sfxmodelfactory.hxx> - -#include <string.h> - -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 ); - -// Layout dump filter -extern uno::Sequence< OUString > SAL_CALL LayoutDumpFilter_getSupportedServiceNames() throw(); -extern OUString SAL_CALL LayoutDumpFilter_getImplementationName() throw(); -extern uno::Reference< uno::XInterface > SAL_CALL LayoutDumpFilter_createInstance( const uno::Reference< XMultiServiceFactory > &rSMgr ) throw( uno::Exception ); - -// #i73788# -#include "cppuhelper/implementationentry.hxx" -namespace comp_FinalThreadManager { - -// component and service helper functions: -OUString SAL_CALL _getImplementationName(); -com::sun::star::uno::Sequence< 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 - -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 sw_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() ); - } - else if( LayoutDumpFilter_getImplementationName().equalsAsciiL( - pImplName, nImplNameLen ) ) - { - xFactory = ::cppu::createSingleFactory( xMSF, - LayoutDumpFilter_getImplementationName(), - LayoutDumpFilter_createInstance, - LayoutDumpFilter_getSupportedServiceNames() ); - } - 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 deleted file mode 100644 index 8e80738003e2..000000000000 --- a/sw/source/ui/uno/unomailmerge.cxx +++ /dev/null @@ -1,1227 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <vcl/svapp.hxx> -#include <osl/mutex.hxx> -#include <svl/itemprop.hxx> -#include <svl/urihelper.hxx> -#include <svx/dataaccessdescriptor.hxx> -#include <tools/shl.hxx> -#include <unotools/tempfile.hxx> -#include <sfx2/app.hxx> -#include <sfx2/docfile.hxx> -#include <sfx2/docfilt.hxx> -#include <comphelper/processfactory.hxx> -#include <comphelper/string.hxx> -#include <cppuhelper/supportsservice.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/Desktop.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 <unomid.h> - -#include <boost/scoped_ptr.hpp> - -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 namespace SWUnoHelper; - -typedef ::utl::SharedUNOComponent< XInterface > SharedComponent; - -osl::Mutex & GetMailMergeMutex() -{ - static osl::Mutex aMutex; - return aMutex; -} - -enum CloseResult -{ - eSuccess, // successfully closed - eVetoed, // vetoed, ownership transferred 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 (const 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 OUString &rURL, - bool bClose ) - throw (RuntimeException) -{ - // try to open the document readonly and hidden - Reference< frame::XModel > xTmpModel; - Sequence < PropertyValue > aArgs( 1 ); - aArgs[0].Name = "Hidden"; - sal_Bool bVal = sal_True; - aArgs[0].Value <<= bVal; - try - { - Reference < XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); - xTmpModel = Reference < XModel >( xDesktop->loadComponentFromURL( - rURL, "_blank", 0, aArgs ), UNO_QUERY ); - } - catch (const 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 is ok here, since the document will be explicitly closed - 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; - OUString m_sTemporaryFile; - sal_Int32 m_nPendingDeleteAttempts; - - public: - DelayedFileDeletion( const Reference< XModel >& _rxModel, - const OUString& _rTemporaryFile ); - - protected: - ~DelayedFileDeletion( ); - - // XCloseListener - virtual void SAL_CALL queryClosing( const EventObject& _rSource, sal_Bool _bGetsOwnership ) throw (util::CloseVetoException, RuntimeException, std::exception); - virtual void SAL_CALL notifyClosing( const EventObject& _rSource ) throw (RuntimeException, std::exception); - - // XEventListener - virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException, std::exception); - - private: - void implTakeOwnership( ); - DECL_LINK( OnTryDeleteFile, void* ); - - private: - DelayedFileDeletion( const DelayedFileDeletion& ); // never implemented - DelayedFileDeletion& operator=( const DelayedFileDeletion& ); // never implemented - }; - - DelayedFileDeletion::DelayedFileDeletion( const Reference< XModel >& _rxModel, const OUString& _rTemporaryFile ) - : - m_xDocument( _rxModel, UNO_QUERY ) - ,m_sTemporaryFile( _rTemporaryFile ) - ,m_nPendingDeleteAttempts( 0 ) - { - osl_atomic_increment( &m_refCount ); - try - { - if ( m_xDocument.is() ) - { - m_xDocument->addCloseListener( this ); - // successfully added -> keep ourself alive - acquire(); - } - else { - OSL_FAIL("DelayedFileDeletion::DelayedFileDeletion: model is no component!" ); - } - } - catch (const Exception&) - { - OSL_FAIL("DelayedFileDeletion::DelayedFileDeletion: could not register as event listener at the model!" ); - } - osl_atomic_decrement( &m_refCount ); - } - - IMPL_LINK_NOARG(DelayedFileDeletion, OnTryDeleteFile) - { - ::osl::ClearableMutexGuard aGuard( m_aMutex ); - - bool bSuccess = 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 = true; - } - catch (const util::CloseVetoException&) - { - // somebody vetoed -> next try - if ( m_nPendingDeleteAttempts ) - { - // next attempt - --m_nPendingDeleteAttempts; - m_aDeleteTimer.Start(); - } - else - bSuccess = true; // can't do anything here ... - } - catch (const Exception&) - { - OSL_FAIL("DelayedFileDeletion::OnTryDeleteFile: caught a strange exception!" ); - bSuccess = 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_FAIL("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, std::exception) - { - ::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, std::exception) - { - OSL_FAIL("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, std::exception) - { - OSL_FAIL("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( ) - { - } -} - -static bool DeleteTmpFile_Impl( - Reference< frame::XModel > &rxModel, - SfxObjectShellRef &rxDocSh, - const OUString &rTmpFileURL ) -{ - bool bRes = false; - if (!rTmpFileURL.isEmpty()) - { - 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 ) ), - nDataCommandType(sdb::CommandType::TABLE), - nOutputType(MailMergeType::PRINTER), - bEscapeProcessing(sal_True), //!! allow to process properties like "Filter", "Order", ... - bSinglePrintJobs(sal_False), - bFileNameFromColumn(sal_False), - bSendAsHTML(sal_False), - bSendAsAttachment(sal_False), - bSaveAsSingleFile(sal_False), - bDisposing(sal_False), - m_pMgr(0) -{ - // create empty document - // like in: SwModule::InsertEnv (appenv.cxx) - xDocSh = new SwDocShell( SFX_CREATE_MODE_STANDARD ); - xDocSh->DoInitNew( 0 ); - SfxViewFrame *pFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 ); - SwView *pView = (SwView*) pFrame->GetViewShell(); - pView->AttrChangedNotify( &pView->GetWrtShell() ); //So that SelectShell is called. - xModel = xDocSh->GetModel(); -} - -SwXMailMerge::~SwXMailMerge() -{ - if (!aTmpFileName.isEmpty()) - 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_FAIL("owner ship transfered to vetoing object!" ); - - xModel = 0; - xDocSh = 0; // destroy doc shell - } -} - -// Guarantee object consistence in case of an exception -class MailMergeExecuteFinalizer { -public: - MailMergeExecuteFinalizer(SwXMailMerge *mailmerge) - : m_pMailMerge(mailmerge) - { - assert(m_pMailMerge); //mailmerge object missing - } - ~MailMergeExecuteFinalizer() - { - osl::MutexGuard pMgrGuard( GetMailMergeMutex() ); - m_pMailMerge->m_pMgr = 0; - } - -private: - // Disallow copy - MailMergeExecuteFinalizer(const MailMergeExecuteFinalizer&) {} - - SwXMailMerge *m_pMailMerge; -}; - -uno::Any SAL_CALL SwXMailMerge::execute( - const uno::Sequence< beans::NamedValue >& rArguments ) - throw (IllegalArgumentException, Exception, - RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - MailMergeExecuteFinalizer aFinalizer(this); - - // 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; - - sal_Bool bOK = sal_True; - if (rName == UNO_NAME_SELECTION) - bOK = rValue >>= aCurSelection; - else if (rName == UNO_NAME_RESULT_SET) - bOK = rValue >>= xCurResultSet; - else if (rName == UNO_NAME_CONNECTION) - bOK = rValue >>= xCurConnection; - else if (rName == UNO_NAME_MODEL) - throw PropertyVetoException("Property is read-only: " + rName, static_cast < cppu::OWeakObject * > ( this ) ); - else if (rName == UNO_NAME_DATA_SOURCE_NAME) - bOK = rValue >>= aCurDataSourceName; - else if (rName == UNO_NAME_DAD_COMMAND) - bOK = rValue >>= aCurDataCommand; - else if (rName == UNO_NAME_FILTER) - bOK = rValue >>= aCurFilter; - else if (rName == UNO_NAME_DOCUMENT_URL) - { - bOK = rValue >>= aCurDocumentURL; - if (!aCurDocumentURL.isEmpty() - && !LoadFromURL_impl( xCurModel, xCurDocSh, aCurDocumentURL, false )) - throw RuntimeException("Failed to create document from URL: " + aCurDocumentURL, static_cast < cppu::OWeakObject * > ( this ) ); - } - else if (rName == UNO_NAME_OUTPUT_URL) - { - bOK = rValue >>= aCurOutputURL; - if (!aCurOutputURL.isEmpty()) - { - if (!UCB_IsDirectory(aCurOutputURL)) - throw IllegalArgumentException("URL does not point to a directory: " + aCurOutputURL, static_cast < cppu::OWeakObject * > ( this ), 0 ); - if (UCB_IsReadOnlyFileName(aCurOutputURL)) - throw IllegalArgumentException("URL is read-only: " + aCurOutputURL, static_cast < cppu::OWeakObject * > ( this ), 0 ); - } - } - else if (rName == UNO_NAME_FILE_NAME_PREFIX) - bOK = rValue >>= aCurFileNamePrefix; - else if (rName == UNO_NAME_DAD_COMMAND_TYPE) - bOK = rValue >>= nCurDataCommandType; - else if (rName == UNO_NAME_OUTPUT_TYPE) - bOK = rValue >>= nCurOutputType; - else if (rName == UNO_NAME_ESCAPE_PROCESSING) - bOK = rValue >>= bCurEscapeProcessing; - else if (rName == UNO_NAME_SINGLE_PRINT_JOBS) - bOK = rValue >>= bCurSinglePrintJobs; - else if (rName == UNO_NAME_FILE_NAME_FROM_COLUMN) - bOK = rValue >>= bCurFileNameFromColumn; - else if (rName == UNO_NAME_SUBJECT) - bOK = rValue >>= sSubject; - else if (rName == UNO_NAME_ADDRESS_FROM_COLUMN) - bOK = rValue >>= sAddressFromColumn; - else if (rName == UNO_NAME_SEND_AS_HTML) - bOK = rValue >>= bSendAsHTML; - else if (rName == UNO_NAME_MAIL_BODY) - bOK = rValue >>= sMailBody; - else if (rName == UNO_NAME_ATTACHMENT_NAME) - bOK = rValue >>= sAttachmentName; - else if (rName == UNO_NAME_ATTACHMENT_FILTER) - bOK = rValue >>= sAttachmentFilter; - else if (rName == UNO_NAME_COPIES_TO) - bOK = rValue >>= aCopiesTo; - else if (rName == UNO_NAME_BLIND_COPIES_TO) - bOK = rValue >>= aBlindCopiesTo; - else if (rName == UNO_NAME_SEND_AS_ATTACHMENT) - bOK = rValue >>= bSendAsAttachment; - else if (rName == UNO_NAME_PRINT_OPTIONS) - bOK = rValue >>= aPrintSettings; - else if (rName == UNO_NAME_SAVE_AS_SINGLE_FILE) - bOK = rValue >>= bSaveAsSingleFile; - else if (rName == UNO_NAME_SAVE_FILTER) - bOK = rValue >>= sSaveFilter; - else if (rName == UNO_NAME_SAVE_FILTER_OPTIONS) - bOK = rValue >>= sSaveFilterOptions; - else if (rName == UNO_NAME_SAVE_FILTER_DATA) - bOK = rValue >>= aSaveFilterData; - else if (rName == UNO_NAME_IN_SERVER_PASSWORD) - bOK = rValue >>= sInServerPassword; - else if (rName == UNO_NAME_OUT_SERVER_PASSWORD) - bOK = rValue >>= sOutServerPassword; - else - throw UnknownPropertyException( OUString( "Property is unknown: " ) + rName, static_cast < cppu::OWeakObject * > ( this ) ); - - if (!bOK) - throw IllegalArgumentException("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() ); - - bool bValid = 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 - { - bool bEverythingsFine = true; - for ( ; ( pBookmarks != pBookmarksEnd ) && bEverythingsFine; ++pBookmarks ) - { - if ( xRowLocate->moveToBookmark( *pBookmarks ) ) - *pTranslated <<= xCurResultSet->getRow(); - else - bEverythingsFine = false; - } - if ( bEverythingsFine ) - bValid = true; - } - catch (const Exception&) - { - bValid = false; - } - } - - if ( !bValid ) - { - throw IllegalArgumentException( - OUString( "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, sal_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 (!aCurDocumentURL.isEmpty()) - pView->AttrChangedNotify( &pView->GetWrtShell() );//So that SelectShell is called. - - SharedComponent aRowSetDisposeHelper; - if (!xCurResultSet.is()) - { - if (aCurDataSourceName.isEmpty() || aCurDataCommand.isEmpty() ) - { - OSL_FAIL("PropertyValues missing or unset"); - throw IllegalArgumentException("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( "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( "ActiveConnection", makeAny( xCurConnection ) ); - xRowSetPropSet->setPropertyValue( "DataSourceName", makeAny( aCurDataSourceName ) ); - xRowSetPropSet->setPropertyValue( "Command", makeAny( aCurDataCommand ) ); - xRowSetPropSet->setPropertyValue( "CommandType", makeAny( nCurDataCommandType ) ); - xRowSetPropSet->setPropertyValue( "EscapeProcessing", makeAny( bCurEscapeProcessing ) ); - xRowSetPropSet->setPropertyValue( "ApplyFilter", makeAny( sal_True ) ); - xRowSetPropSet->setPropertyValue( "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( "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; - - sal_uInt16 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("Invalid value of property: OutputType", static_cast < cppu::OWeakObject * > ( this ), 0 ); - } - - SwNewDBMgr* pMgr = rSh.GetNewDBMgr(); - //force layout creation - rSh.CalcLayout(); - OSL_ENSURE( pMgr, "database manager missing" ); - m_pMgr = pMgr; - - SwMergeDescriptor aMergeDesc( nMergeType, rSh, aDescriptor ); - - boost::scoped_ptr< SwMailMergeConfigItem > pMMConfigItem; - uno::Reference< mail::XMailService > xInService; - if (MailMergeType::PRINTER == nCurOutputType) - { - IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess(); - SwPrintData aPrtData( pIDDA->getPrintData() ); - 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.isEmpty()) - { - // if OutputURL or FileNamePrefix are missing get - // them from DocumentURL - aURLObj.SetSmartURL( aCurDocumentURL ); - if (aCurFileNamePrefix.isEmpty()) - aCurFileNamePrefix = aURLObj.GetBase(); // filename without extension - if (aCurOutputURL.isEmpty()) - { - aURLObj.removeSegment(); - aCurOutputURL = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); - } - } - else // default empty document without URL - { - if (aCurOutputURL.isEmpty()) - throw RuntimeException("OutputURL is not set and can not be obtained.", static_cast < cppu::OWeakObject * > ( this ) ); - } - - aURLObj.SetSmartURL( aCurOutputURL ); - OUString aPath = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI ); - - OUString aDelim = OUString(INET_PATH_TOKEN); - if (aPath.getLength() >= aDelim.getLength() && - aPath.copy( aPath.getLength() - aDelim.getLength() ) == aDelim) - aPath += aDelim; - if (bCurFileNameFromColumn) - pMgr->SetEMailColumn( aCurFileNamePrefix ); - else - { - aPath += aCurFileNamePrefix; - pMgr->SetEMailColumn( OUString() ); - } - pMgr->SetSubject( aPath ); - if(MailMergeType::FILE == nCurOutputType) - { - aMergeDesc.sSaveToFilter = sSaveFilter; - aMergeDesc.sSaveToFilterOptions = sSaveFilterOptions; - aMergeDesc.aSaveToFilterData = aSaveFilterData; - aMergeDesc.bCreateSingleFile = bSaveAsSingleFile; - } - else - { - pMgr->SetEMailColumn( sAddressFromColumn ); - if(sAddressFromColumn.isEmpty()) - throw RuntimeException("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.reset(new SwMailMergeConfigItem); - aMergeDesc.pMailMergeConfigItem = pMMConfigItem.get(); - aMergeDesc.xSmtpServer = SwMailMergeHelper::ConnectToSmtpServer( - *pMMConfigItem, - xInService, - sInServerPassword, sOutServerPassword ); - if( !aMergeDesc.xSmtpServer.is() || !aMergeDesc.xSmtpServer->isConnected()) - throw RuntimeException("Failed to connect to mail server.", static_cast < cppu::OWeakObject * > ( this ) ); - } - } - - // save document with temporary filename - const SfxFilter *pSfxFlt = SwIoSystem::GetFilterOfFormat( - OUString( FILTER_XML ), - SwDocShell::Factory().GetFilterContainer() ); - OUString aExtension(comphelper::string::stripStart(pSfxFlt->GetDefaultExtension(), '*')); - utl::TempFile aTempFile( OUString("SwMM"), &aExtension ); - aTmpFileName = aTempFile.GetURL(); - - Reference< XStorable > xStorable( xCurModel, UNO_QUERY ); - bool bStoredAsTemporary = false; - if ( xStorable.is() ) - { - try - { - xStorable->storeAsURL( aTmpFileName, Sequence< PropertyValue >() ); - bStoredAsTemporary = true; - } - catch (const Exception&) - { - } - } - if ( !bStoredAsTemporary ) - throw RuntimeException("Failed to save temporary file.", static_cast < cppu::OWeakObject * > ( this ) ); - - pMgr->SetMergeSilent( sal_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)); - sal_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 = ""; - } - // (in case it wasn't a temporary model, it will be closed in the dtor, at the latest) - - if (!bSucc) - throw Exception("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 SAL_CALL SwXMailMerge::cancel() throw (com::sun::star::uno::RuntimeException, std::exception) -{ - // Cancel may be called from a second thread, so this protects from m_pMgr - /// cleanup in the execute function. - osl::MutexGuard pMgrGuard( GetMailMergeMutex() ); - if (m_pMgr) - m_pMgr->MergeCancel(); -} - -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, std::exception) -{ - 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, std::exception) -{ - 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; - 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_FAIL("unknown WID"); - } - Any aOld( pData, pCur->aType ); - - bool bChanged = 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.isEmpty() - && !LoadFromURL_impl( xModel, xDocSh, aText, true )) - throw RuntimeException("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.isEmpty()) - { - if (!UCB_IsDirectory(aText)) - throw IllegalArgumentException("URL does not point to a directory: " + aText, static_cast < cppu::OWeakObject * > ( this ), 0 ); - if (UCB_IsReadOnlyFileName(aText)) - throw IllegalArgumentException("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_FAIL("invalid pointer" ); - } - OSL_ENSURE( bOK, "set value failed" ); - bChanged = true; - } - if (!bOK) - throw IllegalArgumentException("Property type mismatch or property not set: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ), 0 ); - - if (bChanged) - { - PropertyChangeEvent aChgEvt( (XPropertySet *) this, rPropertyName, - sal_False, pCur->nWID, aOld, rValue ); - launchEvent( aChgEvt ); - } - } -} - -uno::Any SAL_CALL SwXMailMerge::getPropertyValue( - const OUString& rPropertyName ) - throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) -{ - 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_FAIL("unknown WID"); - } - } - - return aRet; -} - -void SAL_CALL SwXMailMerge::addPropertyChangeListener( - const OUString& rPropertyName, - const uno::Reference< beans::XPropertyChangeListener >& rListener ) - throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) -{ - 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, std::exception) -{ - 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, std::exception) -{ - // no vetoable property, thus no support for vetoable change listeners - OSL_FAIL("not implemented"); -} - -void SAL_CALL SwXMailMerge::removeVetoableChangeListener( - const OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*rListener*/ ) - throw (UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) -{ - // no vetoable property, thus no support for vetoable change listeners - OSL_FAIL("not implemented"); -} - -void SAL_CALL SwXMailMerge::dispose() - throw(RuntimeException, std::exception) -{ - 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, std::exception) -{ - SolarMutexGuard aGuard; - if (!bDisposing && rxListener.is()) - aEvtListeners.addInterface( rxListener ); -} - -void SAL_CALL SwXMailMerge::removeEventListener( - const Reference< XEventListener >& rxListener ) - throw(RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - if (!bDisposing && rxListener.is()) - aEvtListeners.removeInterface( rxListener ); -} - -void SAL_CALL SwXMailMerge::addMailMergeEventListener( - const uno::Reference< XMailMergeListener >& rxListener ) - throw (RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - if (!bDisposing && rxListener.is()) - aMergeListeners.addInterface( rxListener ); -} - -void SAL_CALL SwXMailMerge::removeMailMergeEventListener( - const uno::Reference< XMailMergeListener >& rxListener ) - throw (RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - if (!bDisposing && rxListener.is()) - aMergeListeners.removeInterface( rxListener ); -} - -OUString SAL_CALL SwXMailMerge::getImplementationName() - throw(RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - return SwXMailMerge_getImplementationName(); -} - -sal_Bool SAL_CALL SwXMailMerge::supportsService( const OUString& rServiceName ) - throw(RuntimeException, std::exception) -{ - return cppu::supportsService(this, rServiceName); -} - -uno::Sequence< OUString > SAL_CALL SwXMailMerge::getSupportedServiceNames() - throw(RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - return SwXMailMerge_getSupportedServiceNames(); -} - -uno::Sequence< OUString > SAL_CALL SwXMailMerge_getSupportedServiceNames() - throw() -{ - uno::Sequence< OUString > aNames(2); - OUString *pName = aNames.getArray(); - pName[0] = "com.sun.star.text.MailMerge"; - pName[1] = "com.sun.star.sdb.DataAccessDescriptor"; - return aNames; -} - -OUString SAL_CALL SwXMailMerge_getImplementationName() - throw() -{ - return OUString( "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 - SwGlobals::ensure(); - 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 deleted file mode 100644 index ba9293248b9a..000000000000 --- a/sw/source/ui/uno/unomod.cxx +++ /dev/null @@ -1,990 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <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 <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/view/DocumentZoomType.hpp> -#include <comphelper/ChainablePropertySetInfo.hxx> -#include <cppuhelper/supportsservice.hxx> -#include <edtwin.hxx> -#include <rtl/ustrbuf.hxx> -#include <tools/urlobj.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; - -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_ZOOM_TYPE, - HANDLE_VIEWSET_ZOOM, - HANDLE_VIEWSET_SHOW_CONTENT_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, - HANDLE_VIEWSET_SCROLLBAR_TIPS -}; - -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 const aViewSettingsMap_Impl[] = - { - { OUString( "HelpURL" ), HANDLE_VIEWSET_HELP_URL , cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { OUString( "HorizontalRulerMetric"),HANDLE_VIEWSET_HORI_RULER_METRIC , cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, - { OUString( "IsRasterVisible"), HANDLE_VIEWSET_IS_RASTER_VISIBLE, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "IsSnapToRaster"), HANDLE_VIEWSET_IS_SNAP_TO_RASTER, cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "IsVertRulerRightAligned"),HANDLE_VIEWSET_VRULER_RIGHT , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowContentTips" ), HANDLE_VIEWSET_SHOW_CONTENT_TIPS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "RasterResolutionX"), HANDLE_VIEWSET_RASTER_RESOLUTION_X, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, - { OUString( "RasterResolutionY"), HANDLE_VIEWSET_RASTER_RESOLUTION_Y, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, - { OUString( "RasterSubdivisionX"), HANDLE_VIEWSET_RASTER_SUBDIVISION_X, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, - { OUString( "RasterSubdivisionY"), HANDLE_VIEWSET_RASTER_SUBDIVISION_Y, cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowAnnotations" ), HANDLE_VIEWSET_ANNOTATIONS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowBreaks"), HANDLE_VIEWSET_BREAKS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowDrawings"), HANDLE_VIEWSET_DRAWINGS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowFieldCommands"), HANDLE_VIEWSET_FIELD_COMMANDS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowFootnoteBackground"),HANDLE_VIEWSET_FOOTNOTE_BACKGROUND , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowGraphics"), HANDLE_VIEWSET_GRAPHICS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowHiddenCharacters"), HANDLE_VIEWSET_HIDDEN_CHARACTERS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowHiddenParagraphs"), HANDLE_VIEWSET_HIDDEN_PARAGRAPHS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowHiddenText"), HANDLE_VIEWSET_HIDDEN_TEXT , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowHoriRuler"), HANDLE_VIEWSET_HRULER , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowHoriScrollBar"), HANDLE_VIEWSET_HSCROLL , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowIndexMarkBackground"),HANDLE_VIEWSET_INDEX_MARK_BACKGROUND, cppu::UnoType<bool>::get(),PROPERTY_NONE, 0}, - { OUString( "ShowNonprintingCharacters"),HANDLE_VIEWSET_NONPRINTING_CHARACTERS, cppu::UnoType<bool>::get(),PROPERTY_NONE, 0}, - { OUString( "ShowOnlineLayout"), HANDLE_VIEWSET_ONLINE_LAYOUT , cppu::UnoType<bool>::get(), PropertyAttribute::MAYBEVOID, 0}, - { OUString( "ShowParaBreaks"), HANDLE_VIEWSET_PARA_BREAKS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowProtectedSpaces"), HANDLE_VIEWSET_PROTECTED_SPACES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowRulers"), HANDLE_VIEWSET_SHOW_RULER , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowScrollBarTips"), HANDLE_VIEWSET_SCROLLBAR_TIPS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowSoftHyphens"), HANDLE_VIEWSET_SOFT_HYPHENS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowSpaces"), HANDLE_VIEWSET_SPACES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowTableBoundaries"), HANDLE_VIEWSET_TABLE_BOUNDARIES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowTables"), HANDLE_VIEWSET_TABLES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowTabstops"), HANDLE_VIEWSET_TABSTOPS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowTextBoundaries"), HANDLE_VIEWSET_TEXT_BOUNDARIES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowTextFieldBackground"),HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND, cppu::UnoType<bool>::get(),PROPERTY_NONE, 0}, - { OUString( "ShowVertRuler"), HANDLE_VIEWSET_VRULER , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "ShowVertScrollBar"), HANDLE_VIEWSET_VSCROLL , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "SmoothScrolling"), HANDLE_VIEWSET_SMOOTH_SCROLLING , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "VerticalRulerMetric"), HANDLE_VIEWSET_VERT_RULER_METRIC , cppu::UnoType<sal_Int32>::get(), PROPERTY_NONE, 0}, - { OUString( "ZoomType"), HANDLE_VIEWSET_ZOOM_TYPE , cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, - { OUString( "ZoomValue"), HANDLE_VIEWSET_ZOOM , cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, - { OUString(), 0, css::uno::Type(), 0, 0 } - }; - return new ChainablePropertySetInfo ( aViewSettingsMap_Impl ); -} - -static ChainablePropertySetInfo * lcl_createPrintSettingsInfo() -{ - static PropertyInfo const aPrintSettingsMap_Impl[] = - { - { OUString( "PrintAnnotationMode" ), HANDLE_PRINTSET_ANNOTATION_MODE , cppu::UnoType<sal_Int16>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintBlackFonts" ), HANDLE_PRINTSET_BLACK_FONTS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintControls" ), HANDLE_PRINTSET_CONTROLS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintDrawings" ), HANDLE_PRINTSET_DRAWINGS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintGraphics" ), HANDLE_PRINTSET_GRAPHICS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintHiddenText"), HANDLE_PRINTSET_HIDDEN_TEXT , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintLeftPages" ), HANDLE_PRINTSET_LEFT_PAGES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintPageBackground" ), HANDLE_PRINTSET_PAGE_BACKGROUND , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintProspect" ), HANDLE_PRINTSET_PROSPECT , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintProspectRTL" ), HANDLE_PRINTSET_PROSPECT_RTL , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintReversed" ), HANDLE_PRINTSET_REVERSED , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintRightPages" ), HANDLE_PRINTSET_RIGHT_PAGES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintFaxName" ), HANDLE_PRINTSET_FAX_NAME , cppu::UnoType<OUString>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintPaperFromSetup" ), HANDLE_PRINTSET_PAPER_FROM_SETUP , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintTables" ), HANDLE_PRINTSET_TABLES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintTextPlaceholder"), HANDLE_PRINTSET_PLACEHOLDER , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintSingleJobs" ), HANDLE_PRINTSET_SINGLE_JOBS , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString( "PrintEmptyPages" ), HANDLE_PRINTSET_EMPTY_PAGES , cppu::UnoType<bool>::get(), PROPERTY_NONE, 0}, - { OUString(), 0, css::uno::Type(), 0, 0 } - }; - return new ChainablePropertySetInfo ( aPrintSettingsMap_Impl ); -} - -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( "com.sun.star.text.GlobalSettings"); - const Sequence< OUString > aSeq( &sService, 1 ); - return aSeq; -} - -OUString SAL_CALL SwXModule_getImplementationName() throw() -{ - return OUString( "SwXModule" ); -} - -SwXModule::SwXModule() : - pxViewSettings(0), - pxPrintSettings(0) -{ -} - -SwXModule::~SwXModule() -{ - delete pxViewSettings; - delete pxPrintSettings; -} - -Reference< XPropertySet > SwXModule::getViewSettings(void) throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(!pxViewSettings) - { - ((SwXModule*)this)->pxViewSettings = new Reference< XPropertySet > ; - OSL_FAIL("Web or Text?"); - *pxViewSettings = static_cast < HelperBaseNoState * > ( new SwXViewSettings( sal_False, 0 ) ); - } - return *pxViewSettings; -} - -Reference< XPropertySet > SwXModule::getPrintSettings(void) throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(!pxPrintSettings) - { - ((SwXModule*)this)->pxPrintSettings = new Reference< XPropertySet > ; - OSL_FAIL("Web or Text?"); - *pxPrintSettings = static_cast < HelperBaseNoState * > ( new SwXPrintSettings ( PRINT_SETTINGS_MODULE ) ); - } - return *pxPrintSettings; -} - -OUString SwXModule::getImplementationName(void) throw( RuntimeException, std::exception ) -{ - return SwXModule_getImplementationName(); -} - -sal_Bool SwXModule::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -Sequence< OUString > SwXModule::getSupportedServiceNames(void) throw( RuntimeException, std::exception ) -{ - return SwXModule_getSupportedServiceNames(); -} - -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 (); - mpPrtOpt = const_cast< SwPrintData * >(&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 (); - mpPrtOpt = const_cast< SwPrintData * >(&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, std::exception ) -{ - return OUString("SwXPrintSettings"); -} - -sal_Bool SwXPrintSettings::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -Sequence< OUString > SwXPrintSettings::getSupportedServiceNames(void) throw( RuntimeException, std::exception ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = "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 ( "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, sal_True); break; - case HANDLE_VIEWSET_NONPRINTING_CHARACTERS: mpViewOption->SetViewMetaChars( bVal ); break; - case HANDLE_VIEWSET_FOOTNOTE_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_True); break; - case HANDLE_VIEWSET_TEXT_FIELD_BACKGROUND : mpViewOption->SetAppearanceFlag(VIEWOPT_FIELD_SHADINGS, bVal, sal_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, sal_True); break; - case HANDLE_VIEWSET_TEXT_BOUNDARIES : mpViewOption->SetDocBoundaries(bVal); break; - case HANDLE_VIEWSET_SMOOTH_SCROLLING : mpViewOption->SetSmoothScroll(bVal); break; - case HANDLE_VIEWSET_SHOW_CONTENT_TIPS : mpViewOption->SetShowContentTips(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_SCROLLBAR_TIPS : mpViewOption->SetShowScrollBarTips(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; - 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( - OUString( "SwXViewSettings: invalid zoom type"), 0, 0); - } - mpViewOption->SetZoomType( eZoom ); - mbApplyZoom = sal_True; - } - break; - case HANDLE_VIEWSET_ONLINE_LAYOUT : - { - if( pView && !bVal != !pView->GetWrtShell().GetViewOptions()->getBrowseMode() ) - { - SwViewOption aOpt( *pView->GetWrtShell().GetViewOptions() ); - aOpt.setBrowseMode( bVal ); - pView->GetWrtShell().ApplyViewOptions( aOpt ); - pView->RecheckBrowseMode(); - - // must be set in mpViewOption as this will overwrite settings in _post! - if(mpViewOption) - mpViewOption->setBrowseMode(bVal); - - // disable multiple layout - pView->GetDocShell()->ToggleBrowserMode(bVal, pView ); - } - } - break; - case HANDLE_VIEWSET_HELP_URL : - { - if ( pView ) - { - OUString sHelpURL; - if ( ! ( rValue >>= sHelpURL ) ) - throw IllegalArgumentException(); - - INetURLObject aHID( sHelpURL ); - if ( aHID.GetProtocol() == INET_PROT_HID ) - pView->GetEditWin().SetHelpId( OUStringToOString( aHID.GetURLPath(), RTL_TEXTENCODING_UTF8 ) ); - else - throw IllegalArgumentException (); - } - 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->ChangeVRulerMetric((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 ) -{ - 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(sal_True); break; - case HANDLE_VIEWSET_VRULER : bBoolVal = mpConstViewOption->IsViewVRuler(sal_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_SHOW_CONTENT_TIPS : bBoolVal = mpConstViewOption->IsShowContentTips(); 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_SCROLLBAR_TIPS : bBoolVal = mpConstViewOption->IsShowScrollBarTips(); 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_FAIL("SwXViewSettings: invalid zoom type"); - break; - } - rValue <<= nRet; - } - break; - case HANDLE_VIEWSET_ONLINE_LAYOUT: - if(pView) - bBoolVal = pView->GetWrtShell().GetViewOptions()->getBrowseMode(); - break; - case HANDLE_VIEWSET_HELP_URL : - { - if ( pView ) - { - bBool = false; - OUStringBuffer sHelpURL; - sHelpURL.appendAscii ( INET_HID_SCHEME ); - SwEditWin &rEditWin = pView->GetEditWin(); - sHelpURL.append( OStringToOUString( rEditWin.GetHelpId(), RTL_TEXTENCODING_UTF8 ) ); - rValue <<= sHelpURL.makeStringAndClear(); - } - else - throw UnknownPropertyException(); - } - break; - case HANDLE_VIEWSET_HORI_RULER_METRIC: - { - if ( pView ) - { - FieldUnit eUnit; - pView->GetHRulerMetric( eUnit ); - rValue <<= (sal_Int32)eUnit; - } - else - { - const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb ); - rValue <<= (sal_Int32)pUsrPref->GetHScrollMetric(); - } - bBool = false; - } - break; - case HANDLE_VIEWSET_VERT_RULER_METRIC: - { - if ( pView ) - { - FieldUnit eUnit; - pView->GetVRulerMetric( eUnit ); - rValue <<= (sal_Int32)eUnit; - } - else - { - const SwMasterUsrPref* pUsrPref = SW_MOD()->GetUsrPref( bWeb ); - rValue <<= (sal_Int32)pUsrPref->GetVScrollMetric(); - } - bBool = false; - } - break; - default: OSL_FAIL("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, std::exception ) -{ - return OUString("SwXViewSettings"); -} - -sal_Bool SwXViewSettings::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -Sequence< OUString > SwXViewSettings::getSupportedServiceNames(void) throw( RuntimeException, std::exception ) -{ - Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = "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 deleted file mode 100644 index 4acb8e88d816..000000000000 --- a/sw/source/ui/uno/unomodule.cxx +++ /dev/null @@ -1,154 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/frame/DispatchResultState.hpp> - -#include "swmodule.hxx" -#include "swdll.hxx" -#include "unomodule.hxx" -#include <cppuhelper/supportsservice.hxx> -#include <sfx2/objface.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/request.hxx> -#include <osl/mutex.hxx> -#include <vcl/svapp.hxx> - -using namespace css; - -OUString SAL_CALL SwUnoModule_getImplementationName() throw( uno::RuntimeException ) -{ - return OUString( "com.sun.star.comp.Writer.WriterModule" ); -} - -uno::Sequence< OUString > SAL_CALL SwUnoModule_getSupportedServiceNames() throw( uno::RuntimeException ) -{ - uno::Sequence< OUString > aSeq( 1 ); - aSeq[0] = "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, std::exception) -{ - // 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; - SwGlobals::ensure(); - 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, std::exception ) -{ - 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, std::exception ) -{ -} - -void SAL_CALL SwUnoModule::removeStatusListener( - const uno::Reference< frame::XStatusListener > & /*xControl*/, - const util::URL& /*aURL*/) throw( uno::RuntimeException, std::exception ) -{ -} - -uno::Sequence< uno::Reference< frame::XDispatch > > SAL_CALL SwUnoModule::queryDispatches( - const uno::Sequence< frame::DispatchDescriptor >& seqDescripts ) throw( uno::RuntimeException, std::exception ) -{ - sal_Int32 nCount = seqDescripts.getLength(); - uno::Sequence< uno::Reference< frame::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 -uno::Reference< frame::XDispatch > SAL_CALL SwUnoModule::queryDispatch( - const util::URL& aURL, const OUString& /*sTargetFrameName*/, - sal_Int32 /*eSearchFlags*/ ) throw( uno::RuntimeException, std::exception ) -{ - uno::Reference< frame::XDispatch > xReturn; - - SolarMutexGuard aGuard; - SwGlobals::ensure(); - const SfxSlot* pSlot = SW_MOD()->GetInterface()->GetSlot( aURL.Complete ); - if ( pSlot ) - xReturn = uno::Reference< frame::XDispatch >(static_cast< frame::XDispatch* >(this), uno::UNO_QUERY); - - return xReturn; -} - -// XServiceInfo -OUString SAL_CALL SwUnoModule::getImplementationName( ) throw(uno::RuntimeException, std::exception) -{ - return SwUnoModule_getImplementationName(); -} - -sal_Bool SAL_CALL SwUnoModule::supportsService( const OUString& sServiceName ) throw(uno::RuntimeException, std::exception) -{ - return cppu::supportsService(this, sServiceName); -} - -uno::Sequence< OUString > SAL_CALL SwUnoModule::getSupportedServiceNames( ) throw(uno::RuntimeException, std::exception) -{ - 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 deleted file mode 100644 index a32e2c5dfc4b..000000000000 --- a/sw/source/ui/uno/unomodule.hxx +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_SW_SOURCE_UI_UNO_UNOMODULE_HXX -#define INCLUDED_SW_SOURCE_UI_UNO_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; - } - } - } -} - -class SwUnoModule : public ::cppu::WeakImplHelper3< css::frame::XDispatchProvider, css::frame::XNotifyingDispatch, css::lang::XServiceInfo > -{ - css::uno::Reference < css::lang::XMultiServiceFactory > m_xFactory; - -public: - SwUnoModule( const css::uno::Reference < css::lang::XMultiServiceFactory >& xFactory ) - : m_xFactory( xFactory ) - {} - - // XNotifyingDispatch - virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs, const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw (css::uno::RuntimeException, std::exception); - - // XDispatch - virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs ) throw( css::uno::RuntimeException, std::exception ); - virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) throw( css::uno::RuntimeException, std::exception ); - virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > & xControl, const css::util::URL& aURL) throw( css::uno::RuntimeException, std::exception ); - - // XDispatchProvider - virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( const css::uno::Sequence< css::frame::DispatchDescriptor >& seqDescriptor ) throw( css::uno::RuntimeException, std::exception ) ; - virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch( const css::util::URL & aURL , - const OUString & sTargetFrameName, - sal_Int32 eSearchFlags ) throw( css::uno::RuntimeException, std::exception ) ; - // XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) throw(css::uno::RuntimeException, std::exception); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(css::uno::RuntimeException, std::exception); - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(css::uno::RuntimeException, std::exception); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/uno/unotxdoc.cxx b/sw/source/ui/uno/unotxdoc.cxx deleted file mode 100644 index 6a6ce86d52f6..000000000000 --- a/sw/source/ui/uno/unotxdoc.cxx +++ /dev/null @@ -1,3994 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <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 <sfx2/printer.hxx> -#include <toolkit/helper/vclunohelper.hxx> -#include <toolkit/awt/vclxdevice.hxx> -#include <cmdid.h> -#include <swtypes.hxx> -#include <wdocsh.hxx> -#include <wrtsh.hxx> -#include <pview.hxx> -#include <viewsh.hxx> -#include <pvprtdat.hxx> -#include <printdata.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> -#include <unoprnms.hxx> -#include <unostyle.hxx> -#include <unodraw.hxx> -#include <svl/eitem.hxx> -#include <pagedesc.hxx> -#include <unotools/textsearch.hxx> -#include <unocrsr.hxx> -#include <unofieldcoll.hxx> -#include <unoidxcoll.hxx> -#include <unocrsrhelper.hxx> -#include <unotxvw.hxx> -#include <poolfmt.hxx> -#include <globdoc.hxx> -#include <viewopt.hxx> -#include <unochart.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 <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 <doc.hxx> -#include <editeng/forbiddencharacterstable.hxx> -#include <svl/zforlist.hxx> -#include <drawdoc.hxx> -#include <SwStyleNameMapper.hxx> -#include <osl/file.hxx> -#include <comphelper/storagehelper.hxx> -#include <cppuhelper/supportsservice.hxx> - -// #i12836# enhanced pdf export -#include <EnhancedPDFExportHelper.hxx> -#include <numrule.hxx> - -#include <editeng/langitem.hxx> -#include <docary.hxx> -#include <i18nlangtag/languagetag.hxx> - -#include <format.hxx> -#include <charfmt.hxx> -#include <fmtcol.hxx> -#include <istyleaccess.hxx> - -#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> -#include <comphelper/processfactory.hxx> -#include <comphelper/servicehelper.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 ::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 - -extern bool sw_GetPostIts( IDocumentFieldsAccess* pIDFA, _SetGetExpFlds * pSrtLst ); - -static SwPrintUIOptions * lcl_GetPrintUIOptions( - SwDocShell * pDocShell, - const SfxViewShell * pView ) -{ - if (!pDocShell) - return NULL; - - const sal_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 = sw_GetPostIts( pDocShell->GetDoc(), 0 ); - - // get default values to use in dialog from documents SwPrintData - const SwPrintData &rPrintData = pDocShell->GetDoc()->getPrintData(); - - // Get current page number - sal_uInt16 nCurrentPage = 1; - SwWrtShell* pSh = pDocShell->GetWrtShell(); - if (pSh) - { - SwPaM* pShellCrsr = pSh->GetCrsr(); - nCurrentPage = pShellCrsr->GetPageNum(true, 0); - } - else if (!bSwSrcView) - { - const SwPagePreview* pPreview = dynamic_cast< const SwPagePreview* >(pView); - OSL_ENSURE(pPreview, "Unexpected type of the view shell"); - if (pPreview) - nCurrentPage = pPreview->GetSelectedPage(); - } - return new SwPrintUIOptions( nCurrentPage, bWebDoc, bSwSrcView, bHasSelection, bHasPostIts, rPrintData ); -} - -static SwTxtFmtColl *lcl_GetParaStyle(const OUString& 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; -} - -static void lcl_DisposeView( SfxViewFrame* pToClose, SwDocShell* pDocShell ) -{ - // check if the view frame still exists - SfxViewFrame* pFound = SfxViewFrame::GetFirst( pDocShell, - sal_False ); - while(pFound) - { - if( pFound == pToClose) - { - pToClose->DoClose(); - break; - } - pFound = SfxViewFrame::GetNext( *pFound, - pDocShell, - sal_False ); - } -} - -class SwXTextDocument::Impl -{ -private: - ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper - -public: - ::cppu::OInterfaceContainerHelper m_RefreshListeners; - - Impl() : m_RefreshListeners(m_Mutex) { } - -}; - -namespace -{ - class theSwXTextDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextDocumentUnoTunnelId > {}; -} - -const Sequence< sal_Int8 > & SwXTextDocument::getUnoTunnelId() -{ - return theSwXTextDocumentUnoTunnelId::get().getSeq(); -} - -sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rId ) - throw(RuntimeException, std::exception) -{ - if( rId.getLength() == 16 - && 0 == memcmp( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >( this )); - } - if( rId.getLength() == 16 - && 0 == memcmp( 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, std::exception) -{ - 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::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, std::exception) -{ - return SfxBaseModel::queryAdapter(); -} - -Sequence< uno::Type > SAL_CALL SwXTextDocument::getTypes() throw(RuntimeException, std::exception) -{ - 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) - , m_pImpl(new Impl) - , - 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 ), - // #i117783# - bApplyPagePrintSettingsFromXPagePrintable( sal_False ) -{ -} - -SwXTextDocument::~SwXTextDocument() -{ - InitNewDoc(); - if(xNumFmtAgg.is()) - { - Reference< XInterface > x0; - xNumFmtAgg->setDelegator(x0); - xNumFmtAgg = 0; - } - delete m_pPrintUIOptions; - if (m_pRenderData && m_pRenderData->IsViewOptionAdjust()) - { // rhbz#827695: this can happen if the last page is not printed - // the SwViewShell has been deleted already by SwView::~SwView - // FIXME: replace this awful implementation of XRenderable with - // something less insane that has its own view - m_pRenderData->ViewOptionAdjustCrashPreventionKludge(); - } - 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 && !pNumFmt->GetNumberFormatter()) - pNumFmt->SetNumberFormatter(pDocShell->GetDoc()->GetNumberFormatter( sal_True )); - } - } -} - -Reference< XText > SwXTextDocument::getText(void) throw( RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - throw RuntimeException(); - if(!xBodyText.is()) - { - pBodyText = new SwXBodyText(pDocShell->GetDoc()); - xBodyText = pBodyText; - } - return xBodyText; -} - -void SwXTextDocument::reformat(void) throw( RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - throw RuntimeException(); -} - -void SwXTextDocument::lockControllers(void) throw( RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(IsValid()) - { - UnoActionContext* pContext = new UnoActionContext(pDocShell->GetDoc()); - aActionArr.push_front(pContext); - } - else - throw RuntimeException(); -} - -void SwXTextDocument::unlockControllers(void) throw( RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(!aActionArr.empty()) - { - UnoActionContext* pContext = aActionArr.front(); - aActionArr.pop_front(); - delete pContext; - } - else - throw RuntimeException(); -} - -sal_Bool SwXTextDocument::hasControllersLocked(void) throw( RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - return !aActionArr.empty(); -} - -Reference< frame::XController > SwXTextDocument::getCurrentController(void) throw( RuntimeException, std::exception ) -{ - return SfxBaseModel::getCurrentController(); -} - -void SwXTextDocument::setCurrentController(const Reference< frame::XController > & xController) - throw( NoSuchElementException, RuntimeException, std::exception ) -{ - SfxBaseModel::setCurrentController(xController); -} - -Reference< XInterface > SwXTextDocument::getCurrentSelection() throw( RuntimeException, std::exception ) -{ - 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, std::exception ) -{ - return SfxBaseModel::attachResource(aURL, aArgs); -} - -OUString SwXTextDocument::getURL(void) throw( RuntimeException, std::exception ) -{ - return SfxBaseModel::getURL(); -} - -Sequence< beans::PropertyValue > SwXTextDocument::getArgs(void) throw( RuntimeException, std::exception ) -{ - return SfxBaseModel::getArgs(); -} - -void SwXTextDocument::connectController(const Reference< frame::XController > & xController) throw( RuntimeException, std::exception ) -{ - SfxBaseModel::connectController(xController); -} - -void SwXTextDocument::disconnectController(const Reference< frame::XController > & xController) throw( RuntimeException, std::exception ) -{ - SfxBaseModel::disconnectController(xController); -} - -void SwXTextDocument::dispose(void) throw( RuntimeException, std::exception ) -{ - SfxBaseModel::dispose(); -} - -void SwXTextDocument::close( sal_Bool bDeliverOwnership ) throw( util::CloseVetoException, RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(IsValid() && m_pHiddenViewFrame) - lcl_DisposeView( m_pHiddenViewFrame, pDocShell); - SfxBaseModel::close(bDeliverOwnership); -} - -void SwXTextDocument::addEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException, std::exception ) -{ - SfxBaseModel::addEventListener(aListener); -} - -void SwXTextDocument::removeEventListener(const Reference< lang::XEventListener > & aListener) throw( RuntimeException, std::exception ) -{ - SfxBaseModel::removeEventListener(aListener); -} - -Reference< XPropertySet > SwXTextDocument::getLineNumberingProperties(void) - throw( RuntimeException, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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; - - // Search should take place anywhere - 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); - sal_Bool bCancel; - nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles, - eStart, eEnd, bCancel, - (FindRanges)eRanges, - !pSearch->sSearchText.isEmpty() ? &aSearchOpt : 0, - &aReplace ); - } - else if(pSearch->bStyles) - { - SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc()); - SwTxtFmtColl *pReplaceColl = lcl_GetParaStyle(pSearch->sReplaceText, pUnoCrsr->GetDoc()); - - sal_Bool bCancel; - nResult = pUnoCrsr->Find( *pSearchColl, - eStart, eEnd, bCancel, - (FindRanges)eRanges, pReplaceColl ); - - } - else - { - //todo/mba: assuming that notes should be omitted - sal_Bool bSearchInNotes = sal_False; - sal_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, std::exception ) -{ - SolarMutexGuard aGuard; - Reference< util::XSearchDescriptor > xRet = new SwXTextSearch; - return xRet; - -} - -// Used for findAll/First/Next - -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 ); - -/** - * The following combinations are allowed: - * - Search in the body: -> FND_IN_BODY - * - Search all in the body: -> FND_IN_BODYONLY | FND_IN_SELALL - * - Search in selections: one / all -> FND_IN_SEL [ | FND_IN_SELALL ] - * - Search outside the body: one / all -> FND_IN_OTHER [ | FND_IN_SELALL ] - * - Search everywhere all: -> FND_IN_SELALL - */ - int eRanges(FND_IN_BODY); - if(bParentInExtra) - eRanges = FND_IN_OTHER; - if(bAll) //always - everywhere? - 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_CHARFMT, - 0); - pSearch->FillSearchItemSet(aSearch); - sal_Bool bCancel; - nResult = (sal_Int32)pUnoCrsr->Find( aSearch, !pSearch->bStyles, - eStart, eEnd, bCancel, - (FindRanges)eRanges, - !pSearch->sSearchText.isEmpty() ? &aSearchOpt : 0, - 0 ); - } - else if(pSearch->bStyles) - { - SwTxtFmtColl *pSearchColl = lcl_GetParaStyle(pSearch->sSearchText, pUnoCrsr->GetDoc()); - //pSearch->sReplaceText - SwTxtFmtColl *pReplaceColl = 0; - sal_Bool bCancel; - nResult = (sal_Int32)pUnoCrsr->Find( *pSearchColl, - eStart, eEnd, bCancel, - (FindRanges)eRanges, pReplaceColl ); - } - else - { - //todo/mba: assuming that notes should be omitted - sal_Bool bSearchInNotes = sal_False; - sal_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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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("PageRows", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int16)aData.GetCol(); - pArray[1] = beans::PropertyValue("PageColumns", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetLeftSpace()); - pArray[2] = beans::PropertyValue("LeftMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetRightSpace()); - pArray[3] = beans::PropertyValue("RightMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetTopSpace()); - pArray[4] = beans::PropertyValue("TopMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetBottomSpace()); - pArray[5] = beans::PropertyValue("BottomMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetHorzSpace()); - pArray[6] = beans::PropertyValue("HoriMargin", -1, aVal, PropertyState_DIRECT_VALUE); - aVal <<= (sal_Int32)TWIP_TO_MM100_UNSIGNED(aData.GetVertSpace()); - pArray[7] = beans::PropertyValue("VertMargin", -1, aVal, PropertyState_DIRECT_VALUE); - sal_Bool bTemp = aData.GetLandscape(); - aVal.setValue(&bTemp, ::getCppuBooleanType()); - pArray[8] = beans::PropertyValue("IsLandscape", -1, aVal, PropertyState_DIRECT_VALUE); - } - else - throw RuntimeException(); - return aSeq; -} - -static 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; -} - -static OUString lcl_CreateOutlineString( sal_uInt16 nIndex, - const SwOutlineNodes& rOutlineNodes, const SwNumRule* pOutlRule) -{ - OUString 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 += OUString::number( nVal ); - sEntry += "."; - } - sEntry += rOutlineNodes[ nIndex ]-> - GetTxtNode()->GetExpandTxt( 0, -1, false ); - return sEntry; -} - -void SwXTextDocument::setPagePrintSettings(const Sequence< beans::PropertyValue >& aSettings) - throw( RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(IsValid()) - { - SwPagePreviewPrtData aData; - //if only a few properties are coming, then use the current settings - 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++) - { - OUString sName = pProperties[i].Name; - const Any& rVal = pProperties[i].Value; - sal_Bool bException; - sal_uInt32 nVal = lcl_Any_To_ULONG(rVal, bException); - if( sName.equalsAscii("PageRows" ) ) - { - if(!nVal || nVal > 0xff) - throw RuntimeException(); - aData.SetRow((sal_uInt8)nVal); - } - else if(sName.equalsAscii("PageColumns")) - { - if(!nVal || nVal > 0xff) - throw RuntimeException(); - aData.SetCol((sal_uInt8)nVal); - } - else if(sName.equalsAscii("LeftMargin")) - { - aData.SetLeftSpace(MM100_TO_TWIP_UNSIGNED(nVal)); - } - else if(sName.equalsAscii("RightMargin")) - { - aData.SetRightSpace(MM100_TO_TWIP_UNSIGNED(nVal)); - } - else if(sName.equalsAscii("TopMargin")) - { - aData.SetTopSpace(MM100_TO_TWIP_UNSIGNED(nVal)); - } - else if(sName.equalsAscii("BottomMargin")) - { - aData.SetBottomSpace(MM100_TO_TWIP_UNSIGNED(nVal)); - } - else if(sName.equalsAscii("HoriMargin")) - { - aData.SetHorzSpace(MM100_TO_TWIP_UNSIGNED(nVal)); - } - else if(sName.equalsAscii("VertMargin")) - { - aData.SetVertSpace(MM100_TO_TWIP_UNSIGNED(nVal)); - } - else if(sName.equalsAscii("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, std::exception ) -{ - 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, true)); - - 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 == UNO_NAME_FILE_NAME ) - { - OUString sFileURL; - if ( (rProp.Value >>= sFileURL ) ) - { - // Convert the File URL into a system dependent 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 == UNO_NAME_COPY_COUNT ) - { - sal_Int32 nCopies = 0; - aValue >>= nCopies; - aReq.AppendItem(SfxInt16Item( SID_PRINT_COPIES, (sal_Int16)nCopies ) ); - } - - // Collate-Property - else if ( rProp.Name == UNO_NAME_COLLATE ) - { - 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 == UNO_NAME_SORT ) - { - 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 == UNO_NAME_PAGES ) - { - OUString sTmp; - if ( rProp.Value >>= sTmp ) - aReq.AppendItem( SfxStringItem( SID_PRINT_PAGES, sTmp ) ); - else - throw IllegalArgumentException(); - } - } - - // #i117783# - bApplyPagePrintSettingsFromXPagePrintable = sal_True; - pFrame->GetViewShell()->ExecuteSlot(aReq); - // Frame close - pFrame->DoClose(); - - } - else - throw RuntimeException(); -} - -Reference< XNameAccess > SwXTextDocument::getReferenceMarks(void) - throw( RuntimeException, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception) -{ - 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, std::exception ) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - throw RuntimeException(); - if(!pxXDrawPage) - { - ((SwXTextDocument*)this)->pDrawPage = new SwXDrawPage(pDocShell->GetDoc()); - ((SwXTextDocument*)this)->pxXDrawPage = new Reference< drawing::XDrawPage >(pDrawPage); - // Create a Reference to trigger the complete initialization of the - // object. Otherwise in some corner cases it would get initialized - // at ::InitNewDoc -> which would get called during - // close() or dispose() -> n#681746 - uno::Reference<lang::XComponent> xComp( *pxXDrawPage, uno::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; - lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this)); - m_pImpl->m_RefreshListeners.disposeAndClear(ev); -} - -void SwXTextDocument::Reactivate(SwDocShell* pNewDocShell) -{ - if(pDocShell && pDocShell != pNewDocShell) - Invalidate(); - pDocShell = pNewDocShell; - bObjectValid = sal_True; -} - -void SwXTextDocument::InitNewDoc() -{ - // first invalidate all collections, then delete references and Set to zero - 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) - { - // #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; - } -} - -css::uno::Reference<css::uno::XInterface> SwXTextDocument::create( - OUString const & rServiceName, - css::uno::Sequence<css::uno::Any> const * arguments) -{ - SolarMutexGuard aGuard; - if (!IsValid()) - { - throw RuntimeException(); - } - sal_uInt16 nType = SwXServiceProvider::GetProviderType(rServiceName); - if (nType != SW_SERVICE_INVALID) - { - return SwXServiceProvider::MakeInstance(nType, pDocShell->GetDoc()); - } - if (rServiceName == "com.sun.star.drawing.DashTable") - { - return GetPropertyHelper()->GetDrawTable(SW_CREATE_DASH_TABLE); - } - if (rServiceName == "com.sun.star.drawing.GradientTable") - { - return GetPropertyHelper()->GetDrawTable(SW_CREATE_GRADIENT_TABLE); - } - if (rServiceName == "com.sun.star.drawing.HatchTable") - { - return GetPropertyHelper()->GetDrawTable(SW_CREATE_HATCH_TABLE); - } - if (rServiceName == "com.sun.star.drawing.BitmapTable") - { - return GetPropertyHelper()->GetDrawTable(SW_CREATE_BITMAP_TABLE); - } - if (rServiceName == "com.sun.star.drawing.TransparencyGradientTable") - { - return GetPropertyHelper()->GetDrawTable(SW_CREATE_TRANSGRADIENT_TABLE); - } - if (rServiceName == "com.sun.star.drawing.MarkerTable") - { - return GetPropertyHelper()->GetDrawTable(SW_CREATE_MARKER_TABLE); - } - if (rServiceName == "com.sun.star.drawing.Defaults") - { - return GetPropertyHelper()->GetDrawTable(SW_CREATE_DRAW_DEFAULTS); - } - if (rServiceName == "com.sun.star.document.Settings") - { - return Reference<XInterface>(*new SwXDocumentSettings(this)); - } - if (rServiceName == "com.sun.star.document.ImportEmbeddedObjectResolver") - { - return static_cast<cppu::OWeakObject *>( - new SvXMLEmbeddedObjectHelper( - *pDocShell, EMBEDDEDOBJECTHELPER_MODE_READ)); - } - if (rServiceName == "com.sun.star.text.DocumentSettings") - { - return Reference<XInterface>(*new SwXDocumentSettings(this)); - } - if (rServiceName == "com.sun.star.chart2.data.DataProvider") - { - return Reference<XInterface>( - dynamic_cast<chart2::data::XDataProvider *>( - pDocShell->getIDocumentChartDataProviderAccess()-> - GetChartDataProvider())); - } - if (!rServiceName.startsWith("com.sun.star.") - || rServiceName.endsWith(".OLE2Shape")) - { - // We do not 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": - throw ServiceNotRegisteredException(); - } - // 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 (rServiceName == "com.sun.star.drawing.temporaryForXMLImportOLE2Shape") - { - aTmpServiceName = "com.sun.star.drawing.OLE2Shape"; - } - Reference<XInterface> xTmp( - arguments == 0 - ? SvxFmMSFactory::createInstance(aTmpServiceName) - : SvxFmMSFactory::createInstanceWithArguments( - aTmpServiceName, *arguments)); - if (rServiceName == "com.sun.star.drawing.GroupShape" - || rServiceName == "com.sun.star.drawing.Shape3DSceneObject") - { - return *new SwXGroupShape(xTmp); - } - if (rServiceName.startsWith("com.sun.star.drawing.")) - { - return *new SwXShape(xTmp); - } - return xTmp; -} - -Reference< XInterface > SwXTextDocument::createInstance(const OUString& rServiceName) - throw( Exception, RuntimeException, std::exception ) -{ - return create(rServiceName, 0); -} - -Reference< XInterface > SwXTextDocument::createInstanceWithArguments( - const OUString& ServiceSpecifier, - const Sequence< Any >& Arguments) - throw( Exception, RuntimeException, std::exception ) -{ - return create(ServiceSpecifier, &Arguments); -} - -Sequence< OUString > SwXTextDocument::getAvailableServiceNames(void) - throw( RuntimeException, std::exception ) -{ - 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].equalsAscii( "com.sun.star.drawing.OLE2Shape" ) ) - { - 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, std::exception ) -{ - return OUString("SwXTextDocument"); -} - -sal_Bool SwXTextDocument::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -Sequence< OUString > SwXTextDocument::getSupportedServiceNames(void) throw( RuntimeException, std::exception ) -{ - 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 ( ( "com.sun.star.document.OfficeDocument" ) ); - pArray[1] = OUString ( ( "com.sun.star.text.GenericTextDocument" ) ); - - if (bTextDoc) - pArray[2] = OUString ( ( "com.sun.star.text.TextDocument" ) ); - else if (bWebDoc) - pArray[2] = OUString ( ( "com.sun.star.text.WebDocument" ) ); - else if (bGlobalDoc) - pArray[2] = OUString ( ( "com.sun.star.text.GlobalDocument" ) ); - - return aRet; -} - -Reference< XIndexAccess > SwXTextDocument::getDocumentIndexes(void) throw( RuntimeException, std::exception ) -{ - 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, std::exception ) -{ - static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo(); - return xRet; -} - -void SwXTextDocument::setPropertyValue(const OUString& rPropertyName, const Any& aValue) - throw (UnknownPropertyException, PropertyVetoException, - IllegalArgumentException, WrappedTargetException, - RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - throw RuntimeException( - "invalid SwXTextDocument", - static_cast< cppu::OWeakObject * >( - static_cast< SwXTextDocumentBaseClass * >(this))); - 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( - "bad WID", - static_cast< cppu::OWeakObject * >( - static_cast< SwXTextDocumentBaseClass * >(this))); - 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 - // #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 - // #i52858# - method name changed - pDrawDoc = dynamic_cast< SwDrawDocument * > (pDocShell->GetDoc()->GetOrCreateDrawModel() ); - pDrawDoc->SetOpenInDesignMode ( bMode ); - } - } - break; - // #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; - - case WID_DOC_DEFAULT_PAGE_MODE: - { - bool bDefaultPageMode( false ); - aValue >>= bDefaultPageMode; - pDocShell->GetDoc()->SetDefaultPageMode( bDefaultPageMode ); - } - break; - case WID_DOC_INTEROP_GRAB_BAG: - setGrabBagItem(aValue); - 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, std::exception ) -{ - 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 : - { - const SwDocStat& rStat(pDocShell->GetDoc()->GetUpdatedDocStat()); - sal_Int32 nValue; - switch(pEntry->nWID) - { - case WID_DOC_CHAR_COUNT :nValue = rStat.nChar;break; - case WID_DOC_PARA_COUNT :nValue = rStat.nPara;break; - case WID_DOC_WORD_COUNT :nValue = rStat.nWord;break; - } - aAny <<= nValue; - } - break; - case WID_DOC_WORD_SEPARATOR : - { - aAny <<= 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 <<= pDocShell->GetDoc()->GetTOIAutoMarkURL(); - break; - case WID_DOC_HIDE_TIPS : - { - sal_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 ( sal_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 = "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; - case WID_DOC_INTEROP_GRAB_BAG: - getGrabBagItem(aAny); - 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, std::exception ) -{ - OSL_FAIL("not implemented"); -} - -void SwXTextDocument::removePropertyChangeListener(const OUString& /*PropertyName*/, - const Reference< XPropertyChangeListener > & /*aListener*/) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} - -void SwXTextDocument::addVetoableChangeListener(const OUString& /*PropertyName*/, - const Reference< XVetoableChangeListener > & /*aListener*/) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} - -void SwXTextDocument::removeVetoableChangeListener(const OUString& /*PropertyName*/, - const Reference< XVetoableChangeListener > & /*aListener*/) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} - -Reference< XNameAccess > SwXTextDocument::getLinks(void) throw( RuntimeException, std::exception ) -{ - if(!pxLinkTargetSupplier) - { - pxLinkTargetSupplier = new Reference< XNameAccess > ; - (*pxLinkTargetSupplier) = new SwXLinkTargetSupplier(*(SwXTextDocument*)this); - } - return (*pxLinkTargetSupplier); -} - -Reference< XEnumerationAccess > SwXTextDocument::getRedlines( ) throw(RuntimeException, std::exception) -{ - if(!pxXRedlines) - { - pxXRedlines = new Reference< XEnumerationAccess > ; - (*pxXRedlines) = new SwXRedlines(pDocShell->GetDoc()); - } - return *pxXRedlines; -} - -void SwXTextDocument::NotifyRefreshListeners() -{ - // why does SwBaseShell not just call refresh? maybe because it's rSh is - // (sometimes) a different shell than GetWrtShell()? - lang::EventObject const ev(static_cast<SwXTextDocumentBaseClass &>(*this)); - m_pImpl->m_RefreshListeners.notifyEach( - & util::XRefreshListener::refreshed, ev); -} - -void SwXTextDocument::refresh(void) throw( RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - throw RuntimeException(); - SwViewShell *pViewShell = pDocShell->GetWrtShell(); - NotifyRefreshListeners(); - if(pViewShell) - pViewShell->CalcLayout(); -} - -void SAL_CALL SwXTextDocument::addRefreshListener( - const Reference<util::XRefreshListener> & xListener) -throw (RuntimeException, std::exception) -{ - // no need to lock here as m_pImpl is const and container threadsafe - m_pImpl->m_RefreshListeners.addInterface(xListener); -} - -void SAL_CALL SwXTextDocument::removeRefreshListener( - const Reference<util::XRefreshListener> & xListener) -throw (RuntimeException, std::exception) -{ - // no need to lock here as m_pImpl is const and container threadsafe - m_pImpl->m_RefreshListeners.removeInterface(xListener); -} - -void SwXTextDocument::updateLinks( ) throw(RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - throw RuntimeException(); - SwDoc* pDoc = pDocShell->GetDoc(); - sfx2::LinkManager& rLnkMan = pDoc->GetLinkManager(); - if( !rLnkMan.GetLinks().empty() ) - { - UnoActionContext aAction(pDoc); - rLnkMan.UpdateAllLinks( false, false, true ); - } -} - -//XPropertyState -PropertyState SAL_CALL SwXTextDocument::getPropertyState( const OUString& rPropertyName ) - throw (UnknownPropertyException, RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - PropertyState eRet = PropertyState_DIRECT_VALUE; - if(!IsValid()) - throw RuntimeException(); - const SfxItemPropertySimpleEntry* pEntry = pPropSet->getPropertyMap().getByName( rPropertyName); - - if(!pEntry) - throw UnknownPropertyException(); - switch(pEntry->nWID) - { - case 0:default:break; - } - return eRet; -} - -Sequence< PropertyState > SAL_CALL SwXTextDocument::getPropertyStates( const Sequence< OUString >& rPropertyNames ) - throw (UnknownPropertyException, RuntimeException, std::exception) -{ - 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, std::exception) -{ - 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, std::exception) -{ - 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( "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 == "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, "SwViewShell 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)) - { - if (!m_pRenderData) - { - OSL_FAIL("GetRenderDoc: no renderdata"); - return 0; - } - SwView *const pSwView(static_cast<SwView *>(rpView)); - SfxObjectShellLock xDocSh(m_pRenderData->GetTempDocShell()); - if (!xDocSh.Is()) - { - xDocSh = pSwView->CreateTmpSelectionDoc(); - m_pRenderData->SetTempDocShell(xDocSh); - } - if (xDocSh.Is()) - { - pDoc = ((SwDocShell*)&xDocSh)->GetDoc(); - rpView = pDoc->GetDocShell()->GetView(); - } - } - else - { - OSL_FAIL("unexpected SwViewShell" ); - } - } - } - return pDoc; -} - -static void lcl_SavePrintUIOptionsToDocumentPrintData( - SwDoc &rDoc, - const SwPrintUIOptions &rPrintUIOptions, - bool bIsPDFEXport ) -{ - SwPrintData aDocPrintData( rDoc.getPrintData() ); - - aDocPrintData.SetPrintGraphic( rPrintUIOptions.IsPrintGraphics() ); - aDocPrintData.SetPrintTable( rPrintUIOptions.IsPrintTables() ); - aDocPrintData.SetPrintDraw( rPrintUIOptions.IsPrintDrawings() ); - aDocPrintData.SetPrintControl( rPrintUIOptions.IsPrintFormControls() ); - aDocPrintData.SetPrintLeftPage( rPrintUIOptions.IsPrintLeftPages() ); - aDocPrintData.SetPrintRightPage( rPrintUIOptions.IsPrintRightPages() ); - aDocPrintData.SetPrintReverse( rPrintUIOptions.IsPrintReverse() ); - aDocPrintData.SetPaperFromSetup( rPrintUIOptions.IsPaperFromSetup() ); - aDocPrintData.SetPrintEmptyPages( rPrintUIOptions.IsPrintEmptyPages( bIsPDFEXport ) ); - aDocPrintData.SetPrintPostIts( rPrintUIOptions.GetPrintPostItsType() ); - aDocPrintData.SetPrintProspect( rPrintUIOptions.IsPrintProspect() ); - aDocPrintData.SetPrintProspect_RTL( rPrintUIOptions.IsPrintProspectRTL() ); - aDocPrintData.SetPrintPageBackground( rPrintUIOptions.IsPrintPageBackground() ); - aDocPrintData.SetPrintBlackFont( rPrintUIOptions.IsPrintWithBlackTextColor() ); - // aDocPrintData.SetPrintSingleJobs( b ); handled by File/Print dialog itself - // arDocPrintData.SetFaxName( s ); n/a in File/Print dialog - aDocPrintData.SetPrintHiddenText( rPrintUIOptions.IsPrintHiddenText() ); - aDocPrintData.SetPrintTextPlaceholder( rPrintUIOptions.IsPrintTextPlaceholders() ); - - rDoc.setPrintData( aDocPrintData ); -} - -sal_Int32 SAL_CALL SwXTextDocument::getRendererCount( - const uno::Any& rSelection, - const uno::Sequence< beans::PropertyValue >& rxOptions ) - throw (IllegalArgumentException, RuntimeException, - std::exception) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - { - throw DisposedException( OUString(), - static_cast< XTextDocument* >(this) ); - } - - 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 ); - - 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(); - - // TODO/mba: we really need a generic way to get the SwViewShell! - SwViewShell* pViewShell = 0; - SwView* pSwView = PTR_CAST(SwView, pView); - if ( pSwView ) - { - pViewShell = pSwView->GetWrtShellPtr(); - } - else - { - if ( bIsPDFExport && bFormat ) - { - //create a hidden view to be able to export as PDF also in print preview - //pView and pSwView are not changed intentionally! - m_pHiddenViewFrame = SfxViewFrame::LoadHiddenDocument( *pRenderDocShell, 2 ); - pViewShell = ((SwView*)m_pHiddenViewFrame->GetViewShell())->GetWrtShellPtr(); - } - else - pViewShell = ((SwPagePreview*)pView)->GetViewShell(); - } - - if (!pViewShell || !pViewShell->GetLayout()) - return 0; - - if (bFormat) - { - // #i38289 - if( pViewShell->GetViewOptions()->getBrowseMode() ) - { - SwViewOption aOpt( *pViewShell->GetViewOptions() ); - aOpt.setBrowseMode( false ); - pViewShell->ApplyViewOptions( aOpt ); - if (pSwView) - { - pSwView->RecheckBrowseMode(); - } - } - - // reformatting 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. - pViewShell->StartAction(); - - if (pSwView) - { - if (m_pRenderData && m_pRenderData->NeedNewViewOptionAdjust( *pViewShell ) ) - m_pRenderData->ViewOptionAdjustStop(); - if (m_pRenderData && !m_pRenderData->IsViewOptionAdjust()) - { - m_pRenderData->ViewOptionAdjustStart( - *pViewShell, *pViewShell->GetViewOptions() ); - } - } - - m_pRenderData->MakeSwPrtOptions( pRenderDocShell, - m_pPrintUIOptions, bIsPDFExport ); - - if (pSwView) - { - // PDF export should not make use of the SwPrtOptions - const SwPrintData *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 ... - pViewShell->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; - } - - // #122919# Force field update before PDF export - pViewShell->SwViewShell::UpdateFlds(sal_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 - pViewShell->CalcLayout(); - pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() ); - - pViewShell->SetPDFExportOption( sal_False ); - - // enable view again - pViewShell->EndAction(); - } - - const sal_Int32 nPageCount = pViewShell->GetPageCount(); - - // get number of pages to be rendered - - const bool bPrintProspect = m_pPrintUIOptions->getBoolValue( "PrintProspect", false ); - if (bPrintProspect) - { - pDoc->CalculatePagePairsForProspectPrinting( *pViewShell->GetLayout(), *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, pViewShell->GetViewOptions(), pOutDev ); - } - - // get set of valid document pages (according to the current settings) - // and their start frames - pDoc->CalculatePagesForPrinting( *pViewShell->GetLayout(), *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, - std::exception) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - { - throw DisposedException( OUString(), - static_cast< XTextDocument* >(this) ); - } - - 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(); - - // TODO/mba: we really need a generic way to get the SwViewShell! - SwViewShell* pVwSh = 0; - SwView* pSwView = PTR_CAST(SwView, pView); - if ( pSwView ) - pVwSh = pSwView->GetWrtShellPtr(); - else - pVwSh = ((SwPagePreview*)pView)->GetViewShell(); - - 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) - { - // #i114210# - // determine the correct page number from the renderer index - // #i114875 - // consider brochure print - const sal_uInt16 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 0 - // #i115048# it seems users didn't like getting double the formatted page size - // revert to "old" behavior scaling to the current paper size of the printer - 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 overridden by the user) - aTmpSize = pVwSh->GetPageSize( nPage, bIsSkipEmptyPages ); - aPreferredPageSize = awt::Size ( TWIP_TO_MM100( 2 * aTmpSize.Width() ), - TWIP_TO_MM100( aTmpSize.Height() )); - } - #else - if( bPrintProspect ) - { - // just switch to an appropriate portrait/landscape format - // FIXME: brochure printing with landscape pages puts the - // pages next to each other, so landscape is currently always - // the better choice - if( aPageSize.Width < aPageSize.Height ) - { - aPreferredPageSize.Width = aPageSize.Height; - aPreferredPageSize.Height = aPageSize.Width; - } - } - #endif - } - } - else - { - aTmpSize = pVwSh->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 = "PageSize"; - aRenderer[0].Value <<= aPageSize; - aRenderer[1].Name = "PageIncludesNonprintableArea"; - aRenderer[1].Value <<= sal_True; - if (aPreferredPageSize.Width && aPreferredPageSize.Height) - { - ++nLen; - aRenderer.realloc( nLen ); - aRenderer[ nLen - 1 ].Name = "PreferredPageSize"; - aRenderer[ nLen - 1 ].Value <<= aPreferredPageSize; - } - if (nPrinterPaperTray >= 0) - { - ++nLen; - aRenderer.realloc( nLen ); - aRenderer[ nLen - 1 ].Name = "PrinterPaperTray"; - aRenderer[ nLen - 1 ].Value <<= nPrinterPaperTray; - } - } - - // #i117783# - if ( bApplyPagePrintSettingsFromXPagePrintable ) - { - const SwPagePreviewPrtData* pPagePrintSettings = - pDocShell->GetDoc()->GetPreviewPrtData(); - if ( pPagePrintSettings && - ( pPagePrintSettings->GetRow() > 1 || - pPagePrintSettings->GetCol() > 1 ) ) - { - // extend render data by page print settings attributes - sal_Int32 nLen = aRenderer.getLength(); - const sal_Int32 nRenderDataIdxStart = nLen; - nLen += 9; - aRenderer.realloc( nLen ); - // put page print settings attribute into render data - const sal_Int32 nRow = pPagePrintSettings->GetRow(); - aRenderer[ nRenderDataIdxStart + 0 ].Name = "NUpRows"; - aRenderer[ nRenderDataIdxStart + 0 ].Value <<= ( nRow > 1 ? nRow : 1 ); - const sal_Int32 nCol = pPagePrintSettings->GetCol(); - aRenderer[ nRenderDataIdxStart + 1 ].Name = "NUpColumns"; - aRenderer[ nRenderDataIdxStart + 1 ].Value <<= ( nCol > 1 ? nCol : 1 ); - aRenderer[ nRenderDataIdxStart + 2 ].Name = "NUpPageMarginLeft"; - aRenderer[ nRenderDataIdxStart + 2 ].Value <<= pPagePrintSettings->GetLeftSpace(); - aRenderer[ nRenderDataIdxStart + 3 ].Name = "NUpPageMarginRight"; - aRenderer[ nRenderDataIdxStart + 3 ].Value <<= pPagePrintSettings->GetRightSpace(); - aRenderer[ nRenderDataIdxStart + 4 ].Name = "NUpPageMarginTop"; - aRenderer[ nRenderDataIdxStart + 4 ].Value <<= pPagePrintSettings->GetTopSpace(); - aRenderer[ nRenderDataIdxStart + 5 ].Name = "NUpPageMarginBottom"; - aRenderer[ nRenderDataIdxStart + 5 ].Value <<= pPagePrintSettings->GetBottomSpace(); - aRenderer[ nRenderDataIdxStart + 6 ].Name = "NUpHorizontalSpacing"; - aRenderer[ nRenderDataIdxStart + 6 ].Value <<= pPagePrintSettings->GetHorzSpace(); - aRenderer[ nRenderDataIdxStart + 7 ].Name = "NUpVerticalSpacing"; - aRenderer[ nRenderDataIdxStart + 7 ].Value <<= pPagePrintSettings->GetVertSpace(); - { - Printer* pPrinter = pDocShell->GetDoc()->getPrinter( false ); - if ( pPrinter ) - { - awt::Size aNewPageSize; - const Size aPageSize = pPrinter->PixelToLogic( pPrinter->GetPaperSizePixel(), MapMode( MAP_100TH_MM ) ); - aNewPageSize = awt::Size( aPageSize.Width(), aPageSize.Height() ); - if ( ( pPagePrintSettings->GetLandscape() && - aPageSize.Width() < aPageSize.Height() ) || - ( !pPagePrintSettings->GetLandscape() && - aPageSize.Width() > aPageSize.Height() ) ) - { - aNewPageSize = awt::Size( aPageSize.Height(), aPageSize.Width() ); - } - aRenderer[ nRenderDataIdxStart + 8 ].Name = "NUpPaperSize"; - aRenderer[ nRenderDataIdxStart + 8 ].Value <<= aNewPageSize; - } - } - } - - bApplyPagePrintSettingsFromXPagePrintable = sal_False; - } - - 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; -} - -void SAL_CALL SwXTextDocument::render( - sal_Int32 nRenderer, - const uno::Any& rSelection, - const uno::Sequence< beans::PropertyValue >& rxOptions ) - throw (IllegalArgumentException, RuntimeException, - std::exception) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - { - throw DisposedException( OUString(), - static_cast< XTextDocument* >(this) ); - } - - // 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", 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); - SwViewShell* pVwSh = 0; - if (pView) - { - // TODO/mba: we really need a generic way to get the SwViewShell! - SwView* pSwView = PTR_CAST(SwView, pView); - if ( pSwView ) - pVwSh = pSwView->GetWrtShellPtr(); - else - pVwSh = ((SwPagePreview*)pView)->GetViewShell(); - } - - // get output device to use - OutputDevice * pOut = lcl_GetOutputDevice( *m_pPrintUIOptions ); - - if(pVwSh && pOut && m_pRenderData->HasSwPrtOptions()) - { - const OUString aPageRange = m_pPrintUIOptions->getStringValue( "PageRange", OUString() ); - const bool bFirstPage = m_pPrintUIOptions->getBoolValue( "IsFirstPage", 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 ); - - // #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, false ); - } - - SwPrintData const& rSwPrtOptions = - *m_pRenderData->GetSwPrtOptions(); - if (bPrintProspect) - pVwSh->PrintProspect( pOut, rSwPrtOptions, nRenderer ); - else // normal printing and PDF export - pVwSh->PrintOrPDFExport( pOut, rSwPrtOptions, nRenderer ); - - // #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, 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->IsViewOptionAdjust()) - m_pRenderData->ViewOptionAdjustStop(); - - if (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, 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, std::exception ) -{ - SolarMutexGuard aGuard; - if ( !pDocShell ) - throw DisposedException( 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, std::exception ) -{ - SolarMutexGuard aGuard; - if (!IsValid()) - { - throw DisposedException("SwXTextDocument not valid", - static_cast<XTextDocument*>(this)); - } - - return SwUnoCursorHelper::CreateFlatParagraphIterator( - *pDocShell->GetDoc(), nTextMarkupType, bAutomatic); -} - -uno::Reference< util::XCloneable > SwXTextDocument::createClone( ) throw (uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - if(!IsValid()) - throw RuntimeException(); - - // create a new document - hidden - copy the storage and return it - // SfxObjectShellRef is used here, since the model should control object lifetime after creation - // and thus SfxObjectShellLock is not allowed here - // the model holds reference to the shell, so the shell will not destructed at the end of method - SfxObjectShellRef 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, - std::exception) -{ - 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("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(sal_uInt16 i = 0; i < pFmts->size(); ++i) - { - const SwAttrSet &rAttrSet = (*pFmts)[i]->GetAttrSet(); - LanguageType nLang = LANGUAGE_DONTKNOW; - if (bLatin) - { - nLang = rAttrSet.GetLanguage( sal_False ).GetLanguage(); - if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) - aAllLangs.insert( nLang ); - } - if (bAsian) - { - nLang = rAttrSet.GetCJKLanguage( sal_False ).GetLanguage(); - if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) - aAllLangs.insert( nLang ); - } - if (bComplex) - { - nLang = rAttrSet.GetCTLLanguage( sal_False ).GetLanguage(); - if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) - aAllLangs.insert( nLang ); - } - } - - const SwTxtFmtColls *pColls = pDoc->GetTxtFmtColls(); - for (sal_uInt16 i = 0; i < pColls->size(); ++i) - { - const SwAttrSet &rAttrSet = (*pColls)[i]->GetAttrSet(); - LanguageType nLang = LANGUAGE_DONTKNOW; - if (bLatin) - { - nLang = rAttrSet.GetLanguage( sal_False ).GetLanguage(); - if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) - aAllLangs.insert( nLang ); - } - if (bAsian) - { - nLang = rAttrSet.GetCJKLanguage( sal_False ).GetLanguage(); - if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) - aAllLangs.insert( nLang ); - } - if (bComplex) - { - nLang = rAttrSet.GetCTLLanguage( sal_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, sal_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, sal_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, sal_False )).GetLanguage(); - if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_SYSTEM) - aAllLangs.insert( nLang ); - } - } - } - - //TODO/mba: it's a strange concept that a view is needed to retrieve core data - SwWrtShell *pWrtSh = pDocShell->GetWrtShell(); - SdrView *pSdrView = pWrtSh->GetDrawView(); - - if( pSdrView ) - { - SdrOutliner* pOutliner = pSdrView->GetTextEditOutliner(); - if(pOutliner) - { - EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine(); - sal_Int32 nParCount = pOutliner->GetParagraphCount(); - for (sal_Int32 nPar=0; nPar<nParCount; nPar++) - { - //every paragraph - std::vector<sal_Int32> aPortions; - rEditEng.GetPortions( nPar, aPortions ); - - for ( size_t nPos = aPortions.size(); nPos; ) - { - //every position - --nPos; - sal_Int32 nEnd = aPortions[ nPos ]; - sal_Int32 nStart = nPos ? aPortions[ nPos - 1 ] : 0; - ESelection aSelection( nPar, nStart, nPar, nEnd ); - SfxItemSet aAttr = rEditEng.GetAttribs( aSelection ); - - LanguageType nLang = LANGUAGE_DONTKNOW; - if (bLatin) - { - nLang = dynamic_cast< const SvxLanguageItem & >(aAttr.Get( EE_CHAR_LANGUAGE, sal_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, sal_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, sal_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 - uno::Sequence< lang::Locale > aLanguages( nMaxCount ); - lang::Locale* pLanguage = aLanguages.getArray(); - if (nMaxCount > 0) - { - sal_Int32 nCount = 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) - { - pLanguage[nCount] = LanguageTag::convertToLocale( *it ); - pLanguage[nCount].Language = aLangTab.GetString( *it ); - nCount += 1; - } - } - } - - return aLanguages; -} - -SwXLinkTargetSupplier::SwXLinkTargetSupplier(SwXTextDocument& rxDoc) : - pxDoc(&rxDoc) -{ - sTables = SW_RES(STR_CONTENT_TYPE_TABLE); - sFrames = SW_RES(STR_CONTENT_TYPE_FRAME); - sGraphics = SW_RES(STR_CONTENT_TYPE_GRAPHIC); - sOLEs = SW_RES(STR_CONTENT_TYPE_OLE); - sSections = SW_RES(STR_CONTENT_TYPE_REGION); - sOutlines = SW_RES(STR_CONTENT_TYPE_OUTLINE); - sBookmarks = SW_RES(STR_CONTENT_TYPE_BOOKMARK); -} - -SwXLinkTargetSupplier::~SwXLinkTargetSupplier() -{ -} - -Any SwXLinkTargetSupplier::getByName(const OUString& rName) - throw( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception ) -{ - Any aRet; - if(!pxDoc) - throw RuntimeException(); - OUString sToCompare(rName); - OUString sSuffix("|"); - if(sToCompare == sTables) - { - sSuffix += "table"; - - 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 += "frame"; - 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 += "region"; - 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 == sGraphics) - { - sSuffix += "graphic"; - 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 += "ole"; - 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 += "outline"; - 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 = ""; - 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, std::exception ) -{ - 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, std::exception ) -{ - OUString 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, std::exception ) -{ - return ::getCppuType((Reference< XPropertySet>*)0); - -} - -sal_Bool SwXLinkTargetSupplier::hasElements(void) throw( RuntimeException, std::exception ) -{ - return 0 != pxDoc; -} - -OUString SwXLinkTargetSupplier::getImplementationName(void) throw( RuntimeException, std::exception ) -{ - return OUString("SwXLinkTargetSupplier"); -} - -sal_Bool SwXLinkTargetSupplier::supportsService(const OUString& rServiceName) - throw( RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -Sequence< OUString > SwXLinkTargetSupplier::getSupportedServiceNames(void) - throw( RuntimeException, std::exception ) -{ - Sequence< OUString > aRet(1); - OUString* pNames = aRet.getArray(); - pNames[0] = "com.sun.star.document.LinkTargets"; - return aRet; -} - -SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper( - Reference< XNameAccess > xAccess, const OUString& rLinkDisplayName, OUString sSuffix ) : - xRealAccess(xAccess), - pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)), - sLinkSuffix(sSuffix), - sLinkDisplayName(rLinkDisplayName), - pxDoc(0) -{ -} - -SwXLinkNameAccessWrapper::SwXLinkNameAccessWrapper(SwXTextDocument& rxDoc, - const OUString& rLinkDisplayName, OUString 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, std::exception ) -{ - Any aRet; - bool bFound = false; - //cut link extension and call the real NameAccess - OUString sParam = rName; - OUString sSuffix(sLinkSuffix); - if(sParam.getLength() > sSuffix.getLength() ) - { - OUString sCmp = sParam.copy(sParam.getLength() - sSuffix.getLength(), - sSuffix.getLength()); - if(sCmp == sSuffix) - { - if(pxDoc) - { - sParam = sParam.copy(0, sParam.getLength() - sSuffix.getLength()); - if(!pxDoc->GetDocShell()) - throw RuntimeException(); - SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc(); - sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().size(); - - 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 = true; - } - } - } - else - { - aRet = xRealAccess->getByName(sParam.copy(0, sParam.getLength() - sSuffix.getLength())); - Reference< XInterface > xInt; - if(!(aRet >>= xInt)) - throw RuntimeException(); - Reference< XPropertySet > xProp(xInt, UNO_QUERY); - aRet <<= xProp; - bFound = true; - } - } - } - if(!bFound) - throw NoSuchElementException(); - return aRet; -} - -Sequence< OUString > SwXLinkNameAccessWrapper::getElementNames(void) - throw( RuntimeException, std::exception ) -{ - 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.size(); - aRet.realloc(nOutlineCount); - OUString* pResArr = aRet.getArray(); - OUString sSuffix("|outline"); - const SwNumRule* pOutlRule = pDoc->GetOutlineNumRule(); - for (sal_uInt16 i = 0; i < nOutlineCount; ++i) - { - OUString 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, std::exception ) -{ - sal_Bool bRet = sal_False; - OUString sParam(rName); - if(sParam.getLength() > sLinkSuffix.getLength() ) - { - OUString sCmp = sParam.copy(sParam.getLength() - sLinkSuffix.getLength(), - sLinkSuffix.getLength()); - if(sCmp == sLinkSuffix) - { - sParam = sParam.copy(0, sParam.getLength() - sLinkSuffix.getLength()); - if(pxDoc) - { - if(!pxDoc->GetDocShell()) - throw RuntimeException(); - SwDoc* pDoc = pxDoc->GetDocShell()->GetDoc(); - sal_uInt16 nOutlineCount = pDoc->GetNodes().GetOutLineNds().size(); - - 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, std::exception ) -{ - return ::getCppuType((Reference<XPropertySet>*)0); -} - -sal_Bool SwXLinkNameAccessWrapper::hasElements(void) throw( RuntimeException, std::exception ) -{ - sal_Bool bRet = sal_False; - if(pxDoc) - { - OSL_FAIL("not implemented"); - } - else - { - bRet = xRealAccess->hasElements(); - } - return bRet; -} - -Reference< XPropertySetInfo > SwXLinkNameAccessWrapper::getPropertySetInfo(void) - throw( RuntimeException, std::exception ) -{ - static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo(); - return xRet; -} - -void SwXLinkNameAccessWrapper::setPropertyValue( - const OUString& , const Any& ) - throw( UnknownPropertyException, - PropertyVetoException, - IllegalArgumentException, - WrappedTargetException, - RuntimeException, std::exception) -{ - throw UnknownPropertyException(); -} - -static Any lcl_GetDisplayBitmap(OUString sLinkSuffix) -{ - Any aRet; - if(!sLinkSuffix.isEmpty()) - sLinkSuffix = sLinkSuffix.copy(1); - sal_uInt16 nImgId = USHRT_MAX; - - if(sLinkSuffix == "outline") - nImgId = CONTENT_TYPE_OUTLINE; - else if(sLinkSuffix == "table") - nImgId = CONTENT_TYPE_TABLE; - else if(sLinkSuffix == "frame") - nImgId = CONTENT_TYPE_FRAME; - else if(sLinkSuffix == "graphic") - nImgId = CONTENT_TYPE_GRAPHIC; - else if(sLinkSuffix == "region") - nImgId = CONTENT_TYPE_REGION; - else if(sLinkSuffix == "ole") - nImgId = CONTENT_TYPE_OLE; - else if(sLinkSuffix.isEmpty()) - nImgId = CONTENT_TYPE_BOOKMARK; - if(USHRT_MAX != nImgId) - { - nImgId += 20000; - ImageList aEntryImages( SW_RES(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, std::exception ) -{ - Any aRet; - if( rPropertyName == UNO_LINK_DISPLAY_NAME ) - { - aRet <<= OUString(sLinkDisplayName); - } - else if( rPropertyName == 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, std::exception ) -{} - -void SwXLinkNameAccessWrapper::removePropertyChangeListener( - const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{} - -void SwXLinkNameAccessWrapper::addVetoableChangeListener( - const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{} - -void SwXLinkNameAccessWrapper::removeVetoableChangeListener( - const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{} - -Reference< XNameAccess > SwXLinkNameAccessWrapper::getLinks(void) - throw( RuntimeException, std::exception ) -{ - return (SwXLinkNameAccessWrapper*)this; -} - -OUString SwXLinkNameAccessWrapper::getImplementationName(void) throw( RuntimeException, std::exception ) -{ - return OUString("SwXLinkNameAccessWrapper"); -} - -sal_Bool SwXLinkNameAccessWrapper::supportsService(const OUString& rServiceName) - throw( RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -Sequence< OUString > SwXLinkNameAccessWrapper::getSupportedServiceNames(void) - throw( RuntimeException, std::exception ) -{ - Sequence< OUString > aRet(1); - OUString* pNames = aRet.getArray(); - pNames[0] = "com.sun.star.document.LinkTargets"; - return aRet; -} - -SwXOutlineTarget::SwXOutlineTarget(const OUString& rOutlineText) : - pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_LINK_TARGET)), - sOutlineText(rOutlineText) -{ -} - -SwXOutlineTarget::~SwXOutlineTarget() -{ -} - -Reference< XPropertySetInfo > SwXOutlineTarget::getPropertySetInfo(void) throw( RuntimeException, std::exception ) -{ - static Reference< XPropertySetInfo > xRet = pPropSet->getPropertySetInfo(); - return xRet; -} - -void SwXOutlineTarget::setPropertyValue( - const OUString& /*PropertyName*/, const Any& /*aValue*/) - throw( UnknownPropertyException, PropertyVetoException, - IllegalArgumentException, WrappedTargetException, RuntimeException, std::exception) -{ - throw UnknownPropertyException(); -} - -Any SwXOutlineTarget::getPropertyValue(const OUString& rPropertyName) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{ - Any aRet; - if(rPropertyName == 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, std::exception ) -{ -} - -void SwXOutlineTarget::removePropertyChangeListener( - const OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{ -} - -void SwXOutlineTarget::addVetoableChangeListener( - const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{ -} - -void SwXOutlineTarget::removeVetoableChangeListener( - const OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/) - throw( UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception ) -{ -} - -OUString SwXOutlineTarget::getImplementationName(void) throw( RuntimeException, std::exception ) -{ - return OUString("SwXOutlineTarget"); -} - -sal_Bool SwXOutlineTarget::supportsService(const OUString& ServiceName) throw( RuntimeException, std::exception ) -{ - return cppu::supportsService(this, ServiceName); -} - -Sequence< OUString > SwXOutlineTarget::getSupportedServiceNames(void) throw( RuntimeException, std::exception ) -{ - Sequence < OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = "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) - { - // #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 > 0 - default: OSL_FAIL("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( - SwViewShell& rSh, const SwViewOption &rViewOptions) - : m_pShell(&rSh) - , m_aOldViewOptions( rViewOptions ) -{ -} - -SwViewOptionAdjust_Impl::~SwViewOptionAdjust_Impl() -{ - if (m_pShell) - { - m_pShell->ApplyViewOptions( m_aOldViewOptions ); - } -} - -void -SwViewOptionAdjust_Impl::AdjustViewOptions(SwPrintData const*const 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_pShell->GetDoc()->ContainsHiddenChars(); - const SwFieldType* pFldType = m_pShell->GetDoc()->GetSysFldType( RES_HIDDENTXTFLD ); - const bool bContainsHiddenFields = pFldType && pFldType->GetDepends(); - pFldType = m_pShell->GetDoc()->GetSysFldType( RES_HIDDENPARAFLD ); - const bool bContainsHiddenParagraphs = pFldType && pFldType->GetDepends(); - pFldType = m_pShell->GetDoc()->GetSysFldType( RES_JUMPEDITFLD ); - const bool bContainsPlaceHolders = pFldType && pFldType->GetDepends(); - const bool bContainsFields = m_pShell->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( sal_False ); // paragraph end - aRenderViewOptions.SetSoftHyph( sal_False ); // aka custom hyphens - aRenderViewOptions.SetBlank( sal_False ); // spaces - aRenderViewOptions.SetHardBlank( sal_False ); // non-breaking spaces - aRenderViewOptions.SetTab( sal_False ); // tabs - aRenderViewOptions.SetLineBreak( sal_False ); // breaks (type 1) - aRenderViewOptions.SetPageBreak( sal_False ); // breaks (type 2) - aRenderViewOptions.SetColumnBreak( sal_False ); // breaks (type 3) - sal_Bool bVal = pPrtOptions? pPrtOptions->bPrintHiddenText : sal_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 : sal_True; - aRenderViewOptions.SetShowPlaceHolderFields( bVal ); - } - - if (bContainsFields) - aRenderViewOptions.SetFldName( sal_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( sal_True ); - - if (m_aOldViewOptions != aRenderViewOptions) // check if reformatting is necessary - { - aRenderViewOptions.SetPrinting( pPrtOptions != NULL ); - m_pShell->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 deleted file mode 100644 index c7e9c4ee4883..000000000000 --- a/sw/source/ui/uno/unotxvw.cxx +++ /dev/null @@ -1,1851 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include "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/unoshape.hxx> -#include <svx/svdpagv.hxx> -#include <swerror.h> -#include <shellio.hxx> -#include <ndtxt.hxx> -#include <SwStyleNameMapper.hxx> -#include <crsskip.hxx> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/drawing/ShapeCollection.hpp> -#include <editeng/outliner.hxx> -#include <editeng/editview.hxx> -#include <unoparagraph.hxx> -#include <unocrsrhelper.hxx> -#include <unotextrange.hxx> -#include <sfx2/docfile.hxx> -#include <switerator.hxx> -#include "swdtflvr.hxx" -#include <vcl/svapp.hxx> -#include <comphelper/processfactory.hxx> -#include <comphelper/servicehelper.hxx> -#include <cppuhelper/supportsservice.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 ::com::sun::star::util::URL; -using comphelper::HelperBaseNoState; - -SwXTextView::SwXTextView(SwView* pSwView) : - SfxBaseController(pSwView), - m_SelChangedListeners(m_aMutex), - 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 - - { - uno::Reference<uno::XInterface> const xInt(static_cast< - cppu::OWeakObject*>(static_cast<SfxBaseController*>(this))); - lang::EventObject aEvent(xInt); - m_SelChangedListeners.disposeAndClear(aEvent); - } - - m_refCount--; - m_pView = 0; -} - -Sequence< uno::Type > SAL_CALL SwXTextView::getTypes( ) throw(uno::RuntimeException, std::exception) -{ - 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; -} - -namespace -{ - class theSwXTextViewImplementationId : public rtl::Static< UnoTunnelIdInit, theSwXTextViewImplementationId > {}; -} - -Sequence< sal_Int8 > SAL_CALL SwXTextView::getImplementationId( ) throw(uno::RuntimeException, std::exception) -{ - return theSwXTextViewImplementationId::get().getSeq(); -} - -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, std::exception) -{ - 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, - std::exception) -{ - SolarMutexGuard aGuard; - - uno::Reference< uno::XInterface > xInterface; - if (!GetView() || !(aInterface >>= xInterface)) - { - return sal_False; - } - - SwWrtShell& rSh = GetView()->GetWrtShell(); - SwDoc* pDoc = GetView()->GetDocShell()->GetDoc(); - std::vector<SdrObject *> sdrObjects; - uno::Reference<awt::XControlModel> const xCtrlModel(xInterface, - UNO_QUERY); - if (xCtrlModel.is()) - { - uno::Reference<awt::XControl> xControl; - SdrObject *const pSdrObject = GetControl(xCtrlModel, xControl); - if (pSdrObject) // hmm... needs view to verify it's in right doc... - { - sdrObjects.push_back(pSdrObject); - } - } - else - { - SwPaM * pPaM(0); - std::pair<OUString, FlyCntType> frame; - OUString tableName; - SwUnoTableCrsr const* pTableCursor(0); - ::sw::mark::IMark const* pMark(0); - SwUnoCursorHelper::GetSelectableFromAny(xInterface, *pDoc, - pPaM, frame, tableName, pTableCursor, pMark, sdrObjects); - if (pPaM) - { - rSh.EnterStdMode(); - rSh.SetSelection(*pPaM); - // the pPaM has been copied - delete it - while (pPaM->GetNext() != pPaM) - delete pPaM->GetNext(); - delete pPaM; - return sal_True; - } - else if (!frame.first.isEmpty()) - { - bool const bSuccess(rSh.GotoFly(frame.first, frame.second)); - if (bSuccess) - { - rSh.HideCrsr(); - rSh.EnterSelFrmMode(); - } - return sal_True; - } - else if (!tableName.isEmpty()) - { - rSh.EnterStdMode(); - rSh.GotoTable(tableName); - return sal_True; - } - else if (pTableCursor) - { - UnoActionRemoveContext const aContext(pDoc); - rSh.EnterStdMode(); - rSh.SetSelection(*pTableCursor); - return sal_True; - } - else if (pMark) - { - rSh.EnterStdMode(); - rSh.GotoMark(pMark); - return sal_True; - } - // sdrObjects handled below - } - sal_Bool bRet(sal_False); - if (sdrObjects.size()) - { - - SdrView *const pDrawView = rSh.GetDrawView(); - SdrPageView *const pPV = pDrawView->GetSdrPageView(); - - pDrawView->SdrEndTextEdit(); - pDrawView->UnmarkAll(); - - for (size_t i = 0; i < sdrObjects.size(); ++i) - { - SdrObject *const pSdrObject(sdrObjects[i]); - // GetSelectableFromAny did not check pSdrObject is in right doc! - if (pPV && pSdrObject->GetPage() == pPV->GetPage()) - { - pDrawView->MarkObj(pSdrObject, pPV); - bRet = sal_True; - } - } - } - return bRet; -} - -uno::Any SwXTextView::getSelection() - throw (uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - uno::Reference< uno::XInterface > aRef; - if(GetView()) - { - //force immediat shell update - m_pView->StopShellTimer(); - //Generating an interface from the current selection. - SwWrtShell& rSh = m_pView->GetWrtShell(); - ShellModes eSelMode = m_pView->GetShellMode(); - switch(eSelMode) - { - case SHELL_MODE_TABLE_TEXT : - { - if(rSh.GetTableCrsr()) - { - OSL_ENSURE(rSh.GetTableFmt(), "not a table format?"); - uno::Reference< text::XTextTableCursor > xCrsr = new SwXTextTableCursor(*rSh.GetTableFmt(), - rSh.GetTableCrsr()); - aRef = uno::Reference< uno::XInterface > (xCrsr, uno::UNO_QUERY); - break; - } - - } - //Without a table selection the text will be delivered. - //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; for UI-Macro connection to flys - const SwFrmFmt* pFmt = rSh.GetFlyFrmFmt(); - if (pFmt) - { - SwXFrame* pxFrame = SwIterator<SwXFrame,SwFmt>::FirstElement(*pFmt); - if(pxFrame) //The only common interface for all 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 = drawing::ShapeCollection::create( - comphelper::getProcessComponentContext()); - - 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, std::exception ) -{ - SolarMutexGuard aGuard; - m_SelChangedListeners.addInterface(rxListener); -} - -void SwXTextView::removeSelectionChangeListener( - const uno::Reference< view::XSelectionChangeListener > & rxListener) - throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - m_SelChangedListeners.removeInterface(rxListener); -} - -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, std::exception ) -{ - 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, std::exception) -{ - 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, std::exception) -{ - 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, std::exception) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception) -{ - 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; - - sal_uInt16 nCount = pDoc->FillRubyList( *rSh.GetCrsr(), aList, 0 ); - Sequence< Sequence< PropertyValue > > aRet(nCount); - Sequence< PropertyValue >* pRet = aRet.getArray(); - OUString aString; - for(sal_uInt16 n = 0; n < nCount; n++) - { - const SwRubyListEntry* pEntry = &aList[n]; - - const OUString& rEntryText = pEntry->GetText(); - const SwFmtRuby& rAttr = pEntry->GetRubyAttr(); - - pRet[n].realloc(5); - PropertyValue* pValues = pRet[n].getArray(); - pValues[0].Name = UNO_NAME_RUBY_BASE_TEXT; - pValues[0].Value <<= OUString(rEntryText); - pValues[1].Name = UNO_NAME_RUBY_TEXT; - pValues[1].Value <<= OUString(rAttr.GetText()); - pValues[2].Name = UNO_NAME_RUBY_CHAR_STYLE_NAME; - SwStyleNameMapper::FillProgName(rAttr.GetCharFmtName(), aString, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true ); - pValues[2].Value <<= aString; - pValues[3].Name = UNO_NAME_RUBY_ADJUST; - pValues[3].Value <<= (sal_Int16)rAttr.GetAdjustment(); - pValues[4].Name = 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, std::exception) -{ - 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++) - { - SwRubyListEntry* 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 == UNO_NAME_RUBY_BASE_TEXT) - { - pProperties[nProp].Value >>= sTmp; - pEntry->SetText(sTmp); - } - else if(pProperties[nProp].Name == UNO_NAME_RUBY_TEXT) - { - pProperties[nProp].Value >>= sTmp; - pEntry->GetRubyAttr().SetText(sTmp); - } - else if(pProperties[nProp].Name == UNO_NAME_RUBY_CHAR_STYLE_NAME) - { - if((pProperties[nProp].Value >>= sTmp)) - { - OUString sName; - SwStyleNameMapper::FillUIName(sTmp, sName, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true ); - sal_uInt16 nPoolId = sName.isEmpty() ? 0 - : SwStyleNameMapper::GetPoolIdFromUIName(sName, - nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); - - pEntry->GetRubyAttr().SetCharFmtName( sName ); - pEntry->GetRubyAttr().SetCharFmtId( nPoolId ); - } - } - else if(pProperties[nProp].Name == UNO_NAME_RUBY_ADJUST) - { - sal_Int16 nTmp = 0; - if((pProperties[nProp].Value >>= nTmp)) - pEntry->GetRubyAttr().SetAdjustment(nTmp); - } - else if(pProperties[nProp].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(aList.begin() + nPos, pEntry); - } - SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); - pDoc->SetRubyList( *rSh.GetCrsr(), aList, 0 ); -} - -SfxObjectShellLock SwXTextView::BuildTmpSelectionDoc() -{ - SwWrtShell& rOldSh = m_pView->GetWrtShell(); - SfxPrinter *pPrt = rOldSh.getIDocumentDeviceAccess()->getPrinter( false ); - SwDocShell* pDocSh; - SfxObjectShellLock xDocSh( pDocSh = new SwDocShell( /*pPrtDoc, */SFX_CREATE_MODE_STANDARD ) ); - xDocSh->DoInitNew( 0 ); - SwDoc *const pTempDoc( pDocSh->GetDoc() ); - // #i103634#, #i112425#: do not expand numbering and fields on PDF export - pTempDoc->SetClipBoard(true); - rOldSh.FillPrtDoc(pTempDoc, pPrt); - SfxViewFrame* pDocFrame = SfxViewFrame::LoadHiddenDocument( *xDocSh, 0 ); - SwView* pDocView = (SwView*) pDocFrame->GetViewShell(); - pDocView->AttrChangedNotify( &pDocView->GetWrtShell() );//So that SelectShell is called. - 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" ); - - uno::Reference<uno::XInterface> const xInt( - static_cast<cppu::OWeakObject*>(static_cast<SfxBaseController*>(this))); - - lang::EventObject const aEvent(xInt); - m_SelChangedListeners.notifyEach( - &view::XSelectionChangeListener::selectionChanged, aEvent); -} - -namespace { - struct DispatchListener - { - URL const & m_rURL; - Sequence<PropertyValue> const& m_rSeq; - explicit DispatchListener(URL const& rURL, - Sequence<PropertyValue> const& rSeq) - : m_rURL(rURL), m_rSeq(rSeq) { } - void operator()(uno::Reference<XDispatch> const & xListener) const - { - xListener->dispatch(m_rURL, m_rSeq); - } - }; -} - -void SwXTextView::NotifyDBChanged() -{ - URL aURL; - aURL.Complete = OUString::createFromAscii(SwXDispatch::GetDBChangeURL()); - - m_SelChangedListeners.forEach<XDispatch>( - DispatchListener(aURL, Sequence<PropertyValue>(0))); -} - -uno::Reference< beans::XPropertySetInfo > SAL_CALL SwXTextView::getPropertySetInfo( ) - throw (uno::RuntimeException, std::exception) -{ - 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, std::exception) -{ - 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_FAIL("unknown WID"); - } - } -} - -uno::Any SAL_CALL SwXTextView::getPropertyValue( - const OUString& rPropertyName ) - throw (beans::UnknownPropertyException, - lang::WrappedTargetException, - uno::RuntimeException, - std::exception) -{ - 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->GetWrtShell().GetPageCount(); - else // WID_LINE_COUNT - nCount = m_pView->GetWrtShell().GetLineCount( sal_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(); - sal_uInt32 nFlag = VIEWOPT_1_ONLINESPELL; - sal_Bool bVal = 0 != (pOpt->GetCoreOptions() & nFlag); - aRet <<= bVal; - } - break; - default : - OSL_FAIL("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, std::exception) -{ - OSL_FAIL("not implemented"); -} - -void SAL_CALL SwXTextView::removePropertyChangeListener( - const OUString& /*rPropertyName*/, - const uno::Reference< beans::XPropertyChangeListener >& /*rxListener*/ ) - throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) -{ - OSL_FAIL("not implemented"); -} - -void SAL_CALL SwXTextView::addVetoableChangeListener( - const OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ ) - throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) -{ - OSL_FAIL("not implemented"); -} - -void SAL_CALL SwXTextView::removeVetoableChangeListener( - const OUString& /*rPropertyName*/, - const uno::Reference< beans::XVetoableChangeListener >& /*rxListener*/ ) - throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception) -{ - OSL_FAIL("not implemented"); -} - -OUString SwXTextView::getImplementationName(void) throw( RuntimeException, std::exception ) -{ - return OUString("SwXTextView"); -} - -sal_Bool SwXTextView::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -Sequence< OUString > SwXTextView::getSupportedServiceNames(void) throw( RuntimeException, std::exception ) -{ - Sequence< OUString > aRet(2); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.TextDocumentView"; - pArray[1] = "com.sun.star.view.OfficeDocumentView"; - return aRet; -} - -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, std::exception ) -{ - SolarMutexGuard aGuard; - OSL_FAIL("not implemented"); - return sal_True; -} - -void SwXTextViewCursor::setVisible(sal_Bool /*bVisible*/) throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - OSL_FAIL("not implemented"); -} - -awt::Point SwXTextViewCursor::getPosition(void) throw( uno::RuntimeException, std::exception ) -{ - 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() - throw(uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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() - throw (uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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() - throw (uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - sal_Bool bRet = sal_False; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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, std::exception) -{ - SolarMutexGuard aGuard; - sal_Bool bRet = sal_False; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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, std::exception) -{ - SolarMutexGuard aGuard; - sal_Bool bRet = sal_False; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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, std::exception) -{ - SolarMutexGuard aGuard; - if(m_pView && xRange.is()) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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; - - //Skip SectionNodes - while(pTmp && pTmp->IsSectionNode()) - { - pTmp = pTmp->StartOfSectionNode(); - } - while(pOwnStartNode && pOwnStartNode->IsSectionNode()) - { - pOwnStartNode = pOwnStartNode->StartOfSectionNode(); - } - //Without Expand it is allowed to jump out with the ViewCursor everywhere, - //with Expand only in the same environment - 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(); - - //Now, the selection must be expanded. - if(bExpand) - { - // The cursor should include everything that has been included - // by him and the transfered Range. - SwPosition aOwnLeft(*aOwnPaM.Start()); - SwPosition aOwnRight(*aOwnPaM.End()); - SwPosition* pParamLeft = rDestPam.Start(); - SwPosition* pParamRight = rDestPam.End(); - // Now four SwPositions are there, two of them are needed, but which? - if(aOwnRight > *pParamRight) - *aOwnPaM.GetPoint() = aOwnRight; - else - *aOwnPaM.GetPoint() = *pParamRight; - aOwnPaM.SetMark(); - if(aOwnLeft < *pParamLeft) - *aOwnPaM.GetMark() = aOwnLeft; - else - *aOwnPaM.GetMark() = *pParamLeft; - } - else - { - //The cursor shall match the passed range. - *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, std::exception) -{ - SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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, std::exception) -{ - SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - m_pView->GetWrtShell().EndDoc( bExpand ); - } - else - throw uno::RuntimeException(); -} - -sal_Bool SwXTextViewCursor::jumpToFirstPage() - throw (uno::RuntimeException, std::exception) -{ - 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(sal_True); - } - else - throw uno::RuntimeException(); - return bRet; -} - -sal_Bool SwXTextViewCursor::jumpToLastPage() - throw(uno::RuntimeException, std::exception) -{ - 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(sal_False); - rSh.SttPg(); - } - else - throw uno::RuntimeException(); - return bRet; -} - -sal_Bool SwXTextViewCursor::jumpToPage(sal_Int16 nPage) throw( uno::RuntimeException, std::exception ) -{ - SolarMutexGuard aGuard; - sal_Bool bRet = sal_False; - if(m_pView) - bRet = m_pView->GetWrtShell().GotoPage(nPage, sal_True); - else - throw uno::RuntimeException(); - return bRet; -} - -sal_Bool SwXTextViewCursor::jumpToNextPage(void) throw( uno::RuntimeException, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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, std::exception ) -{ - 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() - throw (uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - sal_Int16 nRet = 0; - if(m_pView) - { - SwWrtShell& rSh = m_pView->GetWrtShell(); - SwPaM* pShellCrsr = rSh.GetCrsr(); - nRet = static_cast<sal_Int16>(pShellCrsr->GetPageNum( true, 0 )); - } - else - throw uno::RuntimeException(); - return nRet; -} - -sal_Bool SwXTextViewCursor::screenDown() - throw (uno::RuntimeException, std::exception) -{ - 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() - throw (uno::RuntimeException, std::exception) -{ - 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() - throw (uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - uno::Reference< text::XText > xRet; - if(m_pView) - { - if (!IsTextSelection( sal_False )) - throw uno::RuntimeException("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() - throw (uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - uno::Reference< text::XTextRange > xRet; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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() - throw (uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - uno::Reference< text::XTextRange > xRet; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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() - throw (uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - OUString uRet; - if(m_pView) - { - if (!IsTextSelection( sal_False )) - throw uno::RuntimeException("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, std::exception) -{ - SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection( sal_False )) - throw uno::RuntimeException("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, std::exception) -{ - 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, std::exception) -{ - 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, std::exception) -{ - 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, std::exception) -{ -} - -void SwXTextViewCursor::removePropertyChangeListener( - const OUString& /*aPropertyName*/, const uno::Reference< XPropertyChangeListener >& /*aListener*/ ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) -{ -} - -void SwXTextViewCursor::addVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) - throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) -{ -} - -void SwXTextViewCursor::removeVetoableChangeListener( - const OUString& /*PropertyName*/, const uno::Reference< XVetoableChangeListener >& /*aListener*/ ) throw(UnknownPropertyException, WrappedTargetException, RuntimeException, std::exception) -{ -} - -PropertyState SwXTextViewCursor::getPropertyState( const OUString& rPropertyName ) - throw (UnknownPropertyException, RuntimeException, - std::exception) -{ - 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, - std::exception) -{ - 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, - std::exception) -{ - 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, std::exception) -{ - 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, std::exception) -{ - SolarMutexGuard aGuard; - sal_Bool bRet = sal_False; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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, std::exception) -{ - SolarMutexGuard aGuard; - sal_Bool bRet = sal_False; - if(m_pView) - { - if (!IsTextSelection()) - throw uno::RuntimeException("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() - throw(uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - sal_Bool bRet = sal_False; - if(m_pView) - { - if (!IsTextSelection( sal_False )) - throw uno::RuntimeException("no text selection", static_cast < cppu::OWeakObject * > ( this ) ); - - bRet = m_pView->GetWrtShell().IsAtLeftMargin(); - } - else - throw uno::RuntimeException(); - return bRet; -} - -sal_Bool SwXTextViewCursor::isAtEndOfLine() - throw(uno::RuntimeException, std::exception) -{ - SolarMutexGuard aGuard; - sal_Bool bRet = sal_False; - if(m_pView) - { - if (!IsTextSelection( sal_False )) - throw uno::RuntimeException("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, std::exception) -{ - SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection( sal_False )) - throw uno::RuntimeException("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, std::exception) -{ - SolarMutexGuard aGuard; - if(m_pView) - { - if (!IsTextSelection( sal_False )) - throw uno::RuntimeException("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, std::exception ) -{ - return OUString("SwXTextViewCursor"); -} - -sal_Bool SwXTextViewCursor::supportsService(const OUString& rServiceName) throw( RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} - -Sequence< OUString > SwXTextViewCursor::getSupportedServiceNames(void) throw( RuntimeException, std::exception ) -{ - Sequence< OUString > aRet(7); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.TextViewCursor"; - pArray[1] = "com.sun.star.style.CharacterProperties"; - pArray[2] = "com.sun.star.style.CharacterPropertiesAsian"; - pArray[3] = "com.sun.star.style.CharacterPropertiesComplex"; - pArray[4] = "com.sun.star.style.ParagraphProperties"; - pArray[5] = "com.sun.star.style.ParagraphPropertiesAsian"; - pArray[6] = "com.sun.star.style.ParagraphPropertiesComplex"; - return aRet; -} - -namespace -{ - class theSwXTextViewCursorUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextViewCursorUnoTunnelId > {}; -} - -const uno::Sequence< sal_Int8 > & SwXTextViewCursor::getUnoTunnelId() -{ - return theSwXTextViewCursorUnoTunnelId::get().getSeq(); -} - -//XUnoTunnel -sal_Int64 SAL_CALL SwXTextViewCursor::getSomething( - const uno::Sequence< sal_Int8 >& rId ) - throw(uno::RuntimeException, std::exception) -{ - if( rId.getLength() == 16 - && 0 == memcmp( 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, std::exception) -{ - 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 sal_Bool bLockedView = rSh.IsViewLocked(); - rSh.LockView( sal_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, std::exception) -{ - 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: */ |