fdo#46808, Convert text::AutoTextContainer to new style

Change-Id: Ia33419c4d8cf633b572627edf57c926099d698e5
This commit is contained in:
Noel Grandin
2013-03-19 15:36:11 +02:00
parent 32fe9ef796
commit 70e7bd63ad
13 changed files with 85 additions and 55 deletions

View File

@@ -334,6 +334,7 @@ $(eval $(call gb_ZipUnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/task,\
StatusIndicatorFactory \ StatusIndicatorFactory \
)) ))
$(eval $(call gb_ZipUnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/text,\ $(eval $(call gb_ZipUnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/text,\
AutoTextContainer \
DefaultNumberingProvider \ DefaultNumberingProvider \
)) ))
$(eval $(call gb_ZipUnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/ucb,\ $(eval $(call gb_ZipUnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/ucb,\
@@ -1265,7 +1266,6 @@ $(eval $(call gb_ZipUnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/text
AccessibleTextEmbeddedObject \ AccessibleTextEmbeddedObject \
AccessibleTextFrameView \ AccessibleTextFrameView \
AccessibleTextGraphicObject \ AccessibleTextGraphicObject \
AutoTextContainer \
AutoTextEntry \ AutoTextEntry \
AutoTextGroup \ AutoTextGroup \
BaseFrame \ BaseFrame \
@@ -3647,6 +3647,7 @@ $(eval $(call gb_ZipUnoApi_add_idlfiles,offapi,offapi/com/sun/star/text,\
WritingMode \ WritingMode \
WritingMode2 \ WritingMode2 \
XAutoTextContainer \ XAutoTextContainer \
XAutoTextContainer2 \
XAutoTextEntry \ XAutoTextEntry \
XAutoTextGroup \ XAutoTextGroup \
XBookmarkInsertTool \ XBookmarkInsertTool \

View File

@@ -19,22 +19,15 @@
#ifndef __com_sun_star_text_AutoTextContainer_idl__ #ifndef __com_sun_star_text_AutoTextContainer_idl__
#define __com_sun_star_text_AutoTextContainer_idl__ #define __com_sun_star_text_AutoTextContainer_idl__
#include <com/sun/star/text/XAutoTextContainer.idl> #include <com/sun/star/text/XAutoTextContainer2.idl>
#include <com/sun/star/container/XIndexAccess.idl>
module com { module sun { module star { module text {
module com { module sun { module star { module text {
/** provides access to groups of text blocks. /** provides access to groups of text blocks.
*/ */
published service AutoTextContainer published service AutoTextContainer : XAutoTextContainer2;
{
interface com::sun::star::text::XAutoTextContainer;
[optional] interface com::sun::star::container::XIndexAccess;
};
}; }; }; }; }; }; }; };

View File

@@ -0,0 +1,45 @@
/* -*- 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 __com_sun_star_text_XAutoTextContainer2_idl__
#define __com_sun_star_text_XAutoTextContainer2_idl__
#include <com/sun/star/text/XAutoTextContainer.idl>
#include <com/sun/star/container/XIndexAccess.idl>
module com { module sun { module star { module text {
/**
@since LibreOffice 4.1
*/
published interface XAutoTextContainer2
{
interface com::sun::star::text::XAutoTextContainer;
interface com::sun::star::container::XIndexAccess;
};
}; }; }; };
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Binary file not shown.

View File

@@ -641,7 +641,7 @@ SwVisitingCardPage::~SwVisitingCardPage()
{ {
for(sal_uInt16 i = 0; i < aAutoTextGroupLB.GetEntryCount(); i++) for(sal_uInt16 i = 0; i < aAutoTextGroupLB.GetEntryCount(); i++)
delete (String*)aAutoTextGroupLB.GetEntryData( i ); delete (String*)aAutoTextGroupLB.GetEntryData( i );
_xAutoText = 0; m_xAutoText = 0;
ClearUserData(); ClearUserData();
delete pExampleFrame; delete pExampleFrame;

View File

@@ -17,9 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/text/AutoTextContainer.hpp>
#include <com/sun/star/text/XTextFieldsSupplier.hpp> #include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/util/XRefreshable.hpp> #include <com/sun/star/util/XRefreshable.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include "svtools/treelistentry.hxx" #include "svtools/treelistentry.hxx"
#include <swtypes.hxx> #include <swtypes.hxx>
@@ -52,16 +53,15 @@ void SwVisitingCardPage::InitFrameControl()
getProcessServiceFactory(); getProcessServiceFactory();
//now the AutoText ListBoxes have to be filled //now the AutoText ListBoxes have to be filled
uno::Reference< uno::XInterface > xAText = xMgr->createInstance( "com.sun.star.text.AutoTextContainer" ); m_xAutoText = text::AutoTextContainer::create( comphelper::getComponentContext(xMgr) );
_xAutoText = uno::Reference< container::XNameAccess >(xAText, uno::UNO_QUERY);
uno::Sequence<OUString> aNames = _xAutoText->getElementNames(); uno::Sequence<OUString> aNames = m_xAutoText->getElementNames();
const OUString* pGroups = aNames.getConstArray(); const OUString* pGroups = aNames.getConstArray();
OUString uTitleName( rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_TITLE)) ); OUString uTitleName( rtl::OUString::createFromAscii(SW_PROP_NAME_STR(UNO_NAME_TITLE)) );
for(sal_uInt16 i = 0; i < aNames.getLength(); i++) for(sal_uInt16 i = 0; i < aNames.getLength(); i++)
{ {
uno::Any aGroup = _xAutoText->getByName(pGroups[i]); uno::Any aGroup = m_xAutoText->getByName(pGroups[i]);
uno::Reference< text::XAutoTextGroup > xGroup; uno::Reference< text::XAutoTextGroup > xGroup;
aGroup >>= xGroup; aGroup >>= xGroup;
uno::Reference< container::XIndexAccess > xIdxAcc(xGroup, uno::UNO_QUERY); uno::Reference< container::XIndexAccess > xIdxAcc(xGroup, uno::UNO_QUERY);
@@ -88,9 +88,9 @@ void SwVisitingCardPage::InitFrameControl()
aAutoTextGroupLB.SelectEntryPos(0); aAutoTextGroupLB.SelectEntryPos(0);
String sCurGroupName( String sCurGroupName(
*(String*)aAutoTextGroupLB.GetEntryData(aAutoTextGroupLB.GetSelectEntryPos())); *(String*)aAutoTextGroupLB.GetEntryData(aAutoTextGroupLB.GetSelectEntryPos()));
if(_xAutoText->hasByName(sCurGroupName)) if(m_xAutoText->hasByName(sCurGroupName))
{ {
uno::Any aGroup = _xAutoText->getByName(sCurGroupName); uno::Any aGroup = m_xAutoText->getByName(sCurGroupName);
try try
{ {
uno::Reference< text::XAutoTextGroup > xGroup; uno::Reference< text::XAutoTextGroup > xGroup;
@@ -122,7 +122,7 @@ IMPL_LINK_NOARG(SwVisitingCardPage, FrameControlInitializedHdl)
{ {
String sGroup( *(String*)aAutoTextGroupLB.GetEntryData( String sGroup( *(String*)aAutoTextGroupLB.GetEntryData(
aAutoTextGroupLB.GetSelectEntryPos() ) ); aAutoTextGroupLB.GetSelectEntryPos() ) );
uno::Any aGroup = _xAutoText->getByName(sGroup); uno::Any aGroup = m_xAutoText->getByName(sGroup);
uno::Reference< text::XAutoTextGroup > xGroup; uno::Reference< text::XAutoTextGroup > xGroup;
aGroup >>= xGroup; aGroup >>= xGroup;
@@ -144,13 +144,13 @@ IMPL_LINK_NOARG(SwVisitingCardPage, FrameControlInitializedHdl)
IMPL_LINK( SwVisitingCardPage, AutoTextSelectHdl, void*, pBox ) IMPL_LINK( SwVisitingCardPage, AutoTextSelectHdl, void*, pBox )
{ {
if(_xAutoText.is()) if(m_xAutoText.is())
{ {
if( &aAutoTextGroupLB == pBox ) if( &aAutoTextGroupLB == pBox )
{ {
String sGroup( *(String*)aAutoTextGroupLB.GetEntryData( String sGroup( *(String*)aAutoTextGroupLB.GetEntryData(
aAutoTextGroupLB.GetSelectEntryPos())); aAutoTextGroupLB.GetSelectEntryPos()));
uno::Any aGroup = _xAutoText->getByName(sGroup); uno::Any aGroup = m_xAutoText->getByName(sGroup);
uno::Reference< text::XAutoTextGroup > xGroup; uno::Reference< text::XAutoTextGroup > xGroup;
aGroup >>= xGroup; aGroup >>= xGroup;

View File

@@ -19,6 +19,7 @@
#ifndef _SWUILABIMP_HXX #ifndef _SWUILABIMP_HXX
#define _SWUILABIMP_HXX #define _SWUILABIMP_HXX
#include "labimp.hxx" #include "labimp.hxx"
#include <com/sun/star/text/XAutoTextContainer2.hpp>
class SwLabPage : public SfxTabPage class SwLabPage : public SfxTabPage
{ {
@@ -103,7 +104,7 @@ class SwVisitingCardPage : public SfxTabPage
SwLabItem aLabItem; SwLabItem aLabItem;
SwOneExampleFrame* pExampleFrame; SwOneExampleFrame* pExampleFrame;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > _xAutoText; ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextContainer2 > m_xAutoText;
DECL_LINK( AutoTextSelectHdl, void* ); DECL_LINK( AutoTextSelectHdl, void* );

View File

@@ -36,6 +36,7 @@
#include <com/sun/star/container/XEnumeration.hpp> #include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/container/XElementAccess.hpp> #include <com/sun/star/container/XElementAccess.hpp>
#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/text/XAutoTextContainer2.hpp>
#include <actctrl.hxx> #include <actctrl.hxx>
@@ -100,7 +101,7 @@ class SwGlossaryDlg : public SvxStandardDialog
String sReadonlyPath; String sReadonlyPath;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > _xAutoText; ::com::sun::star::uno::Reference< ::com::sun::star::text::XAutoTextContainer2 > m_xAutoText;
SwOneExampleFrame* pExampleFrame; SwOneExampleFrame* pExampleFrame;
SwGlossaryHdl* pGlossaryHdl; SwGlossaryHdl* pGlossaryHdl;

View File

@@ -19,21 +19,19 @@
#ifndef _UNOATXT_HXX #ifndef _UNOATXT_HXX
#define _UNOATXT_HXX #define _UNOATXT_HXX
#include <com/sun/star/text/XAutoTextGroup.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/text/XAutoTextEntry.hpp> #include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/text/XAutoTextContainer.hpp> #include <com/sun/star/document/XEventsSupplier.hpp>
#include <com/sun/star/text/XText.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/text/XAutoTextGroup.hpp>
#include <com/sun/star/text/XAutoTextEntry.hpp>
#include <com/sun/star/text/XAutoTextContainer2.hpp>
#include <com/sun/star/text/XText.hpp>
#include <svl/itemprop.hxx> #include <svl/itemprop.hxx>
#include <svl/lstner.hxx> #include <svl/lstner.hxx>
#include <cppuhelper/implbase3.hxx> // helper for implementations #include <cppuhelper/implbase2.hxx> // helper for implementations
#include <cppuhelper/implbase4.hxx> // helper for implementations
#include <cppuhelper/implbase5.hxx> // helper for implementations #include <cppuhelper/implbase5.hxx> // helper for implementations
#include <cppuhelper/implbase6.hxx> // helper for implementations #include <cppuhelper/implbase6.hxx> // helper for implementations
#include <svtools/unoevent.hxx> #include <svtools/unoevent.hxx>
@@ -53,11 +51,10 @@ SV_DECL_REF( SwDocShell )
SAL_CALL SwXAutoTextContainer_createInstance( SAL_CALL SwXAutoTextContainer_createInstance(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & ) throw ( ::com::sun::star::uno::Exception ); const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & ) throw ( ::com::sun::star::uno::Exception );
class SwXAutoTextContainer : public cppu::WeakImplHelper3 class SwXAutoTextContainer : public cppu::WeakImplHelper2
< <
::com::sun::star::text::XAutoTextContainer, ::com::sun::star::text::XAutoTextContainer2,
::com::sun::star::lang::XServiceInfo, ::com::sun::star::lang::XServiceInfo
::com::sun::star::container::XIndexAccess
> >
{ {
SwGlossaries *pGlossaries; SwGlossaries *pGlossaries;

View File

@@ -37,6 +37,7 @@
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include <ucbhelper/content.hxx> #include <ucbhelper/content.hxx>
#include <com/sun/star/text/AutoTextContainer.hpp>
#include <com/sun/star/ui/dialogs/XFilePicker.hpp> #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
#include <com/sun/star/ui/dialogs/XFilterManager.hpp> #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
@@ -1132,19 +1133,17 @@ void SwGlossaryDlg::ShowAutoText(const String& rGroup, const String& rShortName)
} }
} }
void SwGlossaryDlg::ResumeShowAutoText() void SwGlossaryDlg::ResumeShowAutoText()
{ {
String sGroup, sShortName; String sGroup, sShortName;
if(GetResumeData(sGroup, sShortName) && m_pExampleWIN->IsVisible()) if(GetResumeData(sGroup, sShortName) && m_pExampleWIN->IsVisible())
{ {
if(!_xAutoText.is()) if(!m_xAutoText.is())
{ {
uno::Reference< lang::XMultiServiceFactory > uno::Reference< lang::XMultiServiceFactory > xMgr = getProcessServiceFactory();
xMgr = getProcessServiceFactory();
//now the AutoText ListBoxes have to be filled //now the AutoText ListBoxes have to be filled
uno::Reference< uno::XInterface > xAText = xMgr->createInstance( "com.sun.star.text.AutoTextContainer" ); m_xAutoText = text::AutoTextContainer::create( comphelper::getComponentContext(xMgr) );
_xAutoText = uno::Reference< container::XNameAccess >(xAText, uno::UNO_QUERY);
} }
uno::Reference< XTextCursor > & xCrsr = pExampleFrame->GetTextCursor(); uno::Reference< XTextCursor > & xCrsr = pExampleFrame->GetTextCursor();
@@ -1152,7 +1151,7 @@ void SwGlossaryDlg::ResumeShowAutoText()
{ {
if(sShortName.Len()) if(sShortName.Len())
{ {
uno::Any aGroup = _xAutoText->getByName(sGroup); uno::Any aGroup = m_xAutoText->getByName(sGroup);
uno::Reference< XAutoTextGroup > xGroup; uno::Reference< XAutoTextGroup > xGroup;
OUString uShortName(sShortName); OUString uShortName(sShortName);
if((aGroup >>= xGroup) && xGroup->hasByName(uShortName)) if((aGroup >>= xGroup) && xGroup->hasByName(uShortName))

View File

@@ -20,7 +20,7 @@
#include <vbahelper/vbahelper.hxx> #include <vbahelper/vbahelper.hxx>
#include "wordvbahelper.hxx" #include "wordvbahelper.hxx"
#include "vbaautotextentry.hxx" #include "vbaautotextentry.hxx"
#include <com/sun/star/text/XAutoTextContainer.hpp> #include <com/sun/star/text/AutoTextContainer.hpp>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include <tools/urlobj.hxx> #include <tools/urlobj.hxx>
@@ -85,8 +85,8 @@ SwVbaTemplate::getPath() throw ( css::uno::RuntimeException )
uno::Any SAL_CALL uno::Any SAL_CALL
SwVbaTemplate::AutoTextEntries( const uno::Any& index ) throw (uno::RuntimeException) SwVbaTemplate::AutoTextEntries( const uno::Any& index ) throw (uno::RuntimeException)
{ {
uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory(); uno::Reference< uno::XComponentContext > xContext = comphelper::getProcessComponentContext();
uno::Reference< text::XAutoTextContainer > xAutoTextContainer( xMgr->createInstance( rtl::OUString("com.sun.star.text.AutoTextContainer") ), uno::UNO_QUERY_THROW ); uno::Reference< text::XAutoTextContainer2 > xAutoTextContainer = text::AutoTextContainer::create( xContext );
// the default template is "Normal.dot" in Word. // the default template is "Normal.dot" in Word.
rtl::OUString sGroup("Normal"); rtl::OUString sGroup("Normal");

View File

@@ -60,9 +60,6 @@ using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::xml::sax::XDocumentHandler; using ::com::sun::star::xml::sax::XDocumentHandler;
const sal_Char sAPI_AutoText[] = "com.sun.star.text.AutoTextContainer";
XMLAutoTextEventExport::XMLAutoTextEventExport( XMLAutoTextEventExport::XMLAutoTextEventExport(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
sal_uInt16 nFlags sal_uInt16 nFlags

View File

@@ -46,10 +46,6 @@ using ::com::sun::star::lang::XMultiServiceFactory;
using ::xmloff::token::IsXMLToken; using ::xmloff::token::IsXMLToken;
using ::xmloff::token::XML_AUTO_TEXT_EVENTS; using ::xmloff::token::XML_AUTO_TEXT_EVENTS;
const sal_Char sAPI_AutoText[] = "com.sun.star.text.AutoTextContainer";
// #110680#
XMLAutoTextEventImport::XMLAutoTextEventImport( XMLAutoTextEventImport::XMLAutoTextEventImport(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext) throw() const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext) throw()
: SvXMLImport(xContext) : SvXMLImport(xContext)